From 933e9168bc123899b4204c60727d97aabbd44d18 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 7 Mar 2023 13:05:26 +0100 Subject: [PATCH 01/91] events for contributionMessageResolver --- ...EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts | 23 +++++++++++++++++++ .../EVENT_CONTRIBUTION_MESSAGE_CREATE.ts | 22 ++++++++++++++++++ backend/src/event/Event.ts | 2 ++ backend/src/event/EventType.ts | 2 ++ .../resolver/ContributionMessageResolver.ts | 17 ++++++++++---- 5 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts create mode 100644 backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts new file mode 100644 index 000000000..f07d38e98 --- /dev/null +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts @@ -0,0 +1,23 @@ +import { User as DbUser } from '@entity/User' +import { Contribution as DbContribution } from '@entity/Contribution' +import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE = async ( + user: DbUser, + moderator: DbUser, + contribution: DbContribution, + contributionMessage: DbContributionMessage, +): Promise => + Event( + EventType.ADMIN_CONTRIBUTION_MESSAGE_CREATE, + user, + moderator, + null, + null, + contribution, + contributionMessage, + null, + null, + ).save() diff --git a/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts b/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts new file mode 100644 index 000000000..b06685a6d --- /dev/null +++ b/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts @@ -0,0 +1,22 @@ +import { User as DbUser } from '@entity/User' +import { Contribution as DbContribution } from '@entity/Contribution' +import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_CONTRIBUTION_MESSAGE_CREATE = async ( + user: DbUser, + contribution: DbContribution, + contributionMessage: DbContributionMessage, +): Promise => + Event( + EventType.CONTRIBUTION_MESSAGE_CREATE, + user, + user, + null, + null, + contribution, + contributionMessage, + null, + null, + ).save() diff --git a/backend/src/event/Event.ts b/backend/src/event/Event.ts index 2e7cca6af..f1c4269c9 100644 --- a/backend/src/event/Event.ts +++ b/backend/src/event/Event.ts @@ -45,10 +45,12 @@ export { EVENT_ADMIN_CONTRIBUTION_UPDATE } from './EVENT_ADMIN_CONTRIBUTION_UPDA export { EVENT_ADMIN_CONTRIBUTION_LINK_CREATE } from './EVENT_ADMIN_CONTRIBUTION_LINK_CREATE' export { EVENT_ADMIN_CONTRIBUTION_LINK_DELETE } from './EVENT_ADMIN_CONTRIBUTION_LINK_DELETE' export { EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE } from './EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE' +export { EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE' export { EVENT_ADMIN_SEND_CONFIRMATION_EMAIL } from './EVENT_ADMIN_SEND_CONFIRMATION_EMAIL' export { EVENT_CONTRIBUTION_CREATE } from './EVENT_CONTRIBUTION_CREATE' export { EVENT_CONTRIBUTION_DELETE } from './EVENT_CONTRIBUTION_DELETE' export { EVENT_CONTRIBUTION_UPDATE } from './EVENT_CONTRIBUTION_UPDATE' +export { EVENT_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_CONTRIBUTION_MESSAGE_CREATE' export { EVENT_LOGIN } from './EVENT_LOGIN' export { EVENT_REGISTER } from './EVENT_REGISTER' export { EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL } from './EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL' diff --git a/backend/src/event/EventType.ts b/backend/src/event/EventType.ts index b219a49ba..dda571b5a 100644 --- a/backend/src/event/EventType.ts +++ b/backend/src/event/EventType.ts @@ -9,10 +9,12 @@ export enum EventType { ADMIN_CONTRIBUTION_LINK_CREATE = 'ADMIN_CONTRIBUTION_LINK_CREATE', ADMIN_CONTRIBUTION_LINK_DELETE = 'ADMIN_CONTRIBUTION_LINK_DELETE', ADMIN_CONTRIBUTION_LINK_UPDATE = 'ADMIN_CONTRIBUTION_LINK_UPDATE', + ADMIN_CONTRIBUTION_MESSAGE_CREATE = 'ADMIN_CONTRIBUTION_MESSAGE_CREATE', ADMIN_SEND_CONFIRMATION_EMAIL = 'ADMIN_SEND_CONFIRMATION_EMAIL', CONTRIBUTION_CREATE = 'CONTRIBUTION_CREATE', CONTRIBUTION_DELETE = 'CONTRIBUTION_DELETE', CONTRIBUTION_UPDATE = 'CONTRIBUTION_UPDATE', + CONTRIBUTION_MESSAGE_CREATE = 'CONTRIBUTION_MESSAGE_CREATE', LOGIN = 'LOGIN', REGISTER = 'REGISTER', REDEEM_REGISTER = 'REDEEM_REGISTER', diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.ts b/backend/src/graphql/resolver/ContributionMessageResolver.ts index adfcdf160..d4cab2340 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.ts @@ -16,6 +16,7 @@ import { RIGHTS } from '@/auth/RIGHTS' import { Context, getUser } from '@/server/context' import { sendAddedContributionMessageEmail } from '@/emails/sendEmailVariants' import LogError from '@/server/LogError' +import { EVENT_CONTRIBUTION_MESSAGE_CREATE } from '@/event/Event' @Resolver() export class ContributionMessageResolver { @@ -56,6 +57,11 @@ export class ContributionMessageResolver { await queryRunner.manager.update(DbContribution, { id: contributionId }, contribution) } await queryRunner.commitTransaction() + await EVENT_CONTRIBUTION_MESSAGE_CREATE( + user, + { id: contributionMessage.contributionId } as DbContribution, + contributionMessage, + ) } catch (e) { await queryRunner.rollbackTransaction() throw new LogError(`ContributionMessage was not sent successfully: ${e}`, e) @@ -97,7 +103,7 @@ export class ContributionMessageResolver { @Args() { contributionId, message }: ContributionMessageArgs, @Ctx() context: Context, ): Promise { - const user = getUser(context) + const moderator = getUser(context) const queryRunner = getConnection().createQueryRunner() await queryRunner.connect() @@ -111,7 +117,7 @@ export class ContributionMessageResolver { if (!contribution) { throw new LogError('Contribution not found', contributionId) } - if (contribution.userId === user.id) { + if (contribution.userId === moderator.id) { throw new LogError('Admin can not answer on his own contribution', contributionId) } if (!contribution.user.emailContact) { @@ -122,7 +128,7 @@ export class ContributionMessageResolver { contributionMessage.contributionId = contributionId contributionMessage.createdAt = new Date() contributionMessage.message = message - contributionMessage.userId = user.id + contributionMessage.userId = moderator.id contributionMessage.type = ContributionMessageType.DIALOG contributionMessage.isModerator = true await queryRunner.manager.insert(DbContributionMessage, contributionMessage) @@ -141,11 +147,12 @@ export class ContributionMessageResolver { lastName: contribution.user.lastName, email: contribution.user.emailContact.email, language: contribution.user.language, - senderFirstName: user.firstName, - senderLastName: user.lastName, + senderFirstName: moderator.firstName, + senderLastName: moderator.lastName, contributionMemo: contribution.memo, }) await queryRunner.commitTransaction() + await EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE({id: contribution.userId} as DbUser, moderator, contribution, contributionMessage) } catch (e) { await queryRunner.rollbackTransaction() throw new LogError(`ContributionMessage was not sent successfully: ${e}`, e) From fd912fb6c8596a2502e52b08c970a9e684bf8c20 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 7 Mar 2023 13:12:39 +0100 Subject: [PATCH 02/91] tests for the two new events --- .../ContributionMessageResolver.test.ts | 26 +++++++++++++++++++ .../resolver/ContributionMessageResolver.ts | 19 ++++++++++---- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts index f3e5e865d..307eef8c5 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts @@ -15,6 +15,8 @@ import { userFactory } from '@/seeds/factory/user' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' import { sendAddedContributionMessageEmail } from '@/emails/sendEmailVariants' +import { EventType } from '@/event/Event' +import { Event as DbEvent } from '@entity/Event' jest.mock('@/emails/sendEmailVariants', () => { const originalModule = jest.requireActual('@/emails/sendEmailVariants') @@ -192,6 +194,18 @@ describe('ContributionMessageResolver', () => { contributionMemo: 'Test env contribution', }) }) + + it('stores the ADMIN_CONTRIBUTION_MESSAGE_CREATE event in the database', async () => { + await expect(DbEvent.find()).resolves.toContainEqual( + expect.objectContaining({ + type: EventType.ADMIN_CONTRIBUTION_MESSAGE_CREATE, + affectedUserId: expect.any(Number), + actingUserId: expect.any(Number), + involvedContributionId: result.data.createContribution.id, + involvedContributionMessageId: expect.any(Number), + }), + ) + }) }) }) }) @@ -317,6 +331,18 @@ describe('ContributionMessageResolver', () => { }), ) }) + + it('stores the CONTRIBUTION_MESSAGE_CREATE event in the database', async () => { + await expect(DbEvent.find()).resolves.toContainEqual( + expect.objectContaining({ + type: EventType.CONTRIBUTION_MESSAGE_CREATE, + affectedUserId: expect.any(Number), + actingUserId: expect.any(Number), + involvedContributionId: result.data.createContribution.id, + involvedContributionMessageId: expect.any(Number), + }), + ) + }) }) }) }) diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.ts b/backend/src/graphql/resolver/ContributionMessageResolver.ts index d4cab2340..c8378bcf4 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.ts @@ -3,7 +3,8 @@ import { getConnection } from '@dbTools/typeorm' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { Contribution as DbContribution } from '@entity/Contribution' -import { UserContact } from '@entity/UserContact' +import { UserContact as DbUserContact } from '@entity/UserContact' +import { User as DbUser } from '@entity/User' import { ContributionMessage, ContributionMessageListResult } from '@model/ContributionMessage' import ContributionMessageArgs from '@arg/ContributionMessageArgs' @@ -16,7 +17,10 @@ import { RIGHTS } from '@/auth/RIGHTS' import { Context, getUser } from '@/server/context' import { sendAddedContributionMessageEmail } from '@/emails/sendEmailVariants' import LogError from '@/server/LogError' -import { EVENT_CONTRIBUTION_MESSAGE_CREATE } from '@/event/Event' +import { + EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE, + EVENT_CONTRIBUTION_MESSAGE_CREATE, +} from '@/event/Event' @Resolver() export class ContributionMessageResolver { @@ -121,7 +125,7 @@ export class ContributionMessageResolver { throw new LogError('Admin can not answer on his own contribution', contributionId) } if (!contribution.user.emailContact) { - contribution.user.emailContact = await UserContact.findOneOrFail({ + contribution.user.emailContact = await DbUserContact.findOneOrFail({ where: { id: contribution.user.emailId }, }) } @@ -152,13 +156,18 @@ export class ContributionMessageResolver { contributionMemo: contribution.memo, }) await queryRunner.commitTransaction() - await EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE({id: contribution.userId} as DbUser, moderator, contribution, contributionMessage) + await EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE( + { id: contribution.userId } as DbUser, + moderator, + contribution, + contributionMessage, + ) } catch (e) { await queryRunner.rollbackTransaction() throw new LogError(`ContributionMessage was not sent successfully: ${e}`, e) } finally { await queryRunner.release() } - return new ContributionMessage(contributionMessage, user) + return new ContributionMessage(contributionMessage, moderator) } } From 920f16aad51574e3a09cf40c1199ce4ff68b1505 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 7 Mar 2023 13:33:08 +0100 Subject: [PATCH 03/91] corrected test name, some code style fixes --- .../graphql/resolver/ContributionResolver.test.ts | 2 +- .../src/graphql/resolver/ContributionResolver.ts | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 053e434ea..2b59bde8b 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -2541,7 +2541,7 @@ describe('ContributionResolver', () => { ) }) - it('stores the CONTRIBUTION_CONFIRM event in the database', async () => { + it('stores the ADMIN_CONTRIBUTION_CONFIRM event in the database', async () => { await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventType.ADMIN_CONTRIBUTION_CONFIRM, diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 62c53d993..34a27997b 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -89,7 +89,6 @@ export class ContributionResolver { logger.trace('contribution to save', contribution) await DbContribution.save(contribution) - await EVENT_CONTRIBUTION_CREATE(user, contribution, amount) return new UnconfirmedContribution(contribution, user, creations) @@ -117,7 +116,6 @@ export class ContributionResolver { contribution.deletedBy = user.id contribution.deletedAt = new Date() await contribution.save() - await EVENT_CONTRIBUTION_DELETE(user, contribution, contribution.amount) const res = await contribution.softRemove() @@ -254,7 +252,6 @@ export class ContributionResolver { contributionToUpdate.contributionStatus = ContributionStatus.PENDING contributionToUpdate.updatedAt = new Date() DbContribution.save(contributionToUpdate) - await EVENT_CONTRIBUTION_UPDATE(user, contributionToUpdate, amount) return new UnconfirmedContribution(contributionToUpdate, user, creations) @@ -307,11 +304,8 @@ export class ContributionResolver { contribution.moderatorId = moderator.id contribution.contributionType = ContributionType.ADMIN contribution.contributionStatus = ContributionStatus.PENDING - logger.trace('contribution to save', contribution) - await DbContribution.save(contribution) - await EVENT_ADMIN_CONTRIBUTION_CREATE(emailContact.user, moderator, contribution, amount) return getUserCreation(emailContact.userId, clientTimezoneOffset) @@ -377,9 +371,7 @@ export class ContributionResolver { result.amount = amount result.memo = contributionToUpdate.memo result.date = contributionToUpdate.contributionDate - result.creation = await getUserCreation(emailContact.user.id, clientTimezoneOffset) - await EVENT_ADMIN_CONTRIBUTION_UPDATE( emailContact.user, moderator, @@ -440,14 +432,12 @@ export class ContributionResolver { contribution.deletedBy = moderator.id await contribution.save() const res = await contribution.softRemove() - await EVENT_ADMIN_CONTRIBUTION_DELETE( { id: contribution.userId } as DbUser, moderator, contribution, contribution.amount, ) - sendContributionDeletedEmail({ firstName: user.firstName, lastName: user.lastName, @@ -558,7 +548,6 @@ export class ContributionResolver { } finally { await queryRunner.release() } - await EVENT_ADMIN_CONTRIBUTION_CONFIRM(user, moderatorUser, contribution, contribution.amount) } finally { releaseLock() @@ -648,14 +637,12 @@ export class ContributionResolver { contributionToUpdate.deniedBy = moderator.id contributionToUpdate.deniedAt = new Date() const res = await contributionToUpdate.save() - await EVENT_ADMIN_CONTRIBUTION_DENY( user, moderator, contributionToUpdate, contributionToUpdate.amount, ) - sendContributionDeniedEmail({ firstName: user.firstName, lastName: user.lastName, From 9493ed58d94e4ea7dd9d65290caebab30a8158ef Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 7 Mar 2023 21:38:17 +0100 Subject: [PATCH 04/91] events for transactionLinkResolver --- .../event/EVENT_CONTRIBUTION_LINK_REDEEM.ts | 27 +++++++++++++++++++ .../event/EVENT_TRANSACTION_LINK_CREATE.ts | 23 ++++++++++++++++ .../event/EVENT_TRANSACTION_LINK_DELETE.ts | 19 +++++++++++++ .../event/EVENT_TRANSACTION_LINK_REDEEM.ts | 24 +++++++++++++++++ backend/src/event/Event.ts | 4 +++ backend/src/event/EventType.ts | 4 +++ .../resolver/TransactionLinkResolver.ts | 23 +++++++++++++++- 7 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts create mode 100644 backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts create mode 100644 backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts create mode 100644 backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts diff --git a/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts b/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts new file mode 100644 index 000000000..395772ac9 --- /dev/null +++ b/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts @@ -0,0 +1,27 @@ +import Decimal from 'decimal.js-light' +import { User as DbUser } from '@entity/User' +import { Transaction as DbTransaction } from '@entity/Transaction' +import { Contribution as DbContribution } from '@entity/Contribution' +import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_CONTRIBUTION_LINK_REDEEM = async ( + user: DbUser, + transaction: DbTransaction, + contribution: DbContribution, + contributionLink: DbContributionLink, + amount: Decimal, +): Promise => + Event( + EventType.CONTRIBUTION_LINK_REDEEM, + user, + user, + null, + transaction, + contribution, + null, + null, + contributionLink, + amount, + ).save() diff --git a/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts b/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts new file mode 100644 index 000000000..36fdb3ff0 --- /dev/null +++ b/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts @@ -0,0 +1,23 @@ +import Decimal from 'decimal.js-light' +import { User as DbUser } from '@entity/User' +import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_TRANSACTION_LINK_CREATE = async ( + user: DbUser, + transactionLink: DbTransactionLink, + amount: Decimal, +): Promise => + Event( + EventType.TRANSACTION_LINK_CREATE, + user, + user, + null, + null, + null, + null, + transactionLink, + null, + amount, + ).save() diff --git a/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts b/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts new file mode 100644 index 000000000..d15c786a8 --- /dev/null +++ b/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts @@ -0,0 +1,19 @@ +import { User as DbUser } from '@entity/User' +import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_TRANSACTION_LINK_DELETE = async ( + user: DbUser, + transactionLink: DbTransactionLink, +): Promise => + Event( + EventType.TRANSACTION_LINK_DELETE, + user, + user, + null, + null, + null, + null, + transactionLink, + ).save() diff --git a/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts b/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts new file mode 100644 index 000000000..58307a4e1 --- /dev/null +++ b/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts @@ -0,0 +1,24 @@ +import Decimal from 'decimal.js-light' +import { User as DbUser } from '@entity/User' +import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_TRANSACTION_LINK_REDEEM = async ( + user: DbUser, + senderUser: DbUser, + transactionLink: DbTransactionLink, + amount: Decimal, +): Promise => + Event( + EventType.TRANSACTION_LINK_REDEEM, + user, + user, + senderUser, + null, + null, + null, + transactionLink, + null, + amount, + ).save() diff --git a/backend/src/event/Event.ts b/backend/src/event/Event.ts index f1c4269c9..cdb05748c 100644 --- a/backend/src/event/Event.ts +++ b/backend/src/event/Event.ts @@ -51,9 +51,13 @@ export { EVENT_CONTRIBUTION_CREATE } from './EVENT_CONTRIBUTION_CREATE' export { EVENT_CONTRIBUTION_DELETE } from './EVENT_CONTRIBUTION_DELETE' export { EVENT_CONTRIBUTION_UPDATE } from './EVENT_CONTRIBUTION_UPDATE' export { EVENT_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_CONTRIBUTION_MESSAGE_CREATE' +export { EVENT_CONTRIBUTION_LINK_REDEEM } from './EVENT_CONTRIBUTION_LINK_REDEEM' export { EVENT_LOGIN } from './EVENT_LOGIN' export { EVENT_REGISTER } from './EVENT_REGISTER' export { EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL } from './EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL' export { EVENT_SEND_CONFIRMATION_EMAIL } from './EVENT_SEND_CONFIRMATION_EMAIL' export { EVENT_TRANSACTION_SEND } from './EVENT_TRANSACTION_SEND' export { EVENT_TRANSACTION_RECEIVE } from './EVENT_TRANSACTION_RECEIVE' +export { EVENT_TRANSACTION_LINK_CREATE } from './EVENT_TRANSACTION_LINK_CREATE' +export { EVENT_TRANSACTION_LINK_DELETE } from './EVENT_TRANSACTION_LINK_DELETE' +export { EVENT_TRANSACTION_LINK_REDEEM } from './EVENT_TRANSACTION_LINK_REDEEM' diff --git a/backend/src/event/EventType.ts b/backend/src/event/EventType.ts index dda571b5a..47056f05e 100644 --- a/backend/src/event/EventType.ts +++ b/backend/src/event/EventType.ts @@ -15,6 +15,7 @@ export enum EventType { CONTRIBUTION_DELETE = 'CONTRIBUTION_DELETE', CONTRIBUTION_UPDATE = 'CONTRIBUTION_UPDATE', CONTRIBUTION_MESSAGE_CREATE = 'CONTRIBUTION_MESSAGE_CREATE', + CONTRIBUTION_LINK_REDEEM = 'CONTRIBUTION_LINK_REDEEM', LOGIN = 'LOGIN', REGISTER = 'REGISTER', REDEEM_REGISTER = 'REDEEM_REGISTER', @@ -22,6 +23,9 @@ export enum EventType { SEND_CONFIRMATION_EMAIL = 'SEND_CONFIRMATION_EMAIL', TRANSACTION_SEND = 'TRANSACTION_SEND', TRANSACTION_RECEIVE = 'TRANSACTION_RECEIVE', + TRANSACTION_LINK_CREATE = 'TRANSACTION_LINK_CREATE', + TRANSACTION_LINK_DELETE = 'TRANSACTION_LINK_DELETE', + TRANSACTION_LINK_REDEEM = 'TRANSACTION_LINK_REDEEM', // VISIT_GRADIDO = 'VISIT_GRADIDO', // VERIFY_REDEEM = 'VERIFY_REDEEM', // INACTIVE_ACCOUNT = 'INACTIVE_ACCOUNT', diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.ts b/backend/src/graphql/resolver/TransactionLinkResolver.ts index 66d0fbb4b..c8539510e 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.ts @@ -35,6 +35,12 @@ import LogError from '@/server/LogError' import { getLastTransaction } from './util/getLastTransaction' import transactionLinkList from './util/transactionLinkList' +import { + EVENT_CONTRIBUTION_LINK_REDEEM, + EVENT_TRANSACTION_LINK_CREATE, + EVENT_TRANSACTION_LINK_DELETE, + EVENT_TRANSACTION_LINK_REDEEM, +} from '@/event/Event' // TODO: do not export, test it inside the resolver export const transactionLinkCode = (date: Date): string => { @@ -89,6 +95,7 @@ export class TransactionLinkResolver { await DbTransactionLink.save(transactionLink).catch((e) => { throw new LogError('Unable to save transaction link', e) }) + await EVENT_TRANSACTION_LINK_CREATE(user, transactionLink, amount) return new TransactionLink(transactionLink, new User(user)) } @@ -122,6 +129,8 @@ export class TransactionLinkResolver { throw new LogError('Transaction link could not be deleted', e) }) + await EVENT_TRANSACTION_LINK_DELETE(user, transactionLink) + return true } @@ -272,7 +281,13 @@ export class TransactionLinkResolver { await queryRunner.manager.update(DbContribution, { id: contribution.id }, contribution) await queryRunner.commitTransaction() - logger.info('creation from contribution link commited successfuly.') + await EVENT_CONTRIBUTION_LINK_REDEEM( + user, + transaction, + contribution, + contributionLink, + contributionLink.amount, + ) } catch (e) { await queryRunner.rollbackTransaction() throw new LogError('Creation from contribution link was not successful', e) @@ -313,6 +328,12 @@ export class TransactionLinkResolver { user, transactionLink, ) + await EVENT_TRANSACTION_LINK_REDEEM( + user, + { id: transactionLink.userId } as DbUser, + transactionLink, + transactionLink.amount, + ) return true } From 09c5aff33e65fc0b5d0f0c2941a90b95f92818b7 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 9 Mar 2023 12:40:29 +0100 Subject: [PATCH 05/91] test contribution link redeem --- .../resolver/TransactionLinkResolver.test.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index 60b4551be..14065a9f4 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -26,6 +26,9 @@ import Decimal from 'decimal.js-light' import { GraphQLError } from 'graphql' import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' import { logger } from '@test/testSetup' +import { EventType } from '@/event/Event' +import { Event as DbEvent } from '@entity/Event' +import { UserContact } from '@entity/UserContact' // mock semaphore to allow use fake timers jest.mock('@/util/TRANSACTIONS_LOCK') @@ -432,6 +435,24 @@ describe('TransactionLinkResolver', () => { }) }) + it('stores the CONTRIBUTION_LINK_REDEEM event in the database', async () => { + const userConatct = await UserContact.findOneOrFail( + { email: 'bibi@bloxberg.de' }, + { relations: ['user'] }, + ) + expect(DbEvent.find()).resolves.toContainEqual( + expect.objectContaining({ + type: EventType.CONTRIBUTION_LINK_REDEEM, + affectedUserId: userConatct.user.id, + actingUserId: userConatct.user.id, + involvedTransactionId: expect.any(Number), + involvedContributionId: expect.any(Number), + involvedContributionLinkId: contributionLink?.id, + amount: contributionLink?.amount, + }), + ) + }) + it('does not allow the user to redeem the contribution link a second time on the same day', async () => { jest.clearAllMocks() await expect( From b14911d3147515beded27c440a11692529792c2f Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 9 Mar 2023 11:05:03 +0100 Subject: [PATCH 06/91] logout event --- backend/src/event/EVENT_LOGOUT.ts | 6 ++++++ backend/src/event/Event.ts | 1 + backend/src/event/EventType.ts | 1 + backend/src/graphql/resolver/UserResolver.ts | 13 ++++--------- 4 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 backend/src/event/EVENT_LOGOUT.ts diff --git a/backend/src/event/EVENT_LOGOUT.ts b/backend/src/event/EVENT_LOGOUT.ts new file mode 100644 index 000000000..1e423359c --- /dev/null +++ b/backend/src/event/EVENT_LOGOUT.ts @@ -0,0 +1,6 @@ +import { User as DbUser } from '@entity/User' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_LOGOUT = async (user: DbUser): Promise => + Event(EventType.LOGOUT, user, user).save() diff --git a/backend/src/event/Event.ts b/backend/src/event/Event.ts index cdb05748c..19fbc81cd 100644 --- a/backend/src/event/Event.ts +++ b/backend/src/event/Event.ts @@ -53,6 +53,7 @@ export { EVENT_CONTRIBUTION_UPDATE } from './EVENT_CONTRIBUTION_UPDATE' export { EVENT_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_CONTRIBUTION_MESSAGE_CREATE' export { EVENT_CONTRIBUTION_LINK_REDEEM } from './EVENT_CONTRIBUTION_LINK_REDEEM' export { EVENT_LOGIN } from './EVENT_LOGIN' +export { EVENT_LOGOUT } from './EVENT_LOGOUT' export { EVENT_REGISTER } from './EVENT_REGISTER' export { EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL } from './EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL' export { EVENT_SEND_CONFIRMATION_EMAIL } from './EVENT_SEND_CONFIRMATION_EMAIL' diff --git a/backend/src/event/EventType.ts b/backend/src/event/EventType.ts index 47056f05e..df4a5cc75 100644 --- a/backend/src/event/EventType.ts +++ b/backend/src/event/EventType.ts @@ -17,6 +17,7 @@ export enum EventType { CONTRIBUTION_MESSAGE_CREATE = 'CONTRIBUTION_MESSAGE_CREATE', CONTRIBUTION_LINK_REDEEM = 'CONTRIBUTION_LINK_REDEEM', LOGIN = 'LOGIN', + LOGOUT = 'LOGOUT', REGISTER = 'REGISTER', REDEEM_REGISTER = 'REDEEM_REGISTER', SEND_ACCOUNT_MULTIREGISTRATION_EMAIL = 'SEND_ACCOUNT_MULTIREGISTRATION_EMAIL', diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 2cd40938f..639f59c09 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -57,6 +57,7 @@ import { EVENT_REGISTER, EVENT_ACTIVATE_ACCOUNT, EVENT_ADMIN_SEND_CONFIRMATION_EMAIL, + EVENT_LOGOUT, } from '@/event/Event' import { getUserCreations } from './util/creations' import { isValidPassword } from '@/password/EncryptorUtils' @@ -185,15 +186,9 @@ export class UserResolver { @Authorized([RIGHTS.LOGOUT]) @Mutation(() => String) - async logout(): Promise { - // TODO: Event still missing here!! - // TODO: We dont need this anymore, but might need this in the future in oder to invalidate a valid JWT-Token. - // Furthermore this hook can be useful for tracking user behaviour (did he logout or not? Warn him if he didn't on next login) - // The functionality is fully client side - the client just needs to delete his token with the current implementation. - // we could try to force this by sending `token: null` or `token: ''` with this call. But since it bares no real security - // we should just return true for now. - logger.info('Logout...') - // remove user.pubKey from logger-context to ensure a correct filter on log-messages belonging to the same user + async logout(@Ctx() context: Context): Promise { + await EVENT_LOGOUT(getUser(context)) + // remove user from logger context logger.addContext('user', 'unknown') return true } From feeeca9fe4def82daeafba6ed3af59294019065c Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 9 Mar 2023 11:05:41 +0100 Subject: [PATCH 07/91] corrected return type --- backend/src/graphql/resolver/UserResolver.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 639f59c09..a65049252 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -185,7 +185,7 @@ export class UserResolver { } @Authorized([RIGHTS.LOGOUT]) - @Mutation(() => String) + @Mutation(() => Boolean) async logout(@Ctx() context: Context): Promise { await EVENT_LOGOUT(getUser(context)) // remove user from logger context From 0265834744f546f6804f8150de98f8dc5944c37a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 9 Mar 2023 11:33:53 +0100 Subject: [PATCH 08/91] events for forgot password email and user info update --- .../src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts | 6 ++++ backend/src/event/EVENT_USER_INFO_UPDATE.ts | 6 ++++ backend/src/event/Event.ts | 1 + backend/src/event/EventType.ts | 2 ++ backend/src/graphql/resolver/UserResolver.ts | 34 +++++++++---------- 5 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts create mode 100644 backend/src/event/EVENT_USER_INFO_UPDATE.ts diff --git a/backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts b/backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts new file mode 100644 index 000000000..4160ce244 --- /dev/null +++ b/backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts @@ -0,0 +1,6 @@ +import { User as DbUser } from '@entity/User' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_EMAIL_FORGOT_PASSWORD = async (user: DbUser): Promise => + Event(EventType.EMAIL_FORGOT_PASSWORD, user, user).save() diff --git a/backend/src/event/EVENT_USER_INFO_UPDATE.ts b/backend/src/event/EVENT_USER_INFO_UPDATE.ts new file mode 100644 index 000000000..681ecd473 --- /dev/null +++ b/backend/src/event/EVENT_USER_INFO_UPDATE.ts @@ -0,0 +1,6 @@ +import { User as DbUser } from '@entity/User' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_USER_INFO_UPDATE = async (user: DbUser): Promise => + Event(EventType.USER_INFO_UPDATE, user, user).save() diff --git a/backend/src/event/Event.ts b/backend/src/event/Event.ts index 19fbc81cd..60da91b70 100644 --- a/backend/src/event/Event.ts +++ b/backend/src/event/Event.ts @@ -52,6 +52,7 @@ export { EVENT_CONTRIBUTION_DELETE } from './EVENT_CONTRIBUTION_DELETE' export { EVENT_CONTRIBUTION_UPDATE } from './EVENT_CONTRIBUTION_UPDATE' export { EVENT_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_CONTRIBUTION_MESSAGE_CREATE' export { EVENT_CONTRIBUTION_LINK_REDEEM } from './EVENT_CONTRIBUTION_LINK_REDEEM' +export { EVENT_EMAIL_FORGOT_PASSWORD } from './EVENT_EMAIL_FORGOT_PASSWORD' export { EVENT_LOGIN } from './EVENT_LOGIN' export { EVENT_LOGOUT } from './EVENT_LOGOUT' export { EVENT_REGISTER } from './EVENT_REGISTER' diff --git a/backend/src/event/EventType.ts b/backend/src/event/EventType.ts index df4a5cc75..cc277e589 100644 --- a/backend/src/event/EventType.ts +++ b/backend/src/event/EventType.ts @@ -16,6 +16,7 @@ export enum EventType { CONTRIBUTION_UPDATE = 'CONTRIBUTION_UPDATE', CONTRIBUTION_MESSAGE_CREATE = 'CONTRIBUTION_MESSAGE_CREATE', CONTRIBUTION_LINK_REDEEM = 'CONTRIBUTION_LINK_REDEEM', + EMAIL_FORGOT_PASSWORD = 'EMAIL_FORGOT_PASSWORD', LOGIN = 'LOGIN', LOGOUT = 'LOGOUT', REGISTER = 'REGISTER', @@ -27,6 +28,7 @@ export enum EventType { TRANSACTION_LINK_CREATE = 'TRANSACTION_LINK_CREATE', TRANSACTION_LINK_DELETE = 'TRANSACTION_LINK_DELETE', TRANSACTION_LINK_REDEEM = 'TRANSACTION_LINK_REDEEM', + USER_INFO_UPDATE = 'USER_INFO_UPDATE', // VISIT_GRADIDO = 'VISIT_GRADIDO', // VERIFY_REDEEM = 'VERIFY_REDEEM', // INACTIVE_ACCOUNT = 'INACTIVE_ACCOUNT', diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index a65049252..196110a31 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -58,6 +58,8 @@ import { EVENT_ACTIVATE_ACCOUNT, EVENT_ADMIN_SEND_CONFIRMATION_EMAIL, EVENT_LOGOUT, + EVENT_EMAIL_FORGOT_PASSWORD, + EVENT_USER_INFO_UPDATE, } from '@/event/Event' import { getUserCreations } from './util/creations' import { isValidPassword } from '@/password/EncryptorUtils' @@ -402,6 +404,7 @@ export class UserResolver { ) } logger.info(`forgotPassword(${email}) successful...`) + await EVENT_EMAIL_FORGOT_PASSWORD(user) return true } @@ -464,8 +467,6 @@ export class UserResolver { await queryRunner.commitTransaction() logger.info('User and UserContact data written successfully...') - - await EVENT_ACTIVATE_ACCOUNT(user) } catch (e) { await queryRunner.rollbackTransaction() throw new LogError('Error on writing User and User Contact data', e) @@ -483,13 +484,9 @@ export class UserResolver { ) } catch (e) { logger.error('Error subscribing to klicktipp', e) - // TODO is this a problem? - // eslint-disable-next-line no-console - /* uncomment this, when you need the activation link on the console - console.log('Could not subscribe to klicktipp') - */ } } + await EVENT_ACTIVATE_ACCOUNT(user) return true } @@ -526,21 +523,21 @@ export class UserResolver { @Ctx() context: Context, ): Promise { logger.info(`updateUserInfos(${firstName}, ${lastName}, ${language}, ***, ***)...`) - const userEntity = getUser(context) + const user = getUser(context) if (firstName) { - userEntity.firstName = firstName + user.firstName = firstName } if (lastName) { - userEntity.lastName = lastName + user.lastName = lastName } if (language) { if (!isLanguage(language)) { throw new LogError('Given language is not a valid language', language) } - userEntity.language = language + user.language = language i18n.setLocale(language) } @@ -552,22 +549,22 @@ export class UserResolver { ) } - if (!verifyPassword(userEntity, password)) { + if (!verifyPassword(user, password)) { throw new LogError(`Old password is invalid`) } // Save new password hash and newly encrypted private key - userEntity.passwordEncryptionType = PasswordEncryptionType.GRADIDO_ID - userEntity.password = encryptPassword(userEntity, passwordNew) + user.passwordEncryptionType = PasswordEncryptionType.GRADIDO_ID + user.password = encryptPassword(user, passwordNew) } // Save hideAmountGDD value if (hideAmountGDD !== undefined) { - userEntity.hideAmountGDD = hideAmountGDD + user.hideAmountGDD = hideAmountGDD } // Save hideAmountGDT value if (hideAmountGDT !== undefined) { - userEntity.hideAmountGDT = hideAmountGDT + user.hideAmountGDT = hideAmountGDT } const queryRunner = getConnection().createQueryRunner() @@ -575,7 +572,7 @@ export class UserResolver { await queryRunner.startTransaction('REPEATABLE READ') try { - await queryRunner.manager.save(userEntity).catch((error) => { + await queryRunner.manager.save(user).catch((error) => { throw new LogError('Error saving user', error) }) @@ -588,6 +585,9 @@ export class UserResolver { await queryRunner.release() } logger.info('updateUserInfos() successfully finished...') + + await EVENT_USER_INFO_UPDATE(user) + return true } From 1792d10733cedb62fccd1e5daab70b2ef6525096 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 9 Mar 2023 11:53:10 +0100 Subject: [PATCH 09/91] more events for the user resolver --- backend/src/event/EVENT_ADMIN_USER_DELETE.ts | 6 ++++++ backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts | 8 ++++++++ backend/src/event/EVENT_ADMIN_USER_UNDELETE.ts | 8 ++++++++ .../src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts | 2 +- backend/src/event/Event.ts | 4 ++++ backend/src/event/EventType.ts | 3 +++ backend/src/graphql/resolver/UserResolver.ts | 17 +++++++++++------ 7 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 backend/src/event/EVENT_ADMIN_USER_DELETE.ts create mode 100644 backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts create mode 100644 backend/src/event/EVENT_ADMIN_USER_UNDELETE.ts diff --git a/backend/src/event/EVENT_ADMIN_USER_DELETE.ts b/backend/src/event/EVENT_ADMIN_USER_DELETE.ts new file mode 100644 index 000000000..bfd5be740 --- /dev/null +++ b/backend/src/event/EVENT_ADMIN_USER_DELETE.ts @@ -0,0 +1,6 @@ +import { User as DbUser } from '@entity/User' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_ADMIN_USER_DELETE = async (user: DbUser, moderator: DbUser): Promise => + Event(EventType.ADMIN_USER_DELETE, user, moderator).save() diff --git a/backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts b/backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts new file mode 100644 index 000000000..3be825ad4 --- /dev/null +++ b/backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts @@ -0,0 +1,8 @@ +import { User as DbUser } from '@entity/User' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_ADMIN_USER_ROLE_SET = async ( + user: DbUser, + moderator: DbUser, +): Promise => Event(EventType.ADMIN_USER_ROLE_SET, user, moderator).save() diff --git a/backend/src/event/EVENT_ADMIN_USER_UNDELETE.ts b/backend/src/event/EVENT_ADMIN_USER_UNDELETE.ts new file mode 100644 index 000000000..eb861dbf1 --- /dev/null +++ b/backend/src/event/EVENT_ADMIN_USER_UNDELETE.ts @@ -0,0 +1,8 @@ +import { User as DbUser } from '@entity/User' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_ADMIN_USER_UNDELETE = async ( + user: DbUser, + moderator: DbUser, +): Promise => Event(EventType.ADMIN_USER_UNDELETE, user, moderator).save() diff --git a/backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts b/backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts index 4160ce244..f7e328369 100644 --- a/backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts +++ b/backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts @@ -3,4 +3,4 @@ import { Event as DbEvent } from '@entity/Event' import { Event, EventType } from './Event' export const EVENT_EMAIL_FORGOT_PASSWORD = async (user: DbUser): Promise => - Event(EventType.EMAIL_FORGOT_PASSWORD, user, user).save() + Event(EventType.EMAIL_FORGOT_PASSWORD, user, { id: 0 } as DbUser).save() diff --git a/backend/src/event/Event.ts b/backend/src/event/Event.ts index 60da91b70..901bc33ff 100644 --- a/backend/src/event/Event.ts +++ b/backend/src/event/Event.ts @@ -47,6 +47,9 @@ export { EVENT_ADMIN_CONTRIBUTION_LINK_DELETE } from './EVENT_ADMIN_CONTRIBUTION export { EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE } from './EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE' export { EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE' export { EVENT_ADMIN_SEND_CONFIRMATION_EMAIL } from './EVENT_ADMIN_SEND_CONFIRMATION_EMAIL' +export { EVENT_ADMIN_USER_DELETE } from './EVENT_ADMIN_USER_DELETE' +export { EVENT_ADMIN_USER_UNDELETE } from './EVENT_ADMIN_USER_UNDELETE' +export { EVENT_ADMIN_USER_ROLE_SET } from './EVENT_ADMIN_USER_ROLE_SET' export { EVENT_CONTRIBUTION_CREATE } from './EVENT_CONTRIBUTION_CREATE' export { EVENT_CONTRIBUTION_DELETE } from './EVENT_CONTRIBUTION_DELETE' export { EVENT_CONTRIBUTION_UPDATE } from './EVENT_CONTRIBUTION_UPDATE' @@ -63,3 +66,4 @@ export { EVENT_TRANSACTION_RECEIVE } from './EVENT_TRANSACTION_RECEIVE' export { EVENT_TRANSACTION_LINK_CREATE } from './EVENT_TRANSACTION_LINK_CREATE' export { EVENT_TRANSACTION_LINK_DELETE } from './EVENT_TRANSACTION_LINK_DELETE' export { EVENT_TRANSACTION_LINK_REDEEM } from './EVENT_TRANSACTION_LINK_REDEEM' +export { EVENT_USER_INFO_UPDATE } from './EVENT_USER_INFO_UPDATE' diff --git a/backend/src/event/EventType.ts b/backend/src/event/EventType.ts index cc277e589..58d03c84b 100644 --- a/backend/src/event/EventType.ts +++ b/backend/src/event/EventType.ts @@ -11,6 +11,9 @@ export enum EventType { ADMIN_CONTRIBUTION_LINK_UPDATE = 'ADMIN_CONTRIBUTION_LINK_UPDATE', ADMIN_CONTRIBUTION_MESSAGE_CREATE = 'ADMIN_CONTRIBUTION_MESSAGE_CREATE', ADMIN_SEND_CONFIRMATION_EMAIL = 'ADMIN_SEND_CONFIRMATION_EMAIL', + ADMIN_USER_DELETE = 'ADMIN_USER_DELETE', + ADMIN_USER_UNDELETE = 'ADMIN_USER_UNDELETE', + ADMIN_USER_ROLE_SET = 'ADMIN_USER_ROLE_SET', CONTRIBUTION_CREATE = 'CONTRIBUTION_CREATE', CONTRIBUTION_DELETE = 'CONTRIBUTION_DELETE', CONTRIBUTION_UPDATE = 'CONTRIBUTION_UPDATE', diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 196110a31..f51d0fdac 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -60,6 +60,9 @@ import { EVENT_LOGOUT, EVENT_EMAIL_FORGOT_PASSWORD, EVENT_USER_INFO_UPDATE, + EVENT_USER_ROLE_SET, + EVENT_ADMIN_USER_ROLE_SET, + EVENT_ADMIN_USER_DELETE, } from '@/event/Event' import { getUserCreations } from './util/creations' import { isValidPassword } from '@/password/EncryptorUtils' @@ -585,7 +588,6 @@ export class UserResolver { await queryRunner.release() } logger.info('updateUserInfos() successfully finished...') - await EVENT_USER_INFO_UPDATE(user) return true @@ -713,8 +715,8 @@ export class UserResolver { throw new LogError('Could not find user with given ID', userId) } // administrator user changes own role? - const moderatorUser = getUser(context) - if (moderatorUser.id === userId) { + const moderator = getUser(context) + if (moderator.id === userId) { throw new LogError('Administrator can not change his own role') } // change isAdmin @@ -735,6 +737,7 @@ export class UserResolver { break } await user.save() + await EVENT_ADMIN_USER_ROLE_SET(user, moderator) const newUser = await DbUser.findOne({ id: userId }) return newUser ? newUser.isAdmin : null } @@ -751,19 +754,20 @@ export class UserResolver { throw new LogError('Could not find user with given ID', userId) } // moderator user disabled own account? - const moderatorUser = getUser(context) - if (moderatorUser.id === userId) { + const moderator = getUser(context) + if (moderator.id === userId) { throw new LogError('Moderator can not delete his own account') } // soft-delete user await user.softRemove() + await EVENT_ADMIN_USER_DELETE(user, moderator) const newUser = await DbUser.findOne({ id: userId }, { withDeleted: true }) return newUser ? newUser.deletedAt : null } @Authorized([RIGHTS.ADMIN_UNDELETE_USER]) @Mutation(() => Date, { nullable: true }) - async unDeleteUser(@Arg('userId', () => Int) userId: number): Promise { + async unDeleteUser(@Arg('userId', () => Int) userId: number, @Ctx() context: Context,): Promise { const user = await DbUser.findOne({ id: userId }, { withDeleted: true }) if (!user) { throw new LogError('Could not find user with given ID', userId) @@ -772,6 +776,7 @@ export class UserResolver { throw new LogError('User is not deleted') } await user.recover() + await EVENT_ADMIN_USER_UNDELETE(user, getUser(context)) return null } From dfbfefd73af3b6ffd7cc874ee0bd1682c23cf4da Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 9 Mar 2023 11:54:14 +0100 Subject: [PATCH 10/91] always write send confirmation event --- backend/src/graphql/resolver/UserResolver.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index f51d0fdac..1d80c650a 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -63,6 +63,7 @@ import { EVENT_USER_ROLE_SET, EVENT_ADMIN_USER_ROLE_SET, EVENT_ADMIN_USER_DELETE, + EVENT_ADMIN_USER_UNDELETE, } from '@/event/Event' import { getUserCreations } from './util/creations' import { isValidPassword } from '@/password/EncryptorUtils' @@ -767,7 +768,10 @@ export class UserResolver { @Authorized([RIGHTS.ADMIN_UNDELETE_USER]) @Mutation(() => Date, { nullable: true }) - async unDeleteUser(@Arg('userId', () => Int) userId: number, @Ctx() context: Context,): Promise { + async unDeleteUser( + @Arg('userId', () => Int) userId: number, + @Ctx() context: Context, + ): Promise { const user = await DbUser.findOne({ id: userId }, { withDeleted: true }) if (!user) { throw new LogError('Could not find user with given ID', userId) @@ -810,9 +814,8 @@ export class UserResolver { // In case EMails are disabled log the activation link for the user if (!emailSent) { logger.info(`Account confirmation link: ${activationLink}`) - } else { - await EVENT_ADMIN_SEND_CONFIRMATION_EMAIL(user, getUser(context)) } + await EVENT_ADMIN_SEND_CONFIRMATION_EMAIL(user, getUser(context)) return true } From ab4e1cfe1f07c898eae8f369f4cfb01a719a865a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 9 Mar 2023 11:55:25 +0100 Subject: [PATCH 11/91] fixed imports --- backend/src/graphql/resolver/UserResolver.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 1d80c650a..13fb74fd5 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -60,7 +60,6 @@ import { EVENT_LOGOUT, EVENT_EMAIL_FORGOT_PASSWORD, EVENT_USER_INFO_UPDATE, - EVENT_USER_ROLE_SET, EVENT_ADMIN_USER_ROLE_SET, EVENT_ADMIN_USER_DELETE, EVENT_ADMIN_USER_UNDELETE, From e79130ea868198680bd30b9a085f52d143e61e7b Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 9 Mar 2023 12:19:53 +0100 Subject: [PATCH 12/91] test all events --- .../src/graphql/resolver/UserResolver.test.ts | 98 ++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index b382b2627..62eea9c0e 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -857,11 +857,25 @@ describe('UserResolver', () => { it('returns true', async () => { await expect(mutate({ mutation: logout })).resolves.toEqual( expect.objectContaining({ - data: { logout: 'true' }, + data: { logout: true }, errors: undefined, }), ) }) + + it('stores the LOGOUT event in the database', async () => { + const userConatct = await UserContact.findOneOrFail( + { email: 'bibi@bloxberg.de' }, + { relations: ['user'] }, + ) + expect(DbEvent.find()).resolves.toContainEqual( + expect.objectContaining({ + type: EventType.LOGOUT, + affectedUserId: userConatct.user.id, + actingUserId: userConatct.user.id, + }), + ) + }) }) }) @@ -1017,6 +1031,20 @@ describe('UserResolver', () => { }), }) }) + + it('stores the EMAIL_FORGOT_PASSWORD event in the database', async () => { + const userConatct = await UserContact.findOneOrFail( + { email: 'bibi@bloxberg.de' }, + { relations: ['user'] }, + ) + expect(DbEvent.find()).resolves.toContainEqual( + expect.objectContaining({ + type: EventType.EMAIL_FORGOT_PASSWORD, + affectedUserId: userConatct.user.id, + actingUserId: 0, + }), + ) + }) }) describe('request reset password again', () => { @@ -1141,6 +1169,20 @@ describe('UserResolver', () => { }), ) }) + + it('stores the USER_INFO_UPDATE event in the database', async () => { + const userConatct = await UserContact.findOneOrFail( + { email: 'bibi@bloxberg.de' }, + { relations: ['user'] }, + ) + expect(DbEvent.find()).resolves.toContainEqual( + expect.objectContaining({ + type: EventType.USER_INFO_UPDATE, + affectedUserId: userConatct.user.id, + actingUserId: userConatct.user.id, + }), + ) + }) }) describe('language is not valid', () => { @@ -1511,6 +1553,24 @@ describe('UserResolver', () => { ) expect(new Date(result.data.setUserRole)).toEqual(expect.any(Date)) }) + + it('stores the ADMIN_USER_ROLE_SET event in the database', async () => { + const userConatct = await UserContact.findOneOrFail( + { email: 'bibi@bloxberg.de' }, + { relations: ['user'] }, + ) + const adminConatct = await UserContact.findOneOrFail( + { email: 'peter@lustig.de' }, + { relations: ['user'] }, + ) + expect(DbEvent.find()).resolves.toContainEqual( + expect.objectContaining({ + type: EventType.ADMIN_USER_ROLE_SET, + affectedUserId: userConatct.user.id, + actingUserId: adminConatct.user.id, + }), + ) + }) }) describe('to usual user', () => { @@ -1696,6 +1756,24 @@ describe('UserResolver', () => { expect(new Date(result.data.deleteUser)).toEqual(expect.any(Date)) }) + it('stores the ADMIN_USER_DELETE event in the database', async () => { + const userConatct = await UserContact.findOneOrFail( + { email: 'bibi@bloxberg.de' }, + { relations: ['user'], withDeleted: true }, + ) + const adminConatct = await UserContact.findOneOrFail( + { email: 'peter@lustig.de' }, + { relations: ['user'] }, + ) + expect(DbEvent.find()).resolves.toContainEqual( + expect.objectContaining({ + type: EventType.ADMIN_USER_DELETE, + affectedUserId: userConatct.user.id, + actingUserId: adminConatct.user.id, + }), + ) + }) + describe('delete deleted user', () => { it('throws an error', async () => { jest.clearAllMocks() @@ -1971,6 +2049,24 @@ describe('UserResolver', () => { }), ) }) + + it('stores the ADMIN_USER_UNDELETE event in the database', async () => { + const userConatct = await UserContact.findOneOrFail( + { email: 'bibi@bloxberg.de' }, + { relations: ['user'] }, + ) + const adminConatct = await UserContact.findOneOrFail( + { email: 'peter@lustig.de' }, + { relations: ['user'] }, + ) + expect(DbEvent.find()).resolves.toContainEqual( + expect.objectContaining({ + type: EventType.ADMIN_USER_UNDELETE, + affectedUserId: userConatct.user.id, + actingUserId: adminConatct.user.id, + }), + ) + }) }) }) }) From d989e5c48977ddcac6bff943c99955904819dc61 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 9 Mar 2023 13:29:46 +0100 Subject: [PATCH 13/91] rename events --- .../EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION.ts | 6 ++++ ...L.ts => EVENT_EMAIL_ADMIN_CONFIRMATION.ts} | 4 +-- ...ACCOUNT.ts => EVENT_EMAIL_CONFIRMATION.ts} | 4 +-- ...NT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL.ts | 6 ---- .../event/EVENT_SEND_CONFIRMATION_EMAIL.ts | 6 ---- .../src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts | 6 ++++ ...{EVENT_REGISTER.ts => EVENT_USER_LOGIN.ts} | 4 +-- .../{EVENT_LOGIN.ts => EVENT_USER_LOGOUT.ts} | 4 +-- ...EVENT_LOGOUT.ts => EVENT_USER_REGISTER.ts} | 4 +-- backend/src/event/Event.ts | 14 ++++---- backend/src/event/EventType.ts | 17 +++++---- .../resolver/ContributionResolver.test.ts | 4 +-- .../src/graphql/resolver/UserResolver.test.ts | 36 +++++++++---------- backend/src/graphql/resolver/UserResolver.ts | 27 +++++++------- 14 files changed, 70 insertions(+), 72 deletions(-) create mode 100644 backend/src/event/EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION.ts rename backend/src/event/{EVENT_ADMIN_SEND_CONFIRMATION_EMAIL.ts => EVENT_EMAIL_ADMIN_CONFIRMATION.ts} (53%) rename backend/src/event/{EVENT_ACTIVATE_ACCOUNT.ts => EVENT_EMAIL_CONFIRMATION.ts} (50%) delete mode 100644 backend/src/event/EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL.ts delete mode 100644 backend/src/event/EVENT_SEND_CONFIRMATION_EMAIL.ts create mode 100644 backend/src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts rename backend/src/event/{EVENT_REGISTER.ts => EVENT_USER_LOGIN.ts} (53%) rename backend/src/event/{EVENT_LOGIN.ts => EVENT_USER_LOGOUT.ts} (52%) rename backend/src/event/{EVENT_LOGOUT.ts => EVENT_USER_REGISTER.ts} (51%) diff --git a/backend/src/event/EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION.ts b/backend/src/event/EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION.ts new file mode 100644 index 000000000..c16bbfac3 --- /dev/null +++ b/backend/src/event/EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION.ts @@ -0,0 +1,6 @@ +import { User as DbUser } from '@entity/User' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION = async (user: DbUser): Promise => + Event(EventType.EMAIL_ACCOUNT_MULTIREGISTRATION, user, { id: 0 } as DbUser).save() diff --git a/backend/src/event/EVENT_ADMIN_SEND_CONFIRMATION_EMAIL.ts b/backend/src/event/EVENT_EMAIL_ADMIN_CONFIRMATION.ts similarity index 53% rename from backend/src/event/EVENT_ADMIN_SEND_CONFIRMATION_EMAIL.ts rename to backend/src/event/EVENT_EMAIL_ADMIN_CONFIRMATION.ts index da4907930..ae10f9fba 100644 --- a/backend/src/event/EVENT_ADMIN_SEND_CONFIRMATION_EMAIL.ts +++ b/backend/src/event/EVENT_EMAIL_ADMIN_CONFIRMATION.ts @@ -2,7 +2,7 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' import { Event, EventType } from './Event' -export const EVENT_ADMIN_SEND_CONFIRMATION_EMAIL = async ( +export const EVENT_EMAIL_ADMIN_CONFIRMATION = async ( user: DbUser, moderator: DbUser, -): Promise => Event(EventType.ADMIN_SEND_CONFIRMATION_EMAIL, user, moderator).save() +): Promise => Event(EventType.EMAIL_ADMIN_CONFIRMATION, user, moderator).save() diff --git a/backend/src/event/EVENT_ACTIVATE_ACCOUNT.ts b/backend/src/event/EVENT_EMAIL_CONFIRMATION.ts similarity index 50% rename from backend/src/event/EVENT_ACTIVATE_ACCOUNT.ts rename to backend/src/event/EVENT_EMAIL_CONFIRMATION.ts index 755cc8fe2..9d64207e0 100644 --- a/backend/src/event/EVENT_ACTIVATE_ACCOUNT.ts +++ b/backend/src/event/EVENT_EMAIL_CONFIRMATION.ts @@ -2,5 +2,5 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' import { Event, EventType } from './Event' -export const EVENT_ACTIVATE_ACCOUNT = async (user: DbUser): Promise => - Event(EventType.ACTIVATE_ACCOUNT, user, user).save() +export const EVENT_EMAIL_CONFIRMATION = async (user: DbUser): Promise => + Event(EventType.EMAIL_CONFIRMATION, user, user).save() diff --git a/backend/src/event/EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL.ts b/backend/src/event/EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL.ts deleted file mode 100644 index 3110ece1f..000000000 --- a/backend/src/event/EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { User as DbUser } from '@entity/User' -import { Event as DbEvent } from '@entity/Event' -import { Event, EventType } from './Event' - -export const EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL = async (user: DbUser): Promise => - Event(EventType.SEND_ACCOUNT_MULTIREGISTRATION_EMAIL, user, { id: 0 } as DbUser).save() diff --git a/backend/src/event/EVENT_SEND_CONFIRMATION_EMAIL.ts b/backend/src/event/EVENT_SEND_CONFIRMATION_EMAIL.ts deleted file mode 100644 index b387c0e60..000000000 --- a/backend/src/event/EVENT_SEND_CONFIRMATION_EMAIL.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { User as DbUser } from '@entity/User' -import { Event as DbEvent } from '@entity/Event' -import { Event, EventType } from './Event' - -export const EVENT_SEND_CONFIRMATION_EMAIL = async (user: DbUser): Promise => - Event(EventType.SEND_CONFIRMATION_EMAIL, user, user).save() diff --git a/backend/src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts b/backend/src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts new file mode 100644 index 000000000..2e224d550 --- /dev/null +++ b/backend/src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts @@ -0,0 +1,6 @@ +import { User as DbUser } from '@entity/User' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_USER_ACTIVATE_ACCOUNT = async (user: DbUser): Promise => + Event(EventType.USER_ACTIVATE_ACCOUNT, user, user).save() diff --git a/backend/src/event/EVENT_REGISTER.ts b/backend/src/event/EVENT_USER_LOGIN.ts similarity index 53% rename from backend/src/event/EVENT_REGISTER.ts rename to backend/src/event/EVENT_USER_LOGIN.ts index 73c6bf4f9..351ec5a95 100644 --- a/backend/src/event/EVENT_REGISTER.ts +++ b/backend/src/event/EVENT_USER_LOGIN.ts @@ -2,5 +2,5 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' import { Event, EventType } from './Event' -export const EVENT_REGISTER = async (user: DbUser): Promise => - Event(EventType.REGISTER, user, user).save() +export const EVENT_USER_LOGIN = async (user: DbUser): Promise => + Event(EventType.USER_LOGIN, user, user).save() diff --git a/backend/src/event/EVENT_LOGIN.ts b/backend/src/event/EVENT_USER_LOGOUT.ts similarity index 52% rename from backend/src/event/EVENT_LOGIN.ts rename to backend/src/event/EVENT_USER_LOGOUT.ts index 2c1e763ec..4f5650fc6 100644 --- a/backend/src/event/EVENT_LOGIN.ts +++ b/backend/src/event/EVENT_USER_LOGOUT.ts @@ -2,5 +2,5 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' import { Event, EventType } from './Event' -export const EVENT_LOGIN = async (user: DbUser): Promise => - Event(EventType.LOGIN, user, user).save() +export const EVENT_USER_LOGOUT = async (user: DbUser): Promise => + Event(EventType.USER_LOGOUT, user, user).save() diff --git a/backend/src/event/EVENT_LOGOUT.ts b/backend/src/event/EVENT_USER_REGISTER.ts similarity index 51% rename from backend/src/event/EVENT_LOGOUT.ts rename to backend/src/event/EVENT_USER_REGISTER.ts index 1e423359c..cdb8b22e2 100644 --- a/backend/src/event/EVENT_LOGOUT.ts +++ b/backend/src/event/EVENT_USER_REGISTER.ts @@ -2,5 +2,5 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' import { Event, EventType } from './Event' -export const EVENT_LOGOUT = async (user: DbUser): Promise => - Event(EventType.LOGOUT, user, user).save() +export const EVENT_USER_REGISTER = async (user: DbUser): Promise => + Event(EventType.USER_REGISTER, user, user).save() diff --git a/backend/src/event/Event.ts b/backend/src/event/Event.ts index 901bc33ff..dc2db17eb 100644 --- a/backend/src/event/Event.ts +++ b/backend/src/event/Event.ts @@ -36,7 +36,6 @@ export const Event = ( export { EventType } from './EventType' -export { EVENT_ACTIVATE_ACCOUNT } from './EVENT_ACTIVATE_ACCOUNT' export { EVENT_ADMIN_CONTRIBUTION_CONFIRM } from './EVENT_ADMIN_CONTRIBUTION_CONFIRM' export { EVENT_ADMIN_CONTRIBUTION_CREATE } from './EVENT_ADMIN_CONTRIBUTION_CREATE' export { EVENT_ADMIN_CONTRIBUTION_DELETE } from './EVENT_ADMIN_CONTRIBUTION_DELETE' @@ -46,7 +45,6 @@ export { EVENT_ADMIN_CONTRIBUTION_LINK_CREATE } from './EVENT_ADMIN_CONTRIBUTION export { EVENT_ADMIN_CONTRIBUTION_LINK_DELETE } from './EVENT_ADMIN_CONTRIBUTION_LINK_DELETE' export { EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE } from './EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE' export { EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE' -export { EVENT_ADMIN_SEND_CONFIRMATION_EMAIL } from './EVENT_ADMIN_SEND_CONFIRMATION_EMAIL' export { EVENT_ADMIN_USER_DELETE } from './EVENT_ADMIN_USER_DELETE' export { EVENT_ADMIN_USER_UNDELETE } from './EVENT_ADMIN_USER_UNDELETE' export { EVENT_ADMIN_USER_ROLE_SET } from './EVENT_ADMIN_USER_ROLE_SET' @@ -55,15 +53,17 @@ export { EVENT_CONTRIBUTION_DELETE } from './EVENT_CONTRIBUTION_DELETE' export { EVENT_CONTRIBUTION_UPDATE } from './EVENT_CONTRIBUTION_UPDATE' export { EVENT_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_CONTRIBUTION_MESSAGE_CREATE' export { EVENT_CONTRIBUTION_LINK_REDEEM } from './EVENT_CONTRIBUTION_LINK_REDEEM' +export { EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION } from './EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION' +export { EVENT_EMAIL_ADMIN_CONFIRMATION } from './EVENT_EMAIL_ADMIN_CONFIRMATION' +export { EVENT_EMAIL_CONFIRMATION } from './EVENT_EMAIL_CONFIRMATION' export { EVENT_EMAIL_FORGOT_PASSWORD } from './EVENT_EMAIL_FORGOT_PASSWORD' -export { EVENT_LOGIN } from './EVENT_LOGIN' -export { EVENT_LOGOUT } from './EVENT_LOGOUT' -export { EVENT_REGISTER } from './EVENT_REGISTER' -export { EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL } from './EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL' -export { EVENT_SEND_CONFIRMATION_EMAIL } from './EVENT_SEND_CONFIRMATION_EMAIL' export { EVENT_TRANSACTION_SEND } from './EVENT_TRANSACTION_SEND' export { EVENT_TRANSACTION_RECEIVE } from './EVENT_TRANSACTION_RECEIVE' export { EVENT_TRANSACTION_LINK_CREATE } from './EVENT_TRANSACTION_LINK_CREATE' export { EVENT_TRANSACTION_LINK_DELETE } from './EVENT_TRANSACTION_LINK_DELETE' export { EVENT_TRANSACTION_LINK_REDEEM } from './EVENT_TRANSACTION_LINK_REDEEM' +export { EVENT_USER_ACTIVATE_ACCOUNT } from './EVENT_USER_ACTIVATE_ACCOUNT' export { EVENT_USER_INFO_UPDATE } from './EVENT_USER_INFO_UPDATE' +export { EVENT_USER_LOGIN } from './EVENT_USER_LOGIN' +export { EVENT_USER_LOGOUT } from './EVENT_USER_LOGOUT' +export { EVENT_USER_REGISTER } from './EVENT_USER_REGISTER' diff --git a/backend/src/event/EventType.ts b/backend/src/event/EventType.ts index 58d03c84b..959a848f5 100644 --- a/backend/src/event/EventType.ts +++ b/backend/src/event/EventType.ts @@ -1,5 +1,4 @@ export enum EventType { - ACTIVATE_ACCOUNT = 'ACTIVATE_ACCOUNT', // TODO CONTRIBUTION_CONFIRM = 'CONTRIBUTION_CONFIRM', ADMIN_CONTRIBUTION_CONFIRM = 'ADMIN_CONTRIBUTION_CONFIRM', ADMIN_CONTRIBUTION_CREATE = 'ADMIN_CONTRIBUTION_CREATE', @@ -10,7 +9,6 @@ export enum EventType { ADMIN_CONTRIBUTION_LINK_DELETE = 'ADMIN_CONTRIBUTION_LINK_DELETE', ADMIN_CONTRIBUTION_LINK_UPDATE = 'ADMIN_CONTRIBUTION_LINK_UPDATE', ADMIN_CONTRIBUTION_MESSAGE_CREATE = 'ADMIN_CONTRIBUTION_MESSAGE_CREATE', - ADMIN_SEND_CONFIRMATION_EMAIL = 'ADMIN_SEND_CONFIRMATION_EMAIL', ADMIN_USER_DELETE = 'ADMIN_USER_DELETE', ADMIN_USER_UNDELETE = 'ADMIN_USER_UNDELETE', ADMIN_USER_ROLE_SET = 'ADMIN_USER_ROLE_SET', @@ -19,25 +17,26 @@ export enum EventType { CONTRIBUTION_UPDATE = 'CONTRIBUTION_UPDATE', CONTRIBUTION_MESSAGE_CREATE = 'CONTRIBUTION_MESSAGE_CREATE', CONTRIBUTION_LINK_REDEEM = 'CONTRIBUTION_LINK_REDEEM', + EMAIL_ACCOUNT_MULTIREGISTRATION = 'EMAIL_ACCOUNT_MULTIREGISTRATION', + EMAIL_ADMIN_CONFIRMATION = 'EMAIL_ADMIN_CONFIRMATION', + EMAIL_CONFIRMATION = 'EMAIL_CONFIRMATION', EMAIL_FORGOT_PASSWORD = 'EMAIL_FORGOT_PASSWORD', - LOGIN = 'LOGIN', - LOGOUT = 'LOGOUT', - REGISTER = 'REGISTER', - REDEEM_REGISTER = 'REDEEM_REGISTER', - SEND_ACCOUNT_MULTIREGISTRATION_EMAIL = 'SEND_ACCOUNT_MULTIREGISTRATION_EMAIL', - SEND_CONFIRMATION_EMAIL = 'SEND_CONFIRMATION_EMAIL', TRANSACTION_SEND = 'TRANSACTION_SEND', TRANSACTION_RECEIVE = 'TRANSACTION_RECEIVE', TRANSACTION_LINK_CREATE = 'TRANSACTION_LINK_CREATE', TRANSACTION_LINK_DELETE = 'TRANSACTION_LINK_DELETE', TRANSACTION_LINK_REDEEM = 'TRANSACTION_LINK_REDEEM', + USER_ACTIVATE_ACCOUNT = 'ACTIVATE_ACCOUNT', USER_INFO_UPDATE = 'USER_INFO_UPDATE', + USER_LOGIN = 'USER_LOGIN', + USER_LOGOUT = 'USER_LOGOUT', + USER_REGISTER = 'USER_REGISTER', + USER_REGISTER_REDEEM = 'USER_REGISTER_REDEEM', // VISIT_GRADIDO = 'VISIT_GRADIDO', // VERIFY_REDEEM = 'VERIFY_REDEEM', // INACTIVE_ACCOUNT = 'INACTIVE_ACCOUNT', // CONFIRM_EMAIL = 'CONFIRM_EMAIL', // REGISTER_EMAIL_KLICKTIPP = 'REGISTER_EMAIL_KLICKTIPP', - // LOGOUT = 'LOGOUT', // REDEEM_LOGIN = 'REDEEM_LOGIN', // SEND_FORGOT_PASSWORD_EMAIL = 'SEND_FORGOT_PASSWORD_EMAIL', // PASSWORD_CHANGE = 'PASSWORD_CHANGE', diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 2b59bde8b..1ac1260a5 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -2573,10 +2573,10 @@ describe('ContributionResolver', () => { }) }) - it('stores the SEND_CONFIRMATION_EMAIL event in the database', async () => { + it('stores the EMAIL_CONFIRMATION event in the database', async () => { await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ - type: EventType.SEND_CONFIRMATION_EMAIL, + type: EventType.EMAIL_CONFIRMATION, }), ) }) diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index 62eea9c0e..6843336cc 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -177,14 +177,14 @@ describe('UserResolver', () => { }) }) - it('stores the REGISTER event in the database', async () => { + it('stores the USER_REGISTER event in the database', async () => { const userConatct = await UserContact.findOneOrFail( { email: 'peter@lustig.de' }, { relations: ['user'] }, ) expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ - type: EventType.REGISTER, + type: EventType.USER_REGISTER, affectedUserId: userConatct.user.id, actingUserId: userConatct.user.id, }), @@ -211,10 +211,10 @@ describe('UserResolver', () => { }) }) - it('stores the SEND_CONFIRMATION_EMAIL event in the database', () => { + it('stores the EMAIL_CONFIRMATION event in the database', () => { expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ - type: EventType.SEND_CONFIRMATION_EMAIL, + type: EventType.EMAIL_CONFIRMATION, affectedUserId: user[0].id, actingUserId: user[0].id, }), @@ -253,14 +253,14 @@ describe('UserResolver', () => { ) }) - it('stores the SEND_ACCOUNT_MULTIREGISTRATION_EMAIL event in the database', async () => { + it('stores the EMAIL_ACCOUNT_MULTIREGISTRATION event in the database', async () => { const userConatct = await UserContact.findOneOrFail( { email: 'peter@lustig.de' }, { relations: ['user'] }, ) expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ - type: EventType.SEND_ACCOUNT_MULTIREGISTRATION_EMAIL, + type: EventType.EMAIL_ACCOUNT_MULTIREGISTRATION, affectedUserId: userConatct.user.id, actingUserId: 0, }), @@ -358,20 +358,20 @@ describe('UserResolver', () => { ) }) - it('stores the ACTIVATE_ACCOUNT event in the database', () => { + it('stores the USER_ACTIVATE_ACCOUNT event in the database', () => { expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ - type: EventType.ACTIVATE_ACCOUNT, + type: EventType.USER_ACTIVATE_ACCOUNT, affectedUserId: user[0].id, actingUserId: user[0].id, }), ) }) - it('stores the REDEEM_REGISTER event in the database', () => { + it('stores the USER_REGISTER_REDEEM event in the database', () => { expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ - type: EventType.REDEEM_REGISTER, + type: EventType.USER_REGISTER_REDEEM, affectedUserId: result.data.createUser.id, actingUserId: result.data.createUser.id, involvedContributionLinkId: link.id, @@ -453,10 +453,10 @@ describe('UserResolver', () => { ) }) - it('stores the REDEEM_REGISTER event in the database', async () => { + it('stores the USER_REGISTER_REDEEM event in the database', async () => { await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ - type: EventType.REDEEM_REGISTER, + type: EventType.USER_REGISTER_REDEEM, affectedUserId: newUser.data.createUser.id, actingUserId: newUser.data.createUser.id, involvedTransactionLinkId: transactionLink.id, @@ -682,14 +682,14 @@ describe('UserResolver', () => { expect(headerPushMock).toBeCalledWith({ key: 'token', value: expect.any(String) }) }) - it('stores the LOGIN event in the database', async () => { + it('stores the USER_LOGIN event in the database', async () => { const userConatct = await UserContact.findOneOrFail( { email: 'bibi@bloxberg.de' }, { relations: ['user'] }, ) expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ - type: EventType.LOGIN, + type: EventType.USER_LOGIN, affectedUserId: userConatct.user.id, actingUserId: userConatct.user.id, }), @@ -863,14 +863,14 @@ describe('UserResolver', () => { ) }) - it('stores the LOGOUT event in the database', async () => { + it('stores the USER_LOGOUT event in the database', async () => { const userConatct = await UserContact.findOneOrFail( { email: 'bibi@bloxberg.de' }, { relations: ['user'] }, ) expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ - type: EventType.LOGOUT, + type: EventType.USER_LOGOUT, affectedUserId: userConatct.user.id, actingUserId: userConatct.user.id, }), @@ -949,10 +949,10 @@ describe('UserResolver', () => { ) }) - it('stores the LOGIN event in the database', () => { + it('stores the USER_LOGIN event in the database', () => { expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ - type: EventType.LOGIN, + type: EventType.USER_LOGIN, affectedUserId: user[0].id, actingUserId: user[0].id, }), diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 13fb74fd5..7fc043089 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -51,13 +51,13 @@ import { hasElopageBuys } from '@/util/hasElopageBuys' import { Event, EventType, - EVENT_LOGIN, - EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL, - EVENT_SEND_CONFIRMATION_EMAIL, - EVENT_REGISTER, - EVENT_ACTIVATE_ACCOUNT, + EVENT_USER_LOGIN, + EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION, + EVENT_EMAIL_CONFIRMATION, + EVENT_USER_REGISTER, + EVENT_USER_ACTIVATE_ACCOUNT, EVENT_ADMIN_SEND_CONFIRMATION_EMAIL, - EVENT_LOGOUT, + EVENT_USER_LOGOUT, EVENT_EMAIL_FORGOT_PASSWORD, EVENT_USER_INFO_UPDATE, EVENT_ADMIN_USER_ROLE_SET, @@ -184,7 +184,7 @@ export class UserResolver { value: encode(dbUser.gradidoID), }) - await EVENT_LOGIN(dbUser) + await EVENT_USER_LOGIN(dbUser) logger.info(`successful Login: ${JSON.stringify(user, null, 2)}`) return user } @@ -192,7 +192,7 @@ export class UserResolver { @Authorized([RIGHTS.LOGOUT]) @Mutation(() => Boolean) async logout(@Ctx() context: Context): Promise { - await EVENT_LOGOUT(getUser(context)) + await EVENT_USER_LOGOUT(getUser(context)) // remove user from logger context logger.addContext('user', 'unknown') return true @@ -247,8 +247,7 @@ export class UserResolver { email, language: foundUser.language, // use language of the emails owner for sending }) - - await EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL(foundUser) + await EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION(foundUser) logger.info( `sendAccountMultiRegistrationEmail by ${firstName} ${lastName} to ${foundUser.firstName} ${foundUser.lastName} <${email}>`, @@ -267,7 +266,7 @@ export class UserResolver { const gradidoID = await newGradidoID() const eventRegisterRedeem = Event( - EventType.REDEEM_REGISTER, + EventType.USER_REGISTER_REDEEM, { id: 0 } as DbUser, { id: 0 } as DbUser, ) @@ -333,7 +332,7 @@ export class UserResolver { }) logger.info(`sendAccountActivationEmail of ${firstName}.${lastName} to ${email}`) - await EVENT_SEND_CONFIRMATION_EMAIL(dbUser) + await EVENT_EMAIL_CONFIRMATION(dbUser) if (!emailSent) { logger.debug(`Account confirmation link: ${activationLink}`) @@ -354,7 +353,7 @@ export class UserResolver { eventRegisterRedeem.actingUser = dbUser await eventRegisterRedeem.save() } else { - await EVENT_REGISTER(dbUser) + await EVENT_USER_REGISTER(dbUser) } return new User(dbUser) @@ -489,7 +488,7 @@ export class UserResolver { logger.error('Error subscribing to klicktipp', e) } } - await EVENT_ACTIVATE_ACCOUNT(user) + await EVENT_USER_ACTIVATE_ACCOUNT(user) return true } From 247adbc6505ec1ac3b8828d42e72b4992cc43d86 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 9 Mar 2023 13:35:13 +0100 Subject: [PATCH 14/91] database migration 0064 --- backend/src/config/index.ts | 2 +- database/migrations/0064-event_rename.ts | 50 ++++++++++++++++++++++++ dht-node/src/config/index.ts | 2 +- federation/src/config/index.ts | 2 +- 4 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 database/migrations/0064-event_rename.ts diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index ef537d804..79e513a6c 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0063-event_link_fields', + DB_VERSION: '0064-event_rename', DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info diff --git a/database/migrations/0064-event_rename.ts b/database/migrations/0064-event_rename.ts new file mode 100644 index 000000000..992b30de9 --- /dev/null +++ b/database/migrations/0064-event_rename.ts @@ -0,0 +1,50 @@ +/* MIGRATION TO CHANGE EVENT NAMES + * + * This migration renames several events to ensure consistent + * naming conventions. + */ + +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn( + 'UPDATE `events` SET `type` = "USER_ACTIVATE_ACCOUNT" WHERE `type` = "ACTIVATE_ACCOUNT";', + ) + await queryFn('UPDATE `events` SET `type` = "USER_LOGIN" WHERE `type` = "LOGIN";') + await queryFn('UPDATE `events` SET `type` = "USER_LOGOUT" WHERE `type` = "LOGOUT";') + await queryFn('UPDATE `events` SET `type` = "USER_REGISTER" WHERE `type` = "REGISTER";') + await queryFn( + 'UPDATE `events` SET `type` = "EMAIL_ACCOUNT_MULTIREGISTRATION" WHERE `type` = "SEND_ACCOUNT_MULTIREGISTRATION_EMAIL";', + ) + await queryFn( + 'UPDATE `events` SET `type` = "EMAIL_CONFIRMATION" WHERE `type` = "SEND_CONFIRMATION_EMAIL";', + ) + await queryFn( + 'UPDATE `events` SET `type` = "EMAIL_ADMIN_CONFIRMATION" WHERE `type` = "ADMIN_SEND_CONFIRMATION_EMAIL";', + ) + await queryFn( + 'UPDATE `events` SET `type` = "USER_REGISTER_REDEEM" WHERE `type` = "REDEEM_REGISTER";', + ) +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn( + 'UPDATE `events` SET `type` = "REDEEM_REGISTER" WHERE `type` = "USER_REGISTER_REDEEM";', + ) + await queryFn( + 'UPDATE `events` SET `type` = "ADMIN_SEND_CONFIRMATION_EMAIL" WHERE `type` = "EMAIL_ADMIN_CONFIRMATION";', + ) + await queryFn( + 'UPDATE `events` SET `type` = "SEND_CONFIRMATION_EMAIL" WHERE `type` = "EMAIL_CONFIRMATION";', + ) + await queryFn( + 'UPDATE `events` SET `type` = "SEND_ACCOUNT_MULTIREGISTRATION_EMAIL" WHERE `type` = "EMAIL_ACCOUNT_MULTIREGISTRATION";', + ) + await queryFn('UPDATE `events` SET `type` = "REGISTER" WHERE `type` = "USER_REGISTER";') + await queryFn('UPDATE `events` SET `type` = "LOGOUT" WHERE `type` = "USER_LOGOUT";') + await queryFn('UPDATE `events` SET `type` = "LOGIN" WHERE `type` = "USER_LOGIN";') + await queryFn( + 'UPDATE `events` SET `type` = "ACTIVATE_ACCOUNT" WHERE `type` = "USER_ACTIVATE_ACCOUNT";', + ) +} diff --git a/dht-node/src/config/index.ts b/dht-node/src/config/index.ts index 78f2b162c..078c0fbf3 100644 --- a/dht-node/src/config/index.ts +++ b/dht-node/src/config/index.ts @@ -3,7 +3,7 @@ import dotenv from 'dotenv' dotenv.config() const constants = { - DB_VERSION: '0063-event_link_fields', + DB_VERSION: '0064-event_rename', LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info LOG_LEVEL: process.env.LOG_LEVEL || 'info', diff --git a/federation/src/config/index.ts b/federation/src/config/index.ts index 61204ca37..f9c002d73 100644 --- a/federation/src/config/index.ts +++ b/federation/src/config/index.ts @@ -11,7 +11,7 @@ Decimal.set({ */ const constants = { - DB_VERSION: '0063-event_link_fields', + DB_VERSION: '0064-event_rename', // DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info From 517169a930ff23464a8e733424e481338f4388a2 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 9 Mar 2023 13:38:44 +0100 Subject: [PATCH 15/91] fix event name --- backend/src/graphql/resolver/UserResolver.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index 6843336cc..3a356afb5 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -1929,14 +1929,14 @@ describe('UserResolver', () => { }) }) - it('stores the ADMIN_SEND_CONFIRMATION_EMAIL event in the database', async () => { + it('stores the EMAIL_ADMIN_CONFIRMATION event in the database', async () => { const userConatct = await UserContact.findOneOrFail( { email: 'bibi@bloxberg.de' }, { relations: ['user'] }, ) expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ - type: EventType.ADMIN_SEND_CONFIRMATION_EMAIL, + type: EventType.EMAIL_ADMIN_CONFIRMATION, affectedUserId: userConatct.user.id, actingUserId: admin.id, }), From ce799541f9997df5934f10ec8d21877f76ed43ec Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 9 Mar 2023 13:39:24 +0100 Subject: [PATCH 16/91] fix event name resolver --- backend/src/graphql/resolver/UserResolver.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 7fc043089..4ac7fb8ab 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -56,7 +56,7 @@ import { EVENT_EMAIL_CONFIRMATION, EVENT_USER_REGISTER, EVENT_USER_ACTIVATE_ACCOUNT, - EVENT_ADMIN_SEND_CONFIRMATION_EMAIL, + EVENT_EMAIL_ADMIN_CONFIRMATION, EVENT_USER_LOGOUT, EVENT_EMAIL_FORGOT_PASSWORD, EVENT_USER_INFO_UPDATE, @@ -813,7 +813,7 @@ export class UserResolver { if (!emailSent) { logger.info(`Account confirmation link: ${activationLink}`) } - await EVENT_ADMIN_SEND_CONFIRMATION_EMAIL(user, getUser(context)) + await EVENT_EMAIL_ADMIN_CONFIRMATION(user, getUser(context)) return true } From 2146c98ee46e4cadd7a40d3b693ce2631d8e679d Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 9 Mar 2023 20:42:07 +0100 Subject: [PATCH 17/91] Add moderatorId for contribution object. --- admin/src/components/Tables/OpenCreationsTable.vue | 3 ++- admin/src/graphql/adminListAllContributions.js | 1 + backend/src/graphql/model/Contribution.ts | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/admin/src/components/Tables/OpenCreationsTable.vue b/admin/src/components/Tables/OpenCreationsTable.vue index a17d3a185..b76decdb5 100644 --- a/admin/src/components/Tables/OpenCreationsTable.vue +++ b/admin/src/components/Tables/OpenCreationsTable.vue @@ -27,9 +27,10 @@ @@ -119,6 +119,7 @@ import { toggleRowDetails } from '../../mixins/toggleRowDetails' import RowDetails from '../RowDetails' import EditCreationFormular from '../EditCreationFormular' import ContributionMessagesList from '../ContributionMessages/ContributionMessagesList' +import { openCreations } from '../../graphql/openCreations' const iconMap = { IN_PROGRESS: 'question-square', @@ -187,6 +188,22 @@ export default { updateState(id) { this.$emit('update-state', id) }, + getOpenCreations(userId) { + this.$apollo + .query({ + query: openCreations, + variables: { + userId, + }, + }) + .then(({ data: { openCreations } }) => { + console.log(openCreations.map((obj) => obj.amount)) + return openCreations.map((obj) => obj.amount) + }) + .catch((error) => { + console.log(error) + }) + }, }, } diff --git a/admin/src/graphql/adminListAllContributions.js b/admin/src/graphql/adminListAllContributions.js index 851cff7b8..9f360f6dc 100644 --- a/admin/src/graphql/adminListAllContributions.js +++ b/admin/src/graphql/adminListAllContributions.js @@ -31,6 +31,7 @@ export const adminListAllContributions = gql` deletedAt deletedBy moderatorId + userId } } } diff --git a/admin/src/graphql/adminUpdateContribution.js b/admin/src/graphql/adminUpdateContribution.js index b7c834109..7738640e7 100644 --- a/admin/src/graphql/adminUpdateContribution.js +++ b/admin/src/graphql/adminUpdateContribution.js @@ -1,14 +1,8 @@ import gql from 'graphql-tag' export const adminUpdateContribution = gql` - mutation ($id: Int!, $email: String!, $amount: Decimal!, $memo: String!, $creationDate: String!) { - adminUpdateContribution( - id: $id - email: $email - amount: $amount - memo: $memo - creationDate: $creationDate - ) { + mutation ($id: Int!, $amount: Decimal!, $memo: String!, $creationDate: String!) { + adminUpdateContribution(id: $id, amount: $amount, memo: $memo, creationDate: $creationDate) { amount date memo diff --git a/admin/src/graphql/openCreations.js b/admin/src/graphql/openCreations.js index f6da9600c..010ed62df 100644 --- a/admin/src/graphql/openCreations.js +++ b/admin/src/graphql/openCreations.js @@ -2,7 +2,7 @@ import gql from 'graphql-tag' export const openCreations = gql` query ($userId: Int) { - openCreations(userId: $userID) { + openCreations(userId: $userId) { year month amount diff --git a/admin/src/pages/CreationConfirm.vue b/admin/src/pages/CreationConfirm.vue index 55caf8677..faea501bb 100644 --- a/admin/src/pages/CreationConfirm.vue +++ b/admin/src/pages/CreationConfirm.vue @@ -44,7 +44,7 @@ :fields="fields" @show-overlay="showOverlay" @update-state="updateStatus" - @update-contributions="$apollo.queries.AllContributions.refetch()" + @update-contributions="$apollo.queries.ListAllContributions.refetch()" /> Date: Fri, 10 Mar 2023 11:36:08 +0100 Subject: [PATCH 21/91] remove email from admin update contribution --- .../arg/AdminUpdateContributionArgs.ts | 3 -- backend/src/graphql/model/Contribution.ts | 6 +++- .../graphql/resolver/ContributionResolver.ts | 28 ++++++------------- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/backend/src/graphql/arg/AdminUpdateContributionArgs.ts b/backend/src/graphql/arg/AdminUpdateContributionArgs.ts index 392365b38..65f1cf3f3 100644 --- a/backend/src/graphql/arg/AdminUpdateContributionArgs.ts +++ b/backend/src/graphql/arg/AdminUpdateContributionArgs.ts @@ -6,9 +6,6 @@ export default class AdminUpdateContributionArgs { @Field(() => Int) id: number - @Field(() => String) - email: string - @Field(() => Decimal) amount: Decimal diff --git a/backend/src/graphql/model/Contribution.ts b/backend/src/graphql/model/Contribution.ts index 69b372e40..989dd32b2 100644 --- a/backend/src/graphql/model/Contribution.ts +++ b/backend/src/graphql/model/Contribution.ts @@ -22,6 +22,7 @@ export class Contribution { this.deletedAt = contribution.deletedAt this.deletedBy = contribution.deletedBy this.moderatorId = contribution.moderatorId + this.userId = contribution.userId } @Field(() => Number) @@ -69,8 +70,11 @@ export class Contribution { @Field(() => String) state: string - @Field(() => Number, { nullable: true }) + @Field(() => Int, { nullable: true }) moderatorId: number | null + + @Field(() => Int, { nullable: true }) + userId: number | null } @ObjectType() diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 2469f60ba..561d5c88c 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -313,41 +313,27 @@ export class ContributionResolver { @Authorized([RIGHTS.ADMIN_UPDATE_CONTRIBUTION]) @Mutation(() => AdminUpdateContribution) async adminUpdateContribution( - @Args() { id, email, amount, memo, creationDate }: AdminUpdateContributionArgs, + @Args() { id, amount, memo, creationDate }: AdminUpdateContributionArgs, @Ctx() context: Context, ): Promise { const clientTimezoneOffset = getClientTimezoneOffset(context) - const emailContact = await UserContact.findOne({ - where: { email }, - withDeleted: true, - relations: ['user'], - }) - if (!emailContact || !emailContact.user) { - throw new LogError('Could not find User', email) - } - if (emailContact.deletedAt || emailContact.user.deletedAt) { - throw new LogError('User was deleted', email) - } const moderator = getUser(context) const contributionToUpdate = await DbContribution.findOne({ where: { id, confirmedAt: IsNull(), deniedAt: IsNull() }, }) + if (!contributionToUpdate) { throw new LogError('Contribution not found', id) } - if (contributionToUpdate.userId !== emailContact.user.id) { - throw new LogError('User of the pending contribution and send user does not correspond') - } - if (contributionToUpdate.moderatorId === null) { throw new LogError('An admin is not allowed to update an user contribution') } const creationDateObj = new Date(creationDate) - let creations = await getUserCreation(emailContact.user.id, clientTimezoneOffset) + let creations = await getUserCreation(contributionToUpdate.userId, clientTimezoneOffset) // TODO: remove this restriction if (contributionToUpdate.contributionDate.getMonth() === creationDateObj.getMonth()) { @@ -371,9 +357,13 @@ export class ContributionResolver { result.memo = contributionToUpdate.memo result.date = contributionToUpdate.contributionDate - result.creation = await getUserCreation(emailContact.user.id, clientTimezoneOffset) + result.creation = await getUserCreation(contributionToUpdate.userId, clientTimezoneOffset) - await EVENT_ADMIN_CONTRIBUTION_UPDATE(emailContact.user.id, contributionToUpdate.id, amount) + await EVENT_ADMIN_CONTRIBUTION_UPDATE( + contributionToUpdate.userId, + contributionToUpdate.id, + amount, + ) return result } From 5ac70867dfca0e51a5915adfecfdfb4712a260a4 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 10 Mar 2023 11:54:28 +0100 Subject: [PATCH 22/91] admin open creations query --- backend/src/auth/RIGHTS.ts | 1 + .../graphql/resolver/ContributionResolver.ts | 24 ++++++++----------- .../src/graphql/resolver/util/creations.ts | 18 +++++++++++++- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/backend/src/auth/RIGHTS.ts b/backend/src/auth/RIGHTS.ts index 8b0e82c86..22be48e40 100644 --- a/backend/src/auth/RIGHTS.ts +++ b/backend/src/auth/RIGHTS.ts @@ -54,4 +54,5 @@ export enum RIGHTS { UPDATE_CONTRIBUTION_LINK = 'UPDATE_CONTRIBUTION_LINK', ADMIN_CREATE_CONTRIBUTION_MESSAGE = 'ADMIN_CREATE_CONTRIBUTION_MESSAGE', DENY_CONTRIBUTION = 'DENY_CONTRIBUTION', + ADMIN_OPEN_CREATIONS = 'ADMIN_OPEN_CREATIONS', } diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 561d5c88c..49ab5fd15 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -27,11 +27,11 @@ import { RIGHTS } from '@/auth/RIGHTS' import { Context, getUser, getClientTimezoneOffset } from '@/server/context' import { backendLogger as logger } from '@/server/logger' import { - getCreationDates, getUserCreation, validateContribution, updateCreations, isValidDateString, + getOpenCreations, } from './util/creations' import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' import { @@ -570,21 +570,17 @@ export class ContributionResolver { @Authorized([RIGHTS.OPEN_CREATIONS]) @Query(() => [OpenCreation]) - async openCreations( - @Arg('userId', () => Int, { nullable: true }) userId: number | null, + async openCreations(@Ctx() context: Context): Promise { + return getOpenCreations(getUser(context).id, getClientTimezoneOffset(context)) + } + + @Authorized([RIGHTS.ADMIN_OPEN_CREATIONS]) + @Query(() => [OpenCreation]) + async adminOpenCreations( + @Arg('userId', () => Int) userId: number, @Ctx() context: Context, ): Promise { - const id = userId || getUser(context).id - const clientTimezoneOffset = getClientTimezoneOffset(context) - const creationDates = getCreationDates(clientTimezoneOffset) - const creations = await getUserCreation(id, clientTimezoneOffset) - return creationDates.map((date, index) => { - return { - month: date.getMonth(), - year: date.getFullYear(), - amount: creations[index], - } - }) + return getOpenCreations(userId, getClientTimezoneOffset(context)) } @Authorized([RIGHTS.DENY_CONTRIBUTION]) diff --git a/backend/src/graphql/resolver/util/creations.ts b/backend/src/graphql/resolver/util/creations.ts index b9ba2e69f..8453781ca 100644 --- a/backend/src/graphql/resolver/util/creations.ts +++ b/backend/src/graphql/resolver/util/creations.ts @@ -4,6 +4,7 @@ import { getConnection } from '@dbTools/typeorm' import { Contribution } from '@entity/Contribution' import Decimal from 'decimal.js-light' import { FULL_CREATION_AVAILABLE, MAX_CREATION_AMOUNT } from '../const/const' +import { OpenCreation } from '@model/OpenCreation' interface CreationMap { id: number @@ -100,7 +101,7 @@ const getCreationMonths = (timezoneOffset: number): number[] => { return getCreationDates(timezoneOffset).map((date) => date.getMonth() + 1) } -export const getCreationDates = (timezoneOffset: number): Date[] => { +const getCreationDates = (timezoneOffset: number): Date[] => { const clientNow = new Date() clientNow.setTime(clientNow.getTime() - timezoneOffset * 60 * 1000) logger.info( @@ -152,3 +153,18 @@ export const updateCreations = ( export const isValidDateString = (dateString: string): boolean => { return new Date(dateString).toString() !== 'Invalid Date' } + +export const getOpenCreations = async ( + id: number, + timezoneOffset: number, +): Promise => { + const creations = await getUserCreation(id, timezoneOffset) + const creationDates = getCreationDates(timezoneOffset) + return creationDates.map((date, index) => { + return { + month: date.getMonth(), + year: date.getFullYear(), + amount: creations[index], + } + }) +} From e07da27414d630e41ab103a05c62953a3ef3e5ed Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 10 Mar 2023 12:48:27 +0100 Subject: [PATCH 23/91] get it working again --- admin/src/components/CreationFormular.vue | 9 +++--- admin/src/components/EditCreationFormular.vue | 17 +++++----- .../components/Tables/OpenCreationsTable.vue | 18 ----------- admin/src/graphql/adminOpenCreations.js | 11 +++++++ admin/src/graphql/openCreations.js | 11 ------- admin/src/mixins/creationMonths.js | 31 ++++++++++++++++--- 6 files changed, 50 insertions(+), 47 deletions(-) create mode 100644 admin/src/graphql/adminOpenCreations.js delete mode 100644 admin/src/graphql/openCreations.js diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue index 137b46400..c6bade1a1 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -117,10 +117,6 @@ export default { return {} }, }, - creation: { - type: Array, - required: true, - }, }, data() { return { @@ -129,6 +125,7 @@ export default { rangeMin: 0, rangeMax: 1000, selected: '', + userId: this.item.userId, } }, methods: { @@ -167,6 +164,10 @@ export default { this.$refs.creationForm.reset() this.value = 0 }) + .finally(() => { + this.$apollo.queries.OpenCreations.refetch() + this.selected = '' + }) }, }, watch: { diff --git a/admin/src/components/EditCreationFormular.vue b/admin/src/components/EditCreationFormular.vue index fbc60df15..1d22460c7 100644 --- a/admin/src/components/EditCreationFormular.vue +++ b/admin/src/components/EditCreationFormular.vue @@ -75,7 +75,6 @@ diff --git a/admin/src/graphql/adminOpenCreations.js b/admin/src/graphql/adminOpenCreations.js new file mode 100644 index 000000000..0e766c0f7 --- /dev/null +++ b/admin/src/graphql/adminOpenCreations.js @@ -0,0 +1,11 @@ +import gql from 'graphql-tag' + +export const adminOpenCreations = gql` + query ($userId: Int!) { + adminOpenCreations(userId: $userId) { + year + month + amount + } + } +` diff --git a/admin/src/graphql/openCreations.js b/admin/src/graphql/openCreations.js deleted file mode 100644 index 010ed62df..000000000 --- a/admin/src/graphql/openCreations.js +++ /dev/null @@ -1,11 +0,0 @@ -import gql from 'graphql-tag' - -export const openCreations = gql` - query ($userId: Int) { - openCreations(userId: $userId) { - year - month - amount - } - } -` diff --git a/admin/src/mixins/creationMonths.js b/admin/src/mixins/creationMonths.js index c26dc5b02..57e0ab17e 100644 --- a/admin/src/mixins/creationMonths.js +++ b/admin/src/mixins/creationMonths.js @@ -1,9 +1,11 @@ +import { adminOpenCreations } from '../graphql/adminOpenCreations' + export const creationMonths = { - props: { - creation: { - type: Array, - default: () => [1000, 1000, 1000], - }, + data() { + return { + creation: [1000, 1000, 1000], + userId: 0, + } }, computed: { creationDates() { @@ -38,4 +40,23 @@ export const creationMonths = { return this.creationDates.map((date) => this.$d(date, 'monthShort')).join(' | ') }, }, + apollo: { + OpenCreations: { + query() { + return adminOpenCreations + }, + variables() { + return { + userId: this.userId, + } + }, + fetchPolicy: 'no-cache', + update({ adminOpenCreations }) { + this.creation = adminOpenCreations.map((obj) => obj.amount) + }, + error({ message }) { + this.toastError(message) + }, + }, + }, } From c8b9de35d8b6bf0c070a72b36e0d543e33d15f9f Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 10 Mar 2023 13:08:57 +0100 Subject: [PATCH 24/91] eslint-plugin-jest --- backend/.eslintrc.js | 8 ++++++- backend/package.json | 1 + backend/yarn.lock | 55 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index 096e4d60a..5eafeffa3 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -4,7 +4,7 @@ module.exports = { node: true, }, parser: '@typescript-eslint/parser', - plugins: ['prettier', '@typescript-eslint', 'type-graphql'], + plugins: ['prettier', '@typescript-eslint', 'type-graphql', 'jest'], extends: ['standard', 'eslint:recommended', 'plugin:prettier/recommended'], // add your custom rules here rules: { @@ -16,6 +16,12 @@ module.exports = { htmlWhitespaceSensitivity: 'ignore', }, ], + // jest + 'jest/no-disabled-tests': 'off', // TODO + 'jest/no-focused-tests': 'error', + 'jest/no-identical-title': 'error', + 'jest/prefer-to-have-length': 'warn', + 'jest/valid-expect': 'error', }, overrides: [ // only for ts files diff --git a/backend/package.json b/backend/package.json index dab5e50af..69cb26c93 100644 --- a/backend/package.json +++ b/backend/package.json @@ -62,6 +62,7 @@ "eslint-config-prettier": "^8.3.0", "eslint-config-standard": "^16.0.3", "eslint-plugin-import": "^2.23.4", + "eslint-plugin-jest": "^27.2.1", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^3.4.0", "eslint-plugin-promise": "^5.1.0", diff --git a/backend/yarn.lock b/backend/yarn.lock index 3151557ab..7d896258f 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -1239,6 +1239,14 @@ "@typescript-eslint/types" "5.53.0" "@typescript-eslint/visitor-keys" "5.53.0" +"@typescript-eslint/scope-manager@5.54.1": + version "5.54.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.54.1.tgz#6d864b4915741c608a58ce9912edf5a02bb58735" + integrity sha512-zWKuGliXxvuxyM71UA/EcPxaviw39dB2504LqAmFDjmkpO8qNLHcmzlh6pbHs1h/7YQ9bnsO8CCcYCSA8sykUg== + dependencies: + "@typescript-eslint/types" "5.54.1" + "@typescript-eslint/visitor-keys" "5.54.1" + "@typescript-eslint/types@4.33.0": version "4.33.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.33.0.tgz#a1e59036a3b53ae8430ceebf2a919dc7f9af6d72" @@ -1249,6 +1257,11 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.53.0.tgz#f79eca62b97e518ee124086a21a24f3be267026f" integrity sha512-5kcDL9ZUIP756K6+QOAfPkigJmCPHcLN7Zjdz76lQWWDdzfOhZDTj1irs6gPBKiXx5/6O3L0+AvupAut3z7D2A== +"@typescript-eslint/types@5.54.1": + version "5.54.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.54.1.tgz#29fbac29a716d0f08c62fe5de70c9b6735de215c" + integrity sha512-G9+1vVazrfAfbtmCapJX8jRo2E4MDXxgm/IMOF4oGh3kq7XuK3JRkOg6y2Qu1VsTRmWETyTkWt1wxy7X7/yLkw== + "@typescript-eslint/typescript-estree@4.33.0": version "4.33.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.33.0.tgz#0dfb51c2908f68c5c08d82aefeaf166a17c24609" @@ -1275,6 +1288,19 @@ semver "^7.3.7" tsutils "^3.21.0" +"@typescript-eslint/typescript-estree@5.54.1": + version "5.54.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.54.1.tgz#df7b6ae05fd8fef724a87afa7e2f57fa4a599be1" + integrity sha512-bjK5t+S6ffHnVwA0qRPTZrxKSaFYocwFIkZx5k7pvWfsB1I57pO/0M0Skatzzw1sCkjJ83AfGTL0oFIFiDX3bg== + dependencies: + "@typescript-eslint/types" "5.54.1" + "@typescript-eslint/visitor-keys" "5.54.1" + debug "^4.3.4" + globby "^11.1.0" + is-glob "^4.0.3" + semver "^7.3.7" + tsutils "^3.21.0" + "@typescript-eslint/utils@5.53.0": version "5.53.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.53.0.tgz#e55eaad9d6fffa120575ffaa530c7e802f13bce8" @@ -1289,6 +1315,20 @@ eslint-utils "^3.0.0" semver "^7.3.7" +"@typescript-eslint/utils@^5.10.0": + version "5.54.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.54.1.tgz#7a3ee47409285387b9d4609ea7e1020d1797ec34" + integrity sha512-IY5dyQM8XD1zfDe5X8jegX6r2EVU5o/WJnLu/znLPWCBF7KNGC+adacXnt5jEYS9JixDcoccI6CvE4RCjHMzCQ== + dependencies: + "@types/json-schema" "^7.0.9" + "@types/semver" "^7.3.12" + "@typescript-eslint/scope-manager" "5.54.1" + "@typescript-eslint/types" "5.54.1" + "@typescript-eslint/typescript-estree" "5.54.1" + eslint-scope "^5.1.1" + eslint-utils "^3.0.0" + semver "^7.3.7" + "@typescript-eslint/visitor-keys@4.33.0": version "4.33.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.33.0.tgz#2a22f77a41604289b7a186586e9ec48ca92ef1dd" @@ -1305,6 +1345,14 @@ "@typescript-eslint/types" "5.53.0" eslint-visitor-keys "^3.3.0" +"@typescript-eslint/visitor-keys@5.54.1": + version "5.54.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.54.1.tgz#d7a8a0f7181d6ac748f4d47b2306e0513b98bf8b" + integrity sha512-q8iSoHTgwCfgcRJ2l2x+xCbu8nBlRAlsQ33k24Adj8eoVBE0f8dUeI+bAa8F84Mv05UGbAx57g2zrRsYIooqQg== + dependencies: + "@typescript-eslint/types" "5.54.1" + eslint-visitor-keys "^3.3.0" + "@wry/equality@^0.1.2": version "0.1.11" resolved "https://registry.yarnpkg.com/@wry/equality/-/equality-0.1.11.tgz#35cb156e4a96695aa81a9ecc4d03787bc17f1790" @@ -2714,6 +2762,13 @@ eslint-plugin-import@^2.23.4: resolve "^1.20.0" tsconfig-paths "^3.11.0" +eslint-plugin-jest@^27.2.1: + version "27.2.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-27.2.1.tgz#b85b4adf41c682ea29f1f01c8b11ccc39b5c672c" + integrity sha512-l067Uxx7ZT8cO9NJuf+eJHvt6bqJyz2Z29wykyEdz/OtmcELQl2MQGQLX8J94O1cSJWAwUSEvCjwjA7KEK3Hmg== + dependencies: + "@typescript-eslint/utils" "^5.10.0" + eslint-plugin-node@^11.1.0: version "11.1.0" resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz#c95544416ee4ada26740a30474eefc5402dc671d" From 04a87be90d7c8f3621fb3f89b82c75d9dea3ba6e Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 10 Mar 2023 13:09:35 +0100 Subject: [PATCH 25/91] fix eslint jest errors --- .../resolver/ContributionLinkResolver.test.ts | 20 +++--- .../ContributionMessageResolver.test.ts | 8 +-- .../resolver/ContributionResolver.test.ts | 72 +++++++++---------- .../resolver/TransactionLinkResolver.test.ts | 22 +++--- 4 files changed, 61 insertions(+), 61 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts index 4563d2a6a..606bce109 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts @@ -266,7 +266,7 @@ describe('Contribution Links', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "A Start-Date must be set"', () => { expect(logger.error).toBeCalledWith('A Start-Date must be set') }) @@ -287,7 +287,7 @@ describe('Contribution Links', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "An End-Date must be set"', () => { expect(logger.error).toBeCalledWith('An End-Date must be set') }) @@ -311,7 +311,7 @@ describe('Contribution Links', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "The value of validFrom must before or equals the validTo"', () => { expect(logger.error).toBeCalledWith( `The value of validFrom must before or equals the validTo`, ) @@ -334,7 +334,7 @@ describe('Contribution Links', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "The value of name is too short"', () => { expect(logger.error).toBeCalledWith('The value of name is too short', 3) }) @@ -355,7 +355,7 @@ describe('Contribution Links', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "The value of name is too long"', () => { expect(logger.error).toBeCalledWith('The value of name is too long', 101) }) @@ -376,7 +376,7 @@ describe('Contribution Links', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "The value of memo is too short"', () => { expect(logger.error).toBeCalledWith('The value of memo is too short', 3) }) @@ -397,7 +397,7 @@ describe('Contribution Links', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "The value of memo is too long"', () => { expect(logger.error).toBeCalledWith('The value of memo is too long', 256) }) @@ -418,7 +418,7 @@ describe('Contribution Links', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "The amount must be a positiv value"', () => { expect(logger.error).toBeCalledWith('The amount must be a positiv value', new Decimal(0)) }) }) @@ -476,7 +476,7 @@ describe('Contribution Links', () => { }) }) - it('logs the error thrown', () => { + it('logs the error "Contribution Link not found"', () => { expect(logger.error).toBeCalledWith('Contribution Link not found', -1) }) @@ -546,7 +546,7 @@ describe('Contribution Links', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "Contribution Link not found"', () => { expect(logger.error).toBeCalledWith('Contribution Link not found', -1) }) }) diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts index 8b5c5a0a7..642844e31 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts @@ -113,7 +113,7 @@ describe('ContributionMessageResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "ContributionMessage was not sent successfully: Error: Contribution not found"', () => { expect(logger.error).toBeCalledWith( 'ContributionMessage was not sent successfully: Error: Contribution not found', new Error('Contribution not found'), @@ -153,7 +153,7 @@ describe('ContributionMessageResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "ContributionMessage was not sent successfully: Error: Admin can not answer on his own contribution"', () => { expect(logger.error).toBeCalledWith( 'ContributionMessage was not sent successfully: Error: Admin can not answer on his own contribution', new Error('Admin can not answer on his own contribution'), @@ -251,7 +251,7 @@ describe('ContributionMessageResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "ContributionMessage was not sent successfully: Error: Contribution not found"', () => { expect(logger.error).toBeCalledWith( 'ContributionMessage was not sent successfully: Error: Contribution not found', new Error('Contribution not found'), @@ -283,7 +283,7 @@ describe('ContributionMessageResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "ContributionMessage was not sent successfully: Error: Can not send message to contribution of another user"', () => { expect(logger.error).toBeCalledWith( 'ContributionMessage was not sent successfully: Error: Can not send message to contribution of another user', new Error('Can not send message to contribution of another user'), diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 274067ba0..cc7357e99 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -201,7 +201,7 @@ describe('ContributionResolver', () => { expect(errorObjects).toEqual([new GraphQLError('Memo text is too short')]) }) - it('logs the error found', () => { + it('logs the error "Memo text is too short"', () => { expect(logger.error).toBeCalledWith('Memo text is too short', 4) }) @@ -219,7 +219,7 @@ describe('ContributionResolver', () => { expect(errorObjects).toEqual([new GraphQLError('Memo text is too long')]) }) - it('logs the error found', () => { + it('logs the error "Memo text is too long"', () => { expect(logger.error).toBeCalledWith('Memo text is too long', 259) }) @@ -238,7 +238,7 @@ describe('ContributionResolver', () => { ]) }) - it('logs the error found', () => { + it('logs the error "No information for available creations for the given date"', () => { expect(logger.error).toBeCalledWith( 'No information for available creations for the given date', expect.any(Date), @@ -261,7 +261,7 @@ describe('ContributionResolver', () => { ]) }) - it('logs the error found', () => { + it('logs the error "No information for available creations for the given date" again', () => { expect(logger.error).toBeCalledWith( 'No information for available creations for the given date', expect.any(Date), @@ -336,7 +336,7 @@ describe('ContributionResolver', () => { expect(errorObjects).toEqual([new GraphQLError('Memo text is too short')]) }) - it('logs the error found', () => { + it('logs the error "Memo text is too short"', () => { expect(logger.error).toBeCalledWith('Memo text is too short', 4) }) }) @@ -357,7 +357,7 @@ describe('ContributionResolver', () => { expect(errorObjects).toEqual([new GraphQLError('Memo text is too long')]) }) - it('logs the error found', () => { + it('logs the error "Memo text is too long"', () => { expect(logger.error).toBeCalledWith('Memo text is too long', 259) }) }) @@ -382,7 +382,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error found', () => { + it('logs the error "Contribution not found"', () => { expect(logger.error).toBeCalledWith('Contribution not found', -1) }) }) @@ -411,7 +411,7 @@ describe('ContributionResolver', () => { ]) }) - it('logs the error found', () => { + it('logs the error "Can not update contribution of another user"', () => { expect(logger.error).toBeCalledWith( 'Can not update contribution of another user', expect.any(Object), @@ -445,7 +445,7 @@ describe('ContributionResolver', () => { ]) }) - it('logs the error found', () => { + it('logs the error "An admin is not allowed to update an user contribution"', () => { expect(logger.error).toBeCalledWith( 'An admin is not allowed to update an user contribution', ) @@ -491,7 +491,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error found', () => { + it('logs the error "Contribution can not be updated due to status"', () => { expect(logger.error).toBeCalledWith( 'Contribution can not be updated due to status', ContributionStatus.DELETED, @@ -526,7 +526,7 @@ describe('ContributionResolver', () => { ]) }) - it('logs the error found', () => { + it('logs the error "The amount to be created exceeds the amount still available for this month"', () => { expect(logger.error).toBeCalledWith( 'The amount to be created exceeds the amount still available for this month', new Decimal(1019), @@ -553,7 +553,7 @@ describe('ContributionResolver', () => { ]) }) - it('logs the error found', () => { + it('logs the error "Month of contribution can not be changed"', () => { expect(logger.error).toBeCalledWith('Month of contribution can not be changed') }) }) @@ -657,7 +657,7 @@ describe('ContributionResolver', () => { expect(errorObjects).toEqual([new GraphQLError('Contribution not found')]) }) - it('logs the error found', () => { + it('logs the error "Contribution not found"', () => { expect(logger.error).toBeCalledWith('Contribution not found', -1) }) }) @@ -701,7 +701,7 @@ describe('ContributionResolver', () => { expect(errorObjects).toEqual([new GraphQLError('Contribution not found')]) }) - it('logs the error found', () => { + it('logs the error "Contribution not found"', () => { expect(logger.error).toBeCalledWith('Contribution not found', expect.any(Number)) }) }) @@ -746,7 +746,7 @@ describe('ContributionResolver', () => { expect(errorObjects).toEqual([new GraphQLError('Contribution not found')]) }) - it('logs the error found', () => { + it('logs the error "Contribution not found"', () => { expect(logger.error).toBeCalledWith(`Contribution not found`, expect.any(Number)) }) }) @@ -791,7 +791,7 @@ describe('ContributionResolver', () => { expect(errorObjects).toEqual([new GraphQLError('Contribution not found')]) }) - it('logs the error found', () => { + it('logs the error "Contribution not found"', () => { expect(logger.error).toBeCalledWith(`Contribution not found`, expect.any(Number)) }) }) @@ -877,7 +877,7 @@ describe('ContributionResolver', () => { expect(errorObjects).toEqual([new GraphQLError('Contribution not found')]) }) - it('logs the error found', () => { + it('logs the error "Contribution not found"', () => { expect(logger.error).toBeCalledWith('Contribution not found', expect.any(Number)) }) }) @@ -907,7 +907,7 @@ describe('ContributionResolver', () => { ]) }) - it('logs the error found', () => { + it('logs the error "Can not delete contribution of another user"', () => { expect(logger.error).toBeCalledWith( 'Can not delete contribution of another user', expect.any(Contribution), @@ -981,7 +981,7 @@ describe('ContributionResolver', () => { ]) }) - it('logs the error found', () => { + it('logs the error "A confirmed contribution can not be deleted"', () => { expect(logger.error).toBeCalledWith( 'A confirmed contribution can not be deleted', expect.objectContaining({ contributionStatus: 'CONFIRMED' }), @@ -1846,7 +1846,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "Could not find user"', () => { expect(logger.error).toBeCalledWith('Could not find user', 'some@fake.email') }) }) @@ -1873,7 +1873,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "Cannot create contribution since the user was deleted"', () => { expect(logger.error).toBeCalledWith( 'Cannot create contribution since the user was deleted', expect.objectContaining({ @@ -1909,7 +1909,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "Cannot create contribution since the users email is not activated"', () => { expect(logger.error).toBeCalledWith( 'Cannot create contribution since the users email is not activated', expect.objectContaining({ emailChecked: false }), @@ -1935,7 +1935,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "CreationDate is invalid"', () => { expect(logger.error).toBeCalledWith('CreationDate is invalid', 'invalid-date') }) }) @@ -1957,7 +1957,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "No information for available creations for the given date"', () => { expect(logger.error).toBeCalledWith( 'No information for available creations for the given date', new Date(variables.creationDate), @@ -1982,7 +1982,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "No information for available creations for the given date"', () => { expect(logger.error).toBeCalledWith( 'No information for available creations for the given date', new Date(variables.creationDate), @@ -2007,7 +2007,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "The amount to be created exceeds the amount still available for this month"', () => { expect(logger.error).toBeCalledWith( 'The amount to be created exceeds the amount still available for this month', new Decimal(2000), @@ -2058,7 +2058,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "The amount to be created exceeds the amount still available for this month"', () => { expect(logger.error).toBeCalledWith( 'The amount to be created exceeds the amount still available for this month', new Decimal(1000), @@ -2097,7 +2097,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "Could not find User"', () => { expect(logger.error).toBeCalledWith('Could not find User', 'bob@baumeister.de') }) }) @@ -2123,7 +2123,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "User was deleted"', () => { expect(logger.error).toBeCalledWith('User was deleted', 'stephen@hawking.uk') }) }) @@ -2149,7 +2149,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "Contribution not found"', () => { expect(logger.error).toBeCalledWith('Contribution not found', -1) }) }) @@ -2181,7 +2181,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "User of the pending contribution and send user does not correspond"', () => { expect(logger.error).toBeCalledWith( 'User of the pending contribution and send user does not correspond', ) @@ -2216,7 +2216,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "The amount to be created exceeds the amount still available for this month"', () => { expect(logger.error).toBeCalledWith( 'The amount to be created exceeds the amount still available for this month', new Decimal(1900), @@ -2326,7 +2326,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "Contribution not found"', () => { expect(logger.error).toBeCalledWith('Contribution not found', -1) }) }) @@ -2466,7 +2466,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "Contribution not found"', () => { expect(logger.error).toBeCalledWith('Contribution not found', -1) }) }) @@ -2500,7 +2500,7 @@ describe('ContributionResolver', () => { ) }) - it('logs the error thrown', () => { + it('logs the error "Moderator can not confirm own contribution"', () => { expect(logger.error).toBeCalledWith('Moderator can not confirm own contribution') }) }) @@ -2595,7 +2595,7 @@ describe('ContributionResolver', () => { }) }) - it('logs the error thrown', () => { + it('logs the error "Contribution already confirmed"', () => { expect(logger.error).toBeCalledWith( 'Contribution already confirmed', expect.any(Number), diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index fc5ca170a..c6b733d0d 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -94,7 +94,7 @@ describe('TransactionLinkResolver', () => { errors: [new GraphQLError('Amount must be a positive number')], }) }) - it('logs the error thrown', () => { + it('logs the error "Amount must be a positive number" - 0', () => { expect(logger.error).toBeCalledWith('Amount must be a positive number', new Decimal(0)) }) @@ -112,7 +112,7 @@ describe('TransactionLinkResolver', () => { errors: [new GraphQLError('Amount must be a positive number')], }) }) - it('logs the error thrown', () => { + it('logs the error "Amount must be a positive number" - -10', () => { expect(logger.error).toBeCalledWith('Amount must be a positive number', new Decimal(-10)) }) @@ -130,7 +130,7 @@ describe('TransactionLinkResolver', () => { errors: [new GraphQLError('User has not enough GDD')], }) }) - it('logs the error thrown', () => { + it('logs the error "User has not enough GDD"', () => { expect(logger.error).toBeCalledWith('User has not enough GDD', expect.any(Number)) }) }) @@ -180,7 +180,7 @@ describe('TransactionLinkResolver', () => { }) }) - it('logs the error thrown', () => { + it('logs the error "No contribution link found to given code"', () => { expect(logger.error).toBeCalledWith( 'No contribution link found to given code', 'CL-123456', @@ -224,7 +224,7 @@ describe('TransactionLinkResolver', () => { await resetEntity(DbContributionLink) }) - it('logs the error thrown', () => { + it('logs the error "Contribution link is not valid yet"', () => { expect(logger.error).toBeCalledWith('Contribution link is not valid yet', validFrom) expect(logger.error).toBeCalledWith( 'Creation from contribution link was not successful', @@ -263,7 +263,7 @@ describe('TransactionLinkResolver', () => { await resetEntity(DbContributionLink) }) - it('logs the error thrown', () => { + it('logs the error "Contribution link has unknown cycle"', () => { expect(logger.error).toBeCalledWith('Contribution link has unknown cycle', 'INVALID') expect(logger.error).toBeCalledWith( 'Creation from contribution link was not successful', @@ -302,7 +302,7 @@ describe('TransactionLinkResolver', () => { await resetEntity(DbContributionLink) }) - it('logs the error thrown', () => { + it('logs the error "Contribution link is no longer valid"', () => { expect(logger.error).toBeCalledWith('Contribution link is no longer valid', validTo) expect(logger.error).toBeCalledWith( 'Creation from contribution link was not successful', @@ -394,7 +394,7 @@ describe('TransactionLinkResolver', () => { }) }) - it('logs the error thrown', () => { + it('logs the error "Creation from contribution link was not successful"', () => { expect(logger.error).toBeCalledWith( 'Creation from contribution link was not successful', new Error( @@ -451,7 +451,7 @@ describe('TransactionLinkResolver', () => { }) }) - it('logs the error thrown', () => { + it('logs the error "Creation from contribution link was not successful"', () => { expect(logger.error).toBeCalledWith( 'Creation from contribution link was not successful', new Error('Contribution link already redeemed today'), @@ -503,7 +503,7 @@ describe('TransactionLinkResolver', () => { }) }) - it('logs the error thrown', () => { + it('logs the error "Creation from contribution link was not successful"', () => { expect(logger.error).toBeCalledWith( 'Creation from contribution link was not successful', new Error('Contribution link already redeemed today'), @@ -620,7 +620,7 @@ describe('TransactionLinkResolver', () => { }) }) - it('logs the error thrown', () => { + it('logs the error "Could not find requested User"', () => { expect(logger.error).toBeCalledWith('Could not find requested User', -1) }) }) From edd42f02edc4ab67e1b47b2a13221461347999b3 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 10 Mar 2023 14:08:08 +0100 Subject: [PATCH 26/91] fix edit contribution formular, remove unused methods --- .../components/EditCreationFormular.spec.js | 120 ++++++++++-------- admin/src/components/EditCreationFormular.vue | 12 +- .../Tables/OpenCreationsTable.spec.js | 6 +- .../components/Tables/OpenCreationsTable.vue | 22 +--- admin/src/graphql/adminUpdateContribution.js | 1 - 5 files changed, 76 insertions(+), 85 deletions(-) diff --git a/admin/src/components/EditCreationFormular.spec.js b/admin/src/components/EditCreationFormular.spec.js index 4a304dc79..ee0458ba2 100644 --- a/admin/src/components/EditCreationFormular.spec.js +++ b/admin/src/components/EditCreationFormular.spec.js @@ -1,19 +1,18 @@ import { mount } from '@vue/test-utils' import EditCreationFormular from './EditCreationFormular' import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup' +import VueApollo from 'vue-apollo' +import { createMockClient } from 'mock-apollo-client' +import { adminOpenCreations } from '../graphql/adminOpenCreations' +import { adminUpdateContribution } from '../graphql/adminUpdateContribution' + +const mockClient = createMockClient() +const apolloProvider = new VueApollo({ + defaultClient: mockClient, +}) const localVue = global.localVue - -const apolloMutateMock = jest.fn().mockResolvedValue({ - data: { - adminUpdateContribution: { - creation: [0, 0, 0], - amount: 500, - date: new Date(), - memo: 'Test Schöpfung 2', - }, - }, -}) +localVue.use(VueApollo) const stateCommitMock = jest.fn() @@ -23,22 +22,18 @@ const mocks = { const date = new Date(d) return date.toISOString().split('T')[0] }), - $apollo: { - mutate: apolloMutateMock, - }, $store: { commit: stateCommitMock, }, } -const now = new Date(Date.now()) +const now = new Date() const getCreationDate = (sub) => { const date = sub === 0 ? now : new Date(now.getFullYear(), now.getMonth() - sub, 1, 0) return date.toISOString().split('T')[0] } const propsData = { - creation: [200, 400, 600], creationUserData: { memo: 'Test schöpfung 1', amount: 100, @@ -46,20 +41,65 @@ const propsData = { }, item: { id: 0, - email: 'bob@baumeister.de', + amount: '300', + contributionDate: `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`, }, } +const data = () => { + return { creation: ['1000', '1000', '400'] } +} + describe('EditCreationFormular', () => { let wrapper + const adminUpdateContributionMock = jest.fn() + const adminOpenCreationsMock = jest.fn() + mockClient.setRequestHandler( + adminOpenCreations, + adminOpenCreationsMock.mockResolvedValue({ + data: { + adminOpenCreations: [ + { + month: new Date(now.getFullYear(), now.getMonth() - 2).getMonth(), + year: new Date(now.getFullYear(), now.getMonth() - 2).getFullYear(), + amount: '1000', + }, + { + month: new Date(now.getFullYear(), now.getMonth() - 1).getMonth(), + year: new Date(now.getFullYear(), now.getMonth() - 1).getFullYear(), + amount: '1000', + }, + { + month: now.getMonth(), + year: now.getFullYear(), + amount: '400', + }, + ], + }, + }), + ) + mockClient.setRequestHandler( + adminUpdateContribution, + adminUpdateContributionMock.mockResolvedValue({ + data: { + adminUpdateContribution: { + amount: '600', + date: new Date(), + memo: 'This is my memo', + }, + }, + }), + ) + const Wrapper = () => { - return mount(EditCreationFormular, { localVue, mocks, propsData }) + return mount(EditCreationFormular, { localVue, mocks, propsData, data, apolloProvider }) } describe('mount', () => { - beforeEach(() => { + beforeEach(async () => { wrapper = Wrapper() + await wrapper.vm.$nextTick() }) it('has a DIV element with the class.component-edit-creation-formular', () => { @@ -89,42 +129,16 @@ describe('EditCreationFormular', () => { }) it('calls the API', () => { - expect(apolloMutateMock).toBeCalledWith( - expect.objectContaining({ - variables: { - id: 0, - email: 'bob@baumeister.de', - creationDate: getCreationDate(0), - amount: 500, - memo: 'Test Schöpfung 2', - }, - }), - ) - }) - - it('emits update-user-data', () => { - expect(wrapper.emitted('update-user-data')).toEqual([ - [ - { - id: 0, - email: 'bob@baumeister.de', - }, - [0, 0, 0], - ], - ]) + expect(adminUpdateContributionMock).toBeCalledWith({ + id: 0, + creationDate: getCreationDate(0), + amount: 500, + memo: 'Test Schöpfung 2', + }) }) it('emits update-creation-data', () => { - expect(wrapper.emitted('update-creation-data')).toEqual([ - [ - { - amount: 500, - date: expect.any(Date), - memo: 'Test Schöpfung 2', - row: expect.any(Object), - }, - ], - ]) + expect(wrapper.emitted('update-creation-data')).toBeTruthy() }) it('toasts a success message', () => { @@ -134,7 +148,7 @@ describe('EditCreationFormular', () => { describe('change and save memo and value with error', () => { beforeEach(async () => { - apolloMutateMock.mockRejectedValue({ message: 'Oh no!' }) + adminUpdateContributionMock.mockRejectedValue({ message: 'Oh no!' }) await wrapper.find('input[type="number"]').setValue(500) await wrapper.find('textarea').setValue('Test Schöpfung 2') await wrapper.find('.test-submit').trigger('click') diff --git a/admin/src/components/EditCreationFormular.vue b/admin/src/components/EditCreationFormular.vue index 1d22460c7..994a734f6 100644 --- a/admin/src/components/EditCreationFormular.vue +++ b/admin/src/components/EditCreationFormular.vue @@ -108,6 +108,7 @@ export default { }, methods: { submitCreation() { + // console.log('submitCreation', this.selected) this.$apollo .mutate({ mutation: adminUpdateContribution, @@ -119,12 +120,7 @@ export default { }, }) .then((result) => { - this.$emit('update-creation-data', { - amount: Number(result.data.adminUpdateContribution.amount), - date: result.data.adminUpdateContribution.date, - memo: result.data.adminUpdateContribution.memo, - row: this.row, - }) + this.$emit('update-creation-data') this.toastSuccess( this.$t('creation_form.toasted_update', { value: this.value, @@ -151,7 +147,9 @@ export default { computed: { creationIndex() { const month = this.$d(new Date(this.item.contributionDate), 'month') - return this.radioOptions.findIndex((obj) => obj.item.short === month) + return this.radioOptions.findIndex((obj) => { + return obj.item.short === month + }) }, selectedComputed() { return this.radioOptions[this.creationIndex].item diff --git a/admin/src/components/Tables/OpenCreationsTable.spec.js b/admin/src/components/Tables/OpenCreationsTable.spec.js index 6542dab31..4cd40017c 100644 --- a/admin/src/components/Tables/OpenCreationsTable.spec.js +++ b/admin/src/components/Tables/OpenCreationsTable.spec.js @@ -17,7 +17,7 @@ const propsData = { amount: 300, memo: 'Aktives Grundeinkommen für Januar 2022', date: '2022-01-01T00:00:00.000Z', - moderator: 1, + moderatorId: 1, creation: [700, 1000, 1000], __typename: 'PendingCreation', }, @@ -29,7 +29,7 @@ const propsData = { amount: 210, memo: 'Aktives Grundeinkommen für Januar 2022', date: '2022-01-01T00:00:00.000Z', - moderator: null, + moderatorId: null, creation: [790, 1000, 1000], __typename: 'PendingCreation', }, @@ -41,7 +41,7 @@ const propsData = { amount: 330, memo: 'Aktives Grundeinkommen für Januar 2022', date: '2022-01-01T00:00:00.000Z', - moderator: 1, + moderatorId: 1, creation: [670, 1000, 1000], __typename: 'PendingCreation', }, diff --git a/admin/src/components/Tables/OpenCreationsTable.vue b/admin/src/components/Tables/OpenCreationsTable.vue index 3b89a7d8c..9e0f3c747 100644 --- a/admin/src/components/Tables/OpenCreationsTable.vue +++ b/admin/src/components/Tables/OpenCreationsTable.vue @@ -96,7 +96,7 @@ :item="row.item" :row="row" :creationUserData="creationUserData" - @update-creation-data="updateCreationData" + @update-creation-data="$emit('update-contributions')" />
@@ -145,16 +145,6 @@ export default { required: true, }, }, - data() { - return { - creationUserData: { - amount: null, - date: null, - memo: null, - moderator: null, - }, - } - }, methods: { myself(item) { return ( @@ -173,16 +163,6 @@ export default { if (item.state === 'IN_PROGRESS') return 'table-primary' if (item.state === 'PENDING') return 'table-primary' }, - updateCreationData(data) { - const row = data.row - this.$emit('update-contributions', data) - delete data.row - this.creationUserData = { ...this.creationUserData, ...data } - row.toggleDetails() - }, - updateUserData(rowItem, newCreation) { - rowItem.creation = newCreation - }, updateState(id) { this.$emit('update-state', id) }, diff --git a/admin/src/graphql/adminUpdateContribution.js b/admin/src/graphql/adminUpdateContribution.js index 7738640e7..c52a0cbc4 100644 --- a/admin/src/graphql/adminUpdateContribution.js +++ b/admin/src/graphql/adminUpdateContribution.js @@ -6,7 +6,6 @@ export const adminUpdateContribution = gql` amount date memo - creation } } ` From 0f01027f6b8ae8cfc44c143511b18f05969d7d45 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 10 Mar 2023 14:11:17 +0100 Subject: [PATCH 27/91] fix open creation tests. remove tests for removed methods --- .../Tables/OpenCreationsTable.spec.js | 44 ------------------- 1 file changed, 44 deletions(-) diff --git a/admin/src/components/Tables/OpenCreationsTable.spec.js b/admin/src/components/Tables/OpenCreationsTable.spec.js index 4cd40017c..cfb91be0d 100644 --- a/admin/src/components/Tables/OpenCreationsTable.spec.js +++ b/admin/src/components/Tables/OpenCreationsTable.spec.js @@ -5,7 +5,6 @@ const localVue = global.localVue const apolloMutateMock = jest.fn().mockResolvedValue({}) const apolloQueryMock = jest.fn().mockResolvedValue({}) -const toggleDetailsMock = jest.fn() const propsData = { items: [ @@ -132,14 +131,6 @@ describe('OpenCreationsTable', () => { }) }) - describe('call updateUserData', () => { - it('user creations has updated data', async () => { - wrapper.vm.updateUserData(propsData.items[0], [444, 555, 666]) - await wrapper.vm.$nextTick() - expect(wrapper.vm.items[0].creation).toEqual([444, 555, 666]) - }) - }) - describe('call updateState', () => { beforeEach(() => { wrapper.vm.updateState(4) @@ -149,40 +140,5 @@ describe('OpenCreationsTable', () => { expect(wrapper.vm.$root.$emit('update-state', 4)).toBeTruthy() }) }) - - describe('call updateCreationData', () => { - const date = new Date() - beforeEach(() => { - wrapper.vm.updateCreationData({ - amount: Number(80.0), - date: date, - memo: 'Test memo', - row: { - item: {}, - detailsShowing: false, - toggleDetails: toggleDetailsMock, - }, - }) - }) - - it('emits update-state', () => { - expect( - wrapper.vm.$emit('update-contributions', { - amount: Number(80.0), - date: date, - memo: 'Test memo', - row: { - item: {}, - detailsShowing: false, - toggleDetails: toggleDetailsMock, - }, - }), - ).toBeTruthy() - }) - - it('calls toggleDetails', () => { - expect(toggleDetailsMock).toBeCalled() - }) - }) }) }) From b6f903374e3b588b815634041f7c1ec129f24917 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 10 Mar 2023 14:12:46 +0100 Subject: [PATCH 28/91] also match tsx files, fix semaphore lint ignore --- backend/.eslintrc.js | 3 ++- backend/src/graphql/resolver/semaphore.test.ts | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index 5eafeffa3..bc2f0a43d 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -2,6 +2,7 @@ module.exports = { root: true, env: { node: true, + // jest: true, }, parser: '@typescript-eslint/parser', plugins: ['prettier', '@typescript-eslint', 'type-graphql', 'jest'], @@ -26,7 +27,7 @@ module.exports = { overrides: [ // only for ts files { - files: ['*.ts'], + files: ['*.ts', '*.tsx'], extends: [ 'plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/recommended-requiring-type-checking', diff --git a/backend/src/graphql/resolver/semaphore.test.ts b/backend/src/graphql/resolver/semaphore.test.ts index 70e3e5f96..1ce133fba 100644 --- a/backend/src/graphql/resolver/semaphore.test.ts +++ b/backend/src/graphql/resolver/semaphore.test.ts @@ -5,8 +5,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import Decimal from 'decimal.js-light' -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import { logger } from '@test/testSetup' import { userFactory } from '@/seeds/factory/user' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { bobBaumeister } from '@/seeds/users/bob-baumeister' From cef0e00f6eec4451997a517cb6a0b496d8c87ef4 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 10 Mar 2023 14:22:07 +0100 Subject: [PATCH 29/91] fix tests --- admin/src/components/CreationFormular.spec.js | 79 +++++++++++++------ admin/src/components/CreationFormular.vue | 3 +- 2 files changed, 56 insertions(+), 26 deletions(-) diff --git a/admin/src/components/CreationFormular.spec.js b/admin/src/components/CreationFormular.spec.js index 5dba2d931..c22b319a9 100644 --- a/admin/src/components/CreationFormular.spec.js +++ b/admin/src/components/CreationFormular.spec.js @@ -2,14 +2,18 @@ import { mount } from '@vue/test-utils' import CreationFormular from './CreationFormular' import { adminCreateContribution } from '../graphql/adminCreateContribution' import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup' +import VueApollo from 'vue-apollo' +import { createMockClient } from 'mock-apollo-client' +import { adminOpenCreations } from '../graphql/adminOpenCreations' + +const mockClient = createMockClient() +const apolloProvider = new VueApollo({ + defaultClient: mockClient, +}) const localVue = global.localVue +localVue.use(VueApollo) -const apolloMutateMock = jest.fn().mockResolvedValue({ - data: { - adminCreateContribution: [0, 0, 0], - }, -}) const stateCommitMock = jest.fn() const mocks = { @@ -18,9 +22,6 @@ const mocks = { const date = new Date(d) return date.toISOString().split('T')[0] }), - $apollo: { - mutate: apolloMutateMock, - }, $store: { commit: stateCommitMock, }, @@ -31,7 +32,8 @@ const propsData = { creation: [], } -const now = new Date(Date.now()) +const now = new Date() + const getCreationDate = (sub) => { const date = sub === 0 ? now : new Date(now.getFullYear(), now.getMonth() - sub, 1, 0) return date.toISOString().split('T')[0] @@ -40,8 +42,43 @@ const getCreationDate = (sub) => { describe('CreationFormular', () => { let wrapper + const adminOpenCreationsMock = jest.fn() + const adminCreateContributionMock = jest.fn() + mockClient.setRequestHandler( + adminOpenCreations, + adminOpenCreationsMock.mockResolvedValue({ + data: { + adminOpenCreations: [ + { + month: new Date(now.getFullYear(), now.getMonth() - 2).getMonth(), + year: new Date(now.getFullYear(), now.getMonth() - 2).getFullYear(), + amount: '200', + }, + { + month: new Date(now.getFullYear(), now.getMonth() - 1).getMonth(), + year: new Date(now.getFullYear(), now.getMonth() - 1).getFullYear(), + amount: '400', + }, + { + month: now.getMonth(), + year: now.getFullYear(), + amount: '600', + }, + ], + }, + }), + ) + mockClient.setRequestHandler( + adminCreateContribution, + adminCreateContributionMock.mockResolvedValue({ + data: { + adminCreateContribution: [0, 0, 0], + }, + }), + ) + const Wrapper = () => { - return mount(CreationFormular, { localVue, mocks, propsData }) + return mount(CreationFormular, { localVue, mocks, propsData, apolloProvider }) } describe('mount', () => { @@ -107,17 +144,11 @@ describe('CreationFormular', () => { }) it('sends ... to apollo', () => { - expect(apolloMutateMock).toBeCalledWith( - expect.objectContaining({ - mutation: adminCreateContribution, - variables: { - email: 'benjamin@bluemchen.de', - creationDate: getCreationDate(2), - amount: 90, - memo: 'Test create coins', - }, - }), - ) + expect(adminCreateContributionMock).toBeCalledWith({ + creationDate: getCreationDate(2), + amount: 90, + memo: 'Test create coins', + }) }) it('emits update-user-data', () => { @@ -144,7 +175,7 @@ describe('CreationFormular', () => { describe('sendForm with server error', () => { beforeEach(async () => { - apolloMutateMock.mockRejectedValueOnce({ message: 'Ouch!' }) + adminCreateContributionMock.mockRejectedValueOnce({ message: 'Ouch!' }) await wrapper.find('.test-submit').trigger('click') }) @@ -212,7 +243,7 @@ describe('CreationFormular', () => { }) it('sends ... to apollo', () => { - expect(apolloMutateMock).toBeCalled() + expect(adminCreateContributionMock).toBeCalled() }) }) @@ -275,7 +306,7 @@ describe('CreationFormular', () => { }) it('sends mutation to apollo', () => { - expect(apolloMutateMock).toBeCalled() + expect(adminCreateContributionMock).toBeCalled() }) it('toast success message', () => { diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue index c6bade1a1..aeaa84cc6 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -133,14 +133,13 @@ export default { // do we want to reset the memo everytime the month changes? this.text = this.$t('creation_form.creation_for') + ' ' + name.short + ' ' + name.year this.rangeMin = 0 - this.rangeMax = name.creation + this.rangeMax = Number(name.creation) }, submitCreation() { this.$apollo .mutate({ mutation: adminCreateContribution, variables: { - email: this.item.email, creationDate: this.selected.date, amount: Number(this.value), memo: this.text, From d56390bad0396058a4b1e31c7e4f6f216a8cae3a Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 10 Mar 2023 14:22:45 +0100 Subject: [PATCH 30/91] remove creation from admin update contribution --- backend/src/graphql/resolver/ContributionResolver.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 49ab5fd15..b9c73cec5 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -357,8 +357,6 @@ export class ContributionResolver { result.memo = contributionToUpdate.memo result.date = contributionToUpdate.contributionDate - result.creation = await getUserCreation(contributionToUpdate.userId, clientTimezoneOffset) - await EVENT_ADMIN_CONTRIBUTION_UPDATE( contributionToUpdate.userId, contributionToUpdate.id, From 3d41f1d9f36b7e32b4febc9d7864d29bb8339196 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 10 Mar 2023 14:24:34 +0100 Subject: [PATCH 31/91] moderator to moderatorId --- admin/src/pages/Overview.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/src/pages/Overview.spec.js b/admin/src/pages/Overview.spec.js index beb5bc2dd..23585611c 100644 --- a/admin/src/pages/Overview.spec.js +++ b/admin/src/pages/Overview.spec.js @@ -42,7 +42,7 @@ const defaultData = () => { amount: 500, memo: 'Danke für alles', date: new Date(), - moderator: 1, + moderatorId: 1, state: 'PENDING', creation: [500, 500, 500], messagesCount: 0, @@ -64,7 +64,7 @@ const defaultData = () => { amount: 1000000, memo: 'Gut Ergattert', date: new Date(), - moderator: 1, + moderatorId: 1, state: 'PENDING', creation: [500, 500, 500], messagesCount: 0, From 7345ebb386146269b3b206626cb725845f3d65ec Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 10 Mar 2023 14:28:04 +0100 Subject: [PATCH 32/91] jest env not needed --- backend/.eslintrc.js | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index bc2f0a43d..0085e695b 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -2,7 +2,6 @@ module.exports = { root: true, env: { node: true, - // jest: true, }, parser: '@typescript-eslint/parser', plugins: ['prettier', '@typescript-eslint', 'type-graphql', 'jest'], From d9f5c1e89e252f49aa3f2e06bca5259b74e104b6 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 10 Mar 2023 14:28:27 +0100 Subject: [PATCH 33/91] use moderator id to identify myself --- admin/src/components/Tables/OpenCreationsTable.spec.js | 2 +- admin/src/components/Tables/OpenCreationsTable.vue | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/admin/src/components/Tables/OpenCreationsTable.spec.js b/admin/src/components/Tables/OpenCreationsTable.spec.js index cfb91be0d..8f91aca03 100644 --- a/admin/src/components/Tables/OpenCreationsTable.spec.js +++ b/admin/src/components/Tables/OpenCreationsTable.spec.js @@ -82,7 +82,7 @@ const mocks = { $store: { state: { moderator: { - id: 0, + id: 1, name: 'test moderator', }, }, diff --git a/admin/src/components/Tables/OpenCreationsTable.vue b/admin/src/components/Tables/OpenCreationsTable.vue index 9e0f3c747..9d93eba60 100644 --- a/admin/src/components/Tables/OpenCreationsTable.vue +++ b/admin/src/components/Tables/OpenCreationsTable.vue @@ -147,10 +147,7 @@ export default { }, methods: { myself(item) { - return ( - `${item.firstName} ${item.lastName}` === - `${this.$store.state.moderator.firstName} ${this.$store.state.moderator.lastName}` - ) + return item.userId === this.$store.state.moderator.id }, getStatusIcon(status) { return iconMap[status] ? iconMap[status] : 'default-icon' From f8cc681e06102b2d4e827c736e966c78f65c1311 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 10 Mar 2023 15:26:07 +0100 Subject: [PATCH 34/91] fix unit tests --- .../resolver/ContributionResolver.test.ts | 18 +++--------------- backend/src/seeds/graphql/mutations.ts | 11 ++--------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 274067ba0..944d9a03c 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -434,7 +434,6 @@ describe('ContributionResolver', () => { mutation: adminUpdateContribution, variables: { id: pendingContribution.data.createContribution.id, - email: 'bibi@bloxberg.de', amount: 10.0, memo: 'Test env contribution', creationDate: new Date().toString(), @@ -1667,7 +1666,6 @@ describe('ContributionResolver', () => { mutation: adminUpdateContribution, variables: { id: 1, - email: 'bibi@bloxberg.de', amount: new Decimal(300), memo: 'Danke Bibi!', creationDate: contributionDateFormatter(new Date()), @@ -1746,7 +1744,6 @@ describe('ContributionResolver', () => { mutation: adminUpdateContribution, variables: { id: 1, - email: 'bibi@bloxberg.de', amount: new Decimal(300), memo: 'Danke Bibi!', creationDate: contributionDateFormatter(new Date()), @@ -2076,7 +2073,7 @@ describe('ContributionResolver', () => { // stephen@hawking.uk: [1000, 1000, 1000] - deleted // garrick@ollivander.com: [1000, 1000, 1000] - not activated - describe('user for creation to update does not exist', () => { + describe.skip('user for creation to update does not exist', () => { it('throws an error', async () => { jest.clearAllMocks() await expect( @@ -2084,7 +2081,6 @@ describe('ContributionResolver', () => { mutation: adminUpdateContribution, variables: { id: 1, - email: 'bob@baumeister.de', amount: new Decimal(300), memo: 'Danke Bibi!', creationDate: contributionDateFormatter(new Date()), @@ -2102,7 +2098,7 @@ describe('ContributionResolver', () => { }) }) - describe('user for creation to update is deleted', () => { + describe.skip('user for creation to update is deleted', () => { it('throws an error', async () => { jest.clearAllMocks() await expect( @@ -2110,7 +2106,6 @@ describe('ContributionResolver', () => { mutation: adminUpdateContribution, variables: { id: 1, - email: 'stephen@hawking.uk', amount: new Decimal(300), memo: 'Danke Bibi!', creationDate: contributionDateFormatter(new Date()), @@ -2136,7 +2131,6 @@ describe('ContributionResolver', () => { mutation: adminUpdateContribution, variables: { id: -1, - email: 'bibi@bloxberg.de', amount: new Decimal(300), memo: 'Danke Bibi!', creationDate: contributionDateFormatter(new Date()), @@ -2154,7 +2148,7 @@ describe('ContributionResolver', () => { }) }) - describe('user email does not match creation user', () => { + describe.skip('user email does not match creation user', () => { it('throws an error', async () => { jest.clearAllMocks() await expect( @@ -2162,7 +2156,6 @@ describe('ContributionResolver', () => { mutation: adminUpdateContribution, variables: { id: creation ? creation.id : -1, - email: 'bibi@bloxberg.de', amount: new Decimal(300), memo: 'Danke Bibi!', creationDate: creation @@ -2197,7 +2190,6 @@ describe('ContributionResolver', () => { mutation: adminUpdateContribution, variables: { id: creation ? creation.id : -1, - email: 'peter@lustig.de', amount: new Decimal(1900), memo: 'Danke Peter!', creationDate: creation @@ -2233,7 +2225,6 @@ describe('ContributionResolver', () => { mutation: adminUpdateContribution, variables: { id: creation ? creation.id : -1, - email: 'peter@lustig.de', amount: new Decimal(300), memo: 'Danke Peter!', creationDate: creation @@ -2248,7 +2239,6 @@ describe('ContributionResolver', () => { date: expect.any(String), memo: 'Danke Peter!', amount: '300', - creation: ['1000', '700', '500'], }, }, }), @@ -2274,7 +2264,6 @@ describe('ContributionResolver', () => { mutation: adminUpdateContribution, variables: { id: creation ? creation.id : -1, - email: 'peter@lustig.de', amount: new Decimal(200), memo: 'Das war leider zu Viel!', creationDate: creation @@ -2289,7 +2278,6 @@ describe('ContributionResolver', () => { date: expect.any(String), memo: 'Das war leider zu Viel!', amount: '200', - creation: ['1000', '800', '1000'], }, }, }), diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index 69d6d16d8..94b840815 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -127,18 +127,11 @@ export const unDeleteUser = gql` ` export const adminUpdateContribution = gql` - mutation ($id: Int!, $email: String!, $amount: Decimal!, $memo: String!, $creationDate: String!) { - adminUpdateContribution( - id: $id - email: $email - amount: $amount - memo: $memo - creationDate: $creationDate - ) { + mutation ($id: Int!, $amount: Decimal!, $memo: String!, $creationDate: String!) { + adminUpdateContribution(id: $id, amount: $amount, memo: $memo, creationDate: $creationDate) { amount date memo - creation } } ` From 193da5fd0f4d085dbc11c5a8b624f0f2382ac75e Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 12 Mar 2023 02:11:54 +0100 Subject: [PATCH 35/91] update config --- backend/.eslintrc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index 0085e695b..6ce43ef35 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -17,10 +17,10 @@ module.exports = { }, ], // jest - 'jest/no-disabled-tests': 'off', // TODO + 'jest/no-disabled-tests': 'error', 'jest/no-focused-tests': 'error', 'jest/no-identical-title': 'error', - 'jest/prefer-to-have-length': 'warn', + 'jest/prefer-to-have-length': 'error', 'jest/valid-expect': 'error', }, overrides: [ From 62411198852240bb2029d55ab83e57334e6c7380 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 12 Mar 2023 02:18:13 +0100 Subject: [PATCH 36/91] fix skip tests --- backend/src/emails/sendEmailTranslated.test.ts | 2 ++ backend/src/graphql/resolver/ContributionResolver.test.ts | 1 + backend/src/graphql/resolver/TransactionLinkResolver.test.ts | 1 + backend/src/graphql/resolver/UserResolver.test.ts | 1 + backend/src/util/decay.test.ts | 1 + 5 files changed, 6 insertions(+) diff --git a/backend/src/emails/sendEmailTranslated.test.ts b/backend/src/emails/sendEmailTranslated.test.ts index f3c75a7a6..73edb79f3 100644 --- a/backend/src/emails/sendEmailTranslated.test.ts +++ b/backend/src/emails/sendEmailTranslated.test.ts @@ -102,10 +102,12 @@ describe('sendEmailTranslated', () => { }) }) + // eslint-disable-next-line jest/no-disabled-tests it.skip('calls "i18n.setLocale" with "en"', () => { expect(i18n.setLocale).toBeCalledWith('en') }) + // eslint-disable-next-line jest/no-disabled-tests it.skip('calls "i18n.__" for translation', () => { expect(i18n.__).toBeCalled() }) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index cc7357e99..a15c64e85 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -2225,6 +2225,7 @@ describe('ContributionResolver', () => { }) }) + // eslint-disable-next-line jest/no-disabled-tests describe.skip('creation update is successful changing month', () => { // skipped as changing the month is currently disable it('returns update creation object', async () => { diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index c6b733d0d..35d3f42f6 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -759,6 +759,7 @@ describe('TransactionLinkResolver', () => { }) // TODO: works not as expected, because 'redeemedAt' and 'redeemedBy' have to be added to the transaktion link factory + // eslint-disable-next-line jest/no-disabled-tests describe.skip('filter by redeemed', () => { it('finds 6 open transaction links, 1 deleted, and no redeemed', async () => { await expect( diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index a57346583..083badc30 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -789,6 +789,7 @@ describe('UserResolver', () => { }) }) + // eslint-disable-next-line jest/no-disabled-tests describe.skip('user is in database but password is not set', () => { beforeAll(async () => { jest.clearAllMocks() diff --git a/backend/src/util/decay.test.ts b/backend/src/util/decay.test.ts index cf00ec851..0e7b02f56 100644 --- a/backend/src/util/decay.test.ts +++ b/backend/src/util/decay.test.ts @@ -16,6 +16,7 @@ describe('utils/decay', () => { expect(decayFormula(amount, seconds).toString()).toBe('1.000000021964959992727444') }) // we get pretty close, but not exact here, skipping + // eslint-disable-next-line jest/no-disabled-tests it.skip('has correct forward calculation', () => { const amount = new Decimal(1.0).div( new Decimal('0.99999997803504048973201202316767079413460520837376'), From 9febdbf81b010968210b8512154bda7387a2795a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 10 Mar 2023 15:06:35 +0100 Subject: [PATCH 37/91] eslint-plugin-import --- backend/.eslintrc.js | 21 +- backend/package.json | 3 +- backend/yarn.lock | 704 +++++++++++++++++++++++++++++-------------- 3 files changed, 491 insertions(+), 237 deletions(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index 6ce43ef35..bb03a23fa 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -4,9 +4,20 @@ module.exports = { node: true, }, parser: '@typescript-eslint/parser', - plugins: ['prettier', '@typescript-eslint', 'type-graphql', 'jest'], - extends: ['standard', 'eslint:recommended', 'plugin:prettier/recommended'], - // add your custom rules here + plugins: ['prettier', '@typescript-eslint', 'type-graphql', 'jest', 'import'], + extends: [ + 'standard', + 'eslint:recommended', + 'plugin:prettier/recommended', + 'plugin:import/recommended', + 'plugin:import/typescript', + ], + settings: { + 'import/resolver': { + typescript: true, + node: true, + }, + }, rules: { 'no-console': ['error'], 'no-debugger': 'error', @@ -22,6 +33,10 @@ module.exports = { 'jest/no-identical-title': 'error', 'jest/prefer-to-have-length': 'error', 'jest/valid-expect': 'error', + // import + 'import/no-deprecated': 'error', + 'import/no-empty-named-blocks': 'error', + 'import/no-mutable-exports': 'error', }, overrides: [ // only for ts files diff --git a/backend/package.json b/backend/package.json index 69cb26c93..34eb78bca 100644 --- a/backend/package.json +++ b/backend/package.json @@ -61,7 +61,8 @@ "eslint": "^7.29.0", "eslint-config-prettier": "^8.3.0", "eslint-config-standard": "^16.0.3", - "eslint-plugin-import": "^2.23.4", + "eslint-import-resolver-typescript": "^3.5.3", + "eslint-plugin-import": "^2.27.5", "eslint-plugin-jest": "^27.2.1", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^3.4.0", diff --git a/backend/yarn.lock b/backend/yarn.lock index 7d896258f..f5db29695 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -712,6 +712,18 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" +"@pkgr/utils@^2.3.1": + version "2.3.1" + resolved "https://registry.yarnpkg.com/@pkgr/utils/-/utils-2.3.1.tgz#0a9b06ffddee364d6642b3cd562ca76f55b34a03" + integrity sha512-wfzX8kc1PMyUILA+1Z/EqoE4UCXGy0iRGMhPwdfae1+f0OXlLqCk+By+aMzgJBzR9AzS4CDizioG6Ss1gvAFJw== + dependencies: + cross-spawn "^7.0.3" + is-glob "^4.0.3" + open "^8.4.0" + picocolors "^1.0.0" + tiny-glob "^0.2.9" + tslib "^2.4.0" + "@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": version "1.1.2" resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf" @@ -1668,15 +1680,15 @@ array-flatten@1.1.1: resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" integrity sha1-ml9pkFGx5wczKPKgCJaLZOopVdI= -array-includes@^3.1.3: - version "3.1.4" - resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.4.tgz#f5b493162c760f3539631f005ba2bb46acb45ba9" - integrity sha512-ZTNSQkmWumEbiHO2GF4GmWxYVTiQyJy2XOTa15sdQSrvKn7l+180egQMqlrMOUMCyLMD7pmyQe4mMDUT6Behrw== +array-includes@^3.1.6: + version "3.1.6" + resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.6.tgz#9e9e720e194f198266ba9e18c29e6a9b0e4b225f" + integrity sha512-sgTbLvL6cNnw24FnbaDyjmvddQ2ML8arZsgaJhoABMoplz/4QRhtrYS+alr1BUM1Bwp6dhx8vVCBSLG+StwOFw== dependencies: call-bind "^1.0.2" - define-properties "^1.1.3" - es-abstract "^1.19.1" - get-intrinsic "^1.1.1" + define-properties "^1.1.4" + es-abstract "^1.20.4" + get-intrinsic "^1.1.3" is-string "^1.0.7" array-union@^2.1.0: @@ -1684,14 +1696,25 @@ array-union@^2.1.0: resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== -array.prototype.flat@^1.2.4: - version "1.2.5" - resolved "https://registry.yarnpkg.com/array.prototype.flat/-/array.prototype.flat-1.2.5.tgz#07e0975d84bbc7c48cd1879d609e682598d33e13" - integrity sha512-KaYU+S+ndVqyUnignHftkwc58o3uVU1jzczILJ1tN2YaIZpFIKBiP/x/j97E5MVPsaCloPbqWLB/8qCTVvT2qg== +array.prototype.flat@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/array.prototype.flat/-/array.prototype.flat-1.3.1.tgz#ffc6576a7ca3efc2f46a143b9d1dda9b4b3cf5e2" + integrity sha512-roTU0KWIOmJ4DRLmwKd19Otg0/mT3qPNt0Qb3GWW8iObuZXxrjB/pzn0R3hqpRSWg4HCwqx+0vwOnWnvlOyeIA== dependencies: call-bind "^1.0.2" - define-properties "^1.1.3" - es-abstract "^1.19.0" + define-properties "^1.1.4" + es-abstract "^1.20.4" + es-shim-unscopables "^1.0.0" + +array.prototype.flatmap@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/array.prototype.flatmap/-/array.prototype.flatmap-1.3.1.tgz#1aae7903c2100433cb8261cd4ed310aab5c4a183" + integrity sha512-8UGn9O1FDVvMNB0UlLv4voxRMze7+FpHyF5mSMRjWHUMlpoDViniy05870VlxhfgTnLbpuwTzvD76MTtWxB/mQ== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + es-shim-unscopables "^1.0.0" arrify@^2.0.1: version "2.0.1" @@ -1725,6 +1748,11 @@ asynckit@^0.4.0: resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= +available-typed-arrays@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7" + integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw== + await-semaphore@^0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/await-semaphore/-/await-semaphore-0.1.3.tgz#2b88018cc8c28e06167ae1cdff02504f1f9688d3" @@ -2319,7 +2347,7 @@ date-format@^4.0.9: resolved "https://registry.yarnpkg.com/date-format/-/date-format-4.0.9.tgz#4788015ac56dedebe83b03bc361f00c1ddcf1923" integrity sha512-+8J+BOUpSrlKLQLeF8xJJVTxS8QfRSuJgwxSVvslzgO3E6khbI0F5mMEPf5mTYhCCm4h99knYP6H3W9n3BQFrg== -debug@2.6.9, debug@^2.2.0, debug@^2.6.9: +debug@2.6.9, debug@^2.2.0: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== @@ -2389,6 +2417,11 @@ defer-to-connect@^1.0.1: resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-1.1.3.tgz#331ae050c08dcf789f8c83a7b81f0ed94f4ac591" integrity sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ== +define-lazy-prop@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz#3f7ae421129bcaaac9bc74905c98a0009ec9ee7f" + integrity sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og== + define-properties@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" @@ -2396,6 +2429,14 @@ define-properties@^1.1.3: dependencies: object-keys "^1.0.12" +define-properties@^1.1.4: + version "1.2.0" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.2.0.tgz#52988570670c9eacedd8064f4a990f2405849bd5" + integrity sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA== + dependencies: + has-property-descriptors "^1.0.0" + object-keys "^1.1.1" + delayed-stream@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" @@ -2601,6 +2642,14 @@ end-of-stream@^1.1.0: dependencies: once "^1.4.0" +enhanced-resolve@^5.10.0: + version "5.12.0" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz#300e1c90228f5b570c4d35babf263f6da7155634" + integrity sha512-QHTXI/sZQmko1cbDoNAa3mJ5qhWUUNAq3vR0/YiD379fWQrcfuoX1+HW2S0MTt7XmoPLapdaDKUtelUSPic7hQ== + dependencies: + graceful-fs "^4.2.4" + tapable "^2.2.0" + enquirer@^2.3.5: version "2.3.6" resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" @@ -2613,13 +2662,6 @@ entities@^2.0.0: resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55" integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A== -error-ex@^1.3.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" - integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== - dependencies: - is-arrayish "^0.2.1" - es-abstract@^1.19.0, es-abstract@^1.19.1: version "1.19.1" resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.19.1.tgz#d4885796876916959de78edaa0df456627115ec3" @@ -2646,6 +2688,61 @@ es-abstract@^1.19.0, es-abstract@^1.19.1: string.prototype.trimstart "^1.0.4" unbox-primitive "^1.0.1" +es-abstract@^1.20.4: + version "1.21.1" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.21.1.tgz#e6105a099967c08377830a0c9cb589d570dd86c6" + integrity sha512-QudMsPOz86xYz/1dG1OuGBKOELjCh99IIWHLzy5znUB6j8xG2yMA7bfTV86VSqKF+Y/H08vQPR+9jyXpuC6hfg== + dependencies: + available-typed-arrays "^1.0.5" + call-bind "^1.0.2" + es-set-tostringtag "^2.0.1" + es-to-primitive "^1.2.1" + function-bind "^1.1.1" + function.prototype.name "^1.1.5" + get-intrinsic "^1.1.3" + get-symbol-description "^1.0.0" + globalthis "^1.0.3" + gopd "^1.0.1" + has "^1.0.3" + has-property-descriptors "^1.0.0" + has-proto "^1.0.1" + has-symbols "^1.0.3" + internal-slot "^1.0.4" + is-array-buffer "^3.0.1" + is-callable "^1.2.7" + is-negative-zero "^2.0.2" + is-regex "^1.1.4" + is-shared-array-buffer "^1.0.2" + is-string "^1.0.7" + is-typed-array "^1.1.10" + is-weakref "^1.0.2" + object-inspect "^1.12.2" + object-keys "^1.1.1" + object.assign "^4.1.4" + regexp.prototype.flags "^1.4.3" + safe-regex-test "^1.0.0" + string.prototype.trimend "^1.0.6" + string.prototype.trimstart "^1.0.6" + typed-array-length "^1.0.4" + unbox-primitive "^1.0.2" + which-typed-array "^1.1.9" + +es-set-tostringtag@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz#338d502f6f674301d710b80c8592de8a15f09cd8" + integrity sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg== + dependencies: + get-intrinsic "^1.1.3" + has "^1.0.3" + has-tostringtag "^1.0.0" + +es-shim-unscopables@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/es-shim-unscopables/-/es-shim-unscopables-1.0.0.tgz#702e632193201e3edf8713635d083d378e510241" + integrity sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w== + dependencies: + has "^1.0.3" + es-to-primitive@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" @@ -2717,21 +2814,34 @@ eslint-config-standard@^16.0.3: resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-16.0.3.tgz#6c8761e544e96c531ff92642eeb87842b8488516" integrity sha512-x4fmJL5hGqNJKGHSjnLdgA6U6h1YW/G2dW9fA+cyVur4SK6lyue8+UgNKWlZtUDTXvgKDD/Oa3GQjmB5kjtVvg== -eslint-import-resolver-node@^0.3.6: - version "0.3.6" - resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz#4048b958395da89668252001dbd9eca6b83bacbd" - integrity sha512-0En0w03NRVMn9Uiyn8YRPDKvWjxCWkslUEhGNTdGx15RvPJYQ+lbOlqrlNI2vEAs4pDYK4f/HN2TbDmk5TP0iw== +eslint-import-resolver-node@^0.3.7: + version "0.3.7" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.7.tgz#83b375187d412324a1963d84fa664377a23eb4d7" + integrity sha512-gozW2blMLJCeFpBwugLTGyvVjNoeo1knonXAcatC6bjPBZitotxdWf7Gimr25N4c0AAOo4eOUfaG82IJPDpqCA== dependencies: debug "^3.2.7" - resolve "^1.20.0" + is-core-module "^2.11.0" + resolve "^1.22.1" -eslint-module-utils@^2.6.2: - version "2.6.2" - resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.6.2.tgz#94e5540dd15fe1522e8ffa3ec8db3b7fa7e7a534" - integrity sha512-QG8pcgThYOuqxupd06oYTZoNOGaUdTY1PqK+oS6ElF6vs4pBdk/aYxFVQQXzcrAqp9m7cl7lb2ubazX+g16k2Q== +eslint-import-resolver-typescript@^3.5.3: + version "3.5.3" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.5.3.tgz#db5ed9e906651b7a59dd84870aaef0e78c663a05" + integrity sha512-njRcKYBc3isE42LaTcJNVANR3R99H9bAxBDMNDr2W7yq5gYPxbU3MkdhsQukxZ/Xg9C2vcyLlDsbKfRDg0QvCQ== + dependencies: + debug "^4.3.4" + enhanced-resolve "^5.10.0" + get-tsconfig "^4.2.0" + globby "^13.1.2" + is-core-module "^2.10.0" + is-glob "^4.0.3" + synckit "^0.8.4" + +eslint-module-utils@^2.7.4: + version "2.7.4" + resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.7.4.tgz#4f3e41116aaf13a20792261e61d3a2e7e0583974" + integrity sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA== dependencies: debug "^3.2.7" - pkg-dir "^2.0.0" eslint-plugin-es@^3.0.0: version "3.0.1" @@ -2741,26 +2851,26 @@ eslint-plugin-es@^3.0.0: eslint-utils "^2.0.0" regexpp "^3.0.0" -eslint-plugin-import@^2.23.4: - version "2.24.2" - resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.24.2.tgz#2c8cd2e341f3885918ee27d18479910ade7bb4da" - integrity sha512-hNVtyhiEtZmpsabL4neEj+6M5DCLgpYyG9nzJY8lZQeQXEn5UPW1DpUdsMHMXsq98dbNm7nt1w9ZMSVpfJdi8Q== +eslint-plugin-import@^2.27.5: + version "2.27.5" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.27.5.tgz#876a6d03f52608a3e5bb439c2550588e51dd6c65" + integrity sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow== dependencies: - array-includes "^3.1.3" - array.prototype.flat "^1.2.4" - debug "^2.6.9" + array-includes "^3.1.6" + array.prototype.flat "^1.3.1" + array.prototype.flatmap "^1.3.1" + debug "^3.2.7" doctrine "^2.1.0" - eslint-import-resolver-node "^0.3.6" - eslint-module-utils "^2.6.2" - find-up "^2.0.0" + eslint-import-resolver-node "^0.3.7" + eslint-module-utils "^2.7.4" has "^1.0.3" - is-core-module "^2.6.0" - minimatch "^3.0.4" - object.values "^1.1.4" - pkg-up "^2.0.0" - read-pkg-up "^3.0.0" - resolve "^1.20.0" - tsconfig-paths "^3.11.0" + is-core-module "^2.11.0" + is-glob "^4.0.3" + minimatch "^3.1.2" + object.values "^1.1.6" + resolve "^1.22.1" + semver "^6.3.0" + tsconfig-paths "^3.14.1" eslint-plugin-jest@^27.2.1: version "27.2.1" @@ -3048,7 +3158,7 @@ fast-glob@^3.1.1: merge2 "^1.3.0" micromatch "^4.0.4" -fast-glob@^3.2.9: +fast-glob@^3.2.11, fast-glob@^3.2.9: version "3.2.12" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.12.tgz#7f39ec99c2e6ab030337142da9e0c18f37afae80" integrity sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w== @@ -3117,13 +3227,6 @@ finalhandler@~1.1.2: statuses "~1.5.0" unpipe "~1.0.0" -find-up@^2.0.0, find-up@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" - integrity sha1-RdG35QbHF93UgndaK3eSCjwMV6c= - dependencies: - locate-path "^2.0.0" - find-up@^4.0.0, find-up@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" @@ -3210,11 +3313,26 @@ function-bind@^1.1.1: resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== +function.prototype.name@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/function.prototype.name/-/function.prototype.name-1.1.5.tgz#cce0505fe1ffb80503e6f9e46cc64e46a12a9621" + integrity sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + es-abstract "^1.19.0" + functions-have-names "^1.2.2" + functional-red-black-tree@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= +functions-have-names@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/functions-have-names/-/functions-have-names-1.2.3.tgz#0404fe4ee2ba2f607f0e0ec3c80bae994133b834" + integrity sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ== + generate-function@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.3.1.tgz#f069617690c10c868e73b8465746764f97c3479f" @@ -3241,6 +3359,15 @@ get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1: has "^1.0.3" has-symbols "^1.0.1" +get-intrinsic@^1.1.3, get-intrinsic@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.0.tgz#7ad1dc0535f3a2904bba075772763e5051f6d05f" + integrity sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q== + dependencies: + function-bind "^1.1.1" + has "^1.0.3" + has-symbols "^1.0.3" + get-package-type@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a" @@ -3290,6 +3417,11 @@ get-symbol-description@^1.0.0: call-bind "^1.0.2" get-intrinsic "^1.1.1" +get-tsconfig@^4.2.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/get-tsconfig/-/get-tsconfig-4.4.0.tgz#64eee64596668a81b8fce18403f94f245ee0d4e5" + integrity sha512-0Gdjo/9+FzsYhXCEFueo2aY1z1tpXrxWZzP7k8ul9qt1U5o8rYJwTJYmaeHdrVosYIVYkOy2iwCJ9FdpocJhPQ== + glob-parent@^5.1.2, glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" @@ -3328,6 +3460,18 @@ globals@^13.6.0, globals@^13.9.0: dependencies: type-fest "^0.20.2" +globalthis@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/globalthis/-/globalthis-1.0.3.tgz#5852882a52b80dc301b0660273e1ed082f0b6ccf" + integrity sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA== + dependencies: + define-properties "^1.1.3" + +globalyzer@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/globalyzer/-/globalyzer-0.1.0.tgz#cb76da79555669a1519d5a8edf093afaa0bf1465" + integrity sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q== + globby@^11.0.3: version "11.0.4" resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.4.tgz#2cbaff77c2f2a62e71e9b2813a67b97a3a3001a5" @@ -3352,6 +3496,29 @@ globby@^11.1.0: merge2 "^1.4.1" slash "^3.0.0" +globby@^13.1.2: + version "13.1.3" + resolved "https://registry.yarnpkg.com/globby/-/globby-13.1.3.tgz#f62baf5720bcb2c1330c8d4ef222ee12318563ff" + integrity sha512-8krCNHXvlCgHDpegPzleMq07yMYTO2sXKASmZmquEYWEmCx6J5UTRbp5RwMJkTJGtcQ44YpiUYUiN0b9mzy8Bw== + dependencies: + dir-glob "^3.0.1" + fast-glob "^3.2.11" + ignore "^5.2.0" + merge2 "^1.4.1" + slash "^4.0.0" + +globrex@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/globrex/-/globrex-0.1.2.tgz#dd5d9ec826232730cd6793a5e33a9302985e6098" + integrity sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg== + +gopd@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.0.1.tgz#29ff76de69dac7489b7c0918a5788e56477c332c" + integrity sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA== + dependencies: + get-intrinsic "^1.1.3" + got@^9.6.0: version "9.6.0" resolved "https://registry.yarnpkg.com/got/-/got-9.6.0.tgz#edf45e7d67f99545705de1f7bbeeeb121765ed85" @@ -3440,6 +3607,11 @@ has-bigints@^1.0.1: resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.1.tgz#64fe6acb020673e3b78db035a5af69aa9d07b113" integrity sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA== +has-bigints@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.2.tgz#0871bd3e3d51626f6ca0966668ba35d5602d6eaa" + integrity sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ== + has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" @@ -3450,11 +3622,28 @@ has-flag@^4.0.0: resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== +has-property-descriptors@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz#610708600606d36961ed04c196193b6a607fa861" + integrity sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ== + dependencies: + get-intrinsic "^1.1.1" + +has-proto@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/has-proto/-/has-proto-1.0.1.tgz#1885c1305538958aff469fef37937c22795408e0" + integrity sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg== + has-symbols@^1.0.1, has-symbols@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.2.tgz#165d3070c00309752a1236a479331e3ac56f1423" integrity sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw== +has-symbols@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" + integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== + has-tostringtag@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/has-tostringtag/-/has-tostringtag-1.0.0.tgz#7e133818a7d394734f941e73c3d3f9291e658b25" @@ -3479,11 +3668,6 @@ he@1.2.0, he@^1.2.0: resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== -hosted-git-info@^2.1.4: - version "2.8.9" - resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9" - integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw== - html-encoding-sniffer@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz#42a6dc4fd33f00281176e8b23759ca4e4fa185f3" @@ -3728,15 +3912,28 @@ internal-slot@^1.0.3: has "^1.0.3" side-channel "^1.0.4" +internal-slot@^1.0.4: + version "1.0.5" + resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.5.tgz#f2a2ee21f668f8627a4667f309dc0f4fb6674986" + integrity sha512-Y+R5hJrzs52QCG2laLn4udYVnxsfny9CpOhNhUvk/SSSVyF6T27FzRbF0sroPidSu3X8oEAkOn2K804mjpt6UQ== + dependencies: + get-intrinsic "^1.2.0" + has "^1.0.3" + side-channel "^1.0.4" + ipaddr.js@1.9.1: version "1.9.1" resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== -is-arrayish@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" - integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= +is-array-buffer@^3.0.1: + version "3.0.2" + resolved "https://registry.yarnpkg.com/is-array-buffer/-/is-array-buffer-3.0.2.tgz#f2653ced8412081638ecb0ebbd0c41c6e0aecbbe" + integrity sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w== + dependencies: + call-bind "^1.0.2" + get-intrinsic "^1.2.0" + is-typed-array "^1.1.10" is-bigint@^1.0.1: version "1.0.4" @@ -3765,6 +3962,11 @@ is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.4: resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.4.tgz#47301d58dd0259407865547853df6d61fe471945" integrity sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w== +is-callable@^1.2.7: + version "1.2.7" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055" + integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA== + is-ci@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c" @@ -3779,7 +3981,14 @@ is-ci@^3.0.0: dependencies: ci-info "^3.1.1" -is-core-module@^2.2.0, is-core-module@^2.6.0: +is-core-module@^2.10.0, is-core-module@^2.11.0: + version "2.11.0" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.11.0.tgz#ad4cb3e3863e814523c96f3f58d26cc570ff0144" + integrity sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw== + dependencies: + has "^1.0.3" + +is-core-module@^2.2.0: version "2.7.0" resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.7.0.tgz#3c0ef7d31b4acfc574f80c58409d568a836848e3" integrity sha512-ByY+tjCciCr+9nLryBYcSD50EOGWt95c7tIsKTG1J2ixKKXPvF7Ej3AVd+UfDydAJom3biBGDBALaO79ktwgEQ== @@ -3800,7 +4009,7 @@ is-date-object@^1.0.1: dependencies: has-tostringtag "^1.0.0" -is-docker@^2.0.0: +is-docker@^2.0.0, is-docker@^2.1.1: version "2.2.1" resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa" integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ== @@ -3848,6 +4057,11 @@ is-negative-zero@^2.0.1: resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.1.tgz#3de746c18dda2319241a53675908d8f766f11c24" integrity sha512-2z6JzQvZRa9A2Y7xC6dQQm4FSTSTNWjKIYYTt4246eMTJmIo0Q+ZyOsU66X8lxK1AbB92dFeglPLrhwpeRKO6w== +is-negative-zero@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.2.tgz#7bf6f03a28003b8b3965de3ac26f664d765f3150" + integrity sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA== + is-npm@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-5.0.0.tgz#43e8d65cc56e1b67f8d47262cf667099193f45a8" @@ -3903,6 +4117,13 @@ is-shared-array-buffer@^1.0.1: resolved "https://registry.yarnpkg.com/is-shared-array-buffer/-/is-shared-array-buffer-1.0.1.tgz#97b0c85fbdacb59c9c446fe653b82cf2b5b7cfe6" integrity sha512-IU0NmyknYZN0rChcKhRO1X8LYz5Isj/Fsqh8NJOSf+N/hCOTwy29F32Ik7a+QszE63IdvmwdTPDd6cZ5pg4cwA== +is-shared-array-buffer@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz#8f259c573b60b6a32d4058a1a07430c0a7344c79" + integrity sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA== + dependencies: + call-bind "^1.0.2" + is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" @@ -3927,6 +4148,17 @@ is-symbol@^1.0.2, is-symbol@^1.0.3: dependencies: has-symbols "^1.0.2" +is-typed-array@^1.1.10, is-typed-array@^1.1.9: + version "1.1.10" + resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.10.tgz#36a5b5cb4189b575d1a3e4b08536bfb485801e3f" + integrity sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A== + dependencies: + available-typed-arrays "^1.0.5" + call-bind "^1.0.2" + for-each "^0.3.3" + gopd "^1.0.1" + has-tostringtag "^1.0.0" + is-typedarray@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" @@ -3939,7 +4171,14 @@ is-weakref@^1.0.1: dependencies: call-bind "^1.0.0" -is-wsl@^2.1.1: +is-weakref@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-weakref/-/is-weakref-1.0.2.tgz#9529f383a9338205e89765e0392efc2f100f06f2" + integrity sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ== + dependencies: + call-bind "^1.0.2" + +is-wsl@^2.1.1, is-wsl@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271" integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww== @@ -4474,11 +4713,6 @@ json-buffer@3.0.0: resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.0.tgz#5b1f397afc75d677bde8bcfc0e47e1f9a3d9a898" integrity sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg= -json-parse-better-errors@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" - integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== - json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" @@ -4508,6 +4742,13 @@ json5@^1.0.1: dependencies: minimist "^1.2.0" +json5@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.2.tgz#63d98d60f21b313b77c4d6da18bfa69d80e1d593" + integrity sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA== + dependencies: + minimist "^1.2.0" + jsonfile@^6.0.1: version "6.1.0" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae" @@ -4641,24 +4882,6 @@ linkify-it@4.0.0: dependencies: uc.micro "^1.0.1" -load-json-file@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b" - integrity sha1-L19Fq5HjMhYjT9U62rZo607AmTs= - dependencies: - graceful-fs "^4.1.2" - parse-json "^4.0.0" - pify "^3.0.0" - strip-bom "^3.0.0" - -locate-path@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" - integrity sha1-K1aLJl7slExtnA3pw9u7ygNUzY4= - dependencies: - p-locate "^2.0.0" - path-exists "^3.0.0" - locate-path@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" @@ -4907,6 +5130,13 @@ minimatch@^3.0.4: dependencies: brace-expansion "^1.1.7" +minimatch@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" + minimist@^1.2.0, minimist@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" @@ -5076,16 +5306,6 @@ nopt@~1.0.10: dependencies: abbrev "1" -normalize-package-data@^2.3.2: - version "2.5.0" - resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" - integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== - dependencies: - hosted-git-info "^2.1.4" - resolve "^1.10.0" - semver "2 || 3 || 4 || 5" - validate-npm-package-license "^3.0.1" - normalize-path@^3.0.0, normalize-path@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" @@ -5132,6 +5352,11 @@ object-inspect@^1.11.0, object-inspect@^1.9.0: resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.11.0.tgz#9dceb146cedd4148a0d9e51ab88d34cf509922b1" integrity sha512-jp7ikS6Sd3GxQfZJPyH3cjcbJF6GZPClgdV+EFygjFLQ5FmW/dRUnTd9PQ9k0JhoNDabWFbpF1yCdSWCC6gexg== +object-inspect@^1.12.2: + version "1.12.3" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.3.tgz#ba62dffd67ee256c8c086dfae69e016cd1f198b9" + integrity sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g== + object-keys@^1.0.12, object-keys@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" @@ -5152,6 +5377,16 @@ object.assign@^4.1.2: has-symbols "^1.0.1" object-keys "^1.1.1" +object.assign@^4.1.4: + version "4.1.4" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.4.tgz#9673c7c7c351ab8c4d0b516f4343ebf4dfb7799f" + integrity sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + has-symbols "^1.0.3" + object-keys "^1.1.1" + object.getownpropertydescriptors@^2.1.1: version "2.1.3" resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.3.tgz#b223cf38e17fefb97a63c10c91df72ccb386df9e" @@ -5161,14 +5396,14 @@ object.getownpropertydescriptors@^2.1.1: define-properties "^1.1.3" es-abstract "^1.19.1" -object.values@^1.1.4: - version "1.1.5" - resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.5.tgz#959f63e3ce9ef108720333082131e4a459b716ac" - integrity sha512-QUZRW0ilQ3PnPpbNtgdNV1PDbEqLIiSFB3l+EnGtBQ/8SUTLj1PZwtQHABZtLgwpJZTSZhuGLOGk57Drx2IvYg== +object.values@^1.1.6: + version "1.1.6" + resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.6.tgz#4abbaa71eba47d63589d402856f908243eea9b1d" + integrity sha512-FVVTkD1vENCsAcwNs9k6jea2uHC/X0+JcjG8YA60FN5CMaJmG95wT9jek/xX9nornqGRrBkKtzuAu2wuHpKqvw== dependencies: call-bind "^1.0.2" - define-properties "^1.1.3" - es-abstract "^1.19.1" + define-properties "^1.1.4" + es-abstract "^1.20.4" on-finished@~2.3.0: version "2.3.0" @@ -5199,6 +5434,15 @@ open@7: is-docker "^2.0.0" is-wsl "^2.1.1" +open@^8.4.0: + version "8.4.2" + resolved "https://registry.yarnpkg.com/open/-/open-8.4.2.tgz#5b5ffe2a8f793dcd2aad73e550cb87b59cb084f9" + integrity sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ== + dependencies: + define-lazy-prop "^2.0.0" + is-docker "^2.1.1" + is-wsl "^2.2.0" + optionator@^0.8.1: version "0.8.3" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" @@ -5240,13 +5484,6 @@ p-finally@^1.0.0: resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" integrity sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow== -p-limit@^1.1.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8" - integrity sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q== - dependencies: - p-try "^1.0.0" - p-limit@^2.2.0: version "2.3.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" @@ -5254,13 +5491,6 @@ p-limit@^2.2.0: dependencies: p-try "^2.0.0" -p-locate@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" - integrity sha1-IKAQOyIqcMj9OcwuWAaA893l7EM= - dependencies: - p-limit "^1.1.0" - p-locate@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" @@ -5275,11 +5505,6 @@ p-timeout@^3.0.0, p-timeout@^3.1.0: dependencies: p-finally "^1.0.0" -p-try@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" - integrity sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M= - p-try@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" @@ -5309,14 +5534,6 @@ parent-module@^1.0.0: dependencies: callsites "^3.0.0" -parse-json@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" - integrity sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA= - dependencies: - error-ex "^1.3.1" - json-parse-better-errors "^1.0.1" - parse5-htmlparser2-tree-adapter@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz#2cdf9ad823321140370d4dbf5d3e92c7c8ddc6e6" @@ -5342,11 +5559,6 @@ parseurl@^1.3.2, parseurl@~1.3.3: resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== -path-exists@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" - integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= - path-exists@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" @@ -5377,13 +5589,6 @@ path-to-regexp@0.1.7: resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" integrity sha1-32BBeABfUi8V60SQ5yR6G/qmf4w= -path-type@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f" - integrity sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg== - dependencies: - pify "^3.0.0" - path-type@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" @@ -5394,16 +5599,16 @@ picocolors@^0.2.1: resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-0.2.1.tgz#570670f793646851d1ba135996962abad587859f" integrity sha512-cMlDqaLEqfSaW8Z7N5Jw+lyIW869EzT73/F5lhtY9cLGoVxSXznfgfXMO0Z5K0o0Q2TkTXq+0KFsdnSe3jDViA== +picocolors@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" + integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== + picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.3: version "2.3.0" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.0.tgz#f1f061de8f6a4bf022892e2d128234fb98302972" integrity sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw== -pify@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" - integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= - pify@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231" @@ -5416,13 +5621,6 @@ pirates@^4.0.1: dependencies: node-modules-regexp "^1.0.0" -pkg-dir@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-2.0.0.tgz#f6d5d1109e19d63edf428e0bd57e12777615334b" - integrity sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s= - dependencies: - find-up "^2.1.0" - pkg-dir@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" @@ -5430,13 +5628,6 @@ pkg-dir@^4.2.0: dependencies: find-up "^4.0.0" -pkg-up@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-2.0.0.tgz#c819ac728059a461cab1c3889a2be3c49a004d7f" - integrity sha1-yBmscoBZpGHKscOImivjxJoATX8= - dependencies: - find-up "^2.1.0" - prelude-ls@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" @@ -5722,23 +5913,6 @@ react-is@^17.0.1: resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== -read-pkg-up@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-3.0.0.tgz#3ed496685dba0f8fe118d0691dc51f4a1ff96f07" - integrity sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc= - dependencies: - find-up "^2.0.0" - read-pkg "^3.0.0" - -read-pkg@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-3.0.0.tgz#9cbc686978fee65d16c00e2b19c237fcf6e38389" - integrity sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k= - dependencies: - load-json-file "^4.0.0" - normalize-package-data "^2.3.2" - path-type "^3.0.0" - readdirp@~3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" @@ -5751,6 +5925,15 @@ reflect-metadata@^0.1.13: resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.1.13.tgz#67ae3ca57c972a2aa1642b10fe363fe32d49dc08" integrity sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg== +regexp.prototype.flags@^1.4.3: + version "1.4.3" + resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz#87cab30f80f66660181a3bb7bf5981a872b367ac" + integrity sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + functions-have-names "^1.2.2" + regexpp@^3.0.0, regexpp@^3.1.0: version "3.2.0" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2" @@ -5797,7 +5980,7 @@ resolve-from@^5.0.0: resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== -resolve@^1.10.0, resolve@^1.10.1, resolve@^1.20.0: +resolve@^1.10.1, resolve@^1.20.0: version "1.20.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A== @@ -5805,7 +5988,7 @@ resolve@^1.10.0, resolve@^1.10.1, resolve@^1.20.0: is-core-module "^2.2.0" path-parse "^1.0.6" -resolve@^1.15.1: +resolve@^1.15.1, resolve@^1.22.1: version "1.22.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.1.tgz#27cb2ebb53f91abb49470a928bba7558066ac177" integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw== @@ -5877,6 +6060,15 @@ safe-identifier@^0.4.1: resolved "https://registry.yarnpkg.com/safe-identifier/-/safe-identifier-0.4.2.tgz#cf6bfca31c2897c588092d1750d30ef501d59fcb" integrity sha512-6pNbSMW6OhAi9j+N8V+U715yBQsaWJ7eyEUaOrawX+isg5ZxhUlV1NipNtgaKHmFGiABwt+ZF04Ii+3Xjkg+8w== +safe-regex-test@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/safe-regex-test/-/safe-regex-test-1.0.0.tgz#793b874d524eb3640d1873aad03596db2d4f2295" + integrity sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA== + dependencies: + call-bind "^1.0.2" + get-intrinsic "^1.1.3" + is-regex "^1.1.4" + "safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0": version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" @@ -5903,11 +6095,6 @@ semver-diff@^3.1.1: dependencies: semver "^6.3.0" -"semver@2 || 3 || 4 || 5", semver@^5.5.0, semver@^5.6.0, semver@^5.7.1: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== - semver@7.x, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5: version "7.3.5" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" @@ -5915,6 +6102,11 @@ semver@7.x, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5: dependencies: lru-cache "^6.0.0" +semver@^5.5.0, semver@^5.6.0, semver@^5.7.1: + version "5.7.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" + integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== + semver@^6.0.0, semver@^6.1.0, semver@^6.2.0, semver@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" @@ -6032,6 +6224,11 @@ slash@^3.0.0: resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== +slash@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-4.0.0.tgz#2422372176c4c6c5addb5e2ada885af984b396a7" + integrity sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew== + slice-ansi@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-4.0.0.tgz#500e8dd0fd55b05815086255b3195adf2a45fe6b" @@ -6076,32 +6273,6 @@ source-map@^0.7.3: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== -spdx-correct@^3.0.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" - integrity sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w== - dependencies: - spdx-expression-parse "^3.0.0" - spdx-license-ids "^3.0.0" - -spdx-exceptions@^2.1.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz#3f28ce1a77a00372683eade4a433183527a2163d" - integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A== - -spdx-expression-parse@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679" - integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== - dependencies: - spdx-exceptions "^2.1.0" - spdx-license-ids "^3.0.0" - -spdx-license-ids@^3.0.0: - version "3.0.10" - resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.10.tgz#0d9becccde7003d6c658d487dd48a32f0bf3014b" - integrity sha512-oie3/+gKf7QtpitB0LYLETe+k8SifzsX4KixvpOsbI6S0kRiRQ5MKOio8eMSAKQ17N06+wdEOXRiId+zOxo0hA== - sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" @@ -6163,6 +6334,15 @@ string.prototype.trimend@^1.0.4: call-bind "^1.0.2" define-properties "^1.1.3" +string.prototype.trimend@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.6.tgz#c4a27fa026d979d79c04f17397f250a462944533" + integrity sha512-JySq+4mrPf9EsDBEDYMOb/lM7XQLulwg5R/m1r0PXEFqrV0qHvl58sdTilSXtKOflCsK2E8jxf+GKC0T07RWwQ== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + string.prototype.trimstart@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz#b36399af4ab2999b4c9c648bd7a3fb2bb26feeed" @@ -6171,6 +6351,15 @@ string.prototype.trimstart@^1.0.4: call-bind "^1.0.2" define-properties "^1.1.3" +string.prototype.trimstart@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.6.tgz#e90ab66aa8e4007d92ef591bbf3cd422c56bdcf4" + integrity sha512-omqjMDaY92pbn5HOX7f9IccLA+U1tA9GvtU4JrodiXFfYB7jPzzHpRzpglLAjtUV6bB557zwClJezTqnAiYnQA== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" @@ -6263,6 +6452,14 @@ symbol-tree@^3.2.4: resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== +synckit@^0.8.4: + version "0.8.5" + resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.8.5.tgz#b7f4358f9bb559437f9f167eb6bc46b3c9818fa3" + integrity sha512-L1dapNV6vu2s/4Sputv8xGsCdAVlb5nRDMFU/E27D44l5U6cw1g0dGd45uLc+OXjNMmF4ntiMdCimzcjFKQI8Q== + dependencies: + "@pkgr/utils" "^2.3.1" + tslib "^2.5.0" + table@^6.0.9: version "6.7.2" resolved "https://registry.yarnpkg.com/table/-/table-6.7.2.tgz#a8d39b9f5966693ca8b0feba270a78722cbaf3b0" @@ -6275,6 +6472,11 @@ table@^6.0.9: string-width "^4.2.3" strip-ansi "^6.0.1" +tapable@^2.2.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0" + integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ== + terminal-link@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/terminal-link/-/terminal-link-2.1.1.tgz#14a64a27ab3c0df933ea546fba55f2d078edc994" @@ -6302,6 +6504,14 @@ throat@^6.0.1: resolved "https://registry.yarnpkg.com/throat/-/throat-6.0.1.tgz#d514fedad95740c12c2d7fc70ea863eb51ade375" integrity sha512-8hmiGIJMDlwjg7dlJ4yKGLK8EsYqKgPWbG3b4wjJddKNwc7N7Dpn08Df4szr/sZdMVeOstrdYSsqzX6BYbcB+w== +tiny-glob@^0.2.9: + version "0.2.9" + resolved "https://registry.yarnpkg.com/tiny-glob/-/tiny-glob-0.2.9.tgz#2212d441ac17928033b110f8b3640683129d31e2" + integrity sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg== + dependencies: + globalyzer "0.1.0" + globrex "^0.1.2" + titleize@2: version "2.1.0" resolved "https://registry.yarnpkg.com/titleize/-/titleize-2.1.0.tgz#5530de07c22147a0488887172b5bd94f5b30a48f" @@ -6411,16 +6621,6 @@ ts-node@^10.0.0: make-error "^1.1.1" yn "3.1.1" -tsconfig-paths@^3.11.0: - version "3.11.0" - resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.11.0.tgz#954c1fe973da6339c78e06b03ce2e48810b65f36" - integrity sha512-7ecdYDnIdmv639mmDwslG6KQg1Z9STTz1j7Gcz0xa+nshh/gKDAHcPxRbWOsA3SPp0tXP2leTcY9Kw+NAkfZzA== - dependencies: - "@types/json5" "^0.0.29" - json5 "^1.0.1" - minimist "^1.2.0" - strip-bom "^3.0.0" - tsconfig-paths@^3.14.0: version "3.14.0" resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.0.tgz#4fcc48f9ccea8826c41b9ca093479de7f5018976" @@ -6431,6 +6631,16 @@ tsconfig-paths@^3.14.0: minimist "^1.2.0" strip-bom "^3.0.0" +tsconfig-paths@^3.14.1: + version "3.14.2" + resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz#6e32f1f79412decd261f92d633a9dc1cfa99f088" + integrity sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g== + dependencies: + "@types/json5" "^0.0.29" + json5 "^1.0.2" + minimist "^1.2.6" + strip-bom "^3.0.0" + tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.3: version "1.14.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" @@ -6446,6 +6656,11 @@ tslib@^2.2.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== +tslib@^2.4.0, tslib@^2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf" + integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg== + tsutils@^3.21.0: version "3.21.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" @@ -6509,6 +6724,15 @@ type-is@^1.6.16, type-is@~1.6.17, type-is@~1.6.18: media-typer "0.3.0" mime-types "~2.1.24" +typed-array-length@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/typed-array-length/-/typed-array-length-1.0.4.tgz#89d83785e5c4098bec72e08b319651f0eac9c1bb" + integrity sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng== + dependencies: + call-bind "^1.0.2" + for-each "^0.3.3" + is-typed-array "^1.1.9" + typedarray-to-buffer@^3.1.5: version "3.1.5" resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080" @@ -6536,6 +6760,16 @@ unbox-primitive@^1.0.1: has-symbols "^1.0.2" which-boxed-primitive "^1.0.2" +unbox-primitive@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.2.tgz#29032021057d5e6cdbd08c5129c226dff8ed6f9e" + integrity sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw== + dependencies: + call-bind "^1.0.2" + has-bigints "^1.0.2" + has-symbols "^1.0.3" + which-boxed-primitive "^1.0.2" + undefsafe@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.3.tgz#6b166e7094ad46313b2202da7ecc2cd7cc6e7aae" @@ -6654,14 +6888,6 @@ valid-data-url@^3.0.0: resolved "https://registry.yarnpkg.com/valid-data-url/-/valid-data-url-3.0.1.tgz#826c1744e71b5632e847dd15dbd45b9fb38aa34f" integrity sha512-jOWVmzVceKlVVdwjNSenT4PbGghU0SBIizAev8ofZVgivk/TVHXSbNL8LP6M3spZvkR9/QolkyJavGSX5Cs0UA== -validate-npm-package-license@^3.0.1: - version "3.0.4" - resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" - integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== - dependencies: - spdx-correct "^3.0.0" - spdx-expression-parse "^3.0.0" - validator@^13.5.2: version "13.6.0" resolved "https://registry.yarnpkg.com/validator/-/validator-13.6.0.tgz#1e71899c14cdc7b2068463cb24c1cc16f6ec7059" @@ -6765,6 +6991,18 @@ which-boxed-primitive@^1.0.2: is-string "^1.0.5" is-symbol "^1.0.3" +which-typed-array@^1.1.9: + version "1.1.9" + resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.9.tgz#307cf898025848cf995e795e8423c7f337efbde6" + integrity sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA== + dependencies: + available-typed-arrays "^1.0.5" + call-bind "^1.0.2" + for-each "^0.3.3" + gopd "^1.0.1" + has-tostringtag "^1.0.0" + is-typed-array "^1.1.10" + which@^1.2.9: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" From 721ccecd129c58e183f83d1bd4232764128192dd Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 10 Mar 2023 15:07:04 +0100 Subject: [PATCH 38/91] fixes --- backend/src/auth/JWT.ts | 6 +++--- backend/src/config/index.ts | 2 +- backend/src/emails/sendEmailVariants.test.ts | 2 +- backend/src/emails/sendEmailVariants.ts | 2 +- backend/src/event/Event.ts | 2 +- backend/src/graphql/arg/AdminCreateContributionArgs.ts | 2 +- backend/src/graphql/arg/AdminUpdateContributionArgs.ts | 2 +- backend/src/graphql/arg/ContributionArgs.ts | 2 +- backend/src/graphql/arg/ContributionLinkArgs.ts | 2 +- backend/src/graphql/arg/TransactionLinkArgs.ts | 2 +- backend/src/graphql/arg/TransactionSendArgs.ts | 2 +- backend/src/graphql/model/AdminUpdateContribution.ts | 2 +- backend/src/graphql/model/Balance.ts | 2 +- backend/src/graphql/model/CommunityStatistics.ts | 2 +- backend/src/graphql/model/Contribution.ts | 2 +- backend/src/graphql/model/ContributionLink.ts | 2 +- backend/src/graphql/model/Decay.ts | 2 +- backend/src/graphql/model/OpenCreation.ts | 2 +- backend/src/graphql/model/Transaction.ts | 2 +- backend/src/graphql/model/TransactionLink.ts | 2 +- backend/src/graphql/model/UnconfirmedContribution.ts | 2 +- backend/src/graphql/model/UserAdmin.ts | 2 +- backend/src/graphql/resolver/BalanceResolver.ts | 2 +- .../graphql/resolver/ContributionLinkResolver.test.ts | 2 +- .../src/graphql/resolver/ContributionLinkResolver.ts | 2 +- .../src/graphql/resolver/ContributionResolver.test.ts | 2 +- backend/src/graphql/resolver/ContributionResolver.ts | 2 +- backend/src/graphql/resolver/StatisticsResolver.ts | 2 +- .../graphql/resolver/TransactionLinkResolver.test.ts | 2 +- .../src/graphql/resolver/TransactionLinkResolver.ts | 2 +- .../src/graphql/resolver/TransactionResolver.test.ts | 2 +- backend/src/graphql/resolver/TransactionResolver.ts | 2 +- backend/src/graphql/resolver/const/const.ts | 2 +- backend/src/graphql/resolver/semaphore.test.ts | 2 +- backend/src/graphql/resolver/util/creations.ts | 2 +- backend/src/graphql/scalar/Decimal.ts | 2 +- backend/src/graphql/schema.ts | 2 +- backend/src/seeds/graphql/mutations.ts | 2 +- backend/src/seeds/graphql/queries.ts | 2 +- backend/src/server/context.ts | 2 +- backend/src/server/createServer.ts | 6 +++--- backend/src/server/logger.ts | 10 +++++----- backend/src/typeorm/repository/TransactionLink.ts | 2 +- backend/src/util/decay.test.ts | 2 +- backend/src/util/decay.ts | 2 +- backend/src/util/utilities.ts | 2 +- backend/src/util/validate.ts | 2 +- backend/src/util/virtualTransactions.ts | 2 +- backend/test/extensions.ts | 2 +- 49 files changed, 57 insertions(+), 57 deletions(-) diff --git a/backend/src/auth/JWT.ts b/backend/src/auth/JWT.ts index 3f9c052f5..a58c2411f 100644 --- a/backend/src/auth/JWT.ts +++ b/backend/src/auth/JWT.ts @@ -1,4 +1,4 @@ -import jwt from 'jsonwebtoken' +import { verify, sign } from 'jsonwebtoken' import CONFIG from '@/config/' import { CustomJwtPayload } from './CustomJwtPayload' import LogError from '@/server/LogError' @@ -6,14 +6,14 @@ import LogError from '@/server/LogError' export const decode = (token: string): CustomJwtPayload | null => { if (!token) throw new LogError('401 Unauthorized') try { - return jwt.verify(token, CONFIG.JWT_SECRET) + return verify(token, CONFIG.JWT_SECRET) } catch (err) { return null } } export const encode = (gradidoID: string): string => { - const token = jwt.sign({ gradidoID }, CONFIG.JWT_SECRET, { + const token = sign({ gradidoID }, CONFIG.JWT_SECRET, { expiresIn: CONFIG.JWT_EXPIRES_IN, }) return token diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 27b51b47d..13f2a7663 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -1,7 +1,7 @@ // ATTENTION: DO NOT PUT ANY SECRETS IN HERE (or the .env) import dotenv from 'dotenv' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' dotenv.config() Decimal.set({ diff --git a/backend/src/emails/sendEmailVariants.test.ts b/backend/src/emails/sendEmailVariants.test.ts index 21c10bdad..24e5b0ebd 100644 --- a/backend/src/emails/sendEmailVariants.test.ts +++ b/backend/src/emails/sendEmailVariants.test.ts @@ -3,7 +3,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { testEnvironment } from '@test/helpers' import { logger, i18n as localization } from '@test/testSetup' import CONFIG from '@/config' diff --git a/backend/src/emails/sendEmailVariants.ts b/backend/src/emails/sendEmailVariants.ts index 4e3881829..c2a2dc366 100644 --- a/backend/src/emails/sendEmailVariants.ts +++ b/backend/src/emails/sendEmailVariants.ts @@ -1,4 +1,4 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import CONFIG from '@/config' import { decimalSeparatorByLanguage } from '@/util/utilities' import { sendEmailTranslated } from './sendEmailTranslated' diff --git a/backend/src/event/Event.ts b/backend/src/event/Event.ts index 8e65d85f2..f771bdee3 100644 --- a/backend/src/event/Event.ts +++ b/backend/src/event/Event.ts @@ -1,5 +1,5 @@ import { EventProtocol as DbEvent } from '@entity/EventProtocol' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { EventProtocolType } from './EventProtocolType' export const Event = ( diff --git a/backend/src/graphql/arg/AdminCreateContributionArgs.ts b/backend/src/graphql/arg/AdminCreateContributionArgs.ts index b09edea32..6259e672e 100644 --- a/backend/src/graphql/arg/AdminCreateContributionArgs.ts +++ b/backend/src/graphql/arg/AdminCreateContributionArgs.ts @@ -1,5 +1,5 @@ import { ArgsType, Field, InputType } from 'type-graphql' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' @InputType() @ArgsType() diff --git a/backend/src/graphql/arg/AdminUpdateContributionArgs.ts b/backend/src/graphql/arg/AdminUpdateContributionArgs.ts index 392365b38..3b10acf1a 100644 --- a/backend/src/graphql/arg/AdminUpdateContributionArgs.ts +++ b/backend/src/graphql/arg/AdminUpdateContributionArgs.ts @@ -1,5 +1,5 @@ import { ArgsType, Field, Int } from 'type-graphql' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' @ArgsType() export default class AdminUpdateContributionArgs { diff --git a/backend/src/graphql/arg/ContributionArgs.ts b/backend/src/graphql/arg/ContributionArgs.ts index 2fa1c5ced..dc4285e4d 100644 --- a/backend/src/graphql/arg/ContributionArgs.ts +++ b/backend/src/graphql/arg/ContributionArgs.ts @@ -1,5 +1,5 @@ import { ArgsType, Field, InputType } from 'type-graphql' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' @InputType() @ArgsType() diff --git a/backend/src/graphql/arg/ContributionLinkArgs.ts b/backend/src/graphql/arg/ContributionLinkArgs.ts index cf0465501..fac1eacc1 100644 --- a/backend/src/graphql/arg/ContributionLinkArgs.ts +++ b/backend/src/graphql/arg/ContributionLinkArgs.ts @@ -1,5 +1,5 @@ import { ArgsType, Field, Int } from 'type-graphql' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' @ArgsType() export default class ContributionLinkArgs { diff --git a/backend/src/graphql/arg/TransactionLinkArgs.ts b/backend/src/graphql/arg/TransactionLinkArgs.ts index 553efcfbe..6c1c4654a 100644 --- a/backend/src/graphql/arg/TransactionLinkArgs.ts +++ b/backend/src/graphql/arg/TransactionLinkArgs.ts @@ -1,5 +1,5 @@ import { ArgsType, Field } from 'type-graphql' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' @ArgsType() export default class TransactionLinkArgs { diff --git a/backend/src/graphql/arg/TransactionSendArgs.ts b/backend/src/graphql/arg/TransactionSendArgs.ts index e75921383..c0faff850 100644 --- a/backend/src/graphql/arg/TransactionSendArgs.ts +++ b/backend/src/graphql/arg/TransactionSendArgs.ts @@ -1,5 +1,5 @@ import { ArgsType, Field } from 'type-graphql' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' @ArgsType() export default class TransactionSendArgs { diff --git a/backend/src/graphql/model/AdminUpdateContribution.ts b/backend/src/graphql/model/AdminUpdateContribution.ts index e824975a4..d5cd4fc7f 100644 --- a/backend/src/graphql/model/AdminUpdateContribution.ts +++ b/backend/src/graphql/model/AdminUpdateContribution.ts @@ -1,5 +1,5 @@ import { ObjectType, Field } from 'type-graphql' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' @ObjectType() export class AdminUpdateContribution { diff --git a/backend/src/graphql/model/Balance.ts b/backend/src/graphql/model/Balance.ts index 9b54f6987..d68237db9 100644 --- a/backend/src/graphql/model/Balance.ts +++ b/backend/src/graphql/model/Balance.ts @@ -1,5 +1,5 @@ import { ObjectType, Field, Int, Float } from 'type-graphql' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' @ObjectType() export class Balance { diff --git a/backend/src/graphql/model/CommunityStatistics.ts b/backend/src/graphql/model/CommunityStatistics.ts index 4864b630d..1fb1ded46 100644 --- a/backend/src/graphql/model/CommunityStatistics.ts +++ b/backend/src/graphql/model/CommunityStatistics.ts @@ -1,5 +1,5 @@ import { ObjectType, Field, Int } from 'type-graphql' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' @ObjectType() export class DynamicStatisticsFields { diff --git a/backend/src/graphql/model/Contribution.ts b/backend/src/graphql/model/Contribution.ts index a683534af..a83adef4b 100644 --- a/backend/src/graphql/model/Contribution.ts +++ b/backend/src/graphql/model/Contribution.ts @@ -1,5 +1,5 @@ import { ObjectType, Field, Int } from 'type-graphql' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { Contribution as dbContribution } from '@entity/Contribution' import { User } from '@entity/User' diff --git a/backend/src/graphql/model/ContributionLink.ts b/backend/src/graphql/model/ContributionLink.ts index 7a06f8dff..13ae31692 100644 --- a/backend/src/graphql/model/ContributionLink.ts +++ b/backend/src/graphql/model/ContributionLink.ts @@ -1,5 +1,5 @@ import { ObjectType, Field, Int } from 'type-graphql' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { ContributionLink as dbContributionLink } from '@entity/ContributionLink' import CONFIG from '@/config' diff --git a/backend/src/graphql/model/Decay.ts b/backend/src/graphql/model/Decay.ts index f59a21249..3e8412dfa 100644 --- a/backend/src/graphql/model/Decay.ts +++ b/backend/src/graphql/model/Decay.ts @@ -1,5 +1,5 @@ import { ObjectType, Field, Int } from 'type-graphql' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' interface DecayInterface { balance: Decimal diff --git a/backend/src/graphql/model/OpenCreation.ts b/backend/src/graphql/model/OpenCreation.ts index 9ef08fd4a..ed9ef731e 100644 --- a/backend/src/graphql/model/OpenCreation.ts +++ b/backend/src/graphql/model/OpenCreation.ts @@ -1,5 +1,5 @@ import { ObjectType, Field, Int } from 'type-graphql' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' @ObjectType() export class OpenCreation { diff --git a/backend/src/graphql/model/Transaction.ts b/backend/src/graphql/model/Transaction.ts index 96b80f9a0..d24c28f2f 100644 --- a/backend/src/graphql/model/Transaction.ts +++ b/backend/src/graphql/model/Transaction.ts @@ -1,7 +1,7 @@ import { ObjectType, Field, Int } from 'type-graphql' import { Decay } from './Decay' import { Transaction as dbTransaction } from '@entity/Transaction' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { TransactionTypeId } from '@enum/TransactionTypeId' import { User } from './User' diff --git a/backend/src/graphql/model/TransactionLink.ts b/backend/src/graphql/model/TransactionLink.ts index b0a8ab184..ddd22f36f 100644 --- a/backend/src/graphql/model/TransactionLink.ts +++ b/backend/src/graphql/model/TransactionLink.ts @@ -1,5 +1,5 @@ import { ObjectType, Field, Int } from 'type-graphql' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' import { User } from './User' import CONFIG from '@/config' diff --git a/backend/src/graphql/model/UnconfirmedContribution.ts b/backend/src/graphql/model/UnconfirmedContribution.ts index 75112ecf5..439f70a16 100644 --- a/backend/src/graphql/model/UnconfirmedContribution.ts +++ b/backend/src/graphql/model/UnconfirmedContribution.ts @@ -1,5 +1,5 @@ import { ObjectType, Field, Int } from 'type-graphql' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { Contribution } from '@entity/Contribution' import { User } from '@entity/User' diff --git a/backend/src/graphql/model/UserAdmin.ts b/backend/src/graphql/model/UserAdmin.ts index e7330471b..84512d812 100644 --- a/backend/src/graphql/model/UserAdmin.ts +++ b/backend/src/graphql/model/UserAdmin.ts @@ -1,5 +1,5 @@ import { ObjectType, Field, Int } from 'type-graphql' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { User } from '@entity/User' @ObjectType() diff --git a/backend/src/graphql/resolver/BalanceResolver.ts b/backend/src/graphql/resolver/BalanceResolver.ts index 18aed5ae6..3a090e551 100644 --- a/backend/src/graphql/resolver/BalanceResolver.ts +++ b/backend/src/graphql/resolver/BalanceResolver.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { Resolver, Query, Ctx, Authorized } from 'type-graphql' import { getCustomRepository } from '@dbTools/typeorm' diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts index 606bce109..aae42c44b 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts @@ -4,7 +4,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-explicit-any */ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { logger } from '@test/testSetup' import { GraphQLError } from 'graphql' import { diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.ts b/backend/src/graphql/resolver/ContributionLinkResolver.ts index cccf47399..f7a47ab01 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.ts @@ -1,4 +1,4 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { Resolver, Args, Arg, Authorized, Mutation, Query, Int } from 'type-graphql' import { MoreThan, IsNull } from '@dbTools/typeorm' diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index a15c64e85..c478902e6 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -6,7 +6,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { stephenHawking } from '@/seeds/users/stephen-hawking' diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index a91b53300..6c895b339 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql' import { IsNull, getConnection } from '@dbTools/typeorm' diff --git a/backend/src/graphql/resolver/StatisticsResolver.ts b/backend/src/graphql/resolver/StatisticsResolver.ts index 38d0000cb..d5ae9503c 100644 --- a/backend/src/graphql/resolver/StatisticsResolver.ts +++ b/backend/src/graphql/resolver/StatisticsResolver.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-return */ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { Resolver, Query, Authorized, FieldResolver } from 'type-graphql' import { getConnection } from '@dbTools/typeorm' diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index 35d3f42f6..b3e4df80d 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -27,7 +27,7 @@ import { listTransactionLinksAdmin } from '@/seeds/graphql/queries' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { User } from '@entity/User' import { UnconfirmedContribution } from '@model/UnconfirmedContribution' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { GraphQLError } from 'graphql' import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' import { logger } from '@test/testSetup' diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.ts b/backend/src/graphql/resolver/TransactionLinkResolver.ts index d6e8e09ae..293f7c6f2 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.ts @@ -1,5 +1,5 @@ import { randomBytes } from 'crypto' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { getConnection } from '@dbTools/typeorm' diff --git a/backend/src/graphql/resolver/TransactionResolver.test.ts b/backend/src/graphql/resolver/TransactionResolver.test.ts index c660a72da..31fc41ed1 100644 --- a/backend/src/graphql/resolver/TransactionResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionResolver.test.ts @@ -5,7 +5,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { EventProtocolType } from '@/event/EventProtocolType' import { userFactory } from '@/seeds/factory/user' import { diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index a11c5b377..83d663f93 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -2,7 +2,7 @@ /* eslint-disable new-cap */ /* eslint-disable @typescript-eslint/no-non-null-assertion */ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { Resolver, Query, Args, Authorized, Ctx, Mutation } from 'type-graphql' import { getCustomRepository, getConnection, In } from '@dbTools/typeorm' diff --git a/backend/src/graphql/resolver/const/const.ts b/backend/src/graphql/resolver/const/const.ts index e4eb9a13b..b97694221 100644 --- a/backend/src/graphql/resolver/const/const.ts +++ b/backend/src/graphql/resolver/const/const.ts @@ -1,4 +1,4 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' export const MAX_CREATION_AMOUNT = new Decimal(1000) export const FULL_CREATION_AVAILABLE = [ diff --git a/backend/src/graphql/resolver/semaphore.test.ts b/backend/src/graphql/resolver/semaphore.test.ts index 1ce133fba..a770638fb 100644 --- a/backend/src/graphql/resolver/semaphore.test.ts +++ b/backend/src/graphql/resolver/semaphore.test.ts @@ -4,7 +4,7 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ /* eslint-disable @typescript-eslint/no-explicit-any */ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { userFactory } from '@/seeds/factory/user' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { bobBaumeister } from '@/seeds/users/bob-baumeister' diff --git a/backend/src/graphql/resolver/util/creations.ts b/backend/src/graphql/resolver/util/creations.ts index 33b48a3a3..e7a3cc965 100644 --- a/backend/src/graphql/resolver/util/creations.ts +++ b/backend/src/graphql/resolver/util/creations.ts @@ -4,7 +4,7 @@ import LogError from '@/server/LogError' import { backendLogger as logger } from '@/server/logger' import { getConnection } from '@dbTools/typeorm' import { Contribution } from '@entity/Contribution' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { FULL_CREATION_AVAILABLE, MAX_CREATION_AMOUNT } from '../const/const' interface CreationMap { diff --git a/backend/src/graphql/scalar/Decimal.ts b/backend/src/graphql/scalar/Decimal.ts index da5a99e0c..0f259343c 100644 --- a/backend/src/graphql/scalar/Decimal.ts +++ b/backend/src/graphql/scalar/Decimal.ts @@ -1,5 +1,5 @@ import { GraphQLScalarType, Kind } from 'graphql' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' export default new GraphQLScalarType({ name: 'Decimal', diff --git a/backend/src/graphql/schema.ts b/backend/src/graphql/schema.ts index f14f45efa..3f12a5d8c 100644 --- a/backend/src/graphql/schema.ts +++ b/backend/src/graphql/schema.ts @@ -4,7 +4,7 @@ import path from 'path' import isAuthorized from './directive/isAuthorized' import DecimalScalar from './scalar/Decimal' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' const schema = async (): Promise => { return buildSchema({ diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index 69d6d16d8..0851c0adc 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -1,4 +1,4 @@ -import gql from 'graphql-tag' +import { gql } from 'graphql-tag' export const subscribeNewsletter = gql` mutation ($email: String!, $language: String!) { diff --git a/backend/src/seeds/graphql/queries.ts b/backend/src/seeds/graphql/queries.ts index 299a0103d..49d9e7cbf 100644 --- a/backend/src/seeds/graphql/queries.ts +++ b/backend/src/seeds/graphql/queries.ts @@ -1,4 +1,4 @@ -import gql from 'graphql-tag' +import { gql } from 'graphql-tag' export const verifyLogin = gql` query { diff --git a/backend/src/server/context.ts b/backend/src/server/context.ts index 32a765777..5727e2707 100644 --- a/backend/src/server/context.ts +++ b/backend/src/server/context.ts @@ -1,7 +1,7 @@ import { Role } from '@/auth/Role' import { User as dbUser } from '@entity/User' import { Transaction as dbTransaction } from '@entity/Transaction' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { ExpressContext } from 'apollo-server-express' import LogError from './LogError' diff --git a/backend/src/server/createServer.ts b/backend/src/server/createServer.ts index 0c5009b6f..5b3be4998 100644 --- a/backend/src/server/createServer.ts +++ b/backend/src/server/createServer.ts @@ -4,7 +4,7 @@ import 'reflect-metadata' import { ApolloServer } from 'apollo-server-express' -import express, { Express } from 'express' +import express, { Express, json, urlencoded } from 'express' // database import connection from '@/typeorm/connection' @@ -66,9 +66,9 @@ const createServer = async ( app.use(cors) // bodyparser json - app.use(express.json()) + app.use(json()) // bodyparser urlencoded for elopage - app.use(express.urlencoded({ extended: true })) + app.use(urlencoded({ extended: true })) // i18n app.use(localization.init) diff --git a/backend/src/server/logger.ts b/backend/src/server/logger.ts index 5cfa94285..e72e425a2 100644 --- a/backend/src/server/logger.ts +++ b/backend/src/server/logger.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ -import log4js from 'log4js' +import { configure, getLogger } from 'log4js' import CONFIG from '@/config' import { readFileSync } from 'fs' @@ -10,11 +10,11 @@ const options = JSON.parse(readFileSync(CONFIG.LOG4JS_CONFIG, 'utf-8')) options.categories.backend.level = CONFIG.LOG_LEVEL options.categories.apollo.level = CONFIG.LOG_LEVEL -log4js.configure(options) +configure(options) -const apolloLogger = log4js.getLogger('apollo') -const backendLogger = log4js.getLogger('backend') -const klickTippLogger = log4js.getLogger('klicktipp') +const apolloLogger = getLogger('apollo') +const backendLogger = getLogger('backend') +const klickTippLogger = getLogger('klicktipp') backendLogger.addContext('user', 'unknown') diff --git a/backend/src/typeorm/repository/TransactionLink.ts b/backend/src/typeorm/repository/TransactionLink.ts index 7df1fd465..d2458b386 100644 --- a/backend/src/typeorm/repository/TransactionLink.ts +++ b/backend/src/typeorm/repository/TransactionLink.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { Repository, EntityRepository } from '@dbTools/typeorm' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' @EntityRepository(dbTransactionLink) export class TransactionLinkRepository extends Repository { diff --git a/backend/src/util/decay.test.ts b/backend/src/util/decay.test.ts index 0e7b02f56..d07ee6569 100644 --- a/backend/src/util/decay.test.ts +++ b/backend/src/util/decay.test.ts @@ -1,4 +1,4 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import 'reflect-metadata' // This might be wise to load in a test setup file import { decayFormula, calculateDecay } from './decay' diff --git a/backend/src/util/decay.ts b/backend/src/util/decay.ts index 641654756..d35eb83a4 100644 --- a/backend/src/util/decay.ts +++ b/backend/src/util/decay.ts @@ -1,4 +1,4 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import CONFIG from '@/config' import { Decay } from '@model/Decay' import LogError from '@/server/LogError' diff --git a/backend/src/util/utilities.ts b/backend/src/util/utilities.ts index fa8e82d9e..2cf53f1e4 100644 --- a/backend/src/util/utilities.ts +++ b/backend/src/util/utilities.ts @@ -1,4 +1,4 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import i18n from 'i18n' export const objectValuesToArray = (obj: { [x: string]: string }): Array => { diff --git a/backend/src/util/validate.ts b/backend/src/util/validate.ts index 482e9eb50..ff4b17841 100644 --- a/backend/src/util/validate.ts +++ b/backend/src/util/validate.ts @@ -1,5 +1,5 @@ import { calculateDecay } from './decay' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { Decay } from '@model/Decay' import { getCustomRepository } from '@dbTools/typeorm' import { TransactionLinkRepository } from '@repository/TransactionLink' diff --git a/backend/src/util/virtualTransactions.ts b/backend/src/util/virtualTransactions.ts index b02f87ee5..2ee899009 100644 --- a/backend/src/util/virtualTransactions.ts +++ b/backend/src/util/virtualTransactions.ts @@ -5,7 +5,7 @@ import { Transaction as dbTransaction } from '@entity/Transaction' import { TransactionTypeId } from '@enum/TransactionTypeId' import { calculateDecay } from './decay' import { User } from '@model/User' -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' const defaultModelFunctions = { hasId: function (): boolean { diff --git a/backend/test/extensions.ts b/backend/test/extensions.ts index 26fb11510..359597f4a 100644 --- a/backend/test/extensions.ts +++ b/backend/test/extensions.ts @@ -3,7 +3,7 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ /* eslint-disable @typescript-eslint/no-empty-interface */ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' expect.extend({ decimalEqual(received, value) { From 73d8f6163dade24b6bee010e9261a35b3b4dd09b Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 10 Mar 2023 15:47:05 +0100 Subject: [PATCH 39/91] more lint rules eslint-import-plugin --- backend/.eslintrc.js | 4 ++++ backend/jest.config.js | 1 + backend/src/graphql/resolver/UserResolver.ts | 4 ++-- backend/src/password/EncryptorUtils.ts | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index bb03a23fa..d816c4a42 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line import/no-commonjs module.exports = { root: true, env: { @@ -37,6 +38,9 @@ module.exports = { 'import/no-deprecated': 'error', 'import/no-empty-named-blocks': 'error', 'import/no-mutable-exports': 'error', + 'import/no-unused-modules': 'error', + 'import/no-commonjs': 'error', + 'import/no-import-module-exports': 'error', }, overrides: [ // only for ts files diff --git a/backend/jest.config.js b/backend/jest.config.js index d6683d292..f76e0e5a9 100644 --- a/backend/jest.config.js +++ b/backend/jest.config.js @@ -1,4 +1,5 @@ /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +// eslint-disable-next-line import/no-commonjs module.exports = { verbose: true, preset: 'ts-jest', diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 078a29a8e..8f9852d9a 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -69,9 +69,9 @@ import { PasswordEncryptionType } from '../enum/PasswordEncryptionType' import LogError from '@/server/LogError' import { EventProtocolType } from '@/event/EventProtocolType' -// eslint-disable-next-line @typescript-eslint/no-var-requires +// eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs const sodium = require('sodium-native') -// eslint-disable-next-line @typescript-eslint/no-var-requires +// eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs const random = require('random-bigint') const LANGUAGES = ['de', 'en', 'es', 'fr', 'nl'] diff --git a/backend/src/password/EncryptorUtils.ts b/backend/src/password/EncryptorUtils.ts index 4c802a86f..4f6238674 100644 --- a/backend/src/password/EncryptorUtils.ts +++ b/backend/src/password/EncryptorUtils.ts @@ -7,7 +7,7 @@ import { backendLogger as logger } from '@/server/logger' import { User } from '@entity/User' import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' -// eslint-disable-next-line @typescript-eslint/no-var-requires +// eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs const sodium = require('sodium-native') // We will reuse this for changePassword From 1af19b55faec7121cf20b67ff7afab2abd25452d Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 10 Mar 2023 16:05:20 +0100 Subject: [PATCH 40/91] more lint rules --- backend/.eslintrc.js | 20 +++++++++++++++++++- backend/jest.config.js | 2 +- backend/src/config/index.ts | 1 + backend/src/graphql/union/QueryLinkResult.ts | 1 + 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index d816c4a42..bad33e974 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -1,4 +1,4 @@ -// eslint-disable-next-line import/no-commonjs +// eslint-disable-next-line import/no-commonjs, import/unambiguous module.exports = { root: true, env: { @@ -39,8 +39,26 @@ module.exports = { 'import/no-empty-named-blocks': 'error', 'import/no-mutable-exports': 'error', 'import/no-unused-modules': 'error', + 'import/no-amd': 'error', 'import/no-commonjs': 'error', 'import/no-import-module-exports': 'error', + 'import/no-nodejs-modules': 'off', + 'import/unambiguous': 'error', + 'import/no-absolute-path': 'error', + 'import/no-cycle': 'error', + 'import/no-dynamic-require': 'error', + 'import/no-internal-modules': 'off', + 'import/no-relative-packages': 'error', + 'import/no-relative-parent-imports': 'off', + 'import/no-self-import': 'error', + 'import/no-useless-path-segments': 'error', + 'import/no-webpack-loader-syntax': 'error', + 'import/consistent-type-specifier-style': 'error', + 'import/exports-last': 'off', + 'import/extensions': 'error', + 'import/first': 'error', + 'import/group-exports': 'off', + 'import/newline-after-import': 'error', }, overrides: [ // only for ts files diff --git a/backend/jest.config.js b/backend/jest.config.js index f76e0e5a9..a6ae81d5f 100644 --- a/backend/jest.config.js +++ b/backend/jest.config.js @@ -1,5 +1,5 @@ /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ -// eslint-disable-next-line import/no-commonjs +// eslint-disable-next-line import/no-commonjs, import/unambiguous module.exports = { verbose: true, preset: 'ts-jest', diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 13f2a7663..d4e5f56a8 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -2,6 +2,7 @@ import dotenv from 'dotenv' import { Decimal } from 'decimal.js-light' + dotenv.config() Decimal.set({ diff --git a/backend/src/graphql/union/QueryLinkResult.ts b/backend/src/graphql/union/QueryLinkResult.ts index bcd0ad6b8..9a35fbc71 100644 --- a/backend/src/graphql/union/QueryLinkResult.ts +++ b/backend/src/graphql/union/QueryLinkResult.ts @@ -1,6 +1,7 @@ import { createUnionType } from 'type-graphql' import { TransactionLink } from '@model/TransactionLink' import { ContributionLink } from '@model/ContributionLink' + export default createUnionType({ name: 'QueryLinkResult', // the name of the GraphQL union types: () => [TransactionLink, ContributionLink] as const, // function that returns tuple of object types classes From c54e6fb8aeb3c01a69dbd7761a31273c0b3a511f Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 10 Mar 2023 16:21:58 +0100 Subject: [PATCH 41/91] new rules + fixes --- backend/.eslintrc.js | 7 +++++++ backend/src/auth/JWT.ts | 2 +- .../src/emails/sendEmailTranslated.test.ts | 2 +- backend/src/emails/sendEmailTranslated.ts | 4 ++-- backend/src/emails/sendEmailVariants.test.ts | 6 +++--- backend/src/emails/sendEmailVariants.ts | 2 +- .../federation/client/1_0/FederationClient.ts | 2 +- .../federation/client/1_1/FederationClient.ts | 2 +- .../federation/validateCommunities.test.ts | 4 ++-- backend/src/federation/validateCommunities.ts | 2 +- backend/src/graphql/directive/isAuthorized.ts | 2 +- backend/src/graphql/model/GdtEntryList.ts | 2 +- backend/src/graphql/model/Transaction.ts | 4 ++-- backend/src/graphql/model/User.ts | 2 +- .../src/graphql/resolver/BalanceResolver.ts | 5 ++--- .../resolver/ContributionLinkResolver.test.ts | 4 ++-- .../resolver/ContributionLinkResolver.ts | 4 ++-- .../ContributionMessageResolver.test.ts | 2 +- .../resolver/ContributionResolver.test.ts | 12 +++++------ .../graphql/resolver/ContributionResolver.ts | 21 +++++++++---------- .../graphql/resolver/EmailOptinCodes.test.ts | 4 ++-- .../resolver/TransactionLinkResolver.test.ts | 8 +++---- .../resolver/TransactionLinkResolver.ts | 11 +++++----- .../resolver/TransactionResolver.test.ts | 10 ++++----- .../graphql/resolver/TransactionResolver.ts | 10 ++++----- .../src/graphql/resolver/UserResolver.test.ts | 18 ++++++++-------- backend/src/graphql/resolver/UserResolver.ts | 6 +++--- .../graphql/resolver/util/creations.test.ts | 6 +++--- .../src/graphql/resolver/util/creations.ts | 4 ++-- .../resolver/util/findContributions.ts | 4 ++-- backend/src/graphql/schema.ts | 4 ++-- backend/src/password/EncryptorUtils.ts | 2 +- backend/src/seeds/creation/index.ts | 2 +- backend/src/seeds/factory/creation.ts | 4 ++-- backend/src/seeds/factory/transactionLink.ts | 2 +- backend/src/seeds/factory/user.ts | 4 ++-- backend/src/seeds/index.ts | 7 +++---- backend/src/server/LogError.test.ts | 3 +-- backend/src/server/context.ts | 2 +- backend/src/server/localization.ts | 2 +- backend/src/server/logger.ts | 3 +-- backend/src/typeorm/connection.ts | 2 +- backend/src/typeorm/repository/User.ts | 2 +- backend/src/util/communityUser.ts | 2 +- backend/src/util/validate.ts | 6 +++--- backend/src/util/virtualTransactions.ts | 8 +++---- backend/test/helpers.ts | 2 +- 47 files changed, 114 insertions(+), 115 deletions(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index bad33e974..95972cca7 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -59,6 +59,13 @@ module.exports = { 'import/first': 'error', 'import/group-exports': 'off', 'import/newline-after-import': 'error', + 'import/no-anonymous-default-export': 'error', + 'import/no-default-export': 'off', + 'import/no-named-default': 'error', + 'import/no-namespace': 'error', + 'import/no-unassigned-import': 'error', + 'import/order': 'error', + 'import/prefer-default-export': 'off', //TODO }, overrides: [ // only for ts files diff --git a/backend/src/auth/JWT.ts b/backend/src/auth/JWT.ts index a58c2411f..3da1f1d3e 100644 --- a/backend/src/auth/JWT.ts +++ b/backend/src/auth/JWT.ts @@ -1,6 +1,6 @@ import { verify, sign } from 'jsonwebtoken' -import CONFIG from '@/config/' import { CustomJwtPayload } from './CustomJwtPayload' +import CONFIG from '@/config/' import LogError from '@/server/LogError' export const decode = (token: string): CustomJwtPayload | null => { diff --git a/backend/src/emails/sendEmailTranslated.test.ts b/backend/src/emails/sendEmailTranslated.test.ts index 73edb79f3..762b88cf0 100644 --- a/backend/src/emails/sendEmailTranslated.test.ts +++ b/backend/src/emails/sendEmailTranslated.test.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/unbound-method */ import { createTransport } from 'nodemailer' +import { sendEmailTranslated } from './sendEmailTranslated' import { logger, i18n } from '@test/testSetup' import CONFIG from '@/config' -import { sendEmailTranslated } from './sendEmailTranslated' CONFIG.EMAIL = false CONFIG.EMAIL_SMTP_URL = 'EMAIL_SMTP_URL' diff --git a/backend/src/emails/sendEmailTranslated.ts b/backend/src/emails/sendEmailTranslated.ts index d8ecd3d38..d865bac8f 100644 --- a/backend/src/emails/sendEmailTranslated.ts +++ b/backend/src/emails/sendEmailTranslated.ts @@ -1,10 +1,10 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ -import CONFIG from '@/config' -import { backendLogger as logger } from '@/server/logger' import path from 'path' import { createTransport } from 'nodemailer' import Email from 'email-templates' import i18n from 'i18n' +import { backendLogger as logger } from '@/server/logger' +import CONFIG from '@/config' import LogError from '@/server/LogError' export const sendEmailTranslated = async (params: { diff --git a/backend/src/emails/sendEmailVariants.test.ts b/backend/src/emails/sendEmailVariants.test.ts index 24e5b0ebd..399ed89ac 100644 --- a/backend/src/emails/sendEmailVariants.test.ts +++ b/backend/src/emails/sendEmailVariants.test.ts @@ -4,9 +4,6 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { Decimal } from 'decimal.js-light' -import { testEnvironment } from '@test/helpers' -import { logger, i18n as localization } from '@test/testSetup' -import CONFIG from '@/config' import { sendAddedContributionMessageEmail, sendAccountActivationEmail, @@ -19,6 +16,9 @@ import { sendTransactionReceivedEmail, } from './sendEmailVariants' import { sendEmailTranslated } from './sendEmailTranslated' +import { testEnvironment } from '@test/helpers' +import { logger, i18n as localization } from '@test/testSetup' +import CONFIG from '@/config' let con: any let testEnv: any diff --git a/backend/src/emails/sendEmailVariants.ts b/backend/src/emails/sendEmailVariants.ts index c2a2dc366..2294ebdd5 100644 --- a/backend/src/emails/sendEmailVariants.ts +++ b/backend/src/emails/sendEmailVariants.ts @@ -1,7 +1,7 @@ import { Decimal } from 'decimal.js-light' +import { sendEmailTranslated } from './sendEmailTranslated' import CONFIG from '@/config' import { decimalSeparatorByLanguage } from '@/util/utilities' -import { sendEmailTranslated } from './sendEmailTranslated' export const sendAddedContributionMessageEmail = (data: { firstName: string diff --git a/backend/src/federation/client/1_0/FederationClient.ts b/backend/src/federation/client/1_0/FederationClient.ts index d4ed5960b..8c68158ff 100644 --- a/backend/src/federation/client/1_0/FederationClient.ts +++ b/backend/src/federation/client/1_0/FederationClient.ts @@ -2,9 +2,9 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { gql } from 'graphql-request' -import { backendLogger as logger } from '@/server/logger' import { Community as DbCommunity } from '@entity/Community' import { GraphQLGetClient } from '../GraphQLGetClient' +import { backendLogger as logger } from '@/server/logger' import LogError from '@/server/LogError' export async function requestGetPublicKey(dbCom: DbCommunity): Promise { diff --git a/backend/src/federation/client/1_1/FederationClient.ts b/backend/src/federation/client/1_1/FederationClient.ts index 122fcf5dc..3f7f7b3da 100644 --- a/backend/src/federation/client/1_1/FederationClient.ts +++ b/backend/src/federation/client/1_1/FederationClient.ts @@ -2,9 +2,9 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ import { gql } from 'graphql-request' -import { backendLogger as logger } from '@/server/logger' import { Community as DbCommunity } from '@entity/Community' import { GraphQLGetClient } from '../GraphQLGetClient' +import { backendLogger as logger } from '@/server/logger' import LogError from '@/server/LogError' export async function requestGetPublicKey(dbCom: DbCommunity): Promise { diff --git a/backend/src/federation/validateCommunities.test.ts b/backend/src/federation/validateCommunities.test.ts index 599564ea6..a99bb3274 100644 --- a/backend/src/federation/validateCommunities.test.ts +++ b/backend/src/federation/validateCommunities.test.ts @@ -5,10 +5,10 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { logger } from '@test/testSetup' import { Community as DbCommunity } from '@entity/Community' -import { testEnvironment, cleanDB } from '@test/helpers' import { validateCommunities } from './validateCommunities' +import { logger } from '@test/testSetup' +import { testEnvironment, cleanDB } from '@test/helpers' let con: any let testEnv: any diff --git a/backend/src/federation/validateCommunities.ts b/backend/src/federation/validateCommunities.ts index 157d83bb5..57e55b943 100644 --- a/backend/src/federation/validateCommunities.ts +++ b/backend/src/federation/validateCommunities.ts @@ -4,8 +4,8 @@ import { IsNull } from '@dbTools/typeorm' import { requestGetPublicKey as v1_0_requestGetPublicKey } from './client/1_0/FederationClient' // eslint-disable-next-line camelcase import { requestGetPublicKey as v1_1_requestGetPublicKey } from './client/1_1/FederationClient' -import { backendLogger as logger } from '@/server/logger' import { ApiVersionType } from './enum/apiVersionType' +import { backendLogger as logger } from '@/server/logger' import LogError from '@/server/LogError' export function startValidateCommunities(timerInterval: number): void { diff --git a/backend/src/graphql/directive/isAuthorized.ts b/backend/src/graphql/directive/isAuthorized.ts index 709f470d4..6cdac9b97 100644 --- a/backend/src/graphql/directive/isAuthorized.ts +++ b/backend/src/graphql/directive/isAuthorized.ts @@ -4,11 +4,11 @@ import { AuthChecker } from 'type-graphql' +import { User } from '@entity/User' import { decode, encode } from '@/auth/JWT' import { ROLE_UNAUTHORIZED, ROLE_USER, ROLE_ADMIN } from '@/auth/ROLES' import { RIGHTS } from '@/auth/RIGHTS' import { INALIENABLE_RIGHTS } from '@/auth/INALIENABLE_RIGHTS' -import { User } from '@entity/User' import LogError from '@/server/LogError' const isAuthorized: AuthChecker = async ({ context }, rights) => { diff --git a/backend/src/graphql/model/GdtEntryList.ts b/backend/src/graphql/model/GdtEntryList.ts index 7c4bffb5a..d992de54c 100644 --- a/backend/src/graphql/model/GdtEntryList.ts +++ b/backend/src/graphql/model/GdtEntryList.ts @@ -3,8 +3,8 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { GdtEntry } from './GdtEntry' import { ObjectType, Field, Int, Float } from 'type-graphql' +import { GdtEntry } from './GdtEntry' @ObjectType() export class GdtEntryList { diff --git a/backend/src/graphql/model/Transaction.ts b/backend/src/graphql/model/Transaction.ts index d24c28f2f..8f0d1eadc 100644 --- a/backend/src/graphql/model/Transaction.ts +++ b/backend/src/graphql/model/Transaction.ts @@ -1,9 +1,9 @@ import { ObjectType, Field, Int } from 'type-graphql' -import { Decay } from './Decay' import { Transaction as dbTransaction } from '@entity/Transaction' import { Decimal } from 'decimal.js-light' -import { TransactionTypeId } from '@enum/TransactionTypeId' +import { Decay } from './Decay' import { User } from './User' +import { TransactionTypeId } from '@enum/TransactionTypeId' @ObjectType() export class Transaction { diff --git a/backend/src/graphql/model/User.ts b/backend/src/graphql/model/User.ts index aeb764941..85c6de798 100644 --- a/backend/src/graphql/model/User.ts +++ b/backend/src/graphql/model/User.ts @@ -1,6 +1,6 @@ import { ObjectType, Field, Int } from 'type-graphql' -import { KlickTipp } from './KlickTipp' import { User as dbUser } from '@entity/User' +import { KlickTipp } from './KlickTipp' import { UserContact } from './UserContact' @ObjectType() diff --git a/backend/src/graphql/resolver/BalanceResolver.ts b/backend/src/graphql/resolver/BalanceResolver.ts index 3a090e551..7600f12b9 100644 --- a/backend/src/graphql/resolver/BalanceResolver.ts +++ b/backend/src/graphql/resolver/BalanceResolver.ts @@ -6,6 +6,8 @@ import { getCustomRepository } from '@dbTools/typeorm' import { Transaction as dbTransaction } from '@entity/Transaction' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' +import { GdtResolver } from './GdtResolver' +import { getLastTransaction } from './util/getLastTransaction' import { TransactionLinkRepository } from '@repository/TransactionLink' import { Balance } from '@model/Balance' @@ -14,9 +16,6 @@ import { backendLogger as logger } from '@/server/logger' import { Context, getUser } from '@/server/context' import { calculateDecay } from '@/util/decay' import { RIGHTS } from '@/auth/RIGHTS' -import { GdtResolver } from './GdtResolver' - -import { getLastTransaction } from './util/getLastTransaction' @Resolver() export class BalanceResolver { diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts index aae42c44b..27846d0e2 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts @@ -5,8 +5,9 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { Decimal } from 'decimal.js-light' -import { logger } from '@test/testSetup' import { GraphQLError } from 'graphql' +import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' +import { logger } from '@test/testSetup' import { login, createContributionLink, @@ -18,7 +19,6 @@ import { cleanDB, testEnvironment, resetToken } from '@test/helpers' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' import { userFactory } from '@/seeds/factory/user' -import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' let mutate: any, query: any, con: any let testEnv: any diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.ts b/backend/src/graphql/resolver/ContributionLinkResolver.ts index f7a47ab01..67c1f0955 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { Resolver, Args, Arg, Authorized, Mutation, Query, Int } from 'type-graphql' import { MoreThan, IsNull } from '@dbTools/typeorm' +import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { CONTRIBUTIONLINK_NAME_MAX_CHARS, CONTRIBUTIONLINK_NAME_MIN_CHARS, @@ -9,17 +10,16 @@ import { MEMO_MIN_CHARS, } from './const/const' import { isStartEndDateValid } from './util/creations' +import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver' import { ContributionLinkList } from '@model/ContributionLinkList' import { ContributionLink } from '@model/ContributionLink' import ContributionLinkArgs from '@arg/ContributionLinkArgs' import { backendLogger as logger } from '@/server/logger' import { RIGHTS } from '@/auth/RIGHTS' -import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Order } from '@enum/Order' import Paginated from '@arg/Paginated' // TODO: this is a strange construct -import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver' import LogError from '@/server/LogError' @Resolver() diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts index 642844e31..df624ed0a 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts @@ -6,9 +6,9 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +import { GraphQLError } from 'graphql' import { cleanDB, resetToken, testEnvironment } from '@test/helpers' import { logger, i18n as localization } from '@test/testSetup' -import { GraphQLError } from 'graphql' import { adminCreateContributionMessage, createContribution, diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index c478902e6..8288fde47 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -7,6 +7,12 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Decimal } from 'decimal.js-light' +import { GraphQLError } from 'graphql' +import { EventProtocol } from '@entity/EventProtocol' +import { Contribution } from '@entity/Contribution' +import { Transaction as DbTransaction } from '@entity/Transaction' +import { User } from '@entity/User' +import { UserInputError } from 'apollo-server-express' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { stephenHawking } from '@/seeds/users/stephen-hawking' @@ -41,18 +47,12 @@ import { contributionDateFormatter, resetEntity, } from '@test/helpers' -import { GraphQLError } from 'graphql' import { userFactory } from '@/seeds/factory/user' import { creationFactory } from '@/seeds/factory/creation' import { creations } from '@/seeds/creation/index' import { peterLustig } from '@/seeds/users/peter-lustig' -import { EventProtocol } from '@entity/EventProtocol' -import { Contribution } from '@entity/Contribution' -import { Transaction as DbTransaction } from '@entity/Transaction' -import { User } from '@entity/User' import { EventProtocolType } from '@/event/EventProtocolType' import { logger, i18n as localization } from '@test/testSetup' -import { UserInputError } from 'apollo-server-express' import { raeuberHotzenplotz } from '@/seeds/users/raeuber-hotzenplotz' import { UnconfirmedContribution } from '@model/UnconfirmedContribution' import { ContributionListResult } from '@model/Contribution' diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 6c895b339..91bffd4e3 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -9,6 +9,16 @@ import { UserContact } from '@entity/UserContact' import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' +import { + getCreationDates, + getUserCreation, + validateContribution, + updateCreations, + isValidDateString, +} from './util/creations' +import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' +import { getLastTransaction } from './util/getLastTransaction' +import { findContributions } from './util/findContributions' import { AdminUpdateContribution } from '@model/AdminUpdateContribution' import { Contribution, ContributionListResult } from '@model/Contribution' import { Decay } from '@model/Decay' @@ -27,14 +37,6 @@ import AdminUpdateContributionArgs from '@arg/AdminUpdateContributionArgs' import { RIGHTS } from '@/auth/RIGHTS' import { Context, getUser, getClientTimezoneOffset } from '@/server/context' import { backendLogger as logger } from '@/server/logger' -import { - getCreationDates, - getUserCreation, - validateContribution, - updateCreations, - isValidDateString, -} from './util/creations' -import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' import { EVENT_CONTRIBUTION_CREATE, EVENT_CONTRIBUTION_DELETE, @@ -54,9 +56,6 @@ import { import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' import LogError from '@/server/LogError' -import { getLastTransaction } from './util/getLastTransaction' -import { findContributions } from './util/findContributions' - @Resolver() export class ContributionResolver { @Authorized([RIGHTS.CREATE_CONTRIBUTION]) diff --git a/backend/src/graphql/resolver/EmailOptinCodes.test.ts b/backend/src/graphql/resolver/EmailOptinCodes.test.ts index 47fb3963c..e9f9bc052 100644 --- a/backend/src/graphql/resolver/EmailOptinCodes.test.ts +++ b/backend/src/graphql/resolver/EmailOptinCodes.test.ts @@ -4,12 +4,12 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { testEnvironment, cleanDB } from '@test/helpers' import { User as DbUser } from '@entity/User' +import { GraphQLError } from 'graphql' +import { testEnvironment, cleanDB } from '@test/helpers' import { createUser, setPassword, forgotPassword } from '@/seeds/graphql/mutations' import { queryOptIn } from '@/seeds/graphql/queries' import CONFIG from '@/config' -import { GraphQLError } from 'graphql' let mutate: any, query: any, con: any let testEnv: any diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index b3e4df80d..f9c4835f0 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -6,6 +6,10 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' +import { User } from '@entity/User' +import { Decimal } from 'decimal.js-light' +import { GraphQLError } from 'graphql' import { transactionLinkCode } from './TransactionLinkResolver' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' @@ -24,11 +28,7 @@ import { createTransactionLink, } from '@/seeds/graphql/mutations' import { listTransactionLinksAdmin } from '@/seeds/graphql/queries' -import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' -import { User } from '@entity/User' import { UnconfirmedContribution } from '@model/UnconfirmedContribution' -import { Decimal } from 'decimal.js-light' -import { GraphQLError } from 'graphql' import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' import { logger } from '@test/testSetup' diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.ts b/backend/src/graphql/resolver/TransactionLinkResolver.ts index 293f7c6f2..6de59f687 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.ts @@ -9,6 +9,11 @@ import { Transaction as DbTransaction } from '@entity/Transaction' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' +import { Resolver, Args, Arg, Authorized, Ctx, Mutation, Query, Int } from 'type-graphql' +import { getUserCreation, validateContribution } from './util/creations' +import { executeTransaction } from './TransactionResolver' +import { getLastTransaction } from './util/getLastTransaction' +import transactionLinkList from './util/transactionLinkList' import { User } from '@model/User' import { ContributionLink } from '@model/ContributionLink' import { Decay } from '@model/Decay' @@ -23,19 +28,13 @@ import TransactionLinkFilters from '@arg/TransactionLinkFilters' import { backendLogger as logger } from '@/server/logger' import { Context, getUser, getClientTimezoneOffset } from '@/server/context' -import { Resolver, Args, Arg, Authorized, Ctx, Mutation, Query, Int } from 'type-graphql' import { calculateBalance } from '@/util/validate' import { RIGHTS } from '@/auth/RIGHTS' import { calculateDecay } from '@/util/decay' -import { getUserCreation, validateContribution } from './util/creations' -import { executeTransaction } from './TransactionResolver' import QueryLinkResult from '@union/QueryLinkResult' import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' import LogError from '@/server/LogError' -import { getLastTransaction } from './util/getLastTransaction' -import transactionLinkList from './util/transactionLinkList' - // TODO: do not export, test it inside the resolver export const transactionLinkCode = (date: Date): string => { const time = date.getTime().toString(16) diff --git a/backend/src/graphql/resolver/TransactionResolver.test.ts b/backend/src/graphql/resolver/TransactionResolver.test.ts index 31fc41ed1..bc06406d4 100644 --- a/backend/src/graphql/resolver/TransactionResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionResolver.test.ts @@ -6,6 +6,11 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Decimal } from 'decimal.js-light' +import { EventProtocol } from '@entity/EventProtocol' +import { Transaction } from '@entity/Transaction' +import { User } from '@entity/User' +import { GraphQLError } from 'graphql' +import { findUserByEmail } from './UserResolver' import { EventProtocolType } from '@/event/EventProtocolType' import { userFactory } from '@/seeds/factory/user' import { @@ -18,13 +23,8 @@ import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { garrickOllivander } from '@/seeds/users/garrick-ollivander' import { peterLustig } from '@/seeds/users/peter-lustig' import { stephenHawking } from '@/seeds/users/stephen-hawking' -import { EventProtocol } from '@entity/EventProtocol' -import { Transaction } from '@entity/Transaction' -import { User } from '@entity/User' import { cleanDB, testEnvironment } from '@test/helpers' import { logger } from '@test/testSetup' -import { GraphQLError } from 'graphql' -import { findUserByEmail } from './UserResolver' let mutate: any, query: any, con: any let testEnv: any diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 83d663f93..b570c0067 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -9,6 +9,10 @@ import { getCustomRepository, getConnection, In } from '@dbTools/typeorm' import { User as dbUser } from '@entity/User' import { Transaction as dbTransaction } from '@entity/Transaction' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' +import { BalanceResolver } from './BalanceResolver' +import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' +import { findUserByEmail } from './UserResolver' +import { getLastTransaction } from './util/getLastTransaction' import { TransactionRepository } from '@repository/Transaction' import { TransactionLinkRepository } from '@repository/TransactionLink' @@ -32,15 +36,9 @@ import { } from '@/emails/sendEmailVariants' import { EVENT_TRANSACTION_RECEIVE, EVENT_TRANSACTION_SEND } from '@/event/Event' -import { BalanceResolver } from './BalanceResolver' -import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' -import { findUserByEmail } from './UserResolver' - import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' import LogError from '@/server/LogError' -import { getLastTransaction } from './util/getLastTransaction' - export const executeTransaction = async ( amount: Decimal, memo: string, diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index 083badc30..f615aeed1 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -6,6 +6,15 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +import { GraphQLError } from 'graphql' +import { User } from '@entity/User' +import { TransactionLink } from '@entity/TransactionLink' +import { EventProtocol } from '@entity/EventProtocol' +import { validate as validateUUID, version as versionUUID } from 'uuid' +import { UserContact } from '@entity/UserContact' +import { OptInType } from '../enum/OptInType' +import { UserContactType } from '../enum/UserContactType' +import { PasswordEncryptionType } from '../enum/PasswordEncryptionType' import { objectValuesToArray } from '@/util/utilities' import { testEnvironment, headerPushMock, resetToken, cleanDB } from '@test/helpers' import { logger, i18n as localization } from '@test/testSetup' @@ -27,8 +36,6 @@ import { sendActivationEmail, } from '@/seeds/graphql/mutations' import { verifyLogin, queryOptIn, searchAdminUsers, searchUsers } from '@/seeds/graphql/queries' -import { GraphQLError } from 'graphql' -import { User } from '@entity/User' import CONFIG from '@/config' import { sendAccountActivationEmail, @@ -38,19 +45,12 @@ import { import { contributionLinkFactory } from '@/seeds/factory/contributionLink' import { transactionLinkFactory } from '@/seeds/factory/transactionLink' import { ContributionLink } from '@model/ContributionLink' -import { TransactionLink } from '@entity/TransactionLink' import { EventProtocolType } from '@/event/EventProtocolType' -import { EventProtocol } from '@entity/EventProtocol' -import { validate as validateUUID, version as versionUUID } from 'uuid' import { peterLustig } from '@/seeds/users/peter-lustig' -import { UserContact } from '@entity/UserContact' -import { OptInType } from '../enum/OptInType' -import { UserContactType } from '../enum/UserContactType' import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { stephenHawking } from '@/seeds/users/stephen-hawking' import { garrickOllivander } from '@/seeds/users/garrick-ollivander' import { encryptPassword } from '@/password/PasswordEncryptor' -import { PasswordEncryptionType } from '../enum/PasswordEncryptionType' import { SecretKeyCryptographyCreateKey } from '@/password/EncryptorUtils' // import { klicktippSignIn } from '@/apis/KlicktippController' diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 8f9852d9a..dfb630776 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -21,6 +21,9 @@ import { User as DbUser } from '@entity/User' import { UserContact as DbUserContact } from '@entity/UserContact' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' +import { PasswordEncryptionType } from '../enum/PasswordEncryptionType' +import { getUserCreations } from './util/creations' +import { FULL_CREATION_AVAILABLE } from './const/const' import { UserRepository } from '@repository/User' import { User } from '@model/User' @@ -61,11 +64,8 @@ import { EVENT_ACTIVATE_ACCOUNT, EVENT_ADMIN_SEND_CONFIRMATION_EMAIL, } from '@/event/Event' -import { getUserCreations } from './util/creations' import { isValidPassword } from '@/password/EncryptorUtils' -import { FULL_CREATION_AVAILABLE } from './const/const' import { encryptPassword, verifyPassword } from '@/password/PasswordEncryptor' -import { PasswordEncryptionType } from '../enum/PasswordEncryptionType' import LogError from '@/server/LogError' import { EventProtocolType } from '@/event/EventProtocolType' diff --git a/backend/src/graphql/resolver/util/creations.test.ts b/backend/src/graphql/resolver/util/creations.test.ts index 4eabec500..7461401c8 100644 --- a/backend/src/graphql/resolver/util/creations.test.ts +++ b/backend/src/graphql/resolver/util/creations.test.ts @@ -4,14 +4,14 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +import { User } from '@entity/User' +import { Contribution } from '@entity/Contribution' +import { getUserCreation } from './creations' import { testEnvironment, cleanDB, contributionDateFormatter } from '@test/helpers' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' -import { User } from '@entity/User' -import { Contribution } from '@entity/Contribution' import { userFactory } from '@/seeds/factory/user' import { login, createContribution, adminCreateContribution } from '@/seeds/graphql/mutations' -import { getUserCreation } from './creations' let mutate: any, con: any let testEnv: any diff --git a/backend/src/graphql/resolver/util/creations.ts b/backend/src/graphql/resolver/util/creations.ts index e7a3cc965..f06b3d8bc 100644 --- a/backend/src/graphql/resolver/util/creations.ts +++ b/backend/src/graphql/resolver/util/creations.ts @@ -1,11 +1,11 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ -import LogError from '@/server/LogError' -import { backendLogger as logger } from '@/server/logger' import { getConnection } from '@dbTools/typeorm' import { Contribution } from '@entity/Contribution' import { Decimal } from 'decimal.js-light' import { FULL_CREATION_AVAILABLE, MAX_CREATION_AMOUNT } from '../const/const' +import { backendLogger as logger } from '@/server/logger' +import LogError from '@/server/LogError' interface CreationMap { id: number diff --git a/backend/src/graphql/resolver/util/findContributions.ts b/backend/src/graphql/resolver/util/findContributions.ts index 8957a29d8..782ec73d5 100644 --- a/backend/src/graphql/resolver/util/findContributions.ts +++ b/backend/src/graphql/resolver/util/findContributions.ts @@ -1,7 +1,7 @@ -import { ContributionStatus } from '@enum/ContributionStatus' -import { Order } from '@enum/Order' import { Contribution as DbContribution } from '@entity/Contribution' import { In } from '@dbTools/typeorm' +import { ContributionStatus } from '@enum/ContributionStatus' +import { Order } from '@enum/Order' export const findContributions = async ( order: Order, diff --git a/backend/src/graphql/schema.ts b/backend/src/graphql/schema.ts index 3f12a5d8c..194a24c00 100644 --- a/backend/src/graphql/schema.ts +++ b/backend/src/graphql/schema.ts @@ -1,10 +1,10 @@ +import path from 'path' import { GraphQLSchema } from 'graphql' import { buildSchema } from 'type-graphql' -import path from 'path' +import { Decimal } from 'decimal.js-light' import isAuthorized from './directive/isAuthorized' import DecimalScalar from './scalar/Decimal' -import { Decimal } from 'decimal.js-light' const schema = async (): Promise => { return buildSchema({ diff --git a/backend/src/password/EncryptorUtils.ts b/backend/src/password/EncryptorUtils.ts index 4f6238674..b4531b3bb 100644 --- a/backend/src/password/EncryptorUtils.ts +++ b/backend/src/password/EncryptorUtils.ts @@ -1,10 +1,10 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ +import { User } from '@entity/User' import CONFIG from '@/config' import LogError from '@/server/LogError' import { backendLogger as logger } from '@/server/logger' -import { User } from '@entity/User' import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs diff --git a/backend/src/seeds/creation/index.ts b/backend/src/seeds/creation/index.ts index 38cb98361..a240595ee 100644 --- a/backend/src/seeds/creation/index.ts +++ b/backend/src/seeds/creation/index.ts @@ -1,5 +1,5 @@ -import { CreationInterface } from './CreationInterface' import { nMonthsBefore } from '../factory/creation' +import { CreationInterface } from './CreationInterface' const bobsSendings = [ { diff --git a/backend/src/seeds/factory/creation.ts b/backend/src/seeds/factory/creation.ts index db58c9d51..ba46f4c09 100644 --- a/backend/src/seeds/factory/creation.ts +++ b/backend/src/seeds/factory/creation.ts @@ -5,11 +5,11 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { login, createContribution, confirmContribution } from '@/seeds/graphql/mutations' -import { CreationInterface } from '@/seeds/creation/CreationInterface' import { ApolloServerTestClient } from 'apollo-server-testing' import { Transaction } from '@entity/Transaction' import { Contribution } from '@entity/Contribution' +import { CreationInterface } from '@/seeds/creation/CreationInterface' +import { login, createContribution, confirmContribution } from '@/seeds/graphql/mutations' import { findUserByEmail } from '@/graphql/resolver/UserResolver' // import CONFIG from '@/config/index' diff --git a/backend/src/seeds/factory/transactionLink.ts b/backend/src/seeds/factory/transactionLink.ts index 797a93183..c6ed68839 100644 --- a/backend/src/seeds/factory/transactionLink.ts +++ b/backend/src/seeds/factory/transactionLink.ts @@ -1,10 +1,10 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/unbound-method */ import { ApolloServerTestClient } from 'apollo-server-testing' +import { TransactionLink } from '@entity/TransactionLink' import { login, createTransactionLink } from '@/seeds/graphql/mutations' import { TransactionLinkInterface } from '@/seeds/transactionLink/TransactionLinkInterface' import { transactionLinkExpireDate } from '@/graphql/resolver/TransactionLinkResolver' -import { TransactionLink } from '@entity/TransactionLink' export const transactionLinkFactory = async ( client: ApolloServerTestClient, diff --git a/backend/src/seeds/factory/user.ts b/backend/src/seeds/factory/user.ts index 854e5a4ed..c82c56648 100644 --- a/backend/src/seeds/factory/user.ts +++ b/backend/src/seeds/factory/user.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/unbound-method */ -import { createUser, setPassword } from '@/seeds/graphql/mutations' import { User } from '@entity/User' -import { UserInterface } from '@/seeds/users/UserInterface' import { ApolloServerTestClient } from 'apollo-server-testing' +import { createUser, setPassword } from '@/seeds/graphql/mutations' +import { UserInterface } from '@/seeds/users/UserInterface' export const userFactory = async ( client: ApolloServerTestClient, diff --git a/backend/src/seeds/index.ts b/backend/src/seeds/index.ts index 55cd65ec1..906268820 100644 --- a/backend/src/seeds/index.ts +++ b/backend/src/seeds/index.ts @@ -5,11 +5,10 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { backendLogger as logger } from '@/server/logger' -import createServer from '../server/createServer' import { createTestClient } from 'apollo-server-testing' - import { name, internet, datatype } from 'faker' +import { entities } from '@entity/index' +import createServer from '../server/createServer' import { users } from './users/index' import { creations } from './creation/index' @@ -19,7 +18,7 @@ import { userFactory } from './factory/user' import { creationFactory } from './factory/creation' import { transactionLinkFactory } from './factory/transactionLink' import { contributionLinkFactory } from './factory/contributionLink' -import { entities } from '@entity/index' +import { backendLogger as logger } from '@/server/logger' import CONFIG from '@/config' CONFIG.EMAIL = false diff --git a/backend/src/server/LogError.test.ts b/backend/src/server/LogError.test.ts index 5aa1cae21..318a477ef 100644 --- a/backend/src/server/LogError.test.ts +++ b/backend/src/server/LogError.test.ts @@ -1,8 +1,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/unbound-method */ -import { logger } from '@test/testSetup' - import LogError from './LogError' +import { logger } from '@test/testSetup' describe('LogError', () => { it('logs an Error when created', () => { diff --git a/backend/src/server/context.ts b/backend/src/server/context.ts index 5727e2707..570865587 100644 --- a/backend/src/server/context.ts +++ b/backend/src/server/context.ts @@ -1,9 +1,9 @@ -import { Role } from '@/auth/Role' import { User as dbUser } from '@entity/User' import { Transaction as dbTransaction } from '@entity/Transaction' import { Decimal } from 'decimal.js-light' import { ExpressContext } from 'apollo-server-express' import LogError from './LogError' +import { Role } from '@/auth/Role' export interface Context { token: string | null diff --git a/backend/src/server/localization.ts b/backend/src/server/localization.ts index 44fb1b526..22616fcf0 100644 --- a/backend/src/server/localization.ts +++ b/backend/src/server/localization.ts @@ -1,6 +1,6 @@ import path from 'path' -import { backendLogger } from './logger' import i18n from 'i18n' +import { backendLogger } from './logger' i18n.configure({ locales: ['en', 'de'], diff --git a/backend/src/server/logger.ts b/backend/src/server/logger.ts index e72e425a2..0887340d4 100644 --- a/backend/src/server/logger.ts +++ b/backend/src/server/logger.ts @@ -1,10 +1,9 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ +import { readFileSync } from 'fs' import { configure, getLogger } from 'log4js' import CONFIG from '@/config' -import { readFileSync } from 'fs' - const options = JSON.parse(readFileSync(CONFIG.LOG4JS_CONFIG, 'utf-8')) options.categories.backend.level = CONFIG.LOG_LEVEL diff --git a/backend/src/typeorm/connection.ts b/backend/src/typeorm/connection.ts index d08d935d4..54b951a79 100644 --- a/backend/src/typeorm/connection.ts +++ b/backend/src/typeorm/connection.ts @@ -1,8 +1,8 @@ // TODO This is super weird - since the entities are defined in another project they have their own globals. // We cannot use our connection here, but must use the external typeorm installation import { Connection, createConnection, FileLogger } from '@dbTools/typeorm' -import CONFIG from '@/config' import { entities } from '@entity/index' +import CONFIG from '@/config' const connection = async (): Promise => { try { diff --git a/backend/src/typeorm/repository/User.ts b/backend/src/typeorm/repository/User.ts index e72a6e717..4928b0cc8 100644 --- a/backend/src/typeorm/repository/User.ts +++ b/backend/src/typeorm/repository/User.ts @@ -1,6 +1,6 @@ -import SearchUsersFilters from '@/graphql/arg/SearchUsersFilters' import { Brackets, EntityRepository, IsNull, Not, Repository } from '@dbTools/typeorm' import { User as DbUser } from '@entity/User' +import SearchUsersFilters from '@/graphql/arg/SearchUsersFilters' @EntityRepository(DbUser) export class UserRepository extends Repository { diff --git a/backend/src/util/communityUser.ts b/backend/src/util/communityUser.ts index 4d04be1b8..dfa477da9 100644 --- a/backend/src/util/communityUser.ts +++ b/backend/src/util/communityUser.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ -import { PasswordEncryptionType } from '@/graphql/enum/PasswordEncryptionType' import { SaveOptions, RemoveOptions } from '@dbTools/typeorm' import { User as dbUser } from '@entity/User' import { UserContact } from '@entity/UserContact' +import { PasswordEncryptionType } from '@/graphql/enum/PasswordEncryptionType' // import { UserContact as EmailContact } from '@entity/UserContact' import { User } from '@model/User' diff --git a/backend/src/util/validate.ts b/backend/src/util/validate.ts index ff4b17841..ce4042b28 100644 --- a/backend/src/util/validate.ts +++ b/backend/src/util/validate.ts @@ -1,10 +1,10 @@ -import { calculateDecay } from './decay' import { Decimal } from 'decimal.js-light' -import { Decay } from '@model/Decay' import { getCustomRepository } from '@dbTools/typeorm' -import { TransactionLinkRepository } from '@repository/TransactionLink' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' import { getLastTransaction } from '../graphql/resolver/util/getLastTransaction' +import { calculateDecay } from './decay' +import { TransactionLinkRepository } from '@repository/TransactionLink' +import { Decay } from '@model/Decay' function isStringBoolean(value: string): boolean { const lowerValue = value.toLowerCase() diff --git a/backend/src/util/virtualTransactions.ts b/backend/src/util/virtualTransactions.ts index 2ee899009..7810ad871 100644 --- a/backend/src/util/virtualTransactions.ts +++ b/backend/src/util/virtualTransactions.ts @@ -1,11 +1,11 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ -import { Transaction } from '@model/Transaction' import { SaveOptions, RemoveOptions } from '@dbTools/typeorm' import { Transaction as dbTransaction } from '@entity/Transaction' -import { TransactionTypeId } from '@enum/TransactionTypeId' -import { calculateDecay } from './decay' -import { User } from '@model/User' import { Decimal } from 'decimal.js-light' +import { calculateDecay } from './decay' +import { Transaction } from '@model/Transaction' +import { TransactionTypeId } from '@enum/TransactionTypeId' +import { User } from '@model/User' const defaultModelFunctions = { hasId: function (): boolean { diff --git a/backend/test/helpers.ts b/backend/test/helpers.ts index a5f721717..15e2d4898 100644 --- a/backend/test/helpers.ts +++ b/backend/test/helpers.ts @@ -7,9 +7,9 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { createTestClient } from 'apollo-server-testing' -import createServer from '../src/server/createServer' import { initialize } from '@dbTools/helpers' import { entities } from '@entity/index' +import createServer from '../src/server/createServer' import { i18n, logger } from './testSetup' export const headerPushMock = jest.fn((t) => { From 31130020b3e9d56cd014b910486fd8ab4edf3ced Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 10 Mar 2023 16:45:00 +0100 Subject: [PATCH 42/91] fixes --- backend/.eslintrc.js | 2 +- backend/src/graphql/scalar/Decimal.ts | 4 +++- backend/src/server/createServer.ts | 29 +++++++-------------------- backend/src/util/decay.test.ts | 1 - backend/src/util/klicktipp.ts | 2 +- backend/src/webhook/elopage.ts | 2 +- 6 files changed, 13 insertions(+), 27 deletions(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index 95972cca7..2b70c0e78 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -65,7 +65,7 @@ module.exports = { 'import/no-namespace': 'error', 'import/no-unassigned-import': 'error', 'import/order': 'error', - 'import/prefer-default-export': 'off', //TODO + 'import/prefer-default-export': 'off', // TODO }, overrides: [ // only for ts files diff --git a/backend/src/graphql/scalar/Decimal.ts b/backend/src/graphql/scalar/Decimal.ts index 0f259343c..586481a6d 100644 --- a/backend/src/graphql/scalar/Decimal.ts +++ b/backend/src/graphql/scalar/Decimal.ts @@ -1,7 +1,7 @@ import { GraphQLScalarType, Kind } from 'graphql' import { Decimal } from 'decimal.js-light' -export default new GraphQLScalarType({ +const DecimalType = new GraphQLScalarType({ name: 'Decimal', description: 'The `Decimal` scalar type to represent currency values', @@ -21,3 +21,5 @@ export default new GraphQLScalarType({ return new Decimal(ast.value) }, }) + +export default DecimalType diff --git a/backend/src/server/createServer.ts b/backend/src/server/createServer.ts index 5b3be4998..f23e90b56 100644 --- a/backend/src/server/createServer.ts +++ b/backend/src/server/createServer.ts @@ -1,35 +1,20 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/restrict-template-expressions */ /* eslint-disable @typescript-eslint/unbound-method */ -import 'reflect-metadata' - import { ApolloServer } from 'apollo-server-express' import express, { Express, json, urlencoded } from 'express' - -// database -import connection from '@/typeorm/connection' -import { checkDBVersion } from '@/typeorm/DBVersion' - -// server +import { Connection } from '@dbTools/typeorm' +import { Logger } from 'log4js' import cors from './cors' import serverContext from './context' import plugins from './plugins' - -// config -import CONFIG from '@/config' - -// graphql -import schema from '@/graphql/schema' - -// webhooks -import { elopageWebhook } from '@/webhook/elopage' -import { Connection } from '@dbTools/typeorm' - import { apolloLogger } from './logger' -import { Logger } from 'log4js' - -// i18n import { i18n } from './localization' +import connection from '@/typeorm/connection' +import { checkDBVersion } from '@/typeorm/DBVersion' +import CONFIG from '@/config' +import schema from '@/graphql/schema' +import { elopageWebhook } from '@/webhook/elopage' // TODO implement // import queryComplexity, { simpleEstimator, fieldConfigEstimator } from "graphql-query-complexity"; diff --git a/backend/src/util/decay.test.ts b/backend/src/util/decay.test.ts index d07ee6569..b33d18d42 100644 --- a/backend/src/util/decay.test.ts +++ b/backend/src/util/decay.test.ts @@ -1,5 +1,4 @@ import { Decimal } from 'decimal.js-light' -import 'reflect-metadata' // This might be wise to load in a test setup file import { decayFormula, calculateDecay } from './decay' describe('utils/decay', () => { diff --git a/backend/src/util/klicktipp.ts b/backend/src/util/klicktipp.ts index baa7970fc..6444d20f6 100644 --- a/backend/src/util/klicktipp.ts +++ b/backend/src/util/klicktipp.ts @@ -1,6 +1,6 @@ +import { User } from '@entity/User' import connection from '@/typeorm/connection' import { getKlickTippUser } from '@/apis/KlicktippController' -import { User } from '@entity/User' import LogError from '@/server/LogError' export async function retrieveNotRegisteredEmails(): Promise { diff --git a/backend/src/webhook/elopage.ts b/backend/src/webhook/elopage.ts index 587bb788c..6f3e3cbdb 100644 --- a/backend/src/webhook/elopage.ts +++ b/backend/src/webhook/elopage.ts @@ -32,8 +32,8 @@ */ import { LoginElopageBuys } from '@entity/LoginElopageBuys' -import { UserResolver } from '@/graphql/resolver/UserResolver' import { UserContact as dbUserContact } from '@entity/UserContact' +import { UserResolver } from '@/graphql/resolver/UserResolver' export const elopageWebhook = async (req: any, res: any): Promise => { // eslint-disable-next-line no-console From 5d1311229f368cf1fa18624caf9fc9ea2ec6be8e Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 10 Mar 2023 19:19:57 +0100 Subject: [PATCH 43/91] more rules --- backend/.eslintrc.js | 13 +++++++++++-- .../src/federation/client/1_0/FederationClient.ts | 2 +- .../src/federation/client/1_1/FederationClient.ts | 2 +- backend/src/graphql/resolver/UserResolver.test.ts | 6 +++--- backend/src/graphql/resolver/UserResolver.ts | 2 +- backend/src/graphql/resolver/util/creations.ts | 2 +- backend/src/seeds/creation/index.ts | 2 +- backend/src/seeds/index.ts | 2 +- backend/src/util/validate.ts | 2 +- backend/test/helpers.ts | 2 +- 10 files changed, 22 insertions(+), 13 deletions(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index 2b70c0e78..b8e4684aa 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -35,22 +35,30 @@ module.exports = { 'jest/prefer-to-have-length': 'error', 'jest/valid-expect': 'error', // import + 'import/export': 'error', 'import/no-deprecated': 'error', 'import/no-empty-named-blocks': 'error', + 'import/no-extraneous-dependencies': 'off', // TODO 'import/no-mutable-exports': 'error', 'import/no-unused-modules': 'error', + 'import/no-named-as-default': 'error', + 'import/no-named-as-default-member': 'error', 'import/no-amd': 'error', 'import/no-commonjs': 'error', 'import/no-import-module-exports': 'error', 'import/no-nodejs-modules': 'off', 'import/unambiguous': 'error', + 'import/default': 'error', + 'import/named': 'error', + 'import/namespace': 'error', 'import/no-absolute-path': 'error', 'import/no-cycle': 'error', 'import/no-dynamic-require': 'error', - 'import/no-internal-modules': 'off', + 'import/no-internal-modules': 'off', // TODO 'import/no-relative-packages': 'error', - 'import/no-relative-parent-imports': 'off', + 'import/no-relative-parent-imports': ['error', { ignore: ['@/*'] }], 'import/no-self-import': 'error', + 'import/no-unresolved': 'error', 'import/no-useless-path-segments': 'error', 'import/no-webpack-loader-syntax': 'error', 'import/consistent-type-specifier-style': 'error', @@ -61,6 +69,7 @@ module.exports = { 'import/newline-after-import': 'error', 'import/no-anonymous-default-export': 'error', 'import/no-default-export': 'off', + 'import/no-duplicates': 'error', 'import/no-named-default': 'error', 'import/no-namespace': 'error', 'import/no-unassigned-import': 'error', diff --git a/backend/src/federation/client/1_0/FederationClient.ts b/backend/src/federation/client/1_0/FederationClient.ts index 8c68158ff..6b0b797ff 100644 --- a/backend/src/federation/client/1_0/FederationClient.ts +++ b/backend/src/federation/client/1_0/FederationClient.ts @@ -3,7 +3,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { gql } from 'graphql-request' import { Community as DbCommunity } from '@entity/Community' -import { GraphQLGetClient } from '../GraphQLGetClient' +import { GraphQLGetClient } from '@/federation/client/GraphQLGetClient' import { backendLogger as logger } from '@/server/logger' import LogError from '@/server/LogError' diff --git a/backend/src/federation/client/1_1/FederationClient.ts b/backend/src/federation/client/1_1/FederationClient.ts index 3f7f7b3da..40c34d240 100644 --- a/backend/src/federation/client/1_1/FederationClient.ts +++ b/backend/src/federation/client/1_1/FederationClient.ts @@ -3,7 +3,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ import { gql } from 'graphql-request' import { Community as DbCommunity } from '@entity/Community' -import { GraphQLGetClient } from '../GraphQLGetClient' +import { GraphQLGetClient } from '@/federation/client/GraphQLGetClient' import { backendLogger as logger } from '@/server/logger' import LogError from '@/server/LogError' diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index f615aeed1..54623e7f5 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -12,9 +12,9 @@ import { TransactionLink } from '@entity/TransactionLink' import { EventProtocol } from '@entity/EventProtocol' import { validate as validateUUID, version as versionUUID } from 'uuid' import { UserContact } from '@entity/UserContact' -import { OptInType } from '../enum/OptInType' -import { UserContactType } from '../enum/UserContactType' -import { PasswordEncryptionType } from '../enum/PasswordEncryptionType' +import { OptInType } from '@enum/OptInType' +import { UserContactType } from '@enum/UserContactType' +import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' import { objectValuesToArray } from '@/util/utilities' import { testEnvironment, headerPushMock, resetToken, cleanDB } from '@test/helpers' import { logger, i18n as localization } from '@test/testSetup' diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index dfb630776..6c59c251c 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -21,9 +21,9 @@ import { User as DbUser } from '@entity/User' import { UserContact as DbUserContact } from '@entity/UserContact' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' -import { PasswordEncryptionType } from '../enum/PasswordEncryptionType' import { getUserCreations } from './util/creations' import { FULL_CREATION_AVAILABLE } from './const/const' +import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' import { UserRepository } from '@repository/User' import { User } from '@model/User' diff --git a/backend/src/graphql/resolver/util/creations.ts b/backend/src/graphql/resolver/util/creations.ts index f06b3d8bc..c9be2c57c 100644 --- a/backend/src/graphql/resolver/util/creations.ts +++ b/backend/src/graphql/resolver/util/creations.ts @@ -3,7 +3,7 @@ import { getConnection } from '@dbTools/typeorm' import { Contribution } from '@entity/Contribution' import { Decimal } from 'decimal.js-light' -import { FULL_CREATION_AVAILABLE, MAX_CREATION_AMOUNT } from '../const/const' +import { FULL_CREATION_AVAILABLE, MAX_CREATION_AMOUNT } from '@/graphql/resolver/const/const' import { backendLogger as logger } from '@/server/logger' import LogError from '@/server/LogError' diff --git a/backend/src/seeds/creation/index.ts b/backend/src/seeds/creation/index.ts index a240595ee..757407438 100644 --- a/backend/src/seeds/creation/index.ts +++ b/backend/src/seeds/creation/index.ts @@ -1,5 +1,5 @@ -import { nMonthsBefore } from '../factory/creation' import { CreationInterface } from './CreationInterface' +import { nMonthsBefore } from '@/seeds/factory/creation' const bobsSendings = [ { diff --git a/backend/src/seeds/index.ts b/backend/src/seeds/index.ts index 906268820..19f936d16 100644 --- a/backend/src/seeds/index.ts +++ b/backend/src/seeds/index.ts @@ -8,7 +8,6 @@ import { createTestClient } from 'apollo-server-testing' import { name, internet, datatype } from 'faker' import { entities } from '@entity/index' -import createServer from '../server/createServer' import { users } from './users/index' import { creations } from './creation/index' @@ -18,6 +17,7 @@ import { userFactory } from './factory/user' import { creationFactory } from './factory/creation' import { transactionLinkFactory } from './factory/transactionLink' import { contributionLinkFactory } from './factory/contributionLink' +import createServer from '@/server/createServer' import { backendLogger as logger } from '@/server/logger' import CONFIG from '@/config' diff --git a/backend/src/util/validate.ts b/backend/src/util/validate.ts index ce4042b28..ec28dfa13 100644 --- a/backend/src/util/validate.ts +++ b/backend/src/util/validate.ts @@ -1,8 +1,8 @@ import { Decimal } from 'decimal.js-light' import { getCustomRepository } from '@dbTools/typeorm' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' -import { getLastTransaction } from '../graphql/resolver/util/getLastTransaction' import { calculateDecay } from './decay' +import { getLastTransaction } from '@/graphql/resolver/util/getLastTransaction' import { TransactionLinkRepository } from '@repository/TransactionLink' import { Decay } from '@model/Decay' diff --git a/backend/test/helpers.ts b/backend/test/helpers.ts index 15e2d4898..ad6d2c4e3 100644 --- a/backend/test/helpers.ts +++ b/backend/test/helpers.ts @@ -9,8 +9,8 @@ import { createTestClient } from 'apollo-server-testing' import { initialize } from '@dbTools/helpers' import { entities } from '@entity/index' -import createServer from '../src/server/createServer' import { i18n, logger } from './testSetup' +import createServer from '@/server/createServer' export const headerPushMock = jest.fn((t) => { context.token = t.value From 448bc55b7fe37043c0cd0e8fb0d61adccfeb9104 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 10 Mar 2023 19:43:28 +0100 Subject: [PATCH 44/91] refine some rules --- backend/.eslintrc.js | 4 +- backend/package.json | 2 + backend/yarn.lock | 294 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 292 insertions(+), 8 deletions(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index b8e4684aa..0ff67d095 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -38,7 +38,7 @@ module.exports = { 'import/export': 'error', 'import/no-deprecated': 'error', 'import/no-empty-named-blocks': 'error', - 'import/no-extraneous-dependencies': 'off', // TODO + 'import/no-extraneous-dependencies': 'error', 'import/no-mutable-exports': 'error', 'import/no-unused-modules': 'error', 'import/no-named-as-default': 'error', @@ -54,7 +54,7 @@ module.exports = { 'import/no-absolute-path': 'error', 'import/no-cycle': 'error', 'import/no-dynamic-require': 'error', - 'import/no-internal-modules': 'off', // TODO + 'import/no-internal-modules': 'off', 'import/no-relative-packages': 'error', 'import/no-relative-parent-imports': ['error', { ignore: ['@/*'] }], 'import/no-self-import': 'error', diff --git a/backend/package.json b/backend/package.json index 34eb78bca..a7ca1bb3e 100644 --- a/backend/package.json +++ b/backend/package.json @@ -29,6 +29,7 @@ "dotenv": "^10.0.0", "email-templates": "^10.0.1", "express": "^4.17.1", + "gradido-database": "file:../database", "graphql": "^15.5.1", "graphql-request": "5.0.0", "i18n": "^0.15.1", @@ -69,6 +70,7 @@ "eslint-plugin-promise": "^5.1.0", "eslint-plugin-type-graphql": "^1.0.0", "faker": "^5.5.3", + "graphql-tag": "^2.12.6", "jest": "^27.2.4", "nodemon": "^2.0.7", "prettier": "^2.3.1", diff --git a/backend/yarn.lock b/backend/yarn.lock index f5db29695..2a611bd3f 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -804,6 +804,11 @@ dependencies: "@sinonjs/commons" "^1.7.0" +"@sqltools/formatter@^1.2.2": + version "1.2.5" + resolved "https://registry.yarnpkg.com/@sqltools/formatter/-/formatter-1.2.5.tgz#3abc203c79b8c3e90fd6c156a0c62d5403520e12" + integrity sha512-Uy0+khmZqUrUGm5dmMqVlnvufZRSK0FbYzVgp0UMstm+F5+W2/jnEEQyc9vo1ZR/E5ZI/B1WjjoTqBqwJL6Krw== + "@szmarczak/http-timer@^1.1.2": version "1.1.2" resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-1.1.2.tgz#b1665e2c461a2cd92f4c1bbf50d5454de0d4b421" @@ -1096,6 +1101,13 @@ resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40" integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ== +"@types/mysql@^2.15.8": + version "2.15.21" + resolved "https://registry.yarnpkg.com/@types/mysql/-/mysql-2.15.21.tgz#7516cba7f9d077f980100c85fd500c8210bd5e45" + integrity sha512-NPotx5CVful7yB+qZbWtXL2fA4e7aEHkihHLjklc6ID8aq7bhguHgeIoC1EmSNTAuCgI6ZXrjt2ZSaXnYX0EUg== + dependencies: + "@types/node" "*" + "@types/node@*", "@types/node@^16.10.3": version "16.10.3" resolved "https://registry.yarnpkg.com/@types/node/-/node-16.10.3.tgz#7a8f2838603ea314d1d22bb3171d899e15c57bd5" @@ -1192,6 +1204,11 @@ dependencies: "@types/yargs-parser" "*" +"@types/zen-observable@0.8.3": + version "0.8.3" + resolved "https://registry.yarnpkg.com/@types/zen-observable/-/zen-observable-0.8.3.tgz#781d360c282436494b32fe7d9f7f8e64b3118aa3" + integrity sha512-fbF6oTd4sGGy0xjHPKAt+eS2CrxJ3+6gQ3FGcBoIJR2TLAyCkCyI8JqZNy+FeON0AhVgNJoUumVoZQjBFUqHkw== + "@typescript-eslint/eslint-plugin@^4.28.0": version "4.33.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.33.0.tgz#c24dc7c8069c7706bc40d99f6fa87edcb2005276" @@ -1493,6 +1510,11 @@ ansi-styles@^5.0.0: resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== +any-promise@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" + integrity sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A== + anymatch@^3.0.3, anymatch@~3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" @@ -1658,6 +1680,11 @@ apollo-utilities@^1.0.1, apollo-utilities@^1.3.0: ts-invariant "^0.4.0" tslib "^1.10.0" +app-root-path@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/app-root-path/-/app-root-path-3.1.0.tgz#5971a2fc12ba170369a7a1ef018c71e6e47c2e86" + integrity sha512-biN3PwB2gUtjaYy/isrU3aNWI5w+fAfvHkSvCKeQGxhmYpwKFUxudR3Yya+KqVRHBmEDYh+/lTozYCFbmzX4nA== + arg@^4.1.0: version "4.1.3" resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" @@ -1670,6 +1697,11 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== + array-differ@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-3.0.0.tgz#3cbb3d0f316810eafcc47624734237d6aee4ae6b" @@ -1843,6 +1875,16 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== +base64-js@^1.3.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" + integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== + +bignumber.js@9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.0.0.tgz#805880f84a329b5eac6e7cb6f8274b6d82bdf075" + integrity sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A== + binary-extensions@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" @@ -1948,6 +1990,14 @@ buffer-from@^1.0.0: resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== +buffer@^6.0.3: + version "6.0.3" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" + integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.2.1" + busboy@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/busboy/-/busboy-0.3.1.tgz#170899274c5bf38aae27d5c62b71268cd585fd1b" @@ -2103,6 +2153,18 @@ cli-boxes@^2.2.1: resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-2.2.1.tgz#ddd5035d25094fce220e9cab40a45840a440318f" integrity sha512-y4coMcylgSCdVinjiDBuR8PCC2bLjyGTwEmPb9NHR/QaNU6EUOXcTY/s6VjGMD6ENSEaeQYHCY0GNGS5jfMwPw== +cli-highlight@^2.1.11: + version "2.1.11" + resolved "https://registry.yarnpkg.com/cli-highlight/-/cli-highlight-2.1.11.tgz#49736fa452f0aaf4fae580e30acb26828d2dc1bf" + integrity sha512-9KDcoEVwyUXrjcJNvHD0NFc/hiwe/WPVYIleQh2O1N2Zro5gWJZ/K+3DGn8w8P/F6FxOgzyC5bxDyHIgCSPhGg== + dependencies: + chalk "^4.0.0" + highlight.js "^10.7.1" + mz "^2.4.0" + parse5 "^5.1.1" + parse5-htmlparser2-tree-adapter "^6.0.0" + yargs "^16.0.0" + cliui@^7.0.2: version "7.0.4" resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" @@ -2112,6 +2174,15 @@ cliui@^7.0.2: strip-ansi "^6.0.0" wrap-ansi "^7.0.0" +cliui@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa" + integrity sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.1" + wrap-ansi "^7.0.0" + clone-response@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/clone-response/-/clone-response-1.0.2.tgz#d1dc973920314df67fbeb94223b4ee350239e96b" @@ -2236,6 +2307,11 @@ core-js-pure@^3.10.2: resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.18.2.tgz#d8cc11d4885ea919f3de776d45e720e4c769d406" integrity sha512-4hMMLUlZhKJKOWbbGD1/VDUxGPEhEoN/T01k7bx271WiBKCvCfkgPzy0IeRS4PB50p6/N1q/SZL4B/TRsTE5bA== +core-util-is@~1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" + integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== + cors@^2.8.5: version "2.8.5" resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29" @@ -2295,6 +2371,11 @@ crypto-random-string@^2.0.0: resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-2.0.0.tgz#ef2a7a966ec11083388369baa02ebead229b30d5" integrity sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA== +crypto@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/crypto/-/crypto-1.0.1.tgz#2af1b7cad8175d24c8a1b0778255794a21803037" + integrity sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig== + css-select@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/css-select/-/css-select-4.3.0.tgz#db7129b2846662fd8628cfc496abb2b59e41529b" @@ -2579,6 +2660,11 @@ dotenv@^10.0.0: resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-10.0.0.tgz#3d4227b8fb95f81096cdd2b66653fb2c7085ba81" integrity sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q== +dotenv@^8.2.0: + version "8.6.0" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.6.0.tgz#061af664d19f7f4d8fc6e4ff9b584ce237adcb8b" + integrity sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g== + duplexer3@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" @@ -3546,6 +3632,20 @@ graceful-fs@^4.1.6, graceful-fs@^4.2.0: resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== +"gradido-database@file:../database": + version "1.19.1" + dependencies: + "@types/uuid" "^8.3.4" + cross-env "^7.0.3" + crypto "^1.0.1" + decimal.js-light "^2.5.1" + dotenv "^10.0.0" + mysql2 "^2.3.0" + reflect-metadata "^0.1.13" + ts-mysql-migrate "^1.0.2" + typeorm "^0.2.38" + uuid "^8.3.2" + graphql-extensions@^0.15.0: version "0.15.0" resolved "https://registry.yarnpkg.com/graphql-extensions/-/graphql-extensions-0.15.0.tgz#3f291f9274876b0c289fa4061909a12678bd9817" @@ -3586,6 +3686,13 @@ graphql-tag@^2.11.0: dependencies: tslib "^2.1.0" +graphql-tag@^2.12.6: + version "2.12.6" + resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.12.6.tgz#d441a569c1d2537ef10ca3d1633b48725329b5f1" + integrity sha512-FdSNcu2QQcWnM2VNvSCCDCVS5PpPqpzgFT8+GXzqJuoDd0CBncxCY278u4mhRO7tMgo2JjgJA5aZ+nWSQ/Z+xg== + dependencies: + tslib "^2.1.0" + graphql-tools@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/graphql-tools/-/graphql-tools-4.0.8.tgz#e7fb9f0d43408fb0878ba66b522ce871bafe9d30" @@ -3668,6 +3775,11 @@ he@1.2.0, he@^1.2.0: resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== +highlight.js@^10.7.1: + version "10.7.3" + resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-10.7.3.tgz#697272e3991356e40c3cac566a74eef681756531" + integrity sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A== + html-encoding-sniffer@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz#42a6dc4fd33f00281176e8b23759ca4e4fa185f3" @@ -3829,6 +3941,11 @@ iconv-lite@0.6.3, iconv-lite@^0.6.2: dependencies: safer-buffer ">= 2.1.2 < 3.0.0" +ieee754@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" + integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== + ignore-by-default@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/ignore-by-default/-/ignore-by-default-1.0.1.tgz#48ca6d72f6c6a3af00a9ad4ae6876be3889e2b09" @@ -3883,7 +4000,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@2.0.4, inherits@^2.0.1: +inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@~2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -4190,6 +4307,11 @@ is-yarn-global@^0.3.0: resolved "https://registry.yarnpkg.com/is-yarn-global/-/is-yarn-global-0.3.0.tgz#d502d3382590ea3004893746754c89139973e232" integrity sha512-VjSeb/lHmkoyd8ryPVIKvOCn4D1koMqY+vqyjjUfc3xyKtP4dYOxM44sZrnqQSzSds3xyOrUTLTC9LVCVgLngw== +isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + integrity sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ== + isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" @@ -4670,6 +4792,13 @@ js-yaml@^3.13.1: argparse "^1.0.7" esprima "^4.0.0" +js-yaml@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== + dependencies: + argparse "^2.0.1" + jsdom@^16.6.0: version "16.7.0" resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-16.7.0.tgz#918ae71965424b197c819f8183a754e18977b710" @@ -5147,6 +5276,11 @@ minimist@^1.2.6: resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== +mkdirp@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" + integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== + moo@^0.5.0, moo@^0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/moo/-/moo-0.5.1.tgz#7aae7f384b9b09f620b6abf6f74ebbcd1b65dbc4" @@ -5202,6 +5336,25 @@ mysql2@^2.3.0: seq-queue "^0.0.5" sqlstring "^2.3.2" +mysql@^2.18.1: + version "2.18.1" + resolved "https://registry.yarnpkg.com/mysql/-/mysql-2.18.1.tgz#2254143855c5a8c73825e4522baf2ea021766717" + integrity sha512-Bca+gk2YWmqp2Uf6k5NFEurwY/0td0cpebAucFpY/3jhrwrVGuxU2uQFCHjU19SJfje0yQvi+rVWdq78hR5lig== + dependencies: + bignumber.js "9.0.0" + readable-stream "2.3.7" + safe-buffer "5.1.2" + sqlstring "2.3.1" + +mz@^2.4.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/mz/-/mz-2.7.0.tgz#95008057a56cafadc2bc63dde7f9ff6955948e32" + integrity sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q== + dependencies: + any-promise "^1.0.0" + object-assign "^4.0.1" + thenify-all "^1.0.0" + named-placeholders@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/named-placeholders/-/named-placeholders-1.1.2.tgz#ceb1fbff50b6b33492b5cf214ccf5e39cef3d0e8" @@ -5342,7 +5495,7 @@ nwsapi@^2.2.0: resolved "https://registry.yarnpkg.com/nwsapi/-/nwsapi-2.2.0.tgz#204879a9e3d068ff2a55139c2c772780681a38b7" integrity sha512-h2AatdwYH+JHiZpv7pt/gSX1XoRGb7L/qSIeuqA6GwYoF9w1vP1cw42TO0aI2pNyshRK5893hNSl+1//vHK7hQ== -object-assign@^4, object-assign@^4.1.1: +object-assign@^4, object-assign@^4.0.1, object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= @@ -5534,7 +5687,7 @@ parent-module@^1.0.0: dependencies: callsites "^3.0.0" -parse5-htmlparser2-tree-adapter@^6.0.1: +parse5-htmlparser2-tree-adapter@^6.0.0, parse5-htmlparser2-tree-adapter@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz#2cdf9ad823321140370d4dbf5d3e92c7c8ddc6e6" integrity sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA== @@ -5546,6 +5699,11 @@ parse5@6.0.1, parse5@^6.0.1: resolved "https://registry.yarnpkg.com/parse5/-/parse5-6.0.1.tgz#e1a1c085c569b3dc08321184f19a39cc27f7c30b" integrity sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw== +parse5@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/parse5/-/parse5-5.1.1.tgz#f68e4e5ba1852ac2cadc00f4555fff6c2abb6178" + integrity sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug== + parseley@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/parseley/-/parseley-0.7.0.tgz#9949e3a0ed05c5072adb04f013c2810cf49171a8" @@ -5682,6 +5840,11 @@ preview-email@^3.0.7: pug "^3.0.2" uuid "^8.3.2" +process-nextick-args@~2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" + integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== + progress@^2.0.0: version "2.0.3" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" @@ -5913,6 +6076,19 @@ react-is@^17.0.1: resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== +readable-stream@2.3.7: + version "2.3.7" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" + integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + readdirp@~3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" @@ -6045,7 +6221,7 @@ run-parallel@^1.1.9: dependencies: queue-microtask "^1.2.2" -safe-buffer@5.1.2, safe-buffer@~5.1.1: +safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.2" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== @@ -6074,6 +6250,11 @@ safe-regex-test@^1.0.0: resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== +sax@>=0.6.0: + version "1.2.4" + resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" + integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== + saxes@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/saxes/-/saxes-5.0.1.tgz#eebab953fa3b7608dbe94e5dadb15c888fa6696d" @@ -6278,6 +6459,11 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= +sqlstring@2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/sqlstring/-/sqlstring-2.3.1.tgz#475393ff9e91479aea62dcaf0ca3d14983a7fb40" + integrity sha512-ooAzh/7dxIG5+uDik1z/Rd1vli0+38izZhGzSa34FwR7IbelPWCCKSNIl8jlL/F7ERvy8CB2jNeM1E9i9mXMAQ== + sqlstring@^2.3.2: version "2.3.2" resolved "https://registry.yarnpkg.com/sqlstring/-/sqlstring-2.3.2.tgz#cdae7169389a1375b18e885f2e60b3e460809514" @@ -6360,6 +6546,13 @@ string.prototype.trimstart@^1.0.6: define-properties "^1.1.4" es-abstract "^1.20.4" +string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" + integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== + dependencies: + safe-buffer "~5.1.0" + strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" @@ -6499,6 +6692,20 @@ text-table@^0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= +thenify-all@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/thenify-all/-/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726" + integrity sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA== + dependencies: + thenify ">= 3.1.0 < 4" + +"thenify@>= 3.1.0 < 4": + version "3.3.1" + resolved "https://registry.yarnpkg.com/thenify/-/thenify-3.3.1.tgz#8932e686a4066038a016dd9e2ca46add9838a95f" + integrity sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw== + dependencies: + any-promise "^1.0.0" + throat@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/throat/-/throat-6.0.1.tgz#d514fedad95740c12c2d7fc70ea863eb51ade375" @@ -6603,6 +6810,14 @@ ts-jest@^27.0.5: semver "7.x" yargs-parser "20.x" +ts-mysql-migrate@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/ts-mysql-migrate/-/ts-mysql-migrate-1.0.2.tgz#736d37c3aa3fef92f226b869098e939950d0e18c" + integrity sha512-zDW6iQsfPCJfQ3JMhfUGjhy8aK+VNTvPrXmJH66PB2EGEvyn4m7x2nBdhDNhKuwYU9LMxW1p+l39Ei+btXNpxA== + dependencies: + "@types/mysql" "^2.15.8" + mysql "^2.18.1" + ts-node@^10.0.0: version "10.2.1" resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.2.1.tgz#4cc93bea0a7aba2179497e65bb08ddfc198b3ab5" @@ -6740,6 +6955,29 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" +typeorm@^0.2.38: + version "0.2.45" + resolved "https://registry.yarnpkg.com/typeorm/-/typeorm-0.2.45.tgz#e5bbb3af822dc4646bad96cfa48cd22fa4687cea" + integrity sha512-c0rCO8VMJ3ER7JQ73xfk0zDnVv0WDjpsP6Q1m6CVKul7DB9iVdWLRjPzc8v2eaeBuomsbZ2+gTaYr8k1gm3bYA== + dependencies: + "@sqltools/formatter" "^1.2.2" + app-root-path "^3.0.0" + buffer "^6.0.3" + chalk "^4.1.0" + 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" + 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" + typescript@^4.3.4: version "4.4.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.3.tgz#bdc5407caa2b109efd4f82fe130656f977a29324" @@ -6843,6 +7081,11 @@ url-parse-lax@^3.0.0: dependencies: prepend-http "^2.0.0" +util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== + util.promisify@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/util.promisify/-/util.promisify-1.1.1.tgz#77832f57ced2c9478174149cae9b96e9918cd54b" @@ -7078,6 +7321,19 @@ xml-name-validator@^3.0.0: resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw== +xml2js@^0.4.23: + version "0.4.23" + resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.23.tgz#a0c69516752421eb2ac758ee4d4ccf58843eac66" + integrity sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug== + dependencies: + sax ">=0.6.0" + xmlbuilder "~11.0.0" + +xmlbuilder@~11.0.0: + version "11.0.1" + resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-11.0.1.tgz#be9bae1c8a046e76b31127726347d0ad7002beb3" + integrity sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA== + xmlchars@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb" @@ -7111,7 +7367,12 @@ yargs-parser@20.x, yargs-parser@^20.2.2: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== -yargs@^16.2.0: +yargs-parser@^21.1.1: + version "21.1.1" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" + integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== + +yargs@^16.0.0, yargs@^16.2.0: version "16.2.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== @@ -7124,6 +7385,19 @@ yargs@^16.2.0: y18n "^5.0.5" yargs-parser "^20.2.2" +yargs@^17.0.1: + version "17.7.1" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.1.tgz#34a77645201d1a8fc5213ace787c220eabbd0967" + integrity sha512-cwiTb08Xuv5fqF4AovYacTFNxk62th7LKJ6BL9IGUpTJrWoU7/7WdQGTP2SjKf1dUNBGzDd28p/Yfs/GI6JrLw== + dependencies: + cliui "^8.0.1" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.3" + y18n "^5.0.5" + yargs-parser "^21.1.1" + yn@3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" @@ -7137,7 +7411,15 @@ zen-observable-ts@^0.8.21: tslib "^1.9.3" zen-observable "^0.8.0" -zen-observable@^0.8.0: +zen-observable-ts@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/zen-observable-ts/-/zen-observable-ts-1.1.0.tgz#2d1aa9d79b87058e9b75698b92791c1838551f83" + integrity sha512-1h4zlLSqI2cRLPJUHJFL8bCWHhkpuXkF+dbGkRaWjgDIG26DmzyshUMrdV/rL3UnR+mhaX4fRq8LPouq0MYYIA== + dependencies: + "@types/zen-observable" "0.8.3" + zen-observable "0.8.15" + +zen-observable@0.8.15, zen-observable@^0.8.0: version "0.8.15" resolved "https://registry.yarnpkg.com/zen-observable/-/zen-observable-0.8.15.tgz#96415c512d8e3ffd920afd3889604e30b9eaac15" integrity sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ== From 18eb7786f74d54e7db3be3f7e0badc4cb2cf1883 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 12 Mar 2023 02:09:47 +0100 Subject: [PATCH 45/91] sync to work in every directory(vscode) --- backend/.eslintrc.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index 0ff67d095..d8d232b25 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -14,6 +14,9 @@ module.exports = { 'plugin:import/typescript', ], settings: { + 'import/parsers': { + '@typescript-eslint/parser': ['.ts', '.tsx'], + }, 'import/resolver': { typescript: true, node: true, @@ -93,7 +96,7 @@ module.exports = { '@typescript-eslint/prefer-regexp-exec': 'off', }, parserOptions: { - tsconfigRootDir: __dirname, + tsconfigRootDir: './', project: ['./tsconfig.json'], // this is to properly reference the referenced project database without requirement of compiling it EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true, From d4b221b6787e611169e666cee26a8bd382172170 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 12 Mar 2023 02:09:56 +0100 Subject: [PATCH 46/91] update eslint command --- backend/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/package.json b/backend/package.json index a7ca1bb3e..d48db9b51 100644 --- a/backend/package.json +++ b/backend/package.json @@ -12,7 +12,7 @@ "clean": "tsc --build --clean", "start": "cross-env TZ=UTC TS_NODE_BASEURL=./build node -r tsconfig-paths/register build/src/index.js", "dev": "cross-env TZ=UTC nodemon -w src --ext ts --exec ts-node -r tsconfig-paths/register src/index.ts", - "lint": "eslint --max-warnings=0 --ext .js,.ts .", + "lint": "eslint --max-warnings=0 .", "test": "cross-env TZ=UTC NODE_ENV=development jest --runInBand --coverage --forceExit --detectOpenHandles", "seed": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/seeds/index.ts", "klicktipp": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/util/klicktipp.ts", From c140e04310d5b7c8577818d7c55b02d6d64219c4 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 21 Mar 2023 14:47:33 +0100 Subject: [PATCH 47/91] ass user relation to allow event --- backend/src/graphql/resolver/ContributionResolver.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index ea84e3ba9..0f7663ddf 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -322,7 +322,8 @@ export class ContributionResolver { const moderator = getUser(context) const contributionToUpdate = await DbContribution.findOne({ - where: { id, confirmedAt: IsNull(), deniedAt: IsNull(), relations: ['user'] }, + where: { id, confirmedAt: IsNull(), deniedAt: IsNull() }, + relations: ['user'], }) if (!contributionToUpdate) { From b64c080447120919951ef1afe2b50f9f4619727b Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 23 Mar 2023 13:27:47 +0100 Subject: [PATCH 48/91] changes requested --- admin/src/components/EditCreationFormular.vue | 1 - .../resolver/ContributionResolver.test.ts | 33 ------------------- .../graphql/resolver/ContributionResolver.ts | 3 +- 3 files changed, 1 insertion(+), 36 deletions(-) diff --git a/admin/src/components/EditCreationFormular.vue b/admin/src/components/EditCreationFormular.vue index 994a734f6..6dbe22ebb 100644 --- a/admin/src/components/EditCreationFormular.vue +++ b/admin/src/components/EditCreationFormular.vue @@ -108,7 +108,6 @@ export default { }, methods: { submitCreation() { - // console.log('submitCreation', this.selected) this.$apollo .mutate({ mutation: adminUpdateContribution, diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 19d19080a..5a6e6d7c6 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -2152,39 +2152,6 @@ describe('ContributionResolver', () => { }) }) - describe.skip('user email does not match creation user', () => { - it('throws an error', async () => { - jest.clearAllMocks() - await expect( - mutate({ - mutation: adminUpdateContribution, - variables: { - id: creation ? creation.id : -1, - amount: new Decimal(300), - memo: 'Danke Bibi!', - creationDate: creation - ? contributionDateFormatter(creation.contributionDate) - : contributionDateFormatter(new Date()), - }, - }), - ).resolves.toEqual( - expect.objectContaining({ - errors: [ - new GraphQLError( - 'User of the pending contribution and send user does not correspond', - ), - ], - }), - ) - }) - - it('logs the error thrown', () => { - expect(logger.error).toBeCalledWith( - 'User of the pending contribution and send user does not correspond', - ) - }) - }) - describe('creation update is not valid', () => { // as this test has not clearly defined that date, it is a false positive it('throws an error', async () => { diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 2a9d96790..ab1c25d2e 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -321,7 +321,6 @@ export class ContributionResolver { const contributionToUpdate = await DbContribution.findOne({ where: { id, confirmedAt: IsNull(), deniedAt: IsNull() }, - relations: ['user'], }) if (!contributionToUpdate) { @@ -358,7 +357,7 @@ export class ContributionResolver { result.date = contributionToUpdate.contributionDate await EVENT_ADMIN_CONTRIBUTION_UPDATE( - contributionToUpdate.user, + { id: contributionToUpdate.userId } as DbUser, moderator, contributionToUpdate, amount, From 90d9b2114ec02ccf4c8911e3f2ca87b6a0a9a988 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 00:38:19 +0100 Subject: [PATCH 49/91] refactor(backend): add klicktipp-api library --- backend/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/package.json b/backend/package.json index 22e75f4af..19427091b 100644 --- a/backend/package.json +++ b/backend/package.json @@ -68,6 +68,7 @@ "eslint-plugin-type-graphql": "^1.0.0", "faker": "^5.5.3", "jest": "^27.2.4", + "klicktipp-api": "^1.0.2", "nodemon": "^2.0.7", "prettier": "^2.3.1", "ts-jest": "^27.0.5", From 34f96eb284ab5c7401d6d139de82ffaf591e3093 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 00:39:48 +0100 Subject: [PATCH 50/91] remove translated library --- backend/src/apis/klicktippConnector.ts | 624 ------------------------- 1 file changed, 624 deletions(-) delete mode 100644 backend/src/apis/klicktippConnector.ts diff --git a/backend/src/apis/klicktippConnector.ts b/backend/src/apis/klicktippConnector.ts deleted file mode 100644 index 0ff741604..000000000 --- a/backend/src/apis/klicktippConnector.ts +++ /dev/null @@ -1,624 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unsafe-return */ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ -/* eslint-disable @typescript-eslint/restrict-template-expressions */ -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import axios, { AxiosRequestConfig, Method } from 'axios' - -export class KlicktippConnector { - private baseURL: string - private sessionName: string - private sessionId: string - private error: string - - constructor(service?: string) { - this.baseURL = service !== undefined ? service : 'https://api.klicktipp.com' - this.sessionName = '' - this.sessionId = '' - } - - /** - * Get last error - * - * @return string an error description of the last error - */ - getLastError(): string { - const result = this.error - return result - } - - /** - * login - * - * @param username The login name of the user to login. - * @param password The password of the user. - * @return TRUE on success - */ - async login(username: string, password: string): Promise { - if (!(username.length > 0 && password.length > 0)) { - throw new Error('Klicktipp Login failed: Illegal Arguments') - } - - const res = await this.httpRequest('/account/login', 'POST', { username, password }, false) - - if (!res.isAxiosError) { - this.sessionId = res.data.sessid - this.sessionName = res.data.session_name - - return true - } - - throw new Error(`Klicktipp Login failed: ${res.response.statusText}`) - } - - /** - * Logs out the user currently logged in. - * - * @return TRUE on success - */ - async logout(): Promise { - const res = await this.httpRequest('/account/logout', 'POST') - - if (!res.isAxiosError) { - this.sessionId = '' - this.sessionName = '' - - return true - } - - throw new Error(`Klicktipp Logout failed: ${res.response.statusText}`) - } - - /** - * Get all subscription processes (lists) of the logged in user. Requires to be logged in. - * - * @return A associative obeject => - */ - async subscriptionProcessIndex(): Promise { - const res = await this.httpRequest('/list', 'GET', {}, true) - - if (!res.isAxiosError) { - return res.data - } - - throw new Error(`Klicktipp Subscription process index failed: ${res.response.statusText}`) - } - - /** - * Get subscription process (list) definition. Requires to be logged in. - * - * @param listid The id of the subscription process - * - * @return An object representing the Klicktipp subscription process. - */ - async subscriptionProcessGet(listid: string): Promise { - if (!listid || listid === '') { - throw new Error('Klicktipp Illegal Arguments') - } - - // retrieve - const res = await this.httpRequest(`/subscriber/${listid}`, 'GET', {}, true) - - if (!res.isAxiosError) { - return res.data - } - - throw new Error(`Klicktipp Subscription process get failed: ${res.response.statusText}`) - } - - /** - * Get subscription process (list) redirection url for given subscription. - * - * @param listid The id of the subscription process. - * @param email The email address of the subscriber. - * - * @return A redirection url as defined in the subscription process. - */ - async subscriptionProcessRedirect(listid: string, email: string): Promise { - if (!listid || listid === '' || !email || email === '') { - throw new Error('Klicktipp Illegal Arguments') - } - - // update - const data = { listid, email } - const res = await this.httpRequest('/list/redirect', 'POST', data) - - if (!res.isAxiosError) { - return res.data - } - - throw new Error( - `Klicktipp Subscription process get redirection url failed: ${res.response.statusText}`, - ) - } - - /** - * Get all manual tags of the logged in user. Requires to be logged in. - * - * @return A associative object => - */ - async tagIndex(): Promise { - const res = await this.httpRequest('/tag', 'GET', {}, true) - - if (!res.isAxiosError) { - return res.data - } - - throw new Error(`Klicktipp Tag index failed: ${res.response.statusText}`) - } - - /** - * Get a tag definition. Requires to be logged in. - * - * @param tagid The tag id. - * - * @return An object representing the Klicktipp tag object. - */ - async tagGet(tagid: string): Promise { - if (!tagid || tagid === '') { - throw new Error('Klicktipp Illegal Arguments') - } - const res = await this.httpRequest(`/tag/${tagid}`, 'GET', {}, true) - - if (!res.isAxiosError) { - return res.data - } - - throw new Error(`Klicktipp Tag get failed: ${res.response.statusText}`) - } - - /** - * Create a new manual tag. Requires to be logged in. - * - * @param name The name of the tag. - * @param text (optional) An additional description of the tag. - * - * @return The id of the newly created tag or false if failed. - */ - async tagCreate(name: string, text?: string): Promise { - if (!name || name === '') { - throw new Error('Klicktipp Illegal Arguments') - } - const data = { - name, - text: text !== undefined ? text : '', - } - const res = await this.httpRequest('/tag', 'POST', data, true) - - if (!res.isAxiosError) { - return res.data - } - - throw new Error(`Klicktipp Tag creation failed: ${res.response.statusText}`) - } - - /** - * Updates a tag. Requires to be logged in. - * - * @param tagid The tag id used to identify which tag to modify. - * @param name (optional) The new tag name. Set empty to leave it unchanged. - * @param text (optional) The new tag description. Set empty to leave it unchanged. - * - * @return TRUE on success - */ - async tagUpdate(tagid: string, name?: string, text?: string): Promise { - if (!tagid || tagid === '' || (name === '' && text === '')) { - throw new Error('Klicktipp Illegal Arguments') - } - const data = { - name: name !== undefined ? name : '', - text: text !== undefined ? text : '', - } - - const res = await this.httpRequest(`/tag/${tagid}`, 'PUT', data, true) - - if (!res.isAxiosError) { - return true - } - - throw new Error(`Klicktipp Tag update failed: ${res.response.statusText}`) - } - - /** - * Deletes a tag. Requires to be logged in. - * - * @param tagid The user id of the user to delete. - * - * @return TRUE on success - */ - async tagDelete(tagid: string): Promise { - if (!tagid || tagid === '') { - throw new Error('Klicktipp Illegal Arguments') - } - - const res = await this.httpRequest(`/tag/${tagid}`, 'DELETE') - - if (!res.isAxiosError) { - return true - } - - throw new Error(`Klicktipp Tag deletion failed: ${res.response.statusText}`) - } - - /** - * Get all contact fields of the logged in user. Requires to be logged in. - * - * @return A associative object => - */ - async fieldIndex(): Promise { - const res = await this.httpRequest('/field', 'GET', {}, true) - - if (!res.isAxiosError) { - return res.data - } - - throw new Error(`Klicktipp Field index failed: ${res.response.statusText}`) - } - - /** - * Subscribe an email. Requires to be logged in. - * - * @param email The email address of the subscriber. - * @param listid (optional) The id subscription process. - * @param tagid (optional) The id of the manual tag the subscriber will be tagged with. - * @param fields (optional) Additional fields of the subscriber. - * - * @return An object representing the Klicktipp subscriber object. - */ - async subscribe( - email: string, - listid?: number, - tagid?: number, - fields?: any, - smsnumber?: string, - ): Promise { - if ((!email || email === '') && smsnumber === '') { - throw new Error('Illegal Arguments') - } - // subscribe - const data = { - email, - fields: fields !== undefined ? fields : {}, - smsnumber: smsnumber !== undefined ? smsnumber : '', - listid: listid !== undefined ? listid : 0, - tagid: tagid !== undefined ? tagid : 0, - } - - const res = await this.httpRequest('/subscriber', 'POST', data, true) - - if (!res.isAxiosError) { - return res.data - } - throw new Error(`Klicktipp Subscription failed: ${res.response.statusText}`) - } - - /** - * Unsubscribe an email. Requires to be logged in. - * - * @param email The email address of the subscriber. - * - * @return TRUE on success - */ - async unsubscribe(email: string): Promise { - if (!email || email === '') { - throw new Error('Klicktipp Illegal Arguments') - } - - // unsubscribe - const data = { email } - - const res = await this.httpRequest('/subscriber/unsubscribe', 'POST', data, true) - - if (!res.isAxiosError) { - return true - } - throw new Error(`Klicktipp Unsubscription failed: ${res.response.statusText}`) - } - - /** - * Tag an email. Requires to be logged in. - * - * @param email The email address of the subscriber. - * @param tagids an array of the manual tag(s) the subscriber will be tagged with. - * - * @return TRUE on success - */ - async tag(email: string, tagids: string): Promise { - if (!email || email === '' || !tagids || tagids === '') { - throw new Error('Klicktipp Illegal Arguments') - } - - // tag - const data = { - email, - tagids, - } - - const res = await this.httpRequest('/subscriber/tag', 'POST', data, true) - - if (!res.isAxiosError) { - return res.data - } - throw new Error(`Klicktipp Tagging failed: ${res.response.statusText}`) - } - - /** - * Untag an email. Requires to be logged in. - * - * @param mixed $email The email address of the subscriber. - * @param mixed $tagid The id of the manual tag that will be removed from the subscriber. - * - * @return TRUE on success. - */ - async untag(email: string, tagid: string): Promise { - if (!email || email === '' || !tagid || tagid === '') { - throw new Error('Klicktipp Illegal Arguments') - } - - // subscribe - const data = { - email, - tagid, - } - - const res = await this.httpRequest('/subscriber/untag', 'POST', data, true) - - if (!res.isAxiosError) { - return true - } - throw new Error(`Klicktipp Untagging failed: ${res.response.statusText}`) - } - - /** - * Resend an autoresponder for an email address. Requires to be logged in. - * - * @param email A valid email address - * @param autoresponder An id of the autoresponder - * - * @return TRUE on success - */ - async resend(email: string, autoresponder: string): Promise { - if (!email || email === '' || !autoresponder || autoresponder === '') { - throw new Error('Klicktipp Illegal Arguments') - } - - // resend/reset autoresponder - const data = { email, autoresponder } - - const res = await this.httpRequest('/subscriber/resend', 'POST', data, true) - - if (!res.isAxiosError) { - return true - } - throw new Error(`Klicktipp Resend failed: ${res.response.statusText}`) - } - - /** - * Get all active subscribers. Requires to be logged in. - * - * @return An array of subscriber ids. - */ - async subscriberIndex(): Promise<[string]> { - const res = await this.httpRequest('/subscriber', 'GET', undefined, true) - - if (!res.isAxiosError) { - return res.data - } - throw new Error(`Klicktipp Subscriber index failed: ${res.response.statusText}`) - } - - /** - * Get subscriber information. Requires to be logged in. - * - * @param subscriberid The subscriber id. - * - * @return An object representing the Klicktipp subscriber. - */ - async subscriberGet(subscriberid: string): Promise { - if (!subscriberid || subscriberid === '') { - throw new Error('Klicktipp Illegal Arguments') - } - - // retrieve - const res = await this.httpRequest(`/subscriber/${subscriberid}`, 'GET', {}, true) - if (!res.isAxiosError) { - return res.data - } - throw new Error(`Klicktipp Subscriber get failed: ${res.response.statusText}`) - } - - /** - * Get a subscriber id by email. Requires to be logged in. - * - * @param email The email address of the subscriber. - * - * @return The id of the subscriber. Use subscriber_get to get subscriber details. - */ - async subscriberSearch(email: string): Promise { - if (!email || email === '') { - throw new Error('Klicktipp Illegal Arguments') - } - // search - const data = { email } - const res = await this.httpRequest('/subscriber/search', 'POST', data, true) - - if (!res.isAxiosError) { - return res.data - } - throw new Error(`Klicktipp Subscriber search failed: ${res.response.statusText}`) - } - - /** - * Get all active subscribers tagged with the given tag id. Requires to be logged in. - * - * @param tagid The id of the tag. - * - * @return An array with id -> subscription date of the tagged subscribers. Use subscriber_get to get subscriber details. - */ - async subscriberTagged(tagid: string): Promise { - if (!tagid || tagid === '') { - throw new Error('Klicktipp Illegal Arguments') - } - - // search - const data = { tagid } - const res = await this.httpRequest('/subscriber/tagged', 'POST', data, true) - - if (!res.isAxiosError) { - return res.data - } - throw new Error(`Klicktipp subscriber tagged failed: ${res.response.statusText}`) - } - - /** - * Updates a subscriber. Requires to be logged in. - * - * @param subscriberid The id of the subscriber to update. - * @param fields (optional) The fields of the subscriber to update - * @param newemail (optional) The new email of the subscriber to update - * - * @return TRUE on success - */ - async subscriberUpdate( - subscriberid: string, - fields?: any, - newemail?: string, - newsmsnumber?: string, - ): Promise { - if (!subscriberid || subscriberid === '') { - throw new Error('Klicktipp Illegal Arguments') - } - - // update - const data = { - fields: fields !== undefined ? fields : {}, - newemail: newemail !== undefined ? newemail : '', - newsmsnumber: newsmsnumber !== undefined ? newsmsnumber : '', - } - const res = await this.httpRequest(`/subscriber/${subscriberid}`, 'PUT', data, true) - if (!res.isAxiosError) { - return true - } - throw new Error(`Klicktipp Subscriber update failed: ${res.response.statusText}`) - } - - /** - * Delete a subscribe. Requires to be logged in. - * - * @param subscriberid The id of the subscriber to update. - * - * @return TRUE on success. - */ - async subscriberDelete(subscriberid: string): Promise { - if (!subscriberid || subscriberid === '') { - throw new Error('Klicktipp Illegal Arguments') - } - - // delete - const res = await this.httpRequest(`/subscriber/${subscriberid}`, 'DELETE', {}, true) - - if (!res.isAxiosError) { - return true - } - throw new Error(`Klicktipp Subscriber deletion failed: ${res.response.statusText}`) - } - - /** - * Subscribe an email. Requires an api key. - * - * @param apikey The api key (listbuildng configuration). - * @param email The email address of the subscriber. - * @param fields (optional) Additional fields of the subscriber. - * - * @return A redirection url as defined in the subscription process. - */ - async signin(apikey: string, email: string, fields?: any, smsnumber?: string): Promise { - if (!apikey || apikey === '' || ((!email || email === '') && smsnumber === '')) { - throw new Error('Klicktipp Illegal Arguments') - } - - // subscribe - const data = { - apikey, - email, - fields: fields !== undefined ? fields : {}, - smsnumber: smsnumber !== undefined ? smsnumber : '', - } - - const res = await this.httpRequest('/subscriber/signin', 'POST', data) - - if (!res.isAxiosError) { - return true - } - throw new Error(`Klicktipp Subscription failed: ${res.response.statusText}`) - } - - /** - * Untag an email. Requires an api key. - * - * @param apikey The api key (listbuildng configuration). - * @param email The email address of the subscriber. - * - * @return TRUE on success - */ - async signout(apikey: string, email: string): Promise { - if (!apikey || apikey === '' || !email || email === '') { - throw new Error('Klicktipp Illegal Arguments') - } - - // untag - const data = { apikey, email } - const res = await this.httpRequest('/subscriber/signout', 'POST', data) - - if (!res.isAxiosError) { - return true - } - throw new Error(`Klicktipp Untagging failed: ${res.response.statusText}`) - } - - /** - * Unsubscribe an email. Requires an api key. - * - * @param apikey The api key (listbuildng configuration). - * @param email The email address of the subscriber. - * - * @return TRUE on success - */ - async signoff(apikey: string, email: string): Promise { - if (!apikey || apikey === '' || !email || email === '') { - throw new Error('Klicktipp Illegal Arguments') - } - - // unsubscribe - const data = { apikey, email } - const res = await this.httpRequest('/subscriber/signoff', 'POST', data) - - if (!res.isAxiosError) { - return true - } - throw new Error(`Klicktipp Unsubscription failed: ${res.response.statusText}`) - } - - async httpRequest(path: string, method?: Method, data?: any, usesession?: boolean): Promise { - if (method === undefined) { - method = 'GET' - } - const options: AxiosRequestConfig = { - baseURL: this.baseURL, - method, - url: path, - data, - headers: { - 'Content-Type': 'application/json', - Content: 'application/json', - Cookie: - usesession && this.sessionName !== '' ? `${this.sessionName}=${this.sessionId}` : '', - }, - } - - return axios(options) - .then((res) => res) - .catch((error) => error) - } -} From 4faa36da391955e49f6b93f25a2aadea085c842d Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 00:40:27 +0100 Subject: [PATCH 51/91] change import to library --- backend/src/apis/KlicktippController.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/src/apis/KlicktippController.ts b/backend/src/apis/KlicktippController.ts index fe9ad563a..a291bb945 100644 --- a/backend/src/apis/KlicktippController.ts +++ b/backend/src/apis/KlicktippController.ts @@ -1,8 +1,10 @@ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { KlicktippConnector } from './klicktippConnector' +import KlicktippConnector from 'klicktipp-api' import CONFIG from '@/config' const klicktippConnector = new KlicktippConnector() From a8a4d62847d12afc6ff31cb67525615b1f5cfc7b Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 00:41:01 +0100 Subject: [PATCH 52/91] create typescript .d.ts file --- backend/@types/klicktipp-api/index.d.ts | 1 + 1 file changed, 1 insertion(+) create mode 100644 backend/@types/klicktipp-api/index.d.ts diff --git a/backend/@types/klicktipp-api/index.d.ts b/backend/@types/klicktipp-api/index.d.ts new file mode 100644 index 000000000..e34bfc6c6 --- /dev/null +++ b/backend/@types/klicktipp-api/index.d.ts @@ -0,0 +1 @@ +declare module 'klicktipp-api' From a78397caf53b5a2aee73b24eecf56b6903e92431 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 00:41:40 +0100 Subject: [PATCH 53/91] change definition of @types to root --- backend/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/tsconfig.json b/backend/tsconfig.json index 52241a0a6..146cd41e3 100644 --- a/backend/tsconfig.json +++ b/backend/tsconfig.json @@ -59,7 +59,7 @@ "@entity/*": ["../database/entity/*", "../../database/build/entity/*"] }, // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ - "typeRoots": ["src/federation/@types", "node_modules/@types"], /* List of folders to include type definitions from. */ + "typeRoots": ["@types", "node_modules/@types"], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ From c2ef4bca8e355026ed6584ea3139bb2a0f3241f3 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 00:42:07 +0100 Subject: [PATCH 54/91] add klicktipp to yarn lock --- backend/yarn.lock | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/yarn.lock b/backend/yarn.lock index 3151557ab..e169a9ce7 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -4526,6 +4526,13 @@ kleur@^3.0.3: resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== +klicktipp-api@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/klicktipp-api/-/klicktipp-api-1.0.2.tgz#a7ba728887c4d9a1c257fa30b78cbe0be92a20ab" + integrity sha512-aQQpuznC0O2W7Oq2BxKDnuLAnGmKTMfudOQ0TAEf0TLv82KH2AsCXl0nbutJ2g1i3MH+sCyGE/r/nwnUhr4QeA== + dependencies: + axios "^0.21.1" + latest-version@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-5.1.0.tgz#119dfe908fe38d15dfa43ecd13fa12ec8832face" From 1d908b3a26fac313e678c91d654a4b5a3b87267e Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 00:45:05 +0100 Subject: [PATCH 55/91] refactor(backend): upgrade coverage to 85% --- backend/jest.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/jest.config.js b/backend/jest.config.js index 66a883b51..f2e2a556d 100644 --- a/backend/jest.config.js +++ b/backend/jest.config.js @@ -6,7 +6,7 @@ module.exports = { collectCoverageFrom: ['src/**/*.ts', '!**/node_modules/**', '!src/seeds/**', '!build/**'], coverageThreshold: { global: { - lines: 81, + lines: 85, }, }, setupFiles: ['/test/testSetup.ts'], From 783831b3de59eddaff219226cbea45732c6e829d Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 00:57:43 +0100 Subject: [PATCH 56/91] Remove unnecessary eslint-disable --- backend/src/apis/KlicktippController.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/backend/src/apis/KlicktippController.ts b/backend/src/apis/KlicktippController.ts index a291bb945..56dd067e9 100644 --- a/backend/src/apis/KlicktippController.ts +++ b/backend/src/apis/KlicktippController.ts @@ -2,8 +2,6 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import KlicktippConnector from 'klicktipp-api' import CONFIG from '@/config' From 43d01cfbf86392ff55751700286b6dfe90f2840c Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 01:04:27 +0100 Subject: [PATCH 57/91] Revert "Remove unnecessary eslint-disable" This reverts commit 783831b3de59eddaff219226cbea45732c6e829d. --- backend/src/apis/KlicktippController.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/src/apis/KlicktippController.ts b/backend/src/apis/KlicktippController.ts index 56dd067e9..a291bb945 100644 --- a/backend/src/apis/KlicktippController.ts +++ b/backend/src/apis/KlicktippController.ts @@ -2,6 +2,8 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import KlicktippConnector from 'klicktipp-api' import CONFIG from '@/config' From eb38eaa6ced57b6126f2b2b794ac312beb4028b9 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 01:06:45 +0100 Subject: [PATCH 58/91] Revert "Remove unnecessary eslint-disable" This reverts commit 783831b3de59eddaff219226cbea45732c6e829d. --- backend/src/apis/KlicktippController.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/src/apis/KlicktippController.ts b/backend/src/apis/KlicktippController.ts index 56dd067e9..a291bb945 100644 --- a/backend/src/apis/KlicktippController.ts +++ b/backend/src/apis/KlicktippController.ts @@ -2,6 +2,8 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import KlicktippConnector from 'klicktipp-api' import CONFIG from '@/config' From 5610e327d3afbd30fac722a92ba589a6a9893508 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 08:11:47 +0100 Subject: [PATCH 59/91] fix(backend): subscription KlickTipp searches user --- frontend/src/components/UserSettings/UserNewsletter.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/components/UserSettings/UserNewsletter.vue b/frontend/src/components/UserSettings/UserNewsletter.vue index 39f3a14af..f17463354 100644 --- a/frontend/src/components/UserSettings/UserNewsletter.vue +++ b/frontend/src/components/UserSettings/UserNewsletter.vue @@ -42,7 +42,6 @@ export default { .mutate({ mutation: this.newsletterState ? subscribeNewsletter : unsubscribeNewsletter, variables: { - email: this.$store.state.email, language: this.newsletterState ? this.$store.state.language : undefined, }, }) From 7149de1b93bfbe0f834ca6650c4ecbc8590651f4 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 08:12:57 +0100 Subject: [PATCH 60/91] remove email from graphql mutation --- frontend/src/graphql/mutations.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/graphql/mutations.js b/frontend/src/graphql/mutations.js index 55858b09b..bd4d6c145 100644 --- a/frontend/src/graphql/mutations.js +++ b/frontend/src/graphql/mutations.js @@ -1,14 +1,14 @@ import gql from 'graphql-tag' export const subscribeNewsletter = gql` - mutation($email: String!, $language: String!) { - subscribeNewsletter(email: $email, language: $language) + mutation($language: String!) { + subscribeNewsletter(language: $language) } ` export const unsubscribeNewsletter = gql` - mutation($email: String!) { - unsubscribeNewsletter(email: $email) + mutation { + unsubscribeNewsletter } ` From 0997d81ca9f6a339fd6728d03b0f5a7abe3d3c6c Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 08:13:25 +0100 Subject: [PATCH 61/91] Remove ununsed Args definition --- backend/src/graphql/arg/SubscribeNewsletterArgs.ts | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 backend/src/graphql/arg/SubscribeNewsletterArgs.ts diff --git a/backend/src/graphql/arg/SubscribeNewsletterArgs.ts b/backend/src/graphql/arg/SubscribeNewsletterArgs.ts deleted file mode 100644 index 98a3bb2d3..000000000 --- a/backend/src/graphql/arg/SubscribeNewsletterArgs.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { ArgsType, Field } from 'type-graphql' - -@ArgsType() -export default class SubscribeNewsletterArgs { - @Field(() => String) - email: string - - @Field(() => String) - language: string -} From d07d76298b1cba69366aaff0762c0402d350ea66 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 08:14:12 +0100 Subject: [PATCH 62/91] email is searched from user object --- .../src/graphql/resolver/KlicktippResolver.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/backend/src/graphql/resolver/KlicktippResolver.ts b/backend/src/graphql/resolver/KlicktippResolver.ts index dd137f07c..7d4444263 100644 --- a/backend/src/graphql/resolver/KlicktippResolver.ts +++ b/backend/src/graphql/resolver/KlicktippResolver.ts @@ -1,7 +1,5 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ -import { Resolver, Query, Authorized, Arg, Mutation, Args } from 'type-graphql' - -import SubscribeNewsletterArgs from '@arg/SubscribeNewsletterArgs' +import { Resolver, Query, Authorized, Arg, Mutation, Args, Ctx } from 'type-graphql' import { getKlickTippUser, @@ -10,6 +8,7 @@ import { klicktippSignIn, } from '@/apis/KlicktippController' import { RIGHTS } from '@/auth/RIGHTS' +import { Context, getUser } from '@/server/context' @Resolver() export class KlicktippResolver { @@ -27,15 +26,18 @@ export class KlicktippResolver { @Authorized([RIGHTS.UNSUBSCRIBE_NEWSLETTER]) @Mutation(() => Boolean) - async unsubscribeNewsletter(@Arg('email') email: string): Promise { - return await unsubscribe(email) + async unsubscribeNewsletter(@Ctx() context: Context): Promise { + const user = getUser(context) + return await unsubscribe(user.emailContact.email) } @Authorized([RIGHTS.SUBSCRIBE_NEWSLETTER]) @Mutation(() => Boolean) async subscribeNewsletter( - @Args() { email, language }: SubscribeNewsletterArgs, + @Arg('language') language: string, + @Ctx() context: Context, ): Promise { - return await klicktippSignIn(email, language) + const user = getUser(context) + return await klicktippSignIn(user.emailContact.email, language) } } From f7af88fcef21324621d9bd142e26e5f00cd18f69 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 08:34:15 +0100 Subject: [PATCH 63/91] unsubscribeNewslette variable language undefined --- frontend/src/components/UserSettings/UserNewsletter.spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/components/UserSettings/UserNewsletter.spec.js b/frontend/src/components/UserSettings/UserNewsletter.spec.js index bb2781586..c21c6b052 100644 --- a/frontend/src/components/UserSettings/UserNewsletter.spec.js +++ b/frontend/src/components/UserSettings/UserNewsletter.spec.js @@ -61,7 +61,7 @@ describe('UserCard_Newsletter', () => { expect(mockAPIcall).toBeCalledWith({ mutation: unsubscribeNewsletter, variables: { - email: 'peter@lustig.de', + language: undefined, }, }) }) @@ -90,7 +90,6 @@ describe('UserCard_Newsletter', () => { expect(mockAPIcall).toBeCalledWith({ mutation: subscribeNewsletter, variables: { - email: 'peter@lustig.de', language: 'de', }, }) From 4081a9eecf829d944d1edff32b7a9d202048507f Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 08:34:33 +0100 Subject: [PATCH 64/91] remove Args import --- backend/src/graphql/resolver/KlicktippResolver.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/KlicktippResolver.ts b/backend/src/graphql/resolver/KlicktippResolver.ts index 7d4444263..661aeb4a6 100644 --- a/backend/src/graphql/resolver/KlicktippResolver.ts +++ b/backend/src/graphql/resolver/KlicktippResolver.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ -import { Resolver, Query, Authorized, Arg, Mutation, Args, Ctx } from 'type-graphql' +import { Resolver, Query, Authorized, Arg, Mutation, Ctx } from 'type-graphql' import { getKlickTippUser, From a3e135969d0f59d97e782a17c15f3e404ff03fa2 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 12:08:47 +0100 Subject: [PATCH 65/91] =?UTF-8?q?fix(frontend):=20FR=20change=20`````=20an?= =?UTF-8?q?d=20``=C2=B4``=20to=20``'``?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/locales/fr.json | 68 ++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/frontend/src/locales/fr.json b/frontend/src/locales/fr.json index 102825acc..0ab1a62d4 100644 --- a/frontend/src/locales/fr.json +++ b/frontend/src/locales/fr.json @@ -23,7 +23,7 @@ "choose-another-community": "Choisissez une autre communauté", "community": "Communauté", "communityMember": "Vous etes un membre actif", - "continue-to-registration": "Continuez l´inscription", + "continue-to-registration": "Continuez l'inscription", "moderator": "Modérateur", "moderators": "Modérateurs", "myContributions": "Mes contributions", @@ -43,20 +43,20 @@ "deleted": "Supprimé", "denied": "supprimé", "in_progress": "Il y a une question du modérateur.", - "myContributionNoteList": "À tout moment vous pouvez éditer ou supprimer les données qui n´ont pas été confirmées.", + "myContributionNoteList": "À tout moment vous pouvez éditer ou supprimer les données qui n'ont pas été confirmées.", "pending": "Inscription en attente de validation" }, "date": "Contribution pour:", "delete": "Supprimer la contribution! Êtes-vous sûr?", "deleted": "La contribution a été supprimée! Mais elle restera visible.", "formText": { - "bringYourTalentsTo": "Apportez vos talents à la communauté! Votre participation bénévole sera récompensée de 20 GDD/heure jusqu´à un plafond de 1000 GDD/mois.", - "describeYourCommunity": "Décrivez votre activité/service à la communauté en mentionnant le nombre d´heures, et calculez le montant à raison de 20 GDD/heure! Après confirmation par l´un de nos collaborateurs, le montant sera crédité sur votre compte.", + "bringYourTalentsTo": "Apportez vos talents à la communauté! Votre participation bénévole sera récompensée de 20 GDD/heure jusqu'à un plafond de 1000 GDD/mois.", + "describeYourCommunity": "Décrivez votre activité/service à la communauté en mentionnant le nombre d'heures, et calculez le montant à raison de 20 GDD/heure! Après confirmation par l'un de nos collaborateurs, le montant sera crédité sur votre compte.", "maxGDDforMonth": "Vous pouvez seulement déclarer un montant maximum de (montant) GDD pour le mois sélectionné.", "openAmountForMonth": "Pour {monthAndYear}, vous pouvez encore déclarer {creation} GDD.", "yourContribution": "Votre contribution au bien commun" }, - "noDateSelected": "Choisissez n´importe quelle date du mois", + "noDateSelected": "Choisissez n'importe quelle date du mois", "selectDate": "Quand a été effectuée votre contribution?", "submit": "Soumettre", "submitted": "La contribution a été soumise.", @@ -70,7 +70,7 @@ "contributionText": "Texte de la contribution", "creation": "Création", "decay": { - "before_startblock_transaction": "Cette transaction n´est pas péremptoire.", + "before_startblock_transaction": "Cette transaction n'est pas péremptoire.", "calculation_decay": "Calcul de la décroissance", "calculation_total": "Calcul du montant total", "decay": "Décroissance", @@ -94,9 +94,9 @@ "email-already-sent": "Nous vous avons déjà envoyé un email il y a moins de 10 minutes.", "empty-transactionlist": "Il y a eu une erreur lors de la transmission du numéro de votre transaction.", "error": "Erreur!", - "no-account": "Malheureusement nous n´avons pas pu trouver de compte (actif) correspondant aux données transmises.", - "no-transactionlist": "Il y a malheureusement eu une erreur. Aucune transaction n´a été envoyée depuis l`serveur.", - "no-user": "Pas d`utilisateur pour cet identifiant.", + "no-account": "Malheureusement nous n'avons pas pu trouver de compte (actif) correspondant aux données transmises.", + "no-transactionlist": "Il y a malheureusement eu une erreur. Aucune transaction n'a été envoyée depuis l'serveur.", + "no-user": "Pas d'utilisateur pour cet identifiant.", "session-expired": "La session a expiré pour des raisons de sécurité.", "unknown-error": "Erreur inconnue: " }, @@ -131,7 +131,7 @@ "memo": "Note", "message": "Message", "new_balance": "Montant du solde après confirmation", - "no_gdd_available": "Vous n´avez pas de GDD à envoyer.", + "no_gdd_available": "Vous n'avez pas de GDD à envoyer.", "password": "Mot de passe", "passwordRepeat": "Répétez le mot de passe", "password_new": "Nouveau mot de passe", @@ -145,7 +145,7 @@ "sender": "Expéditeur", "send_check": "Confirmez la transaction. Veuillez revérifier toutes les données svp!", "send_now": "Envoyez maintenant", - "send_transaction_error": "Malheureusement, la transaction n´a pas pu être effectuée!", + "send_transaction_error": "Malheureusement, la transaction n'a pas pu être effectuée!", "send_transaction_success": "Votre transaction a été effectuée avec succès", "sorry": "Désolé", "thx": "Merci", @@ -155,8 +155,8 @@ "gddCreationTime": "Le champ {_field_} doit comprendre un nombre entre {min} et {max} avec un maximum de une décimale.", "gddSendAmount": "Le champ {_field_} doit comprendre un nombre entre {min} et {max} avec un maximum de deux chiffres après la virgule", "is-not": "Vous ne pouvez pas vous envoyer de Gradido à vous-même", - "usernmae-regex": "Le nom d´utilisateur doit commencer par une lettre, suivi d´au moins deux caractères alphanumériques.", - "usernmae-unique": "Ce nom d´utilisateur est déjà pris." + "usernmae-regex": "Le nom d'utilisateur doit commencer par une lettre, suivi d'au moins deux caractères alphanumériques.", + "usernmae-unique": "Ce nom d'utilisateur est déjà pris." }, "your_amount": "Votre montant" }, @@ -167,7 +167,7 @@ "copy-link": "Copier le lien", "copy-link-with-text": "Copier le lien et le texte", "created": "Le lien a été créé!", - "credit-your-gradido": "Pour l´accréditation du Gradido, cliquer sur le lien!", + "credit-your-gradido": "Pour l'accréditation du Gradido, cliquer sur le lien!", "delete-the-link": "Supprimer le lien?", "deleted": "Le lien a été supprimé!", "expiredOn": "A expiré le", @@ -177,13 +177,13 @@ "link-and-text-copied": "Le lien et votre message ont été copiés dans le presse-papier. Vous pouvez maintenant le joindre à un email ou à un message..", "link-copied": "Le lien a été copié dans le presse-papier. Vous pouvez désormais le coller dans votre email ou votre message.", "link-deleted": "Le lien a été supprimé le on {date}.", - "link-expired": "Le lien n´est plus valide. Sa validité a expiré le {date}.", + "link-expired": "Le lien n'est plus valide. Sa validité a expiré le {date}.", "link-hint": "Attention : tout le monde peut utiliser ce lien. Veuillez en prendre soin!", "link-overview": "Aperçu du lien", "links_count": "Liens actifs", "links_sum": "Ouvrir les liens et les QR codes", - "no-account": "Vous n´avez pas encore de compte Gradido?", - "no-redeem": "Vous n´êtes pas autorisé à percevoir votre propre lien!", + "no-account": "Vous n'avez pas encore de compte Gradido?", + "no-redeem": "Vous n'êtes pas autorisé à percevoir votre propre lien!", "not-copied": "Malheureusement votre appareil ne permet pas de copier! Veuillez copier le lien manuellement svp!", "redeem": "Encaisser", "redeemed": "Encaissé avec succès! Votre compte est crédité de {n} GDD.", @@ -191,8 +191,8 @@ "redeemed-title": "encaisser", "to-login": "Connexion", "to-register": "Enregistrer un nouveau compte.", - "validUntil": "Valide jusqu´au", - "validUntilDate": "Le lien est valide jusqu´au {date}." + "validUntil": "Valide jusqu'au", + "validUntilDate": "Le lien est valide jusqu'au {date}." }, "GDT": "GDT", "gdt": { @@ -208,7 +208,7 @@ "gdt-received": "Gradido Transform (GDT) perçu", "gdtKonto": "Compte GDT", "no-transactions": "Vous ne possédez pas encore Gradido Transform (GDT).", - "not-reachable": "Le Serveur GDT n´est pas accessible.", + "not-reachable": "Le Serveur GDT n'est pas accessible.", "publisher": "Un membre que vous avez référé a apporté un contribution", "raise": "Augmentation", "recruited-member": "Membre invité" @@ -226,15 +226,15 @@ "maxReached": "Max. atteint", "member": "Membre", "message": { - "activateEmail": "Votre compte n´a pas encore été activé. Veuillez vérifier vos emails et cliquer sur le lien d´activation ou faites la demande d´un nouveau lien en utilisant la page qui permet de générer un nouveau mot de passe.", + "activateEmail": "Votre compte n'a pas encore été activé. Veuillez vérifier vos emails et cliquer sur le lien d'activation ou faites la demande d'un nouveau lien en utilisant la page qui permet de générer un nouveau mot de passe.", "checkEmail": "Votre email a bien été vérifié. Vous pouvez vous enregistrer maintenant.", "email": "Nous vous avons envoyé un email.", "errorTitle": "Attention!", - "register": "Vous êtes enregistré maintenant, merci de vérifier votre boîte mail et cliquer sur le lien d´activation.", + "register": "Vous êtes enregistré maintenant, merci de vérifier votre boîte mail et cliquer sur le lien d'activation.", "reply": "Merci, ta réponse a été envoyée.", "reset": "Votre mot de passe a été modifié.", "title": "Merci!", - "unsetPassword": "Votre mot de passe n´a pas été accepté. Merci de le réinitialiser." + "unsetPassword": "Votre mot de passe n'a pas été accepté. Merci de le réinitialiser." }, "navigation": { "admin_area": "Partie administrative", @@ -262,7 +262,7 @@ "send_per_link": "Envoyer GDD via lien", "session": { "extend": "Rester connecter", - "lightText": "S´il n´apparaît aucune activité pendant plus de 10 minutes, la session expirera pour des raisons de sécurité.", + "lightText": "S'il n'apparaît aucune activité pendant plus de 10 minutes, la session expirera pour des raisons de sécurité.", "logoutIn": "Se déconnecter ", "warningText": "Êtes-vous toujours connecté?" }, @@ -285,12 +285,12 @@ "newsletter": { "newsletter": "Information par email", "newsletterFalse": "Vous ne recevrez aucune information par email.", - "newsletterTrue": "Vous recevrez de l´information par email." + "newsletterTrue": "Vous recevrez de l'information par email." }, "password": { "change-password": "Changer le mot de passe", "forgot_pwd": "Mot de passe oublié?", - "resend_subtitle": "Votre lien d´activation a expiré, vous pouvez en obtenir un nouveau ici.", + "resend_subtitle": "Votre lien d'activation a expiré, vous pouvez en obtenir un nouveau ici.", "reset": "Réinitialiser le mot de passe", "reset-password": { "text": "Entrez un nouveau mot de passe que vous utiliserez dans le futur pour vous connecter à votre compte Gradido.." @@ -305,21 +305,21 @@ "showAmountGDD": "Votre montant GDD est visible.", "showAmountGDT": "Votre montant GDT est visible." }, - "signin": "S´identifier", - "signup": "S´inscrire", + "signin": "S'identifier", + "signup": "S'inscrire", "site": { "forgotPassword": { - "heading": "Veuillez entrer l´adresse email sous laquelle vous êtes enregistré ici svp." + "heading": "Veuillez entrer l'adresse email sous laquelle vous êtes enregistré ici svp." }, "resetPassword": { - "heading": "Entrez votre mot de passe et répétez l´action svp." + "heading": "Entrez votre mot de passe et répétez l'action svp." }, "signup": { - "agree": "J´accepte le politique de confidentialité .", + "agree": "J'accepte le politique de confidentialité .", "dont_match": "Les mots de passe ne correspondent pas.", "lowercase": "Une lettre minuscule est requise.", "minimum": "8 caractères minimum.", - "no-whitespace": "Pas d´espace ni d´onglet", + "no-whitespace": "Pas d'espace ni d'onglet", "one_number": "Un chiffre requis.", "special-char": "Un caractère spécial requis (e.g. _ or ä)", "uppercase": "Une lettre majuscule requise." @@ -339,8 +339,8 @@ }, "transaction": { "lastTransactions": "Dernières transactions", - "nullTransactions": "Vous n´avez pas encore de transaction effectuée sur votre compte.", - "receiverDeleted": "Le compte du destinataire n´existe plus", + "nullTransactions": "Vous n'avez pas encore de transaction effectuée sur votre compte.", + "receiverDeleted": "Le compte du destinataire n'existe plus", "receiverNotFound": "Destinataire inconnu", "show_all": "Voir toutes les {count} transactions." }, From 1f136130492e136defc049c17ecdb0ebea6fd32a Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 13:35:03 +0100 Subject: [PATCH 66/91] remove language from mutation --- backend/src/graphql/resolver/KlicktippResolver.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/backend/src/graphql/resolver/KlicktippResolver.ts b/backend/src/graphql/resolver/KlicktippResolver.ts index 661aeb4a6..f3681ce29 100644 --- a/backend/src/graphql/resolver/KlicktippResolver.ts +++ b/backend/src/graphql/resolver/KlicktippResolver.ts @@ -33,11 +33,8 @@ export class KlicktippResolver { @Authorized([RIGHTS.SUBSCRIBE_NEWSLETTER]) @Mutation(() => Boolean) - async subscribeNewsletter( - @Arg('language') language: string, - @Ctx() context: Context, - ): Promise { + async subscribeNewsletter(@Ctx() context: Context): Promise { const user = getUser(context) - return await klicktippSignIn(user.emailContact.email, language) + return await klicktippSignIn(user.emailContact.email, user.language) } } From 68064a9797272ecc03aaff5b27b51951a2cc598e Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 13:35:43 +0100 Subject: [PATCH 67/91] remove language from mutation definition --- frontend/src/graphql/mutations.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/graphql/mutations.js b/frontend/src/graphql/mutations.js index bd4d6c145..4b43cade4 100644 --- a/frontend/src/graphql/mutations.js +++ b/frontend/src/graphql/mutations.js @@ -1,8 +1,8 @@ import gql from 'graphql-tag' export const subscribeNewsletter = gql` - mutation($language: String!) { - subscribeNewsletter(language: $language) + mutation { + subscribeNewsletter } ` From 5a960a6e27d3cebcabbfe4c9cc04b1fae623cf02 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 13:36:18 +0100 Subject: [PATCH 68/91] Frontend mutation call remove language --- frontend/src/components/UserSettings/UserNewsletter.vue | 3 --- 1 file changed, 3 deletions(-) diff --git a/frontend/src/components/UserSettings/UserNewsletter.vue b/frontend/src/components/UserSettings/UserNewsletter.vue index f17463354..50e442a29 100644 --- a/frontend/src/components/UserSettings/UserNewsletter.vue +++ b/frontend/src/components/UserSettings/UserNewsletter.vue @@ -41,9 +41,6 @@ export default { this.$apollo .mutate({ mutation: this.newsletterState ? subscribeNewsletter : unsubscribeNewsletter, - variables: { - language: this.newsletterState ? this.$store.state.language : undefined, - }, }) .then(() => { this.$store.commit('newsletterState', this.newsletterState) From 06a5cd678bb27d4c8b260e4957ca8daa09320bb1 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 24 Mar 2023 13:36:25 +0100 Subject: [PATCH 69/91] Fix test --- frontend/src/components/UserSettings/UserNewsletter.spec.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/frontend/src/components/UserSettings/UserNewsletter.spec.js b/frontend/src/components/UserSettings/UserNewsletter.spec.js index c21c6b052..b211ec169 100644 --- a/frontend/src/components/UserSettings/UserNewsletter.spec.js +++ b/frontend/src/components/UserSettings/UserNewsletter.spec.js @@ -60,9 +60,6 @@ describe('UserCard_Newsletter', () => { it('calls the unsubscribe mutation', () => { expect(mockAPIcall).toBeCalledWith({ mutation: unsubscribeNewsletter, - variables: { - language: undefined, - }, }) }) @@ -89,9 +86,6 @@ describe('UserCard_Newsletter', () => { it('calls the subscribe mutation', () => { expect(mockAPIcall).toBeCalledWith({ mutation: subscribeNewsletter, - variables: { - language: 'de', - }, }) }) From 4c4da6e929c0fd345767a099f21dcf950e82b3f3 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 27 Mar 2023 23:59:46 +0200 Subject: [PATCH 70/91] fixed linting --- backend/src/graphql/resolver/TransactionLinkResolver.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index 2d2bb3b68..e1c73b98c 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -453,7 +453,7 @@ describe('TransactionLinkResolver', () => { { email: 'bibi@bloxberg.de' }, { relations: ['user'] }, ) - expect(DbEvent.find()).resolves.toContainEqual( + await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventType.CONTRIBUTION_LINK_REDEEM, affectedUserId: userConatct.user.id, From f6071d6e078620429472b83875c4ec3222e8f638 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 28 Mar 2023 00:25:14 +0200 Subject: [PATCH 71/91] fix linting --- backend/src/graphql/resolver/UserResolver.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index b30e82f13..205f27e94 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -873,7 +873,7 @@ describe('UserResolver', () => { { email: 'bibi@bloxberg.de' }, { relations: ['user'] }, ) - expect(DbEvent.find()).resolves.toContainEqual( + await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventType.LOGOUT, affectedUserId: userConatct.user.id, @@ -1042,7 +1042,7 @@ describe('UserResolver', () => { { email: 'bibi@bloxberg.de' }, { relations: ['user'] }, ) - expect(DbEvent.find()).resolves.toContainEqual( + await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventType.EMAIL_FORGOT_PASSWORD, affectedUserId: userConatct.user.id, @@ -1180,7 +1180,7 @@ describe('UserResolver', () => { { email: 'bibi@bloxberg.de' }, { relations: ['user'] }, ) - expect(DbEvent.find()).resolves.toContainEqual( + await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventType.USER_INFO_UPDATE, affectedUserId: userConatct.user.id, @@ -1568,7 +1568,7 @@ describe('UserResolver', () => { { email: 'peter@lustig.de' }, { relations: ['user'] }, ) - expect(DbEvent.find()).resolves.toContainEqual( + await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventType.ADMIN_USER_ROLE_SET, affectedUserId: userConatct.user.id, @@ -1770,7 +1770,7 @@ describe('UserResolver', () => { { email: 'peter@lustig.de' }, { relations: ['user'] }, ) - expect(DbEvent.find()).resolves.toContainEqual( + await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventType.ADMIN_USER_DELETE, affectedUserId: userConatct.user.id, @@ -2064,7 +2064,7 @@ describe('UserResolver', () => { { email: 'peter@lustig.de' }, { relations: ['user'] }, ) - expect(DbEvent.find()).resolves.toContainEqual( + await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventType.ADMIN_USER_UNDELETE, affectedUserId: userConatct.user.id, From 00a2ba2387d50ab32a73a2f87ce91e02ff06a4ee Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 28 Mar 2023 01:08:30 +0200 Subject: [PATCH 72/91] lint fixes --- backend/src/graphql/resolver/ContributionResolver.test.ts | 3 --- backend/src/graphql/resolver/TransactionLinkResolver.test.ts | 2 -- backend/src/graphql/resolver/TransactionLinkResolver.ts | 2 -- backend/src/graphql/resolver/UserResolver.test.ts | 2 -- 4 files changed, 9 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index febe6ef6b..1d92ed8b9 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -51,9 +51,6 @@ import { creationFactory } from '@/seeds/factory/creation' import { creations } from '@/seeds/creation/index' import { peterLustig } from '@/seeds/users/peter-lustig' import { Event as DbEvent } from '@entity/Event' -import { Contribution } from '@entity/Contribution' -import { Transaction as DbTransaction } from '@entity/Transaction' -import { User } from '@entity/User' import { EventType } from '@/event/Event' import { logger, i18n as localization } from '@test/testSetup' import { raeuberHotzenplotz } from '@/seeds/users/raeuber-hotzenplotz' diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index 16ce36822..2466f9f6f 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -29,8 +29,6 @@ import { confirmContribution, } from '@/seeds/graphql/mutations' import { listTransactionLinksAdmin } from '@/seeds/graphql/queries' -import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' -import { User } from '@entity/User' import { Transaction } from '@entity/Transaction' import { UnconfirmedContribution } from '@model/UnconfirmedContribution' import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.ts b/backend/src/graphql/resolver/TransactionLinkResolver.ts index 90aff9056..6aa829ac1 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.ts @@ -33,8 +33,6 @@ import { calculateDecay } from '@/util/decay' import QueryLinkResult from '@union/QueryLinkResult' import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' import LogError from '@/server/LogError' -import { getLastTransaction } from './util/getLastTransaction' -import transactionLinkList from './util/transactionLinkList' import { EVENT_CONTRIBUTION_LINK_REDEEM, EVENT_TRANSACTION_LINK_CREATE, diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index c81d76800..f92b01f3f 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -44,10 +44,8 @@ import { import { contributionLinkFactory } from '@/seeds/factory/contributionLink' import { transactionLinkFactory } from '@/seeds/factory/transactionLink' import { ContributionLink } from '@model/ContributionLink' -import { TransactionLink } from '@entity/TransactionLink' import { EventType } from '@/event/Event' import { Event as DbEvent } from '@entity/Event' -import { validate as validateUUID, version as versionUUID } from 'uuid' import { peterLustig } from '@/seeds/users/peter-lustig' import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { stephenHawking } from '@/seeds/users/stephen-hawking' From 69a29f0a31ecb432c10d7ccd5cdb710e89182616 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 28 Mar 2023 01:36:52 +0200 Subject: [PATCH 73/91] fix linting --- backend/.eslintrc.js | 2 ++ backend/src/apis/KlicktippController.ts | 1 + backend/src/event/EVENT_ACTIVATE_ACCOUNT.ts | 1 + .../src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts | 3 ++- .../src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts | 3 ++- .../src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts | 3 ++- backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts | 3 ++- .../event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts | 3 ++- .../event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts | 1 + .../event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts | 3 ++- .../EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts | 1 + .../src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts | 3 ++- .../event/EVENT_ADMIN_SEND_CONFIRMATION_EMAIL.ts | 1 + backend/src/event/EVENT_CONTRIBUTION_CREATE.ts | 3 ++- backend/src/event/EVENT_CONTRIBUTION_DELETE.ts | 3 ++- .../src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts | 3 ++- .../src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts | 1 + backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts | 3 ++- backend/src/event/EVENT_LOGIN.ts | 1 + backend/src/event/EVENT_REGISTER.ts | 1 + .../EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL.ts | 1 + backend/src/event/EVENT_SEND_CONFIRMATION_EMAIL.ts | 1 + backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts | 3 ++- backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts | 1 + backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts | 3 ++- backend/src/event/EVENT_TRANSACTION_RECEIVE.ts | 3 ++- backend/src/event/EVENT_TRANSACTION_SEND.ts | 3 ++- backend/src/event/Event.ts | 7 ++++--- .../src/graphql/resolver/CommunityResolver.test.ts | 2 +- backend/src/graphql/resolver/CommunityResolver.ts | 2 +- .../resolver/ContributionLinkResolver.test.ts | 2 +- .../resolver/ContributionMessageResolver.test.ts | 2 +- .../graphql/resolver/ContributionResolver.test.ts | 2 +- .../src/graphql/resolver/ContributionResolver.ts | 14 +++++++------- .../resolver/TransactionLinkResolver.test.ts | 6 +++--- .../graphql/resolver/TransactionResolver.test.ts | 2 +- backend/src/graphql/resolver/UserResolver.test.ts | 2 +- 37 files changed, 64 insertions(+), 35 deletions(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index d8d232b25..2654104dc 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -94,6 +94,8 @@ module.exports = { 'no-void': ['error', { allowAsStatement: true }], // ignore prefer-regexp-exec rule to allow string.match(regex) '@typescript-eslint/prefer-regexp-exec': 'off', + // this should not run on ts files: https://github.com/import-js/eslint-plugin-import/issues/2215#issuecomment-911245486 + 'import/unambiguous': 'off', }, parserOptions: { tsconfigRootDir: './', diff --git a/backend/src/apis/KlicktippController.ts b/backend/src/apis/KlicktippController.ts index a291bb945..70c0f95b1 100644 --- a/backend/src/apis/KlicktippController.ts +++ b/backend/src/apis/KlicktippController.ts @@ -4,6 +4,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +// eslint-disable-next-line import/no-relative-parent-imports import KlicktippConnector from 'klicktipp-api' import CONFIG from '@/config' diff --git a/backend/src/event/EVENT_ACTIVATE_ACCOUNT.ts b/backend/src/event/EVENT_ACTIVATE_ACCOUNT.ts index 755cc8fe2..98328a008 100644 --- a/backend/src/event/EVENT_ACTIVATE_ACCOUNT.ts +++ b/backend/src/event/EVENT_ACTIVATE_ACCOUNT.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ACTIVATE_ACCOUNT = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts index c85a7a12c..fab0708a4 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts @@ -1,7 +1,8 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_CONFIRM = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts index a10ff1a35..db3fdef32 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts @@ -1,7 +1,8 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_CREATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts index d3dd5508e..515813bef 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts @@ -1,7 +1,8 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_DELETE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts index 5f1203766..6fcdc0312 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts @@ -1,7 +1,8 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_DENY = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts index 2ead791ed..a85df138b 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts @@ -1,7 +1,8 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_LINK_CREATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts index b5816e45d..1e6f9f2eb 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts @@ -1,6 +1,7 @@ import { User as DbUser } from '@entity/User' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_LINK_DELETE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts index 6824833b8..73cc6ce88 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts @@ -1,7 +1,8 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts index f07d38e98..7e87d53ec 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts @@ -2,6 +2,7 @@ import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts index 60315249a..8728e6cd5 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts @@ -1,7 +1,8 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_UPDATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_SEND_CONFIRMATION_EMAIL.ts b/backend/src/event/EVENT_ADMIN_SEND_CONFIRMATION_EMAIL.ts index da4907930..d0e363b05 100644 --- a/backend/src/event/EVENT_ADMIN_SEND_CONFIRMATION_EMAIL.ts +++ b/backend/src/event/EVENT_ADMIN_SEND_CONFIRMATION_EMAIL.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_SEND_CONFIRMATION_EMAIL = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts b/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts index 50cdbcd18..ebf6c1970 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts @@ -1,7 +1,8 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_CREATE = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts b/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts index eab04bf47..153c9ef36 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts @@ -1,7 +1,8 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_DELETE = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts b/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts index 395772ac9..5297fb114 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts @@ -1,9 +1,10 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_LINK_REDEEM = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts b/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts index b06685a6d..8e7896d58 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts @@ -2,6 +2,7 @@ import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_MESSAGE_CREATE = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts b/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts index 82f14edd6..b998acaa0 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts @@ -1,7 +1,8 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_UPDATE = async ( diff --git a/backend/src/event/EVENT_LOGIN.ts b/backend/src/event/EVENT_LOGIN.ts index 2c1e763ec..f7e5f80d8 100644 --- a/backend/src/event/EVENT_LOGIN.ts +++ b/backend/src/event/EVENT_LOGIN.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_LOGIN = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_REGISTER.ts b/backend/src/event/EVENT_REGISTER.ts index 73c6bf4f9..4300bc7f3 100644 --- a/backend/src/event/EVENT_REGISTER.ts +++ b/backend/src/event/EVENT_REGISTER.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_REGISTER = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL.ts b/backend/src/event/EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL.ts index 3110ece1f..7c991fba4 100644 --- a/backend/src/event/EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL.ts +++ b/backend/src/event/EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_SEND_CONFIRMATION_EMAIL.ts b/backend/src/event/EVENT_SEND_CONFIRMATION_EMAIL.ts index b387c0e60..78fc2b867 100644 --- a/backend/src/event/EVENT_SEND_CONFIRMATION_EMAIL.ts +++ b/backend/src/event/EVENT_SEND_CONFIRMATION_EMAIL.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_SEND_CONFIRMATION_EMAIL = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts b/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts index 36fdb3ff0..3a520dee4 100644 --- a/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts +++ b/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts @@ -1,7 +1,8 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_TRANSACTION_LINK_CREATE = async ( diff --git a/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts b/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts index d15c786a8..3ffc3c9c0 100644 --- a/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts +++ b/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts @@ -1,6 +1,7 @@ import { User as DbUser } from '@entity/User' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_TRANSACTION_LINK_DELETE = async ( diff --git a/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts b/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts index 58307a4e1..01ab046e3 100644 --- a/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts +++ b/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts @@ -1,7 +1,8 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_TRANSACTION_LINK_REDEEM = async ( diff --git a/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts b/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts index acb2f5881..7cb4b96a8 100644 --- a/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts +++ b/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts @@ -1,7 +1,8 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_TRANSACTION_RECEIVE = async ( diff --git a/backend/src/event/EVENT_TRANSACTION_SEND.ts b/backend/src/event/EVENT_TRANSACTION_SEND.ts index a342cb0aa..6d2960314 100644 --- a/backend/src/event/EVENT_TRANSACTION_SEND.ts +++ b/backend/src/event/EVENT_TRANSACTION_SEND.ts @@ -1,7 +1,8 @@ -import Decimal from 'decimal.js-light' +import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' import { Event as DbEvent } from '@entity/Event' +/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_TRANSACTION_SEND = async ( diff --git a/backend/src/event/Event.ts b/backend/src/event/Event.ts index cdb05748c..cce5946ee 100644 --- a/backend/src/event/Event.ts +++ b/backend/src/event/Event.ts @@ -1,3 +1,4 @@ +/* eslint-disable import/no-cycle */ import { Event as DbEvent } from '@entity/Event' import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' @@ -5,8 +6,8 @@ import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' -import Decimal from 'decimal.js-light' -import { EventType } from './Event' +import { Decimal } from 'decimal.js-light' +import { EventType } from './EventType' export const Event = ( type: EventType, @@ -34,7 +35,7 @@ export const Event = ( return event } -export { EventType } from './EventType' +export { EventType } export { EVENT_ACTIVATE_ACCOUNT } from './EVENT_ACTIVATE_ACCOUNT' export { EVENT_ADMIN_CONTRIBUTION_CONFIRM } from './EVENT_ADMIN_CONTRIBUTION_CONFIRM' diff --git a/backend/src/graphql/resolver/CommunityResolver.test.ts b/backend/src/graphql/resolver/CommunityResolver.test.ts index 1e8f6a00f..f4352c095 100644 --- a/backend/src/graphql/resolver/CommunityResolver.test.ts +++ b/backend/src/graphql/resolver/CommunityResolver.test.ts @@ -5,8 +5,8 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { getCommunities } from '@/seeds/graphql/queries' import { Community as DbCommunity } from '@entity/Community' +import { getCommunities } from '@/seeds/graphql/queries' import { testEnvironment } from '@test/helpers' let query: any diff --git a/backend/src/graphql/resolver/CommunityResolver.ts b/backend/src/graphql/resolver/CommunityResolver.ts index 1292fa55f..6aca41472 100644 --- a/backend/src/graphql/resolver/CommunityResolver.ts +++ b/backend/src/graphql/resolver/CommunityResolver.ts @@ -1,7 +1,7 @@ import { Resolver, Query, Authorized } from 'type-graphql' -import { Community } from '@model/Community' import { Community as DbCommunity } from '@entity/Community' +import { Community } from '@model/Community' import { RIGHTS } from '@/auth/RIGHTS' diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts index 961f85bcd..6a69e257e 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts @@ -7,6 +7,7 @@ import { Decimal } from 'decimal.js-light' import { GraphQLError } from 'graphql' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' +import { Event as DbEvent } from '@entity/Event' import { logger } from '@test/testSetup' import { login, @@ -20,7 +21,6 @@ import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' import { userFactory } from '@/seeds/factory/user' import { EventType } from '@/event/Event' -import { Event as DbEvent } from '@entity/Event' let mutate: any, query: any, con: any let testEnv: any diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts index 7e685c44e..6b2c7c4d8 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts @@ -7,6 +7,7 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { GraphQLError } from 'graphql' +import { Event as DbEvent } from '@entity/Event' import { cleanDB, resetToken, testEnvironment } from '@test/helpers' import { logger, i18n as localization } from '@test/testSetup' import { @@ -21,7 +22,6 @@ import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' import { sendAddedContributionMessageEmail } from '@/emails/sendEmailVariants' import { EventType } from '@/event/Event' -import { Event as DbEvent } from '@entity/Event' jest.mock('@/emails/sendEmailVariants', () => { const originalModule = jest.requireActual('@/emails/sendEmailVariants') diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 1d92ed8b9..84dd6cb19 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -12,6 +12,7 @@ import { Contribution } from '@entity/Contribution' import { Transaction as DbTransaction } from '@entity/Transaction' import { User } from '@entity/User' import { UserInputError } from 'apollo-server-express' +import { Event as DbEvent } from '@entity/Event' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { stephenHawking } from '@/seeds/users/stephen-hawking' @@ -50,7 +51,6 @@ import { userFactory } from '@/seeds/factory/user' import { creationFactory } from '@/seeds/factory/creation' import { creations } from '@/seeds/creation/index' import { peterLustig } from '@/seeds/users/peter-lustig' -import { Event as DbEvent } from '@entity/Event' import { EventType } from '@/event/Event' import { logger, i18n as localization } from '@test/testSetup' import { raeuberHotzenplotz } from '@/seeds/users/raeuber-hotzenplotz' diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 1df8360c4..83cf29fc7 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -12,6 +12,13 @@ import { Transaction as DbTransaction } from '@entity/Transaction' import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' import { getLastTransaction } from './util/getLastTransaction' import { findContributions } from './util/findContributions' +import { + getUserCreation, + validateContribution, + updateCreations, + isValidDateString, + getOpenCreations, +} from './util/creations' import { AdminUpdateContribution } from '@model/AdminUpdateContribution' import { Contribution, ContributionListResult } from '@model/Contribution' import { Decay } from '@model/Decay' @@ -30,13 +37,6 @@ import AdminUpdateContributionArgs from '@arg/AdminUpdateContributionArgs' import { RIGHTS } from '@/auth/RIGHTS' import { Context, getUser, getClientTimezoneOffset } from '@/server/context' import { backendLogger as logger } from '@/server/logger' -import { - getUserCreation, - validateContribution, - updateCreations, - isValidDateString, - getOpenCreations, -} from './util/creations' import { EVENT_CONTRIBUTION_CREATE, EVENT_CONTRIBUTION_DELETE, diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index 2466f9f6f..5c2fff0ad 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -10,6 +10,9 @@ import { ContributionLink as DbContributionLink } from '@entity/ContributionLink import { User } from '@entity/User' import { Decimal } from 'decimal.js-light' import { GraphQLError } from 'graphql' +import { Transaction } from '@entity/Transaction' +import { Event as DbEvent } from '@entity/Event' +import { UserContact } from '@entity/UserContact' import { transactionLinkCode } from './TransactionLinkResolver' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' @@ -29,13 +32,10 @@ import { confirmContribution, } from '@/seeds/graphql/mutations' import { listTransactionLinksAdmin } from '@/seeds/graphql/queries' -import { Transaction } from '@entity/Transaction' import { UnconfirmedContribution } from '@model/UnconfirmedContribution' import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' import { logger } from '@test/testSetup' import { EventType } from '@/event/Event' -import { Event as DbEvent } from '@entity/Event' -import { UserContact } from '@entity/UserContact' // mock semaphore to allow use fake timers jest.mock('@/util/TRANSACTIONS_LOCK') diff --git a/backend/src/graphql/resolver/TransactionResolver.test.ts b/backend/src/graphql/resolver/TransactionResolver.test.ts index 696fc2c54..f26234363 100644 --- a/backend/src/graphql/resolver/TransactionResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionResolver.test.ts @@ -9,6 +9,7 @@ import { Decimal } from 'decimal.js-light' import { Transaction } from '@entity/Transaction' import { User } from '@entity/User' import { GraphQLError } from 'graphql' +import { Event as DbEvent } from '@entity/Event' import { findUserByEmail } from './UserResolver' import { EventType } from '@/event/Event' import { userFactory } from '@/seeds/factory/user' @@ -22,7 +23,6 @@ import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { garrickOllivander } from '@/seeds/users/garrick-ollivander' import { peterLustig } from '@/seeds/users/peter-lustig' import { stephenHawking } from '@/seeds/users/stephen-hawking' -import { Event as DbEvent } from '@entity/Event' import { cleanDB, testEnvironment } from '@test/helpers' import { logger } from '@test/testSetup' diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index f92b01f3f..5a372bf72 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -11,6 +11,7 @@ import { User } from '@entity/User' import { TransactionLink } from '@entity/TransactionLink' import { validate as validateUUID, version as versionUUID } from 'uuid' import { UserContact } from '@entity/UserContact' +import { Event as DbEvent } from '@entity/Event' import { OptInType } from '@enum/OptInType' import { UserContactType } from '@enum/UserContactType' import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' @@ -45,7 +46,6 @@ import { contributionLinkFactory } from '@/seeds/factory/contributionLink' import { transactionLinkFactory } from '@/seeds/factory/transactionLink' import { ContributionLink } from '@model/ContributionLink' import { EventType } from '@/event/Event' -import { Event as DbEvent } from '@entity/Event' import { peterLustig } from '@/seeds/users/peter-lustig' import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { stephenHawking } from '@/seeds/users/stephen-hawking' From d6536f275fcf4df34193df2b4884e444308ac9b2 Mon Sep 17 00:00:00 2001 From: Hannes Heine Date: Tue, 28 Mar 2023 01:49:08 +0200 Subject: [PATCH 74/91] Update backend/src/graphql/resolver/KlicktippResolver.ts Co-authored-by: Ulf Gebhardt --- backend/src/graphql/resolver/KlicktippResolver.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/KlicktippResolver.ts b/backend/src/graphql/resolver/KlicktippResolver.ts index f3681ce29..0b054ddcc 100644 --- a/backend/src/graphql/resolver/KlicktippResolver.ts +++ b/backend/src/graphql/resolver/KlicktippResolver.ts @@ -28,7 +28,7 @@ export class KlicktippResolver { @Mutation(() => Boolean) async unsubscribeNewsletter(@Ctx() context: Context): Promise { const user = getUser(context) - return await unsubscribe(user.emailContact.email) + return unsubscribe(user.emailContact.email) } @Authorized([RIGHTS.SUBSCRIBE_NEWSLETTER]) From 3c9dca5b46c297c655d384f9c5f9a80fe539543a Mon Sep 17 00:00:00 2001 From: Hannes Heine Date: Tue, 28 Mar 2023 01:49:27 +0200 Subject: [PATCH 75/91] Update backend/src/graphql/resolver/KlicktippResolver.ts Co-authored-by: Ulf Gebhardt --- backend/src/graphql/resolver/KlicktippResolver.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/KlicktippResolver.ts b/backend/src/graphql/resolver/KlicktippResolver.ts index 0b054ddcc..31bde0581 100644 --- a/backend/src/graphql/resolver/KlicktippResolver.ts +++ b/backend/src/graphql/resolver/KlicktippResolver.ts @@ -35,6 +35,6 @@ export class KlicktippResolver { @Mutation(() => Boolean) async subscribeNewsletter(@Ctx() context: Context): Promise { const user = getUser(context) - return await klicktippSignIn(user.emailContact.email, user.language) + return klicktippSignIn(user.emailContact.email, user.language) } } From a81b364fef2a20900c1e75aaad97579006ae2738 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 28 Mar 2023 12:57:34 +0200 Subject: [PATCH 76/91] fix admin create contribution --- admin/src/components/CreationFormular.spec.js | 1 + admin/src/components/CreationFormular.vue | 1 + 2 files changed, 2 insertions(+) diff --git a/admin/src/components/CreationFormular.spec.js b/admin/src/components/CreationFormular.spec.js index c22b319a9..8f8cc03b0 100644 --- a/admin/src/components/CreationFormular.spec.js +++ b/admin/src/components/CreationFormular.spec.js @@ -145,6 +145,7 @@ describe('CreationFormular', () => { it('sends ... to apollo', () => { expect(adminCreateContributionMock).toBeCalledWith({ + email: 'benjamin@bluemchen.de', creationDate: getCreationDate(2), amount: 90, memo: 'Test create coins', diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue index aeaa84cc6..df8611c3b 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -140,6 +140,7 @@ export default { .mutate({ mutation: adminCreateContribution, variables: { + email: this.item.email, creationDate: this.selected.date, amount: Number(this.value), memo: this.text, From a4c82ae1456360b7c164731b21ab5ae6e997a315 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 28 Mar 2023 13:06:37 +0200 Subject: [PATCH 77/91] remove skipped tests as thay are depreciated --- .../resolver/ContributionResolver.test.ts | 50 ------------------- 1 file changed, 50 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 3c9241d7d..dcd24529e 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -2077,56 +2077,6 @@ describe('ContributionResolver', () => { // stephen@hawking.uk: [1000, 1000, 1000] - deleted // garrick@ollivander.com: [1000, 1000, 1000] - not activated - describe.skip('user for creation to update does not exist', () => { - it('throws an error', async () => { - jest.clearAllMocks() - await expect( - mutate({ - mutation: adminUpdateContribution, - variables: { - id: 1, - amount: new Decimal(300), - memo: 'Danke Bibi!', - creationDate: contributionDateFormatter(new Date()), - }, - }), - ).resolves.toEqual( - expect.objectContaining({ - errors: [new GraphQLError('Could not find User')], - }), - ) - }) - - it('logs the error "Could not find User"', () => { - expect(logger.error).toBeCalledWith('Could not find User', 'bob@baumeister.de') - }) - }) - - describe.skip('user for creation to update is deleted', () => { - it('throws an error', async () => { - jest.clearAllMocks() - await expect( - mutate({ - mutation: adminUpdateContribution, - variables: { - id: 1, - amount: new Decimal(300), - memo: 'Danke Bibi!', - creationDate: contributionDateFormatter(new Date()), - }, - }), - ).resolves.toEqual( - expect.objectContaining({ - errors: [new GraphQLError('User was deleted')], - }), - ) - }) - - it('logs the error "User was deleted"', () => { - expect(logger.error).toBeCalledWith('User was deleted', 'stephen@hawking.uk') - }) - }) - describe('creation does not exist', () => { it('throws an error', async () => { jest.clearAllMocks() From e08c156acfad5122772d5c8ebf051fef143a0c63 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 29 Mar 2023 09:47:51 +0200 Subject: [PATCH 78/91] merge conflict solved --- backend/src/graphql/resolver/UserResolver.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index 93dcde73c..d3c78e2af 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -216,7 +216,7 @@ describe('UserResolver', () => { }) }) - it('stores the EMAIL_CONFIRMATION event in the database', () => { + it('stores the EMAIL_CONFIRMATION event in the database', async () => { await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventType.EMAIL_CONFIRMATION, @@ -363,7 +363,7 @@ describe('UserResolver', () => { ) }) - it('stores the USER_ACTIVATE_ACCOUNT event in the database', () => { + it('stores the USER_ACTIVATE_ACCOUNT event in the database', async () => { await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventType.USER_ACTIVATE_ACCOUNT, @@ -373,7 +373,7 @@ describe('UserResolver', () => { ) }) - it('stores the USER_REGISTER_REDEEM event in the database', () => { + it('stores the USER_REGISTER_REDEEM event in the database', async () => { await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventType.USER_REGISTER_REDEEM, @@ -955,7 +955,7 @@ describe('UserResolver', () => { ) }) - it('stores the USER_LOGIN event in the database', () => { + it('stores the USER_LOGIN event in the database', async () => { await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventType.USER_LOGIN, From afd5703c807442f2c2a834045a538b1aadb1cff0 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 29 Mar 2023 11:06:47 +0200 Subject: [PATCH 79/91] missing event tests --- .../resolver/TransactionLinkResolver.test.ts | 109 +++++++++++++++++- 1 file changed, 108 insertions(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index d86f260fe..cdb832963 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -22,6 +22,7 @@ import { createContribution, updateContribution, createTransactionLink, + deleteTransactionLink, confirmContribution, } from '@/seeds/graphql/mutations' import { listTransactionLinksAdmin } from '@/seeds/graphql/queries' @@ -573,6 +574,7 @@ describe('TransactionLinkResolver', () => { describe('link exists', () => { let myCode: string + let myId: number beforeAll(async () => { await mutate({ @@ -589,7 +591,7 @@ describe('TransactionLinkResolver', () => { }) const { data: { - createTransactionLink: { code }, + createTransactionLink: { id, code }, }, } = await mutate({ mutation: createTransactionLink, @@ -599,6 +601,23 @@ describe('TransactionLinkResolver', () => { }, }) myCode = code + myId = id + }) + + it('stores the TRANSACTION_LINK_CREATE event in the database', async () => { + const userConatct = await UserContact.findOneOrFail( + { email: 'bibi@bloxberg.de' }, + { relations: ['user'] }, + ) + await expect(DbEvent.find()).resolves.toContainEqual( + expect.objectContaining({ + type: EventType.TRANSACTION_LINK_CREATE, + affectedUserId: userConatct.user.id, + actingUserId: userConatct.user.id, + involvedTransactionLinkId: myId, + amount: expect.decimalEqual(200), + }), + ) }) describe('own link', () => { @@ -625,6 +644,94 @@ describe('TransactionLinkResolver', () => { expect.any(Number), ) }) + it('delete own link', async () => { + await expect( + mutate({ + mutation: deleteTransactionLink, + variables: { + id: myId, + }, + }), + ).resolves.toMatchObject({ + data: { deleteTransactionLink: true }, + }) + }) + + it('stores the TRANSACTION_LINK_DELETE event in the database', async () => { + const userConatct = await UserContact.findOneOrFail( + { email: 'bibi@bloxberg.de' }, + { relations: ['user'] }, + ) + await expect(DbEvent.find()).resolves.toContainEqual( + expect.objectContaining({ + type: EventType.TRANSACTION_LINK_DELETE, + affectedUserId: userConatct.user.id, + actingUserId: userConatct.user.id, + involvedTransactionLinkId: myId, + }), + ) + }) + }) + + describe('other link', () => { + beforeAll(async () => { + await mutate({ + mutation: login, + variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, + }) + const { + data: { + createTransactionLink: { id, code }, + }, + } = await mutate({ + mutation: createTransactionLink, + variables: { + amount: 200, + memo: 'This is a transaction link from bibi', + }, + }) + myCode = code + myId = id + await mutate({ + mutation: login, + variables: { email: 'peter@lustig.de', password: 'Aa12345_' }, + }) + }) + + it('successfully redeems link', async () => { + await expect( + mutate({ + mutation: redeemTransactionLink, + variables: { + code: myCode, + }, + }), + ).resolves.toMatchObject({ + data: { redeemTransactionLink: true }, + errors: undefined, + }) + }) + + it('stores the TRANSACTION_LINK_REDEEM event in the database', async () => { + const creator = await UserContact.findOneOrFail( + { email: 'bibi@bloxberg.de' }, + { relations: ['user'] }, + ) + const redeemer = await UserContact.findOneOrFail( + { email: 'peter@lustig.de' }, + { relations: ['user'] }, + ) + await expect(DbEvent.find()).resolves.toContainEqual( + expect.objectContaining({ + type: EventType.TRANSACTION_LINK_REDEEM, + affectedUserId: redeemer.user.id, + actingUserId: redeemer.user.id, + involvedUserId: creator.user.id, + involvedTransactionLinkId: myId, + amount: expect.decimalEqual(200), + }), + ) + }) }) }) }) From 90c9802ece7cd094ee76713ecc2f710949dac100 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 29 Mar 2023 15:10:30 +0200 Subject: [PATCH 80/91] disable import/no-cycle --- backend/.eslintrc.js | 2 +- backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts | 1 - backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts | 1 - backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts | 1 - backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts | 1 - backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts | 1 - backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts | 1 - backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts | 1 - backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts | 1 - backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts | 1 - backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts | 1 - backend/src/event/EVENT_CONTRIBUTION_CREATE.ts | 1 - backend/src/event/EVENT_CONTRIBUTION_DELETE.ts | 1 - backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts | 1 - backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts | 1 - backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts | 1 - backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts | 1 - backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts | 1 - backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts | 1 - backend/src/event/EVENT_TRANSACTION_RECEIVE.ts | 1 - backend/src/event/EVENT_TRANSACTION_SEND.ts | 1 - backend/src/event/EVENT_USER_INFO_UPDATE.ts | 1 - backend/src/event/EVENT_USER_LOGIN.ts | 1 - backend/src/event/EVENT_USER_LOGOUT.ts | 1 - backend/src/event/Event.ts | 1 - 25 files changed, 1 insertion(+), 25 deletions(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index 2654104dc..79276ef9d 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -55,7 +55,7 @@ module.exports = { 'import/named': 'error', 'import/namespace': 'error', 'import/no-absolute-path': 'error', - 'import/no-cycle': 'error', + 'import/no-cycle': 'off', 'import/no-dynamic-require': 'error', 'import/no-internal-modules': 'off', 'import/no-relative-packages': 'error', diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts index fab0708a4..33c9ae36e 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts @@ -2,7 +2,6 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_CONFIRM = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts index db3fdef32..bf85345cf 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts @@ -2,7 +2,6 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_CREATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts index 515813bef..dd37c76b5 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts @@ -2,7 +2,6 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_DELETE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts index 6fcdc0312..8d34be87f 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts @@ -2,7 +2,6 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_DENY = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts index a85df138b..b7ee39c36 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts @@ -2,7 +2,6 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_LINK_CREATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts index 1e6f9f2eb..b5816e45d 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts @@ -1,7 +1,6 @@ import { User as DbUser } from '@entity/User' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_LINK_DELETE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts index 73cc6ce88..1cd998e26 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts @@ -2,7 +2,6 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts index 7e87d53ec..f07d38e98 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts @@ -2,7 +2,6 @@ import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts index 8728e6cd5..7d1bc175e 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts @@ -2,7 +2,6 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_UPDATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts b/backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts index 0fc33da3d..3be825ad4 100644 --- a/backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts +++ b/backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts @@ -1,6 +1,5 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_ADMIN_USER_ROLE_SET = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts b/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts index ebf6c1970..f1469c725 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts @@ -2,7 +2,6 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_CREATE = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts b/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts index 153c9ef36..8c62e3ae6 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts @@ -2,7 +2,6 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_DELETE = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts b/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts index 5297fb114..9f44de95d 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts @@ -4,7 +4,6 @@ import { Transaction as DbTransaction } from '@entity/Transaction' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_LINK_REDEEM = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts b/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts index 8e7896d58..b06685a6d 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts @@ -2,7 +2,6 @@ import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_MESSAGE_CREATE = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts b/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts index b998acaa0..c2e6951cc 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts @@ -2,7 +2,6 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_UPDATE = async ( diff --git a/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts b/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts index 3a520dee4..e766fe38e 100644 --- a/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts +++ b/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts @@ -2,7 +2,6 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_TRANSACTION_LINK_CREATE = async ( diff --git a/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts b/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts index 3ffc3c9c0..d15c786a8 100644 --- a/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts +++ b/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts @@ -1,7 +1,6 @@ import { User as DbUser } from '@entity/User' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_TRANSACTION_LINK_DELETE = async ( diff --git a/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts b/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts index 01ab046e3..5f8cd5c4d 100644 --- a/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts +++ b/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts @@ -2,7 +2,6 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_TRANSACTION_LINK_REDEEM = async ( diff --git a/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts b/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts index 7cb4b96a8..c6e06ccb7 100644 --- a/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts +++ b/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts @@ -2,7 +2,6 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_TRANSACTION_RECEIVE = async ( diff --git a/backend/src/event/EVENT_TRANSACTION_SEND.ts b/backend/src/event/EVENT_TRANSACTION_SEND.ts index 6d2960314..888162747 100644 --- a/backend/src/event/EVENT_TRANSACTION_SEND.ts +++ b/backend/src/event/EVENT_TRANSACTION_SEND.ts @@ -2,7 +2,6 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_TRANSACTION_SEND = async ( diff --git a/backend/src/event/EVENT_USER_INFO_UPDATE.ts b/backend/src/event/EVENT_USER_INFO_UPDATE.ts index b69bdcaf9..681ecd473 100644 --- a/backend/src/event/EVENT_USER_INFO_UPDATE.ts +++ b/backend/src/event/EVENT_USER_INFO_UPDATE.ts @@ -1,6 +1,5 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_USER_INFO_UPDATE = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_USER_LOGIN.ts b/backend/src/event/EVENT_USER_LOGIN.ts index e4ae5e330..351ec5a95 100644 --- a/backend/src/event/EVENT_USER_LOGIN.ts +++ b/backend/src/event/EVENT_USER_LOGIN.ts @@ -1,6 +1,5 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_USER_LOGIN = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_USER_LOGOUT.ts b/backend/src/event/EVENT_USER_LOGOUT.ts index 6b726f624..4f5650fc6 100644 --- a/backend/src/event/EVENT_USER_LOGOUT.ts +++ b/backend/src/event/EVENT_USER_LOGOUT.ts @@ -1,6 +1,5 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' -/* eslint-disable-next-line import/no-cycle */ import { Event, EventType } from './Event' export const EVENT_USER_LOGOUT = async (user: DbUser): Promise => diff --git a/backend/src/event/Event.ts b/backend/src/event/Event.ts index e998042be..feb167adf 100644 --- a/backend/src/event/Event.ts +++ b/backend/src/event/Event.ts @@ -1,4 +1,3 @@ -/* eslint-disable import/no-cycle */ import { Event as DbEvent } from '@entity/Event' import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' From cdfcaefa840b589f98937adf5644c802901605ae Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 30 Mar 2023 15:50:20 +0200 Subject: [PATCH 81/91] show moderator id --- admin/src/pages/CreationConfirm.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/src/pages/CreationConfirm.vue b/admin/src/pages/CreationConfirm.vue index 46995e9f7..3c1a1e67e 100644 --- a/admin/src/pages/CreationConfirm.vue +++ b/admin/src/pages/CreationConfirm.vue @@ -212,7 +212,7 @@ export default { return this.formatDateOrDash(value) }, }, - { key: 'moderator', label: this.$t('moderator') }, + { key: 'moderatorId', label: this.$t('moderator') }, { key: 'editCreation', label: this.$t('chat') }, { key: 'confirm', label: this.$t('save') }, ], From 64d896f9734bfa5c005289d6353b98d9d06a8d6e Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 30 Mar 2023 16:14:36 +0200 Subject: [PATCH 82/91] do not allow user to edit admin contributions --- .../Contributions/ContributionListItem.vue | 14 +++++++++----- frontend/src/graphql/queries.js | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionListItem.vue b/frontend/src/components/Contributions/ContributionListItem.vue index 56546d183..27e8459bd 100644 --- a/frontend/src/components/Contributions/ContributionListItem.vue +++ b/frontend/src/components/Contributions/ContributionListItem.vue @@ -47,7 +47,7 @@
{{ amount | GDD }}
-
+
@@ -58,7 +58,7 @@ >
@@ -69,7 +69,7 @@
-
+
{{ $t('moderatorChat') }}
@@ -180,6 +179,11 @@ export default { required: false, default: false, }, + moderatorId: { + type: Number, + required: false, + default: 0, + }, }, data() { return { diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index 7193eded0..87e861752 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -187,6 +187,7 @@ export const listContributions = gql` messagesCount deniedAt deniedBy + moderatorId } } } From 43e2f5fbc839921b5b0fe3deadc85c15baeb104f Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 30 Mar 2023 16:40:07 +0200 Subject: [PATCH 83/91] do not allow user to edit admin contributions --- .../src/graphql/resolver/BalanceResolver.ts | 1 - .../resolver/CommunityResolver.test.ts | 2 +- .../resolver/ContributionLinkResolver.test.ts | 2 +- .../resolver/ContributionLinkResolver.ts | 6 +- .../resolver/ContributionResolver.test.ts | 68 +++++++++++++++---- .../graphql/resolver/ContributionResolver.ts | 9 ++- .../resolver/TransactionLinkResolver.test.ts | 6 +- .../resolver/TransactionLinkResolver.ts | 8 +-- .../resolver/TransactionResolver.test.ts | 4 +- .../graphql/resolver/TransactionResolver.ts | 8 +-- .../src/graphql/resolver/UserResolver.test.ts | 4 +- backend/src/graphql/resolver/UserResolver.ts | 15 ++-- .../src/graphql/resolver/semaphore.test.ts | 2 +- .../src/graphql/resolver/util/creations.ts | 2 +- backend/src/middleware/klicktippMiddleware.ts | 2 +- backend/src/password/EncryptorUtils.ts | 2 +- backend/src/seeds/factory/contributionLink.ts | 2 +- backend/src/util/communityUser.ts | 2 +- backend/src/util/decay.ts | 2 +- backend/src/util/validate.ts | 2 +- 20 files changed, 97 insertions(+), 52 deletions(-) diff --git a/backend/src/graphql/resolver/BalanceResolver.ts b/backend/src/graphql/resolver/BalanceResolver.ts index 7600f12b9..31e2384d4 100644 --- a/backend/src/graphql/resolver/BalanceResolver.ts +++ b/backend/src/graphql/resolver/BalanceResolver.ts @@ -9,7 +9,6 @@ import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' import { GdtResolver } from './GdtResolver' import { getLastTransaction } from './util/getLastTransaction' import { TransactionLinkRepository } from '@repository/TransactionLink' - import { Balance } from '@model/Balance' import { backendLogger as logger } from '@/server/logger' diff --git a/backend/src/graphql/resolver/CommunityResolver.test.ts b/backend/src/graphql/resolver/CommunityResolver.test.ts index f4352c095..5513a73b8 100644 --- a/backend/src/graphql/resolver/CommunityResolver.test.ts +++ b/backend/src/graphql/resolver/CommunityResolver.test.ts @@ -6,8 +6,8 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Community as DbCommunity } from '@entity/Community' -import { getCommunities } from '@/seeds/graphql/queries' import { testEnvironment } from '@test/helpers' +import { getCommunities } from '@/seeds/graphql/queries' let query: any diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts index 6a69e257e..7dfb44e55 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts @@ -9,6 +9,7 @@ import { GraphQLError } from 'graphql' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' import { logger } from '@test/testSetup' +import { cleanDB, testEnvironment, resetToken } from '@test/helpers' import { login, createContributionLink, @@ -16,7 +17,6 @@ import { updateContributionLink, } from '@/seeds/graphql/mutations' import { listContributionLinks } from '@/seeds/graphql/queries' -import { cleanDB, testEnvironment, resetToken } from '@test/helpers' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' import { userFactory } from '@/seeds/factory/user' diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.ts b/backend/src/graphql/resolver/ContributionLinkResolver.ts index 55a23187f..4b19c36e1 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.ts @@ -3,20 +3,20 @@ import { Resolver, Args, Arg, Authorized, Mutation, Query, Int, Ctx } from 'type import { MoreThan, IsNull } from '@dbTools/typeorm' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' +import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver' +import { isStartEndDateValid } from './util/creations' import { CONTRIBUTIONLINK_NAME_MAX_CHARS, CONTRIBUTIONLINK_NAME_MIN_CHARS, MEMO_MAX_CHARS, MEMO_MIN_CHARS, } from './const/const' -import { isStartEndDateValid } from './util/creations' -import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver' import { ContributionLinkList } from '@model/ContributionLinkList' import { ContributionLink } from '@model/ContributionLink' import ContributionLinkArgs from '@arg/ContributionLinkArgs' -import { RIGHTS } from '@/auth/RIGHTS' import { Order } from '@enum/Order' import Paginated from '@arg/Paginated' +import { RIGHTS } from '@/auth/RIGHTS' // TODO: this is a strange construct import LogError from '@/server/LogError' diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 201d04db1..5570f953f 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -13,6 +13,18 @@ import { Transaction as DbTransaction } from '@entity/Transaction' import { User } from '@entity/User' import { UserInputError } from 'apollo-server-express' import { Event as DbEvent } from '@entity/Event' +import { + cleanDB, + resetToken, + testEnvironment, + contributionDateFormatter, + resetEntity, +} from '@test/helpers' +import { logger, i18n as localization } from '@test/testSetup' +import { UnconfirmedContribution } from '@model/UnconfirmedContribution' +import { ContributionListResult } from '@model/Contribution' +import { ContributionStatus } from '@enum/ContributionStatus' +import { Order } from '@enum/Order' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { stephenHawking } from '@/seeds/users/stephen-hawking' @@ -40,24 +52,12 @@ import { sendContributionDeletedEmail, sendContributionDeniedEmail, } from '@/emails/sendEmailVariants' -import { - cleanDB, - resetToken, - testEnvironment, - contributionDateFormatter, - resetEntity, -} from '@test/helpers' import { userFactory } from '@/seeds/factory/user' import { creationFactory } from '@/seeds/factory/creation' import { creations } from '@/seeds/creation/index' import { peterLustig } from '@/seeds/users/peter-lustig' import { EventType } from '@/event/Event' -import { logger, i18n as localization } from '@test/testSetup' import { raeuberHotzenplotz } from '@/seeds/users/raeuber-hotzenplotz' -import { UnconfirmedContribution } from '@model/UnconfirmedContribution' -import { ContributionListResult } from '@model/Contribution' -import { ContributionStatus } from '@enum/ContributionStatus' -import { Order } from '@enum/Order' jest.mock('@/emails/sendEmailVariants') @@ -2040,6 +2040,50 @@ describe('ContributionResolver', () => { }), ) }) + + describe('user tries to update admin contribution', () => { + beforeAll(async () => { + await mutate({ + mutation: login, + variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, + }) + }) + + afterAll(async () => { + await mutate({ + mutation: login, + variables: { email: 'peter@lustig.de', password: 'Aa12345_' }, + }) + }) + + it('logs and throws "Cannot update contribution of moderator" error', async () => { + jest.clearAllMocks() + const adminContribution = await Contribution.findOne({ + where: { + moderatorId: admin.id, + userId: bibi.id, + }, + }) + await expect( + mutate({ + mutation: updateContribution, + variables: { + contributionId: (adminContribution && adminContribution.id) || -1, + amount: 100.0, + memo: 'Test Test Test', + creationDate: new Date().toString(), + }, + }), + ).resolves.toMatchObject({ + errors: [new GraphQLError('Cannot update contribution of moderator')], + }) + expect(logger.error).toBeCalledWith( + 'Cannot update contribution of moderator', + expect.any(Object), + bibi.id, + ) + }) + }) }) describe('second creation surpasses the available amount ', () => { diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index a9446db7f..f756b3a0d 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -9,9 +9,6 @@ import { UserContact } from '@entity/UserContact' import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' -import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' -import { getLastTransaction } from './util/getLastTransaction' -import { findContributions } from './util/findContributions' import { getUserCreation, validateContribution, @@ -19,6 +16,9 @@ import { isValidDateString, getOpenCreations, } from './util/creations' +import { findContributions } from './util/findContributions' +import { getLastTransaction } from './util/getLastTransaction' +import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' import { AdminUpdateContribution } from '@model/AdminUpdateContribution' import { Contribution, ContributionListResult } from '@model/Contribution' import { Decay } from '@model/Decay' @@ -201,6 +201,9 @@ export class ContributionResolver { user.id, ) } + if (contributionToUpdate.moderatorId) { + throw new LogError('Cannot update contribution of moderator', contributionToUpdate, user.id) + } if ( contributionToUpdate.contributionStatus !== ContributionStatus.IN_PROGRESS && contributionToUpdate.contributionStatus !== ContributionStatus.PENDING diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index fd2a44b4b..4f72276d4 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -14,9 +14,11 @@ import { Transaction } from '@entity/Transaction' import { Event as DbEvent } from '@entity/Event' import { UserContact } from '@entity/UserContact' import { transactionLinkCode } from './TransactionLinkResolver' +import { cleanDB, testEnvironment, resetToken, resetEntity } from '@test/helpers' +import { UnconfirmedContribution } from '@model/UnconfirmedContribution' +import { logger } from '@test/testSetup' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' -import { cleanDB, testEnvironment, resetToken, resetEntity } from '@test/helpers' import { creationFactory } from '@/seeds/factory/creation' import { creations } from '@/seeds/creation/index' import { userFactory } from '@/seeds/factory/user' @@ -33,9 +35,7 @@ import { confirmContribution, } from '@/seeds/graphql/mutations' import { listTransactionLinksAdmin } from '@/seeds/graphql/queries' -import { UnconfirmedContribution } from '@model/UnconfirmedContribution' import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' -import { logger } from '@test/testSetup' import { EventType } from '@/event/Event' // mock semaphore to allow use fake timers diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.ts b/backend/src/graphql/resolver/TransactionLinkResolver.ts index 6aa829ac1..3ff6fd36a 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.ts @@ -10,10 +10,10 @@ import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Resolver, Args, Arg, Authorized, Ctx, Mutation, Query, Int } from 'type-graphql' -import { getUserCreation, validateContribution } from './util/creations' -import { executeTransaction } from './TransactionResolver' -import { getLastTransaction } from './util/getLastTransaction' import transactionLinkList from './util/transactionLinkList' +import { getLastTransaction } from './util/getLastTransaction' +import { executeTransaction } from './TransactionResolver' +import { getUserCreation, validateContribution } from './util/creations' import { User } from '@model/User' import { ContributionLink } from '@model/ContributionLink' import { Decay } from '@model/Decay' @@ -25,12 +25,12 @@ import { ContributionCycleType } from '@enum/ContributionCycleType' import TransactionLinkArgs from '@arg/TransactionLinkArgs' import Paginated from '@arg/Paginated' import TransactionLinkFilters from '@arg/TransactionLinkFilters' +import QueryLinkResult from '@union/QueryLinkResult' import { backendLogger as logger } from '@/server/logger' import { Context, getUser, getClientTimezoneOffset } from '@/server/context' import { calculateBalance } from '@/util/validate' import { RIGHTS } from '@/auth/RIGHTS' import { calculateDecay } from '@/util/decay' -import QueryLinkResult from '@union/QueryLinkResult' import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' import LogError from '@/server/LogError' import { diff --git a/backend/src/graphql/resolver/TransactionResolver.test.ts b/backend/src/graphql/resolver/TransactionResolver.test.ts index f26234363..6d039784e 100644 --- a/backend/src/graphql/resolver/TransactionResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionResolver.test.ts @@ -11,6 +11,8 @@ import { User } from '@entity/User' import { GraphQLError } from 'graphql' import { Event as DbEvent } from '@entity/Event' import { findUserByEmail } from './UserResolver' +import { cleanDB, testEnvironment } from '@test/helpers' +import { logger } from '@test/testSetup' import { EventType } from '@/event/Event' import { userFactory } from '@/seeds/factory/user' import { @@ -23,8 +25,6 @@ import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { garrickOllivander } from '@/seeds/users/garrick-ollivander' import { peterLustig } from '@/seeds/users/peter-lustig' import { stephenHawking } from '@/seeds/users/stephen-hawking' -import { cleanDB, testEnvironment } from '@test/helpers' -import { logger } from '@test/testSetup' let mutate: any, query: any, con: any let testEnv: any diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index f38a4a07b..a699e7291 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -9,10 +9,10 @@ import { getCustomRepository, getConnection, In } from '@dbTools/typeorm' import { User as dbUser } from '@entity/User' import { Transaction as dbTransaction } from '@entity/Transaction' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' -import { BalanceResolver } from './BalanceResolver' -import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' -import { findUserByEmail } from './UserResolver' import { getLastTransaction } from './util/getLastTransaction' +import { findUserByEmail } from './UserResolver' +import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' +import { BalanceResolver } from './BalanceResolver' import { TransactionRepository } from '@repository/Transaction' import { TransactionLinkRepository } from '@repository/TransactionLink' @@ -21,9 +21,9 @@ import { Transaction } from '@model/Transaction' import { TransactionList } from '@model/TransactionList' import { Order } from '@enum/Order' import { TransactionTypeId } from '@enum/TransactionTypeId' -import { calculateBalance } from '@/util/validate' import TransactionSendArgs from '@arg/TransactionSendArgs' import Paginated from '@arg/Paginated' +import { calculateBalance } from '@/util/validate' import { backendLogger as logger } from '@/server/logger' import { Context, getUser } from '@/server/context' diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index aebd0f0eb..1b6239fea 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -15,9 +15,10 @@ import { Event as DbEvent } from '@entity/Event' import { OptInType } from '@enum/OptInType' import { UserContactType } from '@enum/UserContactType' import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' -import { objectValuesToArray } from '@/util/utilities' import { testEnvironment, headerPushMock, resetToken, cleanDB } from '@test/helpers' import { logger, i18n as localization } from '@test/testSetup' +import { ContributionLink } from '@model/ContributionLink' +import { objectValuesToArray } from '@/util/utilities' import { printTimeDuration } from '@/util/time' import { userFactory } from '@/seeds/factory/user' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' @@ -44,7 +45,6 @@ import { } from '@/emails/sendEmailVariants' import { contributionLinkFactory } from '@/seeds/factory/contributionLink' import { transactionLinkFactory } from '@/seeds/factory/transactionLink' -import { ContributionLink } from '@model/ContributionLink' import { EventType } from '@/event/Event' import { peterLustig } from '@/seeds/users/peter-lustig' import { bobBaumeister } from '@/seeds/users/bob-baumeister' diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 54d4f583f..0c1cefd12 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -21,8 +21,8 @@ import { User as DbUser } from '@entity/User' import { UserContact as DbUserContact } from '@entity/UserContact' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' -import { getUserCreations } from './util/creations' import { FULL_CREATION_AVAILABLE } from './const/const' +import { getUserCreations } from './util/creations' import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' import { UserRepository } from '@repository/User' @@ -33,18 +33,17 @@ import { OptInType } from '@enum/OptInType' import { Order } from '@enum/Order' import { UserContactType } from '@enum/UserContactType' -import { - sendAccountActivationEmail, - sendAccountMultiRegistrationEmail, - sendResetPasswordEmail, -} from '@/emails/sendEmailVariants' - -import { getTimeDurationObject, printTimeDuration } from '@/util/time' import CreateUserArgs from '@arg/CreateUserArgs' import UnsecureLoginArgs from '@arg/UnsecureLoginArgs' import UpdateUserInfosArgs from '@arg/UpdateUserInfosArgs' import Paginated from '@arg/Paginated' import SearchUsersArgs from '@arg/SearchUsersArgs' +import { getTimeDurationObject, printTimeDuration } from '@/util/time' +import { + sendAccountActivationEmail, + sendAccountMultiRegistrationEmail, + sendResetPasswordEmail, +} from '@/emails/sendEmailVariants' import { backendLogger as logger } from '@/server/logger' import { Context, getUser, getClientTimezoneOffset } from '@/server/context' diff --git a/backend/src/graphql/resolver/semaphore.test.ts b/backend/src/graphql/resolver/semaphore.test.ts index 6b1976021..cc4d589dc 100644 --- a/backend/src/graphql/resolver/semaphore.test.ts +++ b/backend/src/graphql/resolver/semaphore.test.ts @@ -5,12 +5,12 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { Decimal } from 'decimal.js-light' +import { cleanDB, testEnvironment, contributionDateFormatter } from '@test/helpers' import { userFactory } from '@/seeds/factory/user' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { peterLustig } from '@/seeds/users/peter-lustig' import { creationFactory, nMonthsBefore } from '@/seeds/factory/creation' -import { cleanDB, testEnvironment, contributionDateFormatter } from '@test/helpers' import { confirmContribution, createContribution, diff --git a/backend/src/graphql/resolver/util/creations.ts b/backend/src/graphql/resolver/util/creations.ts index 6ebeae8b9..dba0c8c81 100644 --- a/backend/src/graphql/resolver/util/creations.ts +++ b/backend/src/graphql/resolver/util/creations.ts @@ -3,9 +3,9 @@ import { getConnection } from '@dbTools/typeorm' import { Contribution } from '@entity/Contribution' import { Decimal } from 'decimal.js-light' +import { OpenCreation } from '@model/OpenCreation' import { FULL_CREATION_AVAILABLE, MAX_CREATION_AMOUNT } from '@/graphql/resolver/const/const' import { backendLogger as logger } from '@/server/logger' -import { OpenCreation } from '@model/OpenCreation' import LogError from '@/server/LogError' interface CreationMap { diff --git a/backend/src/middleware/klicktippMiddleware.ts b/backend/src/middleware/klicktippMiddleware.ts index 0469b4ccc..568120fe8 100644 --- a/backend/src/middleware/klicktippMiddleware.ts +++ b/backend/src/middleware/klicktippMiddleware.ts @@ -3,8 +3,8 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/restrict-template-expressions */ import { MiddlewareFn } from 'type-graphql' -import { /* klicktippSignIn, */ getKlickTippUser } from '@/apis/KlicktippController' import { KlickTipp } from '@model/KlickTipp' +import { /* klicktippSignIn, */ getKlickTippUser } from '@/apis/KlicktippController' import CONFIG from '@/config' import { klickTippLogger as logger } from '@/server/logger' diff --git a/backend/src/password/EncryptorUtils.ts b/backend/src/password/EncryptorUtils.ts index b4531b3bb..ab8a333d2 100644 --- a/backend/src/password/EncryptorUtils.ts +++ b/backend/src/password/EncryptorUtils.ts @@ -2,10 +2,10 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { User } from '@entity/User' +import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' import CONFIG from '@/config' import LogError from '@/server/LogError' import { backendLogger as logger } from '@/server/logger' -import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs const sodium = require('sodium-native') diff --git a/backend/src/seeds/factory/contributionLink.ts b/backend/src/seeds/factory/contributionLink.ts index 5925cdcfe..6e1d9bd50 100644 --- a/backend/src/seeds/factory/contributionLink.ts +++ b/backend/src/seeds/factory/contributionLink.ts @@ -2,8 +2,8 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/unbound-method */ import { ApolloServerTestClient } from 'apollo-server-testing' -import { login, createContributionLink } from '@/seeds/graphql/mutations' import { ContributionLink } from '@model/ContributionLink' +import { login, createContributionLink } from '@/seeds/graphql/mutations' import { ContributionLinkInterface } from '@/seeds/contributionLink/ContributionLinkInterface' export const contributionLinkFactory = async ( diff --git a/backend/src/util/communityUser.ts b/backend/src/util/communityUser.ts index dfa477da9..d086727bf 100644 --- a/backend/src/util/communityUser.ts +++ b/backend/src/util/communityUser.ts @@ -3,9 +3,9 @@ import { SaveOptions, RemoveOptions } from '@dbTools/typeorm' import { User as dbUser } from '@entity/User' import { UserContact } from '@entity/UserContact' +import { User } from '@model/User' import { PasswordEncryptionType } from '@/graphql/enum/PasswordEncryptionType' // import { UserContact as EmailContact } from '@entity/UserContact' -import { User } from '@model/User' const communityDbUser: dbUser = { id: -1, diff --git a/backend/src/util/decay.ts b/backend/src/util/decay.ts index d35eb83a4..3c76b0995 100644 --- a/backend/src/util/decay.ts +++ b/backend/src/util/decay.ts @@ -1,6 +1,6 @@ import { Decimal } from 'decimal.js-light' -import CONFIG from '@/config' import { Decay } from '@model/Decay' +import CONFIG from '@/config' import LogError from '@/server/LogError' // TODO: externalize all those definitions and functions into an external decay library diff --git a/backend/src/util/validate.ts b/backend/src/util/validate.ts index ec28dfa13..aaadbdd31 100644 --- a/backend/src/util/validate.ts +++ b/backend/src/util/validate.ts @@ -2,9 +2,9 @@ import { Decimal } from 'decimal.js-light' import { getCustomRepository } from '@dbTools/typeorm' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' import { calculateDecay } from './decay' -import { getLastTransaction } from '@/graphql/resolver/util/getLastTransaction' import { TransactionLinkRepository } from '@repository/TransactionLink' import { Decay } from '@model/Decay' +import { getLastTransaction } from '@/graphql/resolver/util/getLastTransaction' function isStringBoolean(value: string): boolean { const lowerValue = value.toLowerCase() From cc98227de02e40b499a85d3b73cca68b72515fed Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 30 Mar 2023 16:40:56 +0200 Subject: [PATCH 84/91] use default values for undefined .env database values --- federation/.env.template | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/federation/.env.template b/federation/.env.template index af6e8f627..5713a7f3f 100644 --- a/federation/.env.template +++ b/federation/.env.template @@ -5,12 +5,11 @@ LOG_LEVEL=$LOG_LEVEL GRAPHIQL=false # Database -DB_HOST=$DB_HOST -DB_PORT=$DB_PORT -DB_DATABASE=$DB_DATABASE +DB_HOST=localhost +DB_PORT=3306 DB_USER=$DB_USER DB_PASSWORD=$DB_PASSWORD +DB_DATABASE=gradido_community # Federation FEDERATION_COMMUNITY_URL=$FEDERATION_COMMUNITY_URL - From 769e36bea5d80dd64472bb382a665362c56eefbf Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 30 Mar 2023 16:55:00 +0200 Subject: [PATCH 85/91] no Float in query --- frontend/src/graphql/queries.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index 87e861752..1a37d082b 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -237,7 +237,7 @@ export const searchAdminUsers = gql` ` export const listContributionMessages = gql` - query($contributionId: Float!, $pageSize: Int = 25, $currentPage: Int = 1, $order: Order = ASC) { + query($contributionId: Int!, $pageSize: Int = 25, $currentPage: Int = 1, $order: Order = ASC) { listContributionMessages( contributionId: $contributionId pageSize: $pageSize From b0c19eda477e78a345217d7c81188de5bacbc0d4 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 30 Mar 2023 17:28:03 +0200 Subject: [PATCH 86/91] fix import order --- backend/.eslintrc.js | 16 ++++++++++++- backend/src/apis/HttpRequest.ts | 1 - backend/src/apis/KlicktippController.ts | 3 ++- backend/src/auth/JWT.ts | 3 ++- .../src/emails/sendEmailTranslated.test.ts | 3 ++- backend/src/emails/sendEmailTranslated.ts | 1 + backend/src/emails/sendEmailVariants.test.ts | 9 +++---- backend/src/emails/sendEmailVariants.ts | 3 ++- .../event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts | 1 + .../event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts | 1 + .../event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts | 1 + .../event/EVENT_ADMIN_CONTRIBUTION_DENY.ts | 1 + .../EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts | 1 + .../EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts | 1 + .../EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts | 1 + ...EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts | 1 + .../event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts | 1 + backend/src/event/EVENT_ADMIN_USER_DELETE.ts | 1 + .../src/event/EVENT_ADMIN_USER_ROLE_SET.ts | 1 + .../src/event/EVENT_ADMIN_USER_UNDELETE.ts | 1 + .../src/event/EVENT_CONTRIBUTION_CREATE.ts | 1 + .../src/event/EVENT_CONTRIBUTION_DELETE.ts | 1 + .../event/EVENT_CONTRIBUTION_LINK_REDEEM.ts | 1 + .../EVENT_CONTRIBUTION_MESSAGE_CREATE.ts | 1 + .../src/event/EVENT_CONTRIBUTION_UPDATE.ts | 1 + .../EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION.ts | 1 + .../event/EVENT_EMAIL_ADMIN_CONFIRMATION.ts | 1 + backend/src/event/EVENT_EMAIL_CONFIRMATION.ts | 1 + .../src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts | 1 + .../event/EVENT_TRANSACTION_LINK_CREATE.ts | 1 + .../event/EVENT_TRANSACTION_LINK_DELETE.ts | 1 + .../event/EVENT_TRANSACTION_LINK_REDEEM.ts | 1 + .../src/event/EVENT_TRANSACTION_RECEIVE.ts | 1 + backend/src/event/EVENT_TRANSACTION_SEND.ts | 1 + .../src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts | 1 + backend/src/event/EVENT_USER_INFO_UPDATE.ts | 1 + backend/src/event/EVENT_USER_LOGIN.ts | 1 + backend/src/event/EVENT_USER_LOGOUT.ts | 1 + backend/src/event/EVENT_USER_REGISTER.ts | 1 + backend/src/event/Event.ts | 1 + .../federation/validateCommunities.test.ts | 3 ++- backend/src/federation/validateCommunities.ts | 5 ++-- backend/src/graphql/directive/isAuthorized.ts | 1 - backend/src/graphql/model/GdtEntryList.ts | 1 + backend/src/graphql/model/Transaction.ts | 3 ++- backend/src/graphql/model/TransactionLink.ts | 3 ++- backend/src/graphql/model/TransactionList.ts | 1 + backend/src/graphql/model/User.ts | 1 + .../src/graphql/resolver/BalanceResolver.ts | 9 +++---- .../src/graphql/resolver/CommunityResolver.ts | 2 -- .../resolver/ContributionLinkResolver.ts | 19 +++++++-------- .../resolver/ContributionMessageResolver.ts | 3 --- .../graphql/resolver/ContributionResolver.ts | 24 +++++++++---------- backend/src/graphql/resolver/GdtResolver.ts | 2 -- .../src/graphql/resolver/KlicktippResolver.ts | 1 - .../graphql/resolver/StatisticsResolver.ts | 3 --- .../resolver/TransactionLinkResolver.test.ts | 3 ++- .../resolver/TransactionLinkResolver.ts | 13 +++++----- .../resolver/TransactionResolver.test.ts | 3 ++- .../graphql/resolver/TransactionResolver.ts | 13 ++++------ backend/src/graphql/resolver/UserResolver.ts | 10 +++----- .../graphql/resolver/util/creations.test.ts | 3 ++- backend/src/graphql/schema.ts | 3 ++- backend/src/index.ts | 1 - backend/src/password/PasswordEncryptor.ts | 1 + backend/src/seeds/creation/index.ts | 3 ++- backend/src/seeds/index.ts | 6 ++--- backend/src/server/LogError.test.ts | 3 ++- backend/src/server/context.ts | 3 ++- backend/src/server/createServer.ts | 11 +++++---- backend/src/server/localization.ts | 2 ++ backend/src/server/logger.ts | 1 + backend/src/util/decay.test.ts | 1 + backend/src/util/validate.ts | 3 ++- backend/src/util/virtualTransactions.ts | 3 ++- backend/test/helpers.ts | 3 ++- 76 files changed, 144 insertions(+), 97 deletions(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index 79276ef9d..59bd53ca6 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -76,7 +76,21 @@ module.exports = { 'import/no-named-default': 'error', 'import/no-namespace': 'error', 'import/no-unassigned-import': 'error', - 'import/order': 'error', + 'import/order': [ + 'error', + { + groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'], + 'newlines-between': 'always', + pathGroups: [ + { + pattern: '@*/**', + group: 'external', + position: 'after', + }, + ], + distinctGroup: false, + }, + ], 'import/prefer-default-export': 'off', // TODO }, overrides: [ diff --git a/backend/src/apis/HttpRequest.ts b/backend/src/apis/HttpRequest.ts index eff0c408a..af7e40dd7 100644 --- a/backend/src/apis/HttpRequest.ts +++ b/backend/src/apis/HttpRequest.ts @@ -1,7 +1,6 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import axios from 'axios' - import { backendLogger as logger } from '@/server/logger' import LogError from '@/server/LogError' diff --git a/backend/src/apis/KlicktippController.ts b/backend/src/apis/KlicktippController.ts index 70c0f95b1..309cf56ee 100644 --- a/backend/src/apis/KlicktippController.ts +++ b/backend/src/apis/KlicktippController.ts @@ -4,9 +4,10 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +import CONFIG from '@/config' + // eslint-disable-next-line import/no-relative-parent-imports import KlicktippConnector from 'klicktipp-api' -import CONFIG from '@/config' const klicktippConnector = new KlicktippConnector() diff --git a/backend/src/auth/JWT.ts b/backend/src/auth/JWT.ts index 3da1f1d3e..f0a320efb 100644 --- a/backend/src/auth/JWT.ts +++ b/backend/src/auth/JWT.ts @@ -1,8 +1,9 @@ import { verify, sign } from 'jsonwebtoken' -import { CustomJwtPayload } from './CustomJwtPayload' import CONFIG from '@/config/' import LogError from '@/server/LogError' +import { CustomJwtPayload } from './CustomJwtPayload' + export const decode = (token: string): CustomJwtPayload | null => { if (!token) throw new LogError('401 Unauthorized') try { diff --git a/backend/src/emails/sendEmailTranslated.test.ts b/backend/src/emails/sendEmailTranslated.test.ts index 762b88cf0..5eea352fb 100644 --- a/backend/src/emails/sendEmailTranslated.test.ts +++ b/backend/src/emails/sendEmailTranslated.test.ts @@ -1,10 +1,11 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/unbound-method */ import { createTransport } from 'nodemailer' -import { sendEmailTranslated } from './sendEmailTranslated' import { logger, i18n } from '@test/testSetup' import CONFIG from '@/config' +import { sendEmailTranslated } from './sendEmailTranslated' + CONFIG.EMAIL = false CONFIG.EMAIL_SMTP_URL = 'EMAIL_SMTP_URL' CONFIG.EMAIL_SMTP_PORT = '1234' diff --git a/backend/src/emails/sendEmailTranslated.ts b/backend/src/emails/sendEmailTranslated.ts index d865bac8f..5cc136edc 100644 --- a/backend/src/emails/sendEmailTranslated.ts +++ b/backend/src/emails/sendEmailTranslated.ts @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ import path from 'path' + import { createTransport } from 'nodemailer' import Email from 'email-templates' import i18n from 'i18n' diff --git a/backend/src/emails/sendEmailVariants.test.ts b/backend/src/emails/sendEmailVariants.test.ts index 399ed89ac..76d8f9a26 100644 --- a/backend/src/emails/sendEmailVariants.test.ts +++ b/backend/src/emails/sendEmailVariants.test.ts @@ -4,6 +4,11 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { Decimal } from 'decimal.js-light' +import { testEnvironment } from '@test/helpers' +import { logger, i18n as localization } from '@test/testSetup' +import CONFIG from '@/config' + +import { sendEmailTranslated } from './sendEmailTranslated' import { sendAddedContributionMessageEmail, sendAccountActivationEmail, @@ -15,10 +20,6 @@ import { sendTransactionLinkRedeemedEmail, sendTransactionReceivedEmail, } from './sendEmailVariants' -import { sendEmailTranslated } from './sendEmailTranslated' -import { testEnvironment } from '@test/helpers' -import { logger, i18n as localization } from '@test/testSetup' -import CONFIG from '@/config' let con: any let testEnv: any diff --git a/backend/src/emails/sendEmailVariants.ts b/backend/src/emails/sendEmailVariants.ts index 2294ebdd5..7da0424dc 100644 --- a/backend/src/emails/sendEmailVariants.ts +++ b/backend/src/emails/sendEmailVariants.ts @@ -1,8 +1,9 @@ import { Decimal } from 'decimal.js-light' -import { sendEmailTranslated } from './sendEmailTranslated' import CONFIG from '@/config' import { decimalSeparatorByLanguage } from '@/util/utilities' +import { sendEmailTranslated } from './sendEmailTranslated' + export const sendAddedContributionMessageEmail = (data: { firstName: string lastName: string diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts index 33c9ae36e..e53a56c11 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_CONFIRM = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts index bf85345cf..530c896ca 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_CREATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts index dd37c76b5..1d776a9e0 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_DELETE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts index 8d34be87f..98d42fcdc 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_DENY = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts index b7ee39c36..3cd55a40c 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_LINK_CREATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts index b5816e45d..d6eb5f205 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts @@ -1,6 +1,7 @@ import { User as DbUser } from '@entity/User' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_LINK_DELETE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts index 1cd998e26..deb7bb574 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts index f07d38e98..68a59da27 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts @@ -2,6 +2,7 @@ import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts index 7d1bc175e..06a5da0c0 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_CONTRIBUTION_UPDATE = async ( diff --git a/backend/src/event/EVENT_ADMIN_USER_DELETE.ts b/backend/src/event/EVENT_ADMIN_USER_DELETE.ts index bfd5be740..6c022ad2c 100644 --- a/backend/src/event/EVENT_ADMIN_USER_DELETE.ts +++ b/backend/src/event/EVENT_ADMIN_USER_DELETE.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_USER_DELETE = async (user: DbUser, moderator: DbUser): Promise => diff --git a/backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts b/backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts index 3be825ad4..e6951d062 100644 --- a/backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts +++ b/backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_USER_ROLE_SET = async ( diff --git a/backend/src/event/EVENT_ADMIN_USER_UNDELETE.ts b/backend/src/event/EVENT_ADMIN_USER_UNDELETE.ts index eb861dbf1..303c4d260 100644 --- a/backend/src/event/EVENT_ADMIN_USER_UNDELETE.ts +++ b/backend/src/event/EVENT_ADMIN_USER_UNDELETE.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_ADMIN_USER_UNDELETE = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts b/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts index f1469c725..b01bad47a 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_CREATE = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts b/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts index 8c62e3ae6..fdfc12448 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_DELETE = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts b/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts index 9f44de95d..3ce38cf03 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts @@ -4,6 +4,7 @@ import { Transaction as DbTransaction } from '@entity/Transaction' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_LINK_REDEEM = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts b/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts index b06685a6d..b977f90da 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts @@ -2,6 +2,7 @@ import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_MESSAGE_CREATE = async ( diff --git a/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts b/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts index c2e6951cc..be1d3d4ed 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_CONTRIBUTION_UPDATE = async ( diff --git a/backend/src/event/EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION.ts b/backend/src/event/EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION.ts index c16bbfac3..0133ab715 100644 --- a/backend/src/event/EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION.ts +++ b/backend/src/event/EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_EMAIL_ADMIN_CONFIRMATION.ts b/backend/src/event/EVENT_EMAIL_ADMIN_CONFIRMATION.ts index ae10f9fba..6132484da 100644 --- a/backend/src/event/EVENT_EMAIL_ADMIN_CONFIRMATION.ts +++ b/backend/src/event/EVENT_EMAIL_ADMIN_CONFIRMATION.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_EMAIL_ADMIN_CONFIRMATION = async ( diff --git a/backend/src/event/EVENT_EMAIL_CONFIRMATION.ts b/backend/src/event/EVENT_EMAIL_CONFIRMATION.ts index 9d64207e0..44eb9323d 100644 --- a/backend/src/event/EVENT_EMAIL_CONFIRMATION.ts +++ b/backend/src/event/EVENT_EMAIL_CONFIRMATION.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_EMAIL_CONFIRMATION = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts b/backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts index f7e328369..20eb5f1fe 100644 --- a/backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts +++ b/backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_EMAIL_FORGOT_PASSWORD = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts b/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts index e766fe38e..dd97a0641 100644 --- a/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts +++ b/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_TRANSACTION_LINK_CREATE = async ( diff --git a/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts b/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts index d15c786a8..de4511b9e 100644 --- a/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts +++ b/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts @@ -1,6 +1,7 @@ import { User as DbUser } from '@entity/User' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_TRANSACTION_LINK_DELETE = async ( diff --git a/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts b/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts index 5f8cd5c4d..d699f3d41 100644 --- a/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts +++ b/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_TRANSACTION_LINK_REDEEM = async ( diff --git a/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts b/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts index c6e06ccb7..d82bbd31c 100644 --- a/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts +++ b/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_TRANSACTION_RECEIVE = async ( diff --git a/backend/src/event/EVENT_TRANSACTION_SEND.ts b/backend/src/event/EVENT_TRANSACTION_SEND.ts index 888162747..d2fd615a5 100644 --- a/backend/src/event/EVENT_TRANSACTION_SEND.ts +++ b/backend/src/event/EVENT_TRANSACTION_SEND.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_TRANSACTION_SEND = async ( diff --git a/backend/src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts b/backend/src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts index 2e224d550..602acb880 100644 --- a/backend/src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts +++ b/backend/src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_USER_ACTIVATE_ACCOUNT = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_USER_INFO_UPDATE.ts b/backend/src/event/EVENT_USER_INFO_UPDATE.ts index 681ecd473..080c68e2c 100644 --- a/backend/src/event/EVENT_USER_INFO_UPDATE.ts +++ b/backend/src/event/EVENT_USER_INFO_UPDATE.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_USER_INFO_UPDATE = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_USER_LOGIN.ts b/backend/src/event/EVENT_USER_LOGIN.ts index 351ec5a95..ba09bc02c 100644 --- a/backend/src/event/EVENT_USER_LOGIN.ts +++ b/backend/src/event/EVENT_USER_LOGIN.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_USER_LOGIN = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_USER_LOGOUT.ts b/backend/src/event/EVENT_USER_LOGOUT.ts index 4f5650fc6..2e6c54841 100644 --- a/backend/src/event/EVENT_USER_LOGOUT.ts +++ b/backend/src/event/EVENT_USER_LOGOUT.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_USER_LOGOUT = async (user: DbUser): Promise => diff --git a/backend/src/event/EVENT_USER_REGISTER.ts b/backend/src/event/EVENT_USER_REGISTER.ts index cdb8b22e2..990ac396f 100644 --- a/backend/src/event/EVENT_USER_REGISTER.ts +++ b/backend/src/event/EVENT_USER_REGISTER.ts @@ -1,5 +1,6 @@ import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' + import { Event, EventType } from './Event' export const EVENT_USER_REGISTER = async (user: DbUser): Promise => diff --git a/backend/src/event/Event.ts b/backend/src/event/Event.ts index feb167adf..1ff8ba995 100644 --- a/backend/src/event/Event.ts +++ b/backend/src/event/Event.ts @@ -6,6 +6,7 @@ import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Decimal } from 'decimal.js-light' + import { EventType } from './EventType' export const Event = ( diff --git a/backend/src/federation/validateCommunities.test.ts b/backend/src/federation/validateCommunities.test.ts index a99bb3274..919a99547 100644 --- a/backend/src/federation/validateCommunities.test.ts +++ b/backend/src/federation/validateCommunities.test.ts @@ -6,10 +6,11 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Community as DbCommunity } from '@entity/Community' -import { validateCommunities } from './validateCommunities' import { logger } from '@test/testSetup' import { testEnvironment, cleanDB } from '@test/helpers' +import { validateCommunities } from './validateCommunities' + let con: any let testEnv: any diff --git a/backend/src/federation/validateCommunities.ts b/backend/src/federation/validateCommunities.ts index 19185e4d9..c4a9f3b1d 100644 --- a/backend/src/federation/validateCommunities.ts +++ b/backend/src/federation/validateCommunities.ts @@ -1,12 +1,13 @@ import { Community as DbCommunity } from '@entity/Community' import { IsNull } from '@dbTools/typeorm' +import { backendLogger as logger } from '@/server/logger' +import LogError from '@/server/LogError' + // eslint-disable-next-line camelcase import { requestGetPublicKey as v1_0_requestGetPublicKey } from './client/1_0/FederationClient' // eslint-disable-next-line camelcase import { requestGetPublicKey as v1_1_requestGetPublicKey } from './client/1_1/FederationClient' import { ApiVersionType } from './enum/apiVersionType' -import { backendLogger as logger } from '@/server/logger' -import LogError from '@/server/LogError' export function startValidateCommunities(timerInterval: number): void { logger.info( diff --git a/backend/src/graphql/directive/isAuthorized.ts b/backend/src/graphql/directive/isAuthorized.ts index 6cdac9b97..845593de6 100644 --- a/backend/src/graphql/directive/isAuthorized.ts +++ b/backend/src/graphql/directive/isAuthorized.ts @@ -3,7 +3,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { AuthChecker } from 'type-graphql' - import { User } from '@entity/User' import { decode, encode } from '@/auth/JWT' import { ROLE_UNAUTHORIZED, ROLE_USER, ROLE_ADMIN } from '@/auth/ROLES' diff --git a/backend/src/graphql/model/GdtEntryList.ts b/backend/src/graphql/model/GdtEntryList.ts index d992de54c..06f77f532 100644 --- a/backend/src/graphql/model/GdtEntryList.ts +++ b/backend/src/graphql/model/GdtEntryList.ts @@ -4,6 +4,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { ObjectType, Field, Int, Float } from 'type-graphql' + import { GdtEntry } from './GdtEntry' @ObjectType() diff --git a/backend/src/graphql/model/Transaction.ts b/backend/src/graphql/model/Transaction.ts index 8f0d1eadc..0a31cd8d6 100644 --- a/backend/src/graphql/model/Transaction.ts +++ b/backend/src/graphql/model/Transaction.ts @@ -1,9 +1,10 @@ import { ObjectType, Field, Int } from 'type-graphql' import { Transaction as dbTransaction } from '@entity/Transaction' import { Decimal } from 'decimal.js-light' +import { TransactionTypeId } from '@enum/TransactionTypeId' + import { Decay } from './Decay' import { User } from './User' -import { TransactionTypeId } from '@enum/TransactionTypeId' @ObjectType() export class Transaction { diff --git a/backend/src/graphql/model/TransactionLink.ts b/backend/src/graphql/model/TransactionLink.ts index ddd22f36f..1ed02b476 100644 --- a/backend/src/graphql/model/TransactionLink.ts +++ b/backend/src/graphql/model/TransactionLink.ts @@ -1,9 +1,10 @@ import { ObjectType, Field, Int } from 'type-graphql' import { Decimal } from 'decimal.js-light' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' -import { User } from './User' import CONFIG from '@/config' +import { User } from './User' + @ObjectType() export class TransactionLink { constructor(transactionLink: dbTransactionLink, user: User, redeemedBy: User | null = null) { diff --git a/backend/src/graphql/model/TransactionList.ts b/backend/src/graphql/model/TransactionList.ts index 888c30dc7..36e51242d 100644 --- a/backend/src/graphql/model/TransactionList.ts +++ b/backend/src/graphql/model/TransactionList.ts @@ -1,4 +1,5 @@ import { ObjectType, Field } from 'type-graphql' + import { Transaction } from './Transaction' import { Balance } from './Balance' diff --git a/backend/src/graphql/model/User.ts b/backend/src/graphql/model/User.ts index 85c6de798..6797b0767 100644 --- a/backend/src/graphql/model/User.ts +++ b/backend/src/graphql/model/User.ts @@ -1,5 +1,6 @@ import { ObjectType, Field, Int } from 'type-graphql' import { User as dbUser } from '@entity/User' + import { KlickTipp } from './KlickTipp' import { UserContact } from './UserContact' diff --git a/backend/src/graphql/resolver/BalanceResolver.ts b/backend/src/graphql/resolver/BalanceResolver.ts index 7600f12b9..0a9b651a9 100644 --- a/backend/src/graphql/resolver/BalanceResolver.ts +++ b/backend/src/graphql/resolver/BalanceResolver.ts @@ -2,21 +2,18 @@ import { Decimal } from 'decimal.js-light' import { Resolver, Query, Ctx, Authorized } from 'type-graphql' import { getCustomRepository } from '@dbTools/typeorm' - import { Transaction as dbTransaction } from '@entity/Transaction' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' - -import { GdtResolver } from './GdtResolver' -import { getLastTransaction } from './util/getLastTransaction' import { TransactionLinkRepository } from '@repository/TransactionLink' - import { Balance } from '@model/Balance' - import { backendLogger as logger } from '@/server/logger' import { Context, getUser } from '@/server/context' import { calculateDecay } from '@/util/decay' import { RIGHTS } from '@/auth/RIGHTS' +import { getLastTransaction } from './util/getLastTransaction' +import { GdtResolver } from './GdtResolver' + @Resolver() export class BalanceResolver { @Authorized([RIGHTS.BALANCE]) diff --git a/backend/src/graphql/resolver/CommunityResolver.ts b/backend/src/graphql/resolver/CommunityResolver.ts index 6aca41472..37c42dd89 100644 --- a/backend/src/graphql/resolver/CommunityResolver.ts +++ b/backend/src/graphql/resolver/CommunityResolver.ts @@ -1,8 +1,6 @@ import { Resolver, Query, Authorized } from 'type-graphql' - import { Community as DbCommunity } from '@entity/Community' import { Community } from '@model/Community' - import { RIGHTS } from '@/auth/RIGHTS' @Resolver() diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.ts b/backend/src/graphql/resolver/ContributionLinkResolver.ts index 55a23187f..5febb95c5 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.ts @@ -1,23 +1,13 @@ import { Decimal } from 'decimal.js-light' import { Resolver, Args, Arg, Authorized, Mutation, Query, Int, Ctx } from 'type-graphql' import { MoreThan, IsNull } from '@dbTools/typeorm' - import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' -import { - CONTRIBUTIONLINK_NAME_MAX_CHARS, - CONTRIBUTIONLINK_NAME_MIN_CHARS, - MEMO_MAX_CHARS, - MEMO_MIN_CHARS, -} from './const/const' -import { isStartEndDateValid } from './util/creations' -import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver' import { ContributionLinkList } from '@model/ContributionLinkList' import { ContributionLink } from '@model/ContributionLink' import ContributionLinkArgs from '@arg/ContributionLinkArgs' import { RIGHTS } from '@/auth/RIGHTS' import { Order } from '@enum/Order' import Paginated from '@arg/Paginated' - // TODO: this is a strange construct import LogError from '@/server/LogError' import { Context, getUser } from '@/server/context' @@ -27,6 +17,15 @@ import { EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE, } from '@/event/Event' +import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver' +import { isStartEndDateValid } from './util/creations' +import { + CONTRIBUTIONLINK_NAME_MAX_CHARS, + CONTRIBUTIONLINK_NAME_MIN_CHARS, + MEMO_MAX_CHARS, + MEMO_MIN_CHARS, +} from './const/const' + @Resolver() export class ContributionLinkResolver { @Authorized([RIGHTS.CREATE_CONTRIBUTION_LINK]) diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.ts b/backend/src/graphql/resolver/ContributionMessageResolver.ts index 999ccc2b1..63cf2fd9c 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.ts @@ -1,19 +1,16 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql' import { getConnection } from '@dbTools/typeorm' - import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { Contribution as DbContribution } from '@entity/Contribution' import { UserContact as DbUserContact } from '@entity/UserContact' import { User as DbUser } from '@entity/User' - import { ContributionMessage, ContributionMessageListResult } from '@model/ContributionMessage' import ContributionMessageArgs from '@arg/ContributionMessageArgs' import { ContributionMessageType } from '@enum/MessageType' import { ContributionStatus } from '@enum/ContributionStatus' import { Order } from '@enum/Order' import Paginated from '@arg/Paginated' - import { RIGHTS } from '@/auth/RIGHTS' import { Context, getUser } from '@/server/context' import { sendAddedContributionMessageEmail } from '@/emails/sendEmailVariants' diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 83cf29fc7..026793b5f 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -2,23 +2,11 @@ import { Decimal } from 'decimal.js-light' import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql' import { IsNull, getConnection } from '@dbTools/typeorm' - import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionMessage } from '@entity/ContributionMessage' import { UserContact } from '@entity/UserContact' import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' - -import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' -import { getLastTransaction } from './util/getLastTransaction' -import { findContributions } from './util/findContributions' -import { - getUserCreation, - validateContribution, - updateCreations, - isValidDateString, - getOpenCreations, -} from './util/creations' import { AdminUpdateContribution } from '@model/AdminUpdateContribution' import { Contribution, ContributionListResult } from '@model/Contribution' import { Decay } from '@model/Decay' @@ -33,7 +21,6 @@ import ContributionArgs from '@arg/ContributionArgs' import Paginated from '@arg/Paginated' import AdminCreateContributionArgs from '@arg/AdminCreateContributionArgs' import AdminUpdateContributionArgs from '@arg/AdminUpdateContributionArgs' - import { RIGHTS } from '@/auth/RIGHTS' import { Context, getUser, getClientTimezoneOffset } from '@/server/context' import { backendLogger as logger } from '@/server/logger' @@ -56,6 +43,17 @@ import { import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' import LogError from '@/server/LogError' +import { + getUserCreation, + validateContribution, + updateCreations, + isValidDateString, + getOpenCreations, +} from './util/creations' +import { findContributions } from './util/findContributions' +import { getLastTransaction } from './util/getLastTransaction' +import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' + @Resolver() export class ContributionResolver { @Authorized([RIGHTS.CREATE_CONTRIBUTION]) diff --git a/backend/src/graphql/resolver/GdtResolver.ts b/backend/src/graphql/resolver/GdtResolver.ts index e12f92458..e5ad56f2d 100644 --- a/backend/src/graphql/resolver/GdtResolver.ts +++ b/backend/src/graphql/resolver/GdtResolver.ts @@ -2,11 +2,9 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-return */ import { Resolver, Query, Args, Ctx, Authorized, Arg, Int, Float } from 'type-graphql' - import { GdtEntryList } from '@model/GdtEntryList' import { Order } from '@enum/Order' import Paginated from '@arg/Paginated' - import { Context, getUser } from '@/server/context' import CONFIG from '@/config' import { apiGet, apiPost } from '@/apis/HttpRequest' diff --git a/backend/src/graphql/resolver/KlicktippResolver.ts b/backend/src/graphql/resolver/KlicktippResolver.ts index 31bde0581..f8aee5e2c 100644 --- a/backend/src/graphql/resolver/KlicktippResolver.ts +++ b/backend/src/graphql/resolver/KlicktippResolver.ts @@ -1,6 +1,5 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ import { Resolver, Query, Authorized, Arg, Mutation, Ctx } from 'type-graphql' - import { getKlickTippUser, getKlicktippTagMap, diff --git a/backend/src/graphql/resolver/StatisticsResolver.ts b/backend/src/graphql/resolver/StatisticsResolver.ts index d5ae9503c..f16a2fd56 100644 --- a/backend/src/graphql/resolver/StatisticsResolver.ts +++ b/backend/src/graphql/resolver/StatisticsResolver.ts @@ -3,12 +3,9 @@ import { Decimal } from 'decimal.js-light' import { Resolver, Query, Authorized, FieldResolver } from 'type-graphql' import { getConnection } from '@dbTools/typeorm' - import { Transaction as DbTransaction } from '@entity/Transaction' import { User as DbUser } from '@entity/User' - import { CommunityStatistics, DynamicStatisticsFields } from '@model/CommunityStatistics' - import { RIGHTS } from '@/auth/RIGHTS' import { calculateDecay } from '@/util/decay' diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index fd2a44b4b..0ac73cbcf 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -13,7 +13,6 @@ import { GraphQLError } from 'graphql' import { Transaction } from '@entity/Transaction' import { Event as DbEvent } from '@entity/Event' import { UserContact } from '@entity/UserContact' -import { transactionLinkCode } from './TransactionLinkResolver' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' import { cleanDB, testEnvironment, resetToken, resetEntity } from '@test/helpers' @@ -38,6 +37,8 @@ import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' import { logger } from '@test/testSetup' import { EventType } from '@/event/Event' +import { transactionLinkCode } from './TransactionLinkResolver' + // mock semaphore to allow use fake timers jest.mock('@/util/TRANSACTIONS_LOCK') TRANSACTIONS_LOCK.acquire = jest.fn().mockResolvedValue(jest.fn()) diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.ts b/backend/src/graphql/resolver/TransactionLinkResolver.ts index 6aa829ac1..e9a388cde 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.ts @@ -1,19 +1,13 @@ import { randomBytes } from 'crypto' + import { Decimal } from 'decimal.js-light' - import { getConnection } from '@dbTools/typeorm' - import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' - import { Resolver, Args, Arg, Authorized, Ctx, Mutation, Query, Int } from 'type-graphql' -import { getUserCreation, validateContribution } from './util/creations' -import { executeTransaction } from './TransactionResolver' -import { getLastTransaction } from './util/getLastTransaction' -import transactionLinkList from './util/transactionLinkList' import { User } from '@model/User' import { ContributionLink } from '@model/ContributionLink' import { Decay } from '@model/Decay' @@ -40,6 +34,11 @@ import { EVENT_TRANSACTION_LINK_REDEEM, } from '@/event/Event' +import transactionLinkList from './util/transactionLinkList' +import { getLastTransaction } from './util/getLastTransaction' +import { executeTransaction } from './TransactionResolver' +import { getUserCreation, validateContribution } from './util/creations' + // TODO: do not export, test it inside the resolver export const transactionLinkCode = (date: Date): string => { const time = date.getTime().toString(16) diff --git a/backend/src/graphql/resolver/TransactionResolver.test.ts b/backend/src/graphql/resolver/TransactionResolver.test.ts index f26234363..baa50e171 100644 --- a/backend/src/graphql/resolver/TransactionResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionResolver.test.ts @@ -10,7 +10,6 @@ import { Transaction } from '@entity/Transaction' import { User } from '@entity/User' import { GraphQLError } from 'graphql' import { Event as DbEvent } from '@entity/Event' -import { findUserByEmail } from './UserResolver' import { EventType } from '@/event/Event' import { userFactory } from '@/seeds/factory/user' import { @@ -26,6 +25,8 @@ import { stephenHawking } from '@/seeds/users/stephen-hawking' import { cleanDB, testEnvironment } from '@test/helpers' import { logger } from '@test/testSetup' +import { findUserByEmail } from './UserResolver' + let mutate: any, query: any, con: any let testEnv: any diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index f38a4a07b..7f3f1c5f1 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -5,17 +5,11 @@ import { Decimal } from 'decimal.js-light' import { Resolver, Query, Args, Authorized, Ctx, Mutation } from 'type-graphql' import { getCustomRepository, getConnection, In } from '@dbTools/typeorm' - import { User as dbUser } from '@entity/User' import { Transaction as dbTransaction } from '@entity/Transaction' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' -import { BalanceResolver } from './BalanceResolver' -import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' -import { findUserByEmail } from './UserResolver' -import { getLastTransaction } from './util/getLastTransaction' import { TransactionRepository } from '@repository/Transaction' import { TransactionLinkRepository } from '@repository/TransactionLink' - import { User } from '@model/User' import { Transaction } from '@model/Transaction' import { TransactionList } from '@model/TransactionList' @@ -24,7 +18,6 @@ import { TransactionTypeId } from '@enum/TransactionTypeId' import { calculateBalance } from '@/util/validate' import TransactionSendArgs from '@arg/TransactionSendArgs' import Paginated from '@arg/Paginated' - import { backendLogger as logger } from '@/server/logger' import { Context, getUser } from '@/server/context' import { RIGHTS } from '@/auth/RIGHTS' @@ -35,10 +28,14 @@ import { sendTransactionReceivedEmail, } from '@/emails/sendEmailVariants' import { EVENT_TRANSACTION_RECEIVE, EVENT_TRANSACTION_SEND } from '@/event/Event' - import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' import LogError from '@/server/LogError' +import { getLastTransaction } from './util/getLastTransaction' +import { findUserByEmail } from './UserResolver' +import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' +import { BalanceResolver } from './BalanceResolver' + export const executeTransaction = async ( amount: Decimal, memo: string, diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 54d4f583f..5f66e7725 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -16,36 +16,29 @@ import { Int, } from 'type-graphql' import { getConnection, getCustomRepository, IsNull, Not } from '@dbTools/typeorm' - import { User as DbUser } from '@entity/User' import { UserContact as DbUserContact } from '@entity/UserContact' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' -import { getUserCreations } from './util/creations' -import { FULL_CREATION_AVAILABLE } from './const/const' import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' import { UserRepository } from '@repository/User' - import { User } from '@model/User' import { SearchAdminUsersResult } from '@model/AdminUser' import { UserAdmin, SearchUsersResult } from '@model/UserAdmin' import { OptInType } from '@enum/OptInType' import { Order } from '@enum/Order' import { UserContactType } from '@enum/UserContactType' - import { sendAccountActivationEmail, sendAccountMultiRegistrationEmail, sendResetPasswordEmail, } from '@/emails/sendEmailVariants' - import { getTimeDurationObject, printTimeDuration } from '@/util/time' import CreateUserArgs from '@arg/CreateUserArgs' import UnsecureLoginArgs from '@arg/UnsecureLoginArgs' import UpdateUserInfosArgs from '@arg/UpdateUserInfosArgs' import Paginated from '@arg/Paginated' import SearchUsersArgs from '@arg/SearchUsersArgs' - import { backendLogger as logger } from '@/server/logger' import { Context, getUser, getClientTimezoneOffset } from '@/server/context' import CONFIG from '@/config' @@ -75,6 +68,9 @@ import { isValidPassword } from '@/password/EncryptorUtils' import { encryptPassword, verifyPassword } from '@/password/PasswordEncryptor' import LogError from '@/server/LogError' +import { FULL_CREATION_AVAILABLE } from './const/const' +import { getUserCreations } from './util/creations' + // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs const sodium = require('sodium-native') // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs diff --git a/backend/src/graphql/resolver/util/creations.test.ts b/backend/src/graphql/resolver/util/creations.test.ts index 7461401c8..a35b37891 100644 --- a/backend/src/graphql/resolver/util/creations.test.ts +++ b/backend/src/graphql/resolver/util/creations.test.ts @@ -6,13 +6,14 @@ import { User } from '@entity/User' import { Contribution } from '@entity/Contribution' -import { getUserCreation } from './creations' import { testEnvironment, cleanDB, contributionDateFormatter } from '@test/helpers' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' import { userFactory } from '@/seeds/factory/user' import { login, createContribution, adminCreateContribution } from '@/seeds/graphql/mutations' +import { getUserCreation } from './creations' + let mutate: any, con: any let testEnv: any diff --git a/backend/src/graphql/schema.ts b/backend/src/graphql/schema.ts index 194a24c00..1aae117d0 100644 --- a/backend/src/graphql/schema.ts +++ b/backend/src/graphql/schema.ts @@ -1,8 +1,9 @@ import path from 'path' + import { GraphQLSchema } from 'graphql' import { buildSchema } from 'type-graphql' - import { Decimal } from 'decimal.js-light' + import isAuthorized from './directive/isAuthorized' import DecimalScalar from './scalar/Decimal' diff --git a/backend/src/index.ts b/backend/src/index.ts index cd6d002cc..d3ebc42cf 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -1,7 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import createServer from './server/createServer' - // config import CONFIG from './config' import { startValidateCommunities } from './federation/validateCommunities' diff --git a/backend/src/password/PasswordEncryptor.ts b/backend/src/password/PasswordEncryptor.ts index 1735106c1..1c7457a40 100644 --- a/backend/src/password/PasswordEncryptor.ts +++ b/backend/src/password/PasswordEncryptor.ts @@ -1,4 +1,5 @@ import { User } from '@entity/User' + // import { logger } from '@test/testSetup' getting error "jest is not defined" import { getUserCryptographicSalt, SecretKeyCryptographyCreateKey } from './EncryptorUtils' diff --git a/backend/src/seeds/creation/index.ts b/backend/src/seeds/creation/index.ts index 757407438..3f2a545a4 100644 --- a/backend/src/seeds/creation/index.ts +++ b/backend/src/seeds/creation/index.ts @@ -1,6 +1,7 @@ -import { CreationInterface } from './CreationInterface' import { nMonthsBefore } from '@/seeds/factory/creation' +import { CreationInterface } from './CreationInterface' + const bobsSendings = [ { amount: 10, diff --git a/backend/src/seeds/index.ts b/backend/src/seeds/index.ts index 19f936d16..9f945086c 100644 --- a/backend/src/seeds/index.ts +++ b/backend/src/seeds/index.ts @@ -8,6 +8,9 @@ import { createTestClient } from 'apollo-server-testing' import { name, internet, datatype } from 'faker' import { entities } from '@entity/index' +import createServer from '@/server/createServer' +import { backendLogger as logger } from '@/server/logger' +import CONFIG from '@/config' import { users } from './users/index' import { creations } from './creation/index' @@ -17,9 +20,6 @@ import { userFactory } from './factory/user' import { creationFactory } from './factory/creation' import { transactionLinkFactory } from './factory/transactionLink' import { contributionLinkFactory } from './factory/contributionLink' -import createServer from '@/server/createServer' -import { backendLogger as logger } from '@/server/logger' -import CONFIG from '@/config' CONFIG.EMAIL = false diff --git a/backend/src/server/LogError.test.ts b/backend/src/server/LogError.test.ts index 318a477ef..5aa1cae21 100644 --- a/backend/src/server/LogError.test.ts +++ b/backend/src/server/LogError.test.ts @@ -1,8 +1,9 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/unbound-method */ -import LogError from './LogError' import { logger } from '@test/testSetup' +import LogError from './LogError' + describe('LogError', () => { it('logs an Error when created', () => { /* eslint-disable-next-line no-new */ diff --git a/backend/src/server/context.ts b/backend/src/server/context.ts index 570865587..1990100dd 100644 --- a/backend/src/server/context.ts +++ b/backend/src/server/context.ts @@ -2,9 +2,10 @@ import { User as dbUser } from '@entity/User' import { Transaction as dbTransaction } from '@entity/Transaction' import { Decimal } from 'decimal.js-light' import { ExpressContext } from 'apollo-server-express' -import LogError from './LogError' import { Role } from '@/auth/Role' +import LogError from './LogError' + export interface Context { token: string | null setHeaders: { key: string; value: string }[] diff --git a/backend/src/server/createServer.ts b/backend/src/server/createServer.ts index f23e90b56..23e1ad0d2 100644 --- a/backend/src/server/createServer.ts +++ b/backend/src/server/createServer.ts @@ -5,17 +5,18 @@ import { ApolloServer } from 'apollo-server-express' import express, { Express, json, urlencoded } from 'express' import { Connection } from '@dbTools/typeorm' import { Logger } from 'log4js' -import cors from './cors' -import serverContext from './context' -import plugins from './plugins' -import { apolloLogger } from './logger' -import { i18n } from './localization' import connection from '@/typeorm/connection' import { checkDBVersion } from '@/typeorm/DBVersion' import CONFIG from '@/config' import schema from '@/graphql/schema' import { elopageWebhook } from '@/webhook/elopage' +import cors from './cors' +import serverContext from './context' +import plugins from './plugins' +import { apolloLogger } from './logger' +import { i18n } from './localization' + // TODO implement // import queryComplexity, { simpleEstimator, fieldConfigEstimator } from "graphql-query-complexity"; diff --git a/backend/src/server/localization.ts b/backend/src/server/localization.ts index 22616fcf0..59ba4cfce 100644 --- a/backend/src/server/localization.ts +++ b/backend/src/server/localization.ts @@ -1,5 +1,7 @@ import path from 'path' + import i18n from 'i18n' + import { backendLogger } from './logger' i18n.configure({ diff --git a/backend/src/server/logger.ts b/backend/src/server/logger.ts index 0887340d4..35587e9c6 100644 --- a/backend/src/server/logger.ts +++ b/backend/src/server/logger.ts @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { readFileSync } from 'fs' + import { configure, getLogger } from 'log4js' import CONFIG from '@/config' diff --git a/backend/src/util/decay.test.ts b/backend/src/util/decay.test.ts index b33d18d42..1d4ebab3b 100644 --- a/backend/src/util/decay.test.ts +++ b/backend/src/util/decay.test.ts @@ -1,4 +1,5 @@ import { Decimal } from 'decimal.js-light' + import { decayFormula, calculateDecay } from './decay' describe('utils/decay', () => { diff --git a/backend/src/util/validate.ts b/backend/src/util/validate.ts index ec28dfa13..02128cb87 100644 --- a/backend/src/util/validate.ts +++ b/backend/src/util/validate.ts @@ -1,11 +1,12 @@ import { Decimal } from 'decimal.js-light' import { getCustomRepository } from '@dbTools/typeorm' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' -import { calculateDecay } from './decay' import { getLastTransaction } from '@/graphql/resolver/util/getLastTransaction' import { TransactionLinkRepository } from '@repository/TransactionLink' import { Decay } from '@model/Decay' +import { calculateDecay } from './decay' + function isStringBoolean(value: string): boolean { const lowerValue = value.toLowerCase() if (lowerValue === 'true' || lowerValue === 'false') { diff --git a/backend/src/util/virtualTransactions.ts b/backend/src/util/virtualTransactions.ts index 7810ad871..442c06b21 100644 --- a/backend/src/util/virtualTransactions.ts +++ b/backend/src/util/virtualTransactions.ts @@ -2,11 +2,12 @@ import { SaveOptions, RemoveOptions } from '@dbTools/typeorm' import { Transaction as dbTransaction } from '@entity/Transaction' import { Decimal } from 'decimal.js-light' -import { calculateDecay } from './decay' import { Transaction } from '@model/Transaction' import { TransactionTypeId } from '@enum/TransactionTypeId' import { User } from '@model/User' +import { calculateDecay } from './decay' + const defaultModelFunctions = { hasId: function (): boolean { throw new Error('Function not implemented.') diff --git a/backend/test/helpers.ts b/backend/test/helpers.ts index ad6d2c4e3..b118f7b9d 100644 --- a/backend/test/helpers.ts +++ b/backend/test/helpers.ts @@ -9,9 +9,10 @@ import { createTestClient } from 'apollo-server-testing' import { initialize } from '@dbTools/helpers' import { entities } from '@entity/index' -import { i18n, logger } from './testSetup' import createServer from '@/server/createServer' +import { i18n, logger } from './testSetup' + export const headerPushMock = jest.fn((t) => { context.token = t.value }) From 80ff97e72a552a07c5e622b98b5932c5d7198532 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 30 Mar 2023 17:39:09 +0200 Subject: [PATCH 87/91] more lint fixes --- backend/.eslintrc.js | 2 +- backend/src/apis/HttpRequest.ts | 1 + backend/src/auth/JWT.ts | 1 + backend/src/emails/sendEmailTranslated.test.ts | 1 + backend/src/emails/sendEmailTranslated.ts | 1 + backend/src/emails/sendEmailVariants.test.ts | 1 + backend/src/emails/sendEmailVariants.ts | 1 + backend/src/federation/client/1_0/FederationClient.ts | 1 + backend/src/federation/client/1_1/FederationClient.ts | 1 + backend/src/federation/validateCommunities.test.ts | 1 + backend/src/federation/validateCommunities.ts | 1 + backend/src/graphql/arg/Paginated.ts | 1 + backend/src/graphql/arg/SearchUsersArgs.ts | 1 + backend/src/graphql/directive/isAuthorized.ts | 1 + backend/src/graphql/model/ContributionLink.ts | 1 + backend/src/graphql/model/ContributionLinkList.ts | 1 + backend/src/graphql/model/GdtEntry.ts | 1 + backend/src/graphql/model/Transaction.ts | 1 + backend/src/graphql/model/TransactionLink.ts | 1 + backend/src/graphql/resolver/BalanceResolver.ts | 1 + backend/src/graphql/resolver/CommunityResolver.test.ts | 1 + backend/src/graphql/resolver/CommunityResolver.ts | 1 + backend/src/graphql/resolver/ContributionLinkResolver.test.ts | 1 + backend/src/graphql/resolver/ContributionLinkResolver.ts | 1 + .../src/graphql/resolver/ContributionMessageResolver.test.ts | 1 + backend/src/graphql/resolver/ContributionMessageResolver.ts | 1 + backend/src/graphql/resolver/ContributionResolver.test.ts | 1 + backend/src/graphql/resolver/ContributionResolver.ts | 1 + backend/src/graphql/resolver/EmailOptinCodes.test.ts | 1 + backend/src/graphql/resolver/GdtResolver.ts | 1 + backend/src/graphql/resolver/KlicktippResolver.ts | 1 + backend/src/graphql/resolver/StatisticsResolver.ts | 1 + backend/src/graphql/resolver/TransactionLinkResolver.test.ts | 1 + backend/src/graphql/resolver/TransactionLinkResolver.ts | 1 + backend/src/graphql/resolver/TransactionResolver.test.ts | 1 + backend/src/graphql/resolver/TransactionResolver.ts | 1 + backend/src/graphql/resolver/UserResolver.test.ts | 1 + backend/src/graphql/resolver/UserResolver.ts | 1 + backend/src/graphql/resolver/semaphore.test.ts | 1 + backend/src/graphql/resolver/util/creations.test.ts | 1 + backend/src/graphql/resolver/util/creations.ts | 1 + backend/src/graphql/resolver/util/findContributions.ts | 1 + backend/src/graphql/resolver/util/transactionLinkList.ts | 1 + backend/src/graphql/union/QueryLinkResult.ts | 1 + backend/src/middleware/klicktippMiddleware.ts | 1 + backend/src/password/EncryptorUtils.ts | 1 + backend/src/seeds/factory/contributionLink.ts | 1 + backend/src/seeds/factory/creation.ts | 1 + backend/src/seeds/factory/transactionLink.ts | 1 + backend/src/seeds/factory/user.ts | 1 + backend/src/seeds/index.ts | 1 + backend/src/server/context.ts | 1 + backend/src/server/createServer.ts | 1 + backend/src/server/logger.ts | 1 + backend/src/typeorm/DBVersion.ts | 1 + backend/src/typeorm/connection.ts | 1 + backend/src/typeorm/repository/Transaction.ts | 1 + backend/src/typeorm/repository/User.ts | 1 + backend/src/util/communityUser.ts | 1 + backend/src/util/decay.ts | 1 + backend/src/util/klicktipp.ts | 1 + backend/src/util/validate.ts | 1 + backend/src/util/virtualTransactions.ts | 1 + backend/src/webhook/elopage.ts | 1 + backend/test/helpers.ts | 1 + 65 files changed, 65 insertions(+), 1 deletion(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index 59bd53ca6..6b6db0486 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -88,7 +88,7 @@ module.exports = { position: 'after', }, ], - distinctGroup: false, + distinctGroup: true, }, ], 'import/prefer-default-export': 'off', // TODO diff --git a/backend/src/apis/HttpRequest.ts b/backend/src/apis/HttpRequest.ts index af7e40dd7..eff0c408a 100644 --- a/backend/src/apis/HttpRequest.ts +++ b/backend/src/apis/HttpRequest.ts @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import axios from 'axios' + import { backendLogger as logger } from '@/server/logger' import LogError from '@/server/LogError' diff --git a/backend/src/auth/JWT.ts b/backend/src/auth/JWT.ts index f0a320efb..93a6a8868 100644 --- a/backend/src/auth/JWT.ts +++ b/backend/src/auth/JWT.ts @@ -1,4 +1,5 @@ import { verify, sign } from 'jsonwebtoken' + import CONFIG from '@/config/' import LogError from '@/server/LogError' diff --git a/backend/src/emails/sendEmailTranslated.test.ts b/backend/src/emails/sendEmailTranslated.test.ts index 5eea352fb..5a095f563 100644 --- a/backend/src/emails/sendEmailTranslated.test.ts +++ b/backend/src/emails/sendEmailTranslated.test.ts @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/unbound-method */ import { createTransport } from 'nodemailer' + import { logger, i18n } from '@test/testSetup' import CONFIG from '@/config' diff --git a/backend/src/emails/sendEmailTranslated.ts b/backend/src/emails/sendEmailTranslated.ts index 5cc136edc..96fd27d83 100644 --- a/backend/src/emails/sendEmailTranslated.ts +++ b/backend/src/emails/sendEmailTranslated.ts @@ -4,6 +4,7 @@ import path from 'path' import { createTransport } from 'nodemailer' import Email from 'email-templates' import i18n from 'i18n' + import { backendLogger as logger } from '@/server/logger' import CONFIG from '@/config' import LogError from '@/server/LogError' diff --git a/backend/src/emails/sendEmailVariants.test.ts b/backend/src/emails/sendEmailVariants.test.ts index 76d8f9a26..849b9d7f1 100644 --- a/backend/src/emails/sendEmailVariants.test.ts +++ b/backend/src/emails/sendEmailVariants.test.ts @@ -4,6 +4,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { Decimal } from 'decimal.js-light' + import { testEnvironment } from '@test/helpers' import { logger, i18n as localization } from '@test/testSetup' import CONFIG from '@/config' diff --git a/backend/src/emails/sendEmailVariants.ts b/backend/src/emails/sendEmailVariants.ts index 7da0424dc..b45e7fc67 100644 --- a/backend/src/emails/sendEmailVariants.ts +++ b/backend/src/emails/sendEmailVariants.ts @@ -1,4 +1,5 @@ import { Decimal } from 'decimal.js-light' + import CONFIG from '@/config' import { decimalSeparatorByLanguage } from '@/util/utilities' diff --git a/backend/src/federation/client/1_0/FederationClient.ts b/backend/src/federation/client/1_0/FederationClient.ts index ce0d708bc..7261bae45 100644 --- a/backend/src/federation/client/1_0/FederationClient.ts +++ b/backend/src/federation/client/1_0/FederationClient.ts @@ -3,6 +3,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { gql } from 'graphql-request' import { Community as DbCommunity } from '@entity/Community' + import { GraphQLGetClient } from '@/federation/client/GraphQLGetClient' import { backendLogger as logger } from '@/server/logger' import LogError from '@/server/LogError' diff --git a/backend/src/federation/client/1_1/FederationClient.ts b/backend/src/federation/client/1_1/FederationClient.ts index 579a9701c..7dca9b465 100644 --- a/backend/src/federation/client/1_1/FederationClient.ts +++ b/backend/src/federation/client/1_1/FederationClient.ts @@ -3,6 +3,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ import { gql } from 'graphql-request' import { Community as DbCommunity } from '@entity/Community' + import { GraphQLGetClient } from '@/federation/client/GraphQLGetClient' import { backendLogger as logger } from '@/server/logger' import LogError from '@/server/LogError' diff --git a/backend/src/federation/validateCommunities.test.ts b/backend/src/federation/validateCommunities.test.ts index 919a99547..d46720ff8 100644 --- a/backend/src/federation/validateCommunities.test.ts +++ b/backend/src/federation/validateCommunities.test.ts @@ -6,6 +6,7 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Community as DbCommunity } from '@entity/Community' + import { logger } from '@test/testSetup' import { testEnvironment, cleanDB } from '@test/helpers' diff --git a/backend/src/federation/validateCommunities.ts b/backend/src/federation/validateCommunities.ts index c4a9f3b1d..642e59929 100644 --- a/backend/src/federation/validateCommunities.ts +++ b/backend/src/federation/validateCommunities.ts @@ -1,5 +1,6 @@ import { Community as DbCommunity } from '@entity/Community' import { IsNull } from '@dbTools/typeorm' + import { backendLogger as logger } from '@/server/logger' import LogError from '@/server/LogError' diff --git a/backend/src/graphql/arg/Paginated.ts b/backend/src/graphql/arg/Paginated.ts index 290dba337..e605c49d4 100644 --- a/backend/src/graphql/arg/Paginated.ts +++ b/backend/src/graphql/arg/Paginated.ts @@ -1,5 +1,6 @@ /* eslint-disable type-graphql/invalid-nullable-input-type */ import { ArgsType, Field, Int } from 'type-graphql' + import { Order } from '@enum/Order' @ArgsType() diff --git a/backend/src/graphql/arg/SearchUsersArgs.ts b/backend/src/graphql/arg/SearchUsersArgs.ts index 39996efca..de7275f63 100644 --- a/backend/src/graphql/arg/SearchUsersArgs.ts +++ b/backend/src/graphql/arg/SearchUsersArgs.ts @@ -1,4 +1,5 @@ import { ArgsType, Field, Int } from 'type-graphql' + import SearchUsersFilters from '@arg/SearchUsersFilters' @ArgsType() diff --git a/backend/src/graphql/directive/isAuthorized.ts b/backend/src/graphql/directive/isAuthorized.ts index 845593de6..09eac70a9 100644 --- a/backend/src/graphql/directive/isAuthorized.ts +++ b/backend/src/graphql/directive/isAuthorized.ts @@ -4,6 +4,7 @@ import { AuthChecker } from 'type-graphql' import { User } from '@entity/User' + import { decode, encode } from '@/auth/JWT' import { ROLE_UNAUTHORIZED, ROLE_USER, ROLE_ADMIN } from '@/auth/ROLES' import { RIGHTS } from '@/auth/RIGHTS' diff --git a/backend/src/graphql/model/ContributionLink.ts b/backend/src/graphql/model/ContributionLink.ts index 13ae31692..0da2fd430 100644 --- a/backend/src/graphql/model/ContributionLink.ts +++ b/backend/src/graphql/model/ContributionLink.ts @@ -1,6 +1,7 @@ import { ObjectType, Field, Int } from 'type-graphql' import { Decimal } from 'decimal.js-light' import { ContributionLink as dbContributionLink } from '@entity/ContributionLink' + import CONFIG from '@/config' @ObjectType() diff --git a/backend/src/graphql/model/ContributionLinkList.ts b/backend/src/graphql/model/ContributionLinkList.ts index d2c347b27..c35f6fae6 100644 --- a/backend/src/graphql/model/ContributionLinkList.ts +++ b/backend/src/graphql/model/ContributionLinkList.ts @@ -1,4 +1,5 @@ import { ObjectType, Field, Int } from 'type-graphql' + import { ContributionLink } from '@model/ContributionLink' @ObjectType() diff --git a/backend/src/graphql/model/GdtEntry.ts b/backend/src/graphql/model/GdtEntry.ts index bbf1cceef..81dda0ca7 100644 --- a/backend/src/graphql/model/GdtEntry.ts +++ b/backend/src/graphql/model/GdtEntry.ts @@ -3,6 +3,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { ObjectType, Field, Float, Int } from 'type-graphql' + import { GdtEntryType } from '@enum/GdtEntryType' @ObjectType() diff --git a/backend/src/graphql/model/Transaction.ts b/backend/src/graphql/model/Transaction.ts index 0a31cd8d6..3538260a5 100644 --- a/backend/src/graphql/model/Transaction.ts +++ b/backend/src/graphql/model/Transaction.ts @@ -1,6 +1,7 @@ import { ObjectType, Field, Int } from 'type-graphql' import { Transaction as dbTransaction } from '@entity/Transaction' import { Decimal } from 'decimal.js-light' + import { TransactionTypeId } from '@enum/TransactionTypeId' import { Decay } from './Decay' diff --git a/backend/src/graphql/model/TransactionLink.ts b/backend/src/graphql/model/TransactionLink.ts index 1ed02b476..1e9c1a64d 100644 --- a/backend/src/graphql/model/TransactionLink.ts +++ b/backend/src/graphql/model/TransactionLink.ts @@ -1,6 +1,7 @@ import { ObjectType, Field, Int } from 'type-graphql' import { Decimal } from 'decimal.js-light' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' + import CONFIG from '@/config' import { User } from './User' diff --git a/backend/src/graphql/resolver/BalanceResolver.ts b/backend/src/graphql/resolver/BalanceResolver.ts index 0a9b651a9..aca10ed0f 100644 --- a/backend/src/graphql/resolver/BalanceResolver.ts +++ b/backend/src/graphql/resolver/BalanceResolver.ts @@ -4,6 +4,7 @@ import { Resolver, Query, Ctx, Authorized } from 'type-graphql' import { getCustomRepository } from '@dbTools/typeorm' import { Transaction as dbTransaction } from '@entity/Transaction' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' + import { TransactionLinkRepository } from '@repository/TransactionLink' import { Balance } from '@model/Balance' import { backendLogger as logger } from '@/server/logger' diff --git a/backend/src/graphql/resolver/CommunityResolver.test.ts b/backend/src/graphql/resolver/CommunityResolver.test.ts index f4352c095..b78d419f9 100644 --- a/backend/src/graphql/resolver/CommunityResolver.test.ts +++ b/backend/src/graphql/resolver/CommunityResolver.test.ts @@ -6,6 +6,7 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Community as DbCommunity } from '@entity/Community' + import { getCommunities } from '@/seeds/graphql/queries' import { testEnvironment } from '@test/helpers' diff --git a/backend/src/graphql/resolver/CommunityResolver.ts b/backend/src/graphql/resolver/CommunityResolver.ts index 37c42dd89..74ba0e57b 100644 --- a/backend/src/graphql/resolver/CommunityResolver.ts +++ b/backend/src/graphql/resolver/CommunityResolver.ts @@ -1,5 +1,6 @@ import { Resolver, Query, Authorized } from 'type-graphql' import { Community as DbCommunity } from '@entity/Community' + import { Community } from '@model/Community' import { RIGHTS } from '@/auth/RIGHTS' diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts index 6a69e257e..6bd62fd9f 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts @@ -8,6 +8,7 @@ import { Decimal } from 'decimal.js-light' import { GraphQLError } from 'graphql' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' + import { logger } from '@test/testSetup' import { login, diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.ts b/backend/src/graphql/resolver/ContributionLinkResolver.ts index 5febb95c5..815901f16 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.ts @@ -2,6 +2,7 @@ import { Decimal } from 'decimal.js-light' import { Resolver, Args, Arg, Authorized, Mutation, Query, Int, Ctx } from 'type-graphql' import { MoreThan, IsNull } from '@dbTools/typeorm' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' + import { ContributionLinkList } from '@model/ContributionLinkList' import { ContributionLink } from '@model/ContributionLink' import ContributionLinkArgs from '@arg/ContributionLinkArgs' diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts index 6b2c7c4d8..357455250 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts @@ -8,6 +8,7 @@ import { GraphQLError } from 'graphql' import { Event as DbEvent } from '@entity/Event' + import { cleanDB, resetToken, testEnvironment } from '@test/helpers' import { logger, i18n as localization } from '@test/testSetup' import { diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.ts b/backend/src/graphql/resolver/ContributionMessageResolver.ts index 63cf2fd9c..b78f441d5 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.ts @@ -5,6 +5,7 @@ import { ContributionMessage as DbContributionMessage } from '@entity/Contributi import { Contribution as DbContribution } from '@entity/Contribution' import { UserContact as DbUserContact } from '@entity/UserContact' import { User as DbUser } from '@entity/User' + import { ContributionMessage, ContributionMessageListResult } from '@model/ContributionMessage' import ContributionMessageArgs from '@arg/ContributionMessageArgs' import { ContributionMessageType } from '@enum/MessageType' diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index df8524a0c..d05060c7e 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -13,6 +13,7 @@ import { Transaction as DbTransaction } from '@entity/Transaction' import { User } from '@entity/User' import { UserInputError } from 'apollo-server-express' import { Event as DbEvent } from '@entity/Event' + import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { stephenHawking } from '@/seeds/users/stephen-hawking' diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 026793b5f..28b393be5 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -7,6 +7,7 @@ import { ContributionMessage } from '@entity/ContributionMessage' import { UserContact } from '@entity/UserContact' import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' + import { AdminUpdateContribution } from '@model/AdminUpdateContribution' import { Contribution, ContributionListResult } from '@model/Contribution' import { Decay } from '@model/Decay' diff --git a/backend/src/graphql/resolver/EmailOptinCodes.test.ts b/backend/src/graphql/resolver/EmailOptinCodes.test.ts index e9f9bc052..0b6ebfbe4 100644 --- a/backend/src/graphql/resolver/EmailOptinCodes.test.ts +++ b/backend/src/graphql/resolver/EmailOptinCodes.test.ts @@ -6,6 +6,7 @@ import { User as DbUser } from '@entity/User' import { GraphQLError } from 'graphql' + import { testEnvironment, cleanDB } from '@test/helpers' import { createUser, setPassword, forgotPassword } from '@/seeds/graphql/mutations' import { queryOptIn } from '@/seeds/graphql/queries' diff --git a/backend/src/graphql/resolver/GdtResolver.ts b/backend/src/graphql/resolver/GdtResolver.ts index e5ad56f2d..00b0aa1bf 100644 --- a/backend/src/graphql/resolver/GdtResolver.ts +++ b/backend/src/graphql/resolver/GdtResolver.ts @@ -2,6 +2,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-return */ import { Resolver, Query, Args, Ctx, Authorized, Arg, Int, Float } from 'type-graphql' + import { GdtEntryList } from '@model/GdtEntryList' import { Order } from '@enum/Order' import Paginated from '@arg/Paginated' diff --git a/backend/src/graphql/resolver/KlicktippResolver.ts b/backend/src/graphql/resolver/KlicktippResolver.ts index f8aee5e2c..31bde0581 100644 --- a/backend/src/graphql/resolver/KlicktippResolver.ts +++ b/backend/src/graphql/resolver/KlicktippResolver.ts @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ import { Resolver, Query, Authorized, Arg, Mutation, Ctx } from 'type-graphql' + import { getKlickTippUser, getKlicktippTagMap, diff --git a/backend/src/graphql/resolver/StatisticsResolver.ts b/backend/src/graphql/resolver/StatisticsResolver.ts index f16a2fd56..3ddc8bfbc 100644 --- a/backend/src/graphql/resolver/StatisticsResolver.ts +++ b/backend/src/graphql/resolver/StatisticsResolver.ts @@ -5,6 +5,7 @@ import { Resolver, Query, Authorized, FieldResolver } from 'type-graphql' import { getConnection } from '@dbTools/typeorm' import { Transaction as DbTransaction } from '@entity/Transaction' import { User as DbUser } from '@entity/User' + import { CommunityStatistics, DynamicStatisticsFields } from '@model/CommunityStatistics' import { RIGHTS } from '@/auth/RIGHTS' import { calculateDecay } from '@/util/decay' diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index 0ac73cbcf..d9010b57a 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -13,6 +13,7 @@ import { GraphQLError } from 'graphql' import { Transaction } from '@entity/Transaction' import { Event as DbEvent } from '@entity/Event' import { UserContact } from '@entity/UserContact' + import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' import { cleanDB, testEnvironment, resetToken, resetEntity } from '@test/helpers' diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.ts b/backend/src/graphql/resolver/TransactionLinkResolver.ts index e9a388cde..2131439d5 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.ts @@ -8,6 +8,7 @@ import { Transaction as DbTransaction } from '@entity/Transaction' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Resolver, Args, Arg, Authorized, Ctx, Mutation, Query, Int } from 'type-graphql' + import { User } from '@model/User' import { ContributionLink } from '@model/ContributionLink' import { Decay } from '@model/Decay' diff --git a/backend/src/graphql/resolver/TransactionResolver.test.ts b/backend/src/graphql/resolver/TransactionResolver.test.ts index baa50e171..558f0c315 100644 --- a/backend/src/graphql/resolver/TransactionResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionResolver.test.ts @@ -10,6 +10,7 @@ import { Transaction } from '@entity/Transaction' import { User } from '@entity/User' import { GraphQLError } from 'graphql' import { Event as DbEvent } from '@entity/Event' + import { EventType } from '@/event/Event' import { userFactory } from '@/seeds/factory/user' import { diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 7f3f1c5f1..f36ac3d68 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -8,6 +8,7 @@ import { getCustomRepository, getConnection, In } from '@dbTools/typeorm' import { User as dbUser } from '@entity/User' import { Transaction as dbTransaction } from '@entity/Transaction' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' + import { TransactionRepository } from '@repository/Transaction' import { TransactionLinkRepository } from '@repository/TransactionLink' import { User } from '@model/User' diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index aebd0f0eb..ccf56a285 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -12,6 +12,7 @@ import { TransactionLink } from '@entity/TransactionLink' import { validate as validateUUID, version as versionUUID } from 'uuid' import { UserContact } from '@entity/UserContact' import { Event as DbEvent } from '@entity/Event' + import { OptInType } from '@enum/OptInType' import { UserContactType } from '@enum/UserContactType' import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 5f66e7725..0be376bd6 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -20,6 +20,7 @@ import { User as DbUser } from '@entity/User' import { UserContact as DbUserContact } from '@entity/UserContact' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' + import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' import { UserRepository } from '@repository/User' import { User } from '@model/User' diff --git a/backend/src/graphql/resolver/semaphore.test.ts b/backend/src/graphql/resolver/semaphore.test.ts index 6b1976021..0fb355676 100644 --- a/backend/src/graphql/resolver/semaphore.test.ts +++ b/backend/src/graphql/resolver/semaphore.test.ts @@ -5,6 +5,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { Decimal } from 'decimal.js-light' + import { userFactory } from '@/seeds/factory/user' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { bobBaumeister } from '@/seeds/users/bob-baumeister' diff --git a/backend/src/graphql/resolver/util/creations.test.ts b/backend/src/graphql/resolver/util/creations.test.ts index a35b37891..37bdb742c 100644 --- a/backend/src/graphql/resolver/util/creations.test.ts +++ b/backend/src/graphql/resolver/util/creations.test.ts @@ -6,6 +6,7 @@ import { User } from '@entity/User' import { Contribution } from '@entity/Contribution' + import { testEnvironment, cleanDB, contributionDateFormatter } from '@test/helpers' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' diff --git a/backend/src/graphql/resolver/util/creations.ts b/backend/src/graphql/resolver/util/creations.ts index 6ebeae8b9..44b675de4 100644 --- a/backend/src/graphql/resolver/util/creations.ts +++ b/backend/src/graphql/resolver/util/creations.ts @@ -3,6 +3,7 @@ import { getConnection } from '@dbTools/typeorm' import { Contribution } from '@entity/Contribution' import { Decimal } from 'decimal.js-light' + import { FULL_CREATION_AVAILABLE, MAX_CREATION_AMOUNT } from '@/graphql/resolver/const/const' import { backendLogger as logger } from '@/server/logger' import { OpenCreation } from '@model/OpenCreation' diff --git a/backend/src/graphql/resolver/util/findContributions.ts b/backend/src/graphql/resolver/util/findContributions.ts index a40279e9c..5c70fafe7 100644 --- a/backend/src/graphql/resolver/util/findContributions.ts +++ b/backend/src/graphql/resolver/util/findContributions.ts @@ -1,5 +1,6 @@ import { Contribution as DbContribution } from '@entity/Contribution' import { In } from '@dbTools/typeorm' + import { ContributionStatus } from '@enum/ContributionStatus' import { Order } from '@enum/Order' diff --git a/backend/src/graphql/resolver/util/transactionLinkList.ts b/backend/src/graphql/resolver/util/transactionLinkList.ts index 2d151b94a..ed90cc852 100644 --- a/backend/src/graphql/resolver/util/transactionLinkList.ts +++ b/backend/src/graphql/resolver/util/transactionLinkList.ts @@ -1,6 +1,7 @@ import { MoreThan } from '@dbTools/typeorm' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { User as DbUser } from '@entity/User' + import { Order } from '@enum/Order' import Paginated from '@arg/Paginated' import TransactionLinkFilters from '@arg/TransactionLinkFilters' diff --git a/backend/src/graphql/union/QueryLinkResult.ts b/backend/src/graphql/union/QueryLinkResult.ts index 9a35fbc71..775320bdd 100644 --- a/backend/src/graphql/union/QueryLinkResult.ts +++ b/backend/src/graphql/union/QueryLinkResult.ts @@ -1,4 +1,5 @@ import { createUnionType } from 'type-graphql' + import { TransactionLink } from '@model/TransactionLink' import { ContributionLink } from '@model/ContributionLink' diff --git a/backend/src/middleware/klicktippMiddleware.ts b/backend/src/middleware/klicktippMiddleware.ts index 0469b4ccc..e133977ee 100644 --- a/backend/src/middleware/klicktippMiddleware.ts +++ b/backend/src/middleware/klicktippMiddleware.ts @@ -3,6 +3,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/restrict-template-expressions */ import { MiddlewareFn } from 'type-graphql' + import { /* klicktippSignIn, */ getKlickTippUser } from '@/apis/KlicktippController' import { KlickTipp } from '@model/KlickTipp' import CONFIG from '@/config' diff --git a/backend/src/password/EncryptorUtils.ts b/backend/src/password/EncryptorUtils.ts index b4531b3bb..9537fb59e 100644 --- a/backend/src/password/EncryptorUtils.ts +++ b/backend/src/password/EncryptorUtils.ts @@ -2,6 +2,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { User } from '@entity/User' + import CONFIG from '@/config' import LogError from '@/server/LogError' import { backendLogger as logger } from '@/server/logger' diff --git a/backend/src/seeds/factory/contributionLink.ts b/backend/src/seeds/factory/contributionLink.ts index 5925cdcfe..565669dad 100644 --- a/backend/src/seeds/factory/contributionLink.ts +++ b/backend/src/seeds/factory/contributionLink.ts @@ -2,6 +2,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/unbound-method */ import { ApolloServerTestClient } from 'apollo-server-testing' + import { login, createContributionLink } from '@/seeds/graphql/mutations' import { ContributionLink } from '@model/ContributionLink' import { ContributionLinkInterface } from '@/seeds/contributionLink/ContributionLinkInterface' diff --git a/backend/src/seeds/factory/creation.ts b/backend/src/seeds/factory/creation.ts index ba46f4c09..d0ca131c7 100644 --- a/backend/src/seeds/factory/creation.ts +++ b/backend/src/seeds/factory/creation.ts @@ -8,6 +8,7 @@ import { ApolloServerTestClient } from 'apollo-server-testing' import { Transaction } from '@entity/Transaction' import { Contribution } from '@entity/Contribution' + import { CreationInterface } from '@/seeds/creation/CreationInterface' import { login, createContribution, confirmContribution } from '@/seeds/graphql/mutations' import { findUserByEmail } from '@/graphql/resolver/UserResolver' diff --git a/backend/src/seeds/factory/transactionLink.ts b/backend/src/seeds/factory/transactionLink.ts index c6ed68839..fa4478074 100644 --- a/backend/src/seeds/factory/transactionLink.ts +++ b/backend/src/seeds/factory/transactionLink.ts @@ -2,6 +2,7 @@ /* eslint-disable @typescript-eslint/unbound-method */ import { ApolloServerTestClient } from 'apollo-server-testing' import { TransactionLink } from '@entity/TransactionLink' + import { login, createTransactionLink } from '@/seeds/graphql/mutations' import { TransactionLinkInterface } from '@/seeds/transactionLink/TransactionLinkInterface' import { transactionLinkExpireDate } from '@/graphql/resolver/TransactionLinkResolver' diff --git a/backend/src/seeds/factory/user.ts b/backend/src/seeds/factory/user.ts index c82c56648..13a274911 100644 --- a/backend/src/seeds/factory/user.ts +++ b/backend/src/seeds/factory/user.ts @@ -2,6 +2,7 @@ /* eslint-disable @typescript-eslint/unbound-method */ import { User } from '@entity/User' import { ApolloServerTestClient } from 'apollo-server-testing' + import { createUser, setPassword } from '@/seeds/graphql/mutations' import { UserInterface } from '@/seeds/users/UserInterface' diff --git a/backend/src/seeds/index.ts b/backend/src/seeds/index.ts index 9f945086c..0d972abb3 100644 --- a/backend/src/seeds/index.ts +++ b/backend/src/seeds/index.ts @@ -8,6 +8,7 @@ import { createTestClient } from 'apollo-server-testing' import { name, internet, datatype } from 'faker' import { entities } from '@entity/index' + import createServer from '@/server/createServer' import { backendLogger as logger } from '@/server/logger' import CONFIG from '@/config' diff --git a/backend/src/server/context.ts b/backend/src/server/context.ts index 1990100dd..4b631bd9c 100644 --- a/backend/src/server/context.ts +++ b/backend/src/server/context.ts @@ -2,6 +2,7 @@ import { User as dbUser } from '@entity/User' import { Transaction as dbTransaction } from '@entity/Transaction' import { Decimal } from 'decimal.js-light' import { ExpressContext } from 'apollo-server-express' + import { Role } from '@/auth/Role' import LogError from './LogError' diff --git a/backend/src/server/createServer.ts b/backend/src/server/createServer.ts index 23e1ad0d2..6ffd18c50 100644 --- a/backend/src/server/createServer.ts +++ b/backend/src/server/createServer.ts @@ -5,6 +5,7 @@ import { ApolloServer } from 'apollo-server-express' import express, { Express, json, urlencoded } from 'express' import { Connection } from '@dbTools/typeorm' import { Logger } from 'log4js' + import connection from '@/typeorm/connection' import { checkDBVersion } from '@/typeorm/DBVersion' import CONFIG from '@/config' diff --git a/backend/src/server/logger.ts b/backend/src/server/logger.ts index 35587e9c6..89f292ab7 100644 --- a/backend/src/server/logger.ts +++ b/backend/src/server/logger.ts @@ -3,6 +3,7 @@ import { readFileSync } from 'fs' import { configure, getLogger } from 'log4js' + import CONFIG from '@/config' const options = JSON.parse(readFileSync(CONFIG.LOG4JS_CONFIG, 'utf-8')) diff --git a/backend/src/typeorm/DBVersion.ts b/backend/src/typeorm/DBVersion.ts index cb53c49f1..c4c8d6c78 100644 --- a/backend/src/typeorm/DBVersion.ts +++ b/backend/src/typeorm/DBVersion.ts @@ -1,4 +1,5 @@ import { Migration } from '@entity/Migration' + import { backendLogger as logger } from '@/server/logger' const getDBVersion = async (): Promise => { diff --git a/backend/src/typeorm/connection.ts b/backend/src/typeorm/connection.ts index 54b951a79..a3a20450b 100644 --- a/backend/src/typeorm/connection.ts +++ b/backend/src/typeorm/connection.ts @@ -2,6 +2,7 @@ // We cannot use our connection here, but must use the external typeorm installation import { Connection, createConnection, FileLogger } from '@dbTools/typeorm' import { entities } from '@entity/index' + import CONFIG from '@/config' const connection = async (): Promise => { diff --git a/backend/src/typeorm/repository/Transaction.ts b/backend/src/typeorm/repository/Transaction.ts index 58e9ca30b..61e87b3c8 100644 --- a/backend/src/typeorm/repository/Transaction.ts +++ b/backend/src/typeorm/repository/Transaction.ts @@ -1,5 +1,6 @@ import { EntityRepository, Repository } from '@dbTools/typeorm' import { Transaction } from '@entity/Transaction' + import { Order } from '@enum/Order' import { TransactionTypeId } from '@enum/TransactionTypeId' diff --git a/backend/src/typeorm/repository/User.ts b/backend/src/typeorm/repository/User.ts index 4928b0cc8..71e43329b 100644 --- a/backend/src/typeorm/repository/User.ts +++ b/backend/src/typeorm/repository/User.ts @@ -1,5 +1,6 @@ import { Brackets, EntityRepository, IsNull, Not, Repository } from '@dbTools/typeorm' import { User as DbUser } from '@entity/User' + import SearchUsersFilters from '@/graphql/arg/SearchUsersFilters' @EntityRepository(DbUser) diff --git a/backend/src/util/communityUser.ts b/backend/src/util/communityUser.ts index dfa477da9..0c9480118 100644 --- a/backend/src/util/communityUser.ts +++ b/backend/src/util/communityUser.ts @@ -3,6 +3,7 @@ import { SaveOptions, RemoveOptions } from '@dbTools/typeorm' import { User as dbUser } from '@entity/User' import { UserContact } from '@entity/UserContact' + import { PasswordEncryptionType } from '@/graphql/enum/PasswordEncryptionType' // import { UserContact as EmailContact } from '@entity/UserContact' import { User } from '@model/User' diff --git a/backend/src/util/decay.ts b/backend/src/util/decay.ts index d35eb83a4..5e2bdb5c6 100644 --- a/backend/src/util/decay.ts +++ b/backend/src/util/decay.ts @@ -1,4 +1,5 @@ import { Decimal } from 'decimal.js-light' + import CONFIG from '@/config' import { Decay } from '@model/Decay' import LogError from '@/server/LogError' diff --git a/backend/src/util/klicktipp.ts b/backend/src/util/klicktipp.ts index 6444d20f6..02bfa1044 100644 --- a/backend/src/util/klicktipp.ts +++ b/backend/src/util/klicktipp.ts @@ -1,4 +1,5 @@ import { User } from '@entity/User' + import connection from '@/typeorm/connection' import { getKlickTippUser } from '@/apis/KlicktippController' import LogError from '@/server/LogError' diff --git a/backend/src/util/validate.ts b/backend/src/util/validate.ts index 02128cb87..628b00d43 100644 --- a/backend/src/util/validate.ts +++ b/backend/src/util/validate.ts @@ -1,6 +1,7 @@ import { Decimal } from 'decimal.js-light' import { getCustomRepository } from '@dbTools/typeorm' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' + import { getLastTransaction } from '@/graphql/resolver/util/getLastTransaction' import { TransactionLinkRepository } from '@repository/TransactionLink' import { Decay } from '@model/Decay' diff --git a/backend/src/util/virtualTransactions.ts b/backend/src/util/virtualTransactions.ts index 442c06b21..f9f13afbc 100644 --- a/backend/src/util/virtualTransactions.ts +++ b/backend/src/util/virtualTransactions.ts @@ -2,6 +2,7 @@ import { SaveOptions, RemoveOptions } from '@dbTools/typeorm' import { Transaction as dbTransaction } from '@entity/Transaction' import { Decimal } from 'decimal.js-light' + import { Transaction } from '@model/Transaction' import { TransactionTypeId } from '@enum/TransactionTypeId' import { User } from '@model/User' diff --git a/backend/src/webhook/elopage.ts b/backend/src/webhook/elopage.ts index 6f3e3cbdb..404f2696a 100644 --- a/backend/src/webhook/elopage.ts +++ b/backend/src/webhook/elopage.ts @@ -33,6 +33,7 @@ import { LoginElopageBuys } from '@entity/LoginElopageBuys' import { UserContact as dbUserContact } from '@entity/UserContact' + import { UserResolver } from '@/graphql/resolver/UserResolver' export const elopageWebhook = async (req: any, res: any): Promise => { diff --git a/backend/test/helpers.ts b/backend/test/helpers.ts index b118f7b9d..f68c15cb8 100644 --- a/backend/test/helpers.ts +++ b/backend/test/helpers.ts @@ -9,6 +9,7 @@ import { createTestClient } from 'apollo-server-testing' import { initialize } from '@dbTools/helpers' import { entities } from '@entity/index' + import createServer from '@/server/createServer' import { i18n, logger } from './testSetup' From 9407386de74172271848057e02639c55ed8ffa75 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 30 Mar 2023 17:57:15 +0200 Subject: [PATCH 88/91] fix alphabetical sort --- backend/.eslintrc.js | 4 ++ backend/src/apis/HttpRequest.ts | 2 +- backend/src/config/index.ts | 2 +- .../src/emails/sendEmailTranslated.test.ts | 2 +- backend/src/emails/sendEmailTranslated.ts | 4 +- backend/src/emails/sendEmailVariants.test.ts | 2 +- .../event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts | 4 +- .../event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts | 4 +- .../event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts | 4 +- .../event/EVENT_ADMIN_CONTRIBUTION_DENY.ts | 4 +- .../EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts | 4 +- .../EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts | 2 +- .../EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts | 4 +- ...EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts | 2 +- .../event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts | 4 +- backend/src/event/EVENT_ADMIN_USER_DELETE.ts | 2 +- .../src/event/EVENT_ADMIN_USER_ROLE_SET.ts | 2 +- .../src/event/EVENT_ADMIN_USER_UNDELETE.ts | 2 +- .../src/event/EVENT_CONTRIBUTION_CREATE.ts | 4 +- .../src/event/EVENT_CONTRIBUTION_DELETE.ts | 4 +- .../event/EVENT_CONTRIBUTION_LINK_REDEEM.ts | 6 +- .../EVENT_CONTRIBUTION_MESSAGE_CREATE.ts | 2 +- .../src/event/EVENT_CONTRIBUTION_UPDATE.ts | 4 +- .../EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION.ts | 2 +- .../event/EVENT_EMAIL_ADMIN_CONFIRMATION.ts | 2 +- backend/src/event/EVENT_EMAIL_CONFIRMATION.ts | 2 +- .../src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts | 2 +- .../event/EVENT_TRANSACTION_LINK_CREATE.ts | 6 +- .../event/EVENT_TRANSACTION_LINK_DELETE.ts | 4 +- .../event/EVENT_TRANSACTION_LINK_REDEEM.ts | 6 +- .../src/event/EVENT_TRANSACTION_RECEIVE.ts | 6 +- backend/src/event/EVENT_TRANSACTION_SEND.ts | 6 +- .../src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts | 2 +- backend/src/event/EVENT_USER_INFO_UPDATE.ts | 2 +- backend/src/event/EVENT_USER_LOGIN.ts | 2 +- backend/src/event/EVENT_USER_LOGOUT.ts | 2 +- backend/src/event/EVENT_USER_REGISTER.ts | 2 +- backend/src/event/Event.ts | 8 +-- .../federation/client/1_0/FederationClient.ts | 4 +- .../federation/client/1_1/FederationClient.ts | 4 +- .../federation/validateCommunities.test.ts | 2 +- backend/src/federation/validateCommunities.ts | 4 +- .../arg/AdminCreateContributionArgs.ts | 2 +- .../arg/AdminUpdateContributionArgs.ts | 2 +- backend/src/graphql/arg/ContributionArgs.ts | 2 +- .../src/graphql/arg/ContributionLinkArgs.ts | 2 +- .../src/graphql/arg/TransactionLinkArgs.ts | 2 +- .../src/graphql/arg/TransactionSendArgs.ts | 2 +- backend/src/graphql/directive/isAuthorized.ts | 8 +-- .../graphql/model/AdminUpdateContribution.ts | 2 +- backend/src/graphql/model/Balance.ts | 2 +- backend/src/graphql/model/Community.ts | 2 +- .../src/graphql/model/CommunityStatistics.ts | 2 +- backend/src/graphql/model/Contribution.ts | 4 +- backend/src/graphql/model/ContributionLink.ts | 4 +- .../src/graphql/model/ContributionMessage.ts | 2 +- backend/src/graphql/model/Decay.ts | 2 +- backend/src/graphql/model/OpenCreation.ts | 2 +- backend/src/graphql/model/Transaction.ts | 2 +- backend/src/graphql/model/TransactionLink.ts | 4 +- backend/src/graphql/model/TransactionList.ts | 2 +- .../graphql/model/UnconfirmedContribution.ts | 4 +- backend/src/graphql/model/User.ts | 2 +- backend/src/graphql/model/UserAdmin.ts | 4 +- backend/src/graphql/model/UserContact.ts | 2 +- .../src/graphql/resolver/BalanceResolver.ts | 16 ++--- .../src/graphql/resolver/CommunityResolver.ts | 4 +- .../resolver/ContributionLinkResolver.test.ts | 12 ++-- .../resolver/ContributionLinkResolver.ts | 24 +++---- .../ContributionMessageResolver.test.ts | 12 ++-- .../resolver/ContributionMessageResolver.ts | 22 +++---- .../resolver/ContributionResolver.test.ts | 44 ++++++------- .../graphql/resolver/ContributionResolver.ts | 56 ++++++++--------- .../graphql/resolver/EmailOptinCodes.test.ts | 4 +- backend/src/graphql/resolver/GdtResolver.ts | 10 +-- .../graphql/resolver/StatisticsResolver.ts | 6 +- .../resolver/TransactionLinkResolver.test.ts | 22 +++---- .../resolver/TransactionLinkResolver.ts | 48 +++++++------- .../resolver/TransactionResolver.test.ts | 4 +- .../graphql/resolver/TransactionResolver.ts | 42 ++++++------- .../src/graphql/resolver/UserResolver.test.ts | 54 ++++++++-------- backend/src/graphql/resolver/UserResolver.ts | 62 +++++++++---------- .../src/graphql/resolver/semaphore.test.ts | 10 +-- .../graphql/resolver/util/creations.test.ts | 8 +-- .../src/graphql/resolver/util/creations.ts | 2 +- .../resolver/util/findContributions.ts | 2 +- .../resolver/util/transactionLinkList.ts | 4 +- backend/src/graphql/scalar/Decimal.ts | 2 +- backend/src/graphql/schema.ts | 2 +- backend/src/graphql/union/QueryLinkResult.ts | 2 +- backend/src/index.ts | 2 +- backend/src/middleware/klicktippMiddleware.ts | 2 +- backend/src/seeds/factory/contributionLink.ts | 2 +- backend/src/seeds/factory/creation.ts | 6 +- backend/src/seeds/factory/transactionLink.ts | 4 +- backend/src/seeds/index.ts | 14 ++--- backend/src/seeds/users/index.ts | 4 +- backend/src/server/context.ts | 4 +- backend/src/server/createServer.ts | 12 ++-- backend/src/util/decay.ts | 2 +- backend/src/util/klicktipp.ts | 2 +- backend/src/util/validate.ts | 4 +- backend/src/util/virtualTransactions.ts | 2 +- backend/test/helpers.ts | 2 +- backend/test/testSetup.ts | 2 +- 105 files changed, 373 insertions(+), 369 deletions(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index 6b6db0486..4cb3d3cf1 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -88,6 +88,10 @@ module.exports = { position: 'after', }, ], + alphabetize: { + order: 'asc' /* sort in ascending order. Options: ['ignore', 'asc', 'desc'] */, + caseInsensitive: true /* ignore case. Options: [true, false] */, + }, distinctGroup: true, }, ], diff --git a/backend/src/apis/HttpRequest.ts b/backend/src/apis/HttpRequest.ts index eff0c408a..d8de68bb8 100644 --- a/backend/src/apis/HttpRequest.ts +++ b/backend/src/apis/HttpRequest.ts @@ -2,8 +2,8 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import axios from 'axios' -import { backendLogger as logger } from '@/server/logger' import LogError from '@/server/LogError' +import { backendLogger as logger } from '@/server/logger' // eslint-disable-next-line @typescript-eslint/no-explicit-any export const apiPost = async (url: string, payload: unknown): Promise => { diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 13e339b13..e6c4e4c24 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -1,7 +1,7 @@ // ATTENTION: DO NOT PUT ANY SECRETS IN HERE (or the .env) -import dotenv from 'dotenv' import { Decimal } from 'decimal.js-light' +import dotenv from 'dotenv' dotenv.config() diff --git a/backend/src/emails/sendEmailTranslated.test.ts b/backend/src/emails/sendEmailTranslated.test.ts index 5a095f563..b930939cf 100644 --- a/backend/src/emails/sendEmailTranslated.test.ts +++ b/backend/src/emails/sendEmailTranslated.test.ts @@ -2,8 +2,8 @@ /* eslint-disable @typescript-eslint/unbound-method */ import { createTransport } from 'nodemailer' -import { logger, i18n } from '@test/testSetup' import CONFIG from '@/config' +import { logger, i18n } from '@test/testSetup' import { sendEmailTranslated } from './sendEmailTranslated' diff --git a/backend/src/emails/sendEmailTranslated.ts b/backend/src/emails/sendEmailTranslated.ts index 96fd27d83..6d89cc257 100644 --- a/backend/src/emails/sendEmailTranslated.ts +++ b/backend/src/emails/sendEmailTranslated.ts @@ -1,13 +1,13 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ import path from 'path' -import { createTransport } from 'nodemailer' import Email from 'email-templates' import i18n from 'i18n' +import { createTransport } from 'nodemailer' -import { backendLogger as logger } from '@/server/logger' import CONFIG from '@/config' import LogError from '@/server/LogError' +import { backendLogger as logger } from '@/server/logger' export const sendEmailTranslated = async (params: { receiver: { diff --git a/backend/src/emails/sendEmailVariants.test.ts b/backend/src/emails/sendEmailVariants.test.ts index 849b9d7f1..141319ac0 100644 --- a/backend/src/emails/sendEmailVariants.test.ts +++ b/backend/src/emails/sendEmailVariants.test.ts @@ -5,9 +5,9 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { Decimal } from 'decimal.js-light' +import CONFIG from '@/config' import { testEnvironment } from '@test/helpers' import { logger, i18n as localization } from '@test/testSetup' -import CONFIG from '@/config' import { sendEmailTranslated } from './sendEmailTranslated' import { diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts index e53a56c11..5843fbee9 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts @@ -1,7 +1,7 @@ -import { Decimal } from 'decimal.js-light' -import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' +import { Decimal } from 'decimal.js-light' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts index 530c896ca..f4ad049ca 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts @@ -1,7 +1,7 @@ -import { Decimal } from 'decimal.js-light' -import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' +import { Decimal } from 'decimal.js-light' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts index 1d776a9e0..399604e35 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts @@ -1,7 +1,7 @@ -import { Decimal } from 'decimal.js-light' -import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' +import { Decimal } from 'decimal.js-light' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts index 98d42fcdc..332d3ab92 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts @@ -1,7 +1,7 @@ -import { Decimal } from 'decimal.js-light' -import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' +import { Decimal } from 'decimal.js-light' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts index 3cd55a40c..4b06cd3ad 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_CREATE.ts @@ -1,7 +1,7 @@ -import { Decimal } from 'decimal.js-light' -import { User as DbUser } from '@entity/User' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' +import { Decimal } from 'decimal.js-light' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts index d6eb5f205..c4cd99f57 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_DELETE.ts @@ -1,6 +1,6 @@ -import { User as DbUser } from '@entity/User' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts index deb7bb574..f8cd2d16f 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE.ts @@ -1,7 +1,7 @@ -import { Decimal } from 'decimal.js-light' -import { User as DbUser } from '@entity/User' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' +import { Decimal } from 'decimal.js-light' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts index 68a59da27..a2385429d 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE.ts @@ -1,7 +1,7 @@ -import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts index 06a5da0c0..f2fcb7478 100644 --- a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts @@ -1,7 +1,7 @@ -import { Decimal } from 'decimal.js-light' -import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' +import { Decimal } from 'decimal.js-light' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_ADMIN_USER_DELETE.ts b/backend/src/event/EVENT_ADMIN_USER_DELETE.ts index 6c022ad2c..bfd3e2bcc 100644 --- a/backend/src/event/EVENT_ADMIN_USER_DELETE.ts +++ b/backend/src/event/EVENT_ADMIN_USER_DELETE.ts @@ -1,5 +1,5 @@ -import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts b/backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts index e6951d062..7902f5318 100644 --- a/backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts +++ b/backend/src/event/EVENT_ADMIN_USER_ROLE_SET.ts @@ -1,5 +1,5 @@ -import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_ADMIN_USER_UNDELETE.ts b/backend/src/event/EVENT_ADMIN_USER_UNDELETE.ts index 303c4d260..338a3a31d 100644 --- a/backend/src/event/EVENT_ADMIN_USER_UNDELETE.ts +++ b/backend/src/event/EVENT_ADMIN_USER_UNDELETE.ts @@ -1,5 +1,5 @@ -import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts b/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts index b01bad47a..96e24ec61 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts @@ -1,7 +1,7 @@ -import { Decimal } from 'decimal.js-light' -import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' +import { Decimal } from 'decimal.js-light' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts b/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts index fdfc12448..acf11bbb0 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts @@ -1,7 +1,7 @@ -import { Decimal } from 'decimal.js-light' -import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' +import { Decimal } from 'decimal.js-light' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts b/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts index 3ce38cf03..1202aa387 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_LINK_REDEEM.ts @@ -1,9 +1,9 @@ -import { Decimal } from 'decimal.js-light' -import { User as DbUser } from '@entity/User' -import { Transaction as DbTransaction } from '@entity/Transaction' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' +import { Transaction as DbTransaction } from '@entity/Transaction' +import { User as DbUser } from '@entity/User' +import { Decimal } from 'decimal.js-light' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts b/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts index b977f90da..bfb7f742e 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_MESSAGE_CREATE.ts @@ -1,7 +1,7 @@ -import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts b/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts index be1d3d4ed..3e3d82b67 100644 --- a/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts +++ b/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts @@ -1,7 +1,7 @@ -import { Decimal } from 'decimal.js-light' -import { User as DbUser } from '@entity/User' import { Contribution as DbContribution } from '@entity/Contribution' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' +import { Decimal } from 'decimal.js-light' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION.ts b/backend/src/event/EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION.ts index 0133ab715..ae3a65ed2 100644 --- a/backend/src/event/EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION.ts +++ b/backend/src/event/EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION.ts @@ -1,5 +1,5 @@ -import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_EMAIL_ADMIN_CONFIRMATION.ts b/backend/src/event/EVENT_EMAIL_ADMIN_CONFIRMATION.ts index 6132484da..6262d42a5 100644 --- a/backend/src/event/EVENT_EMAIL_ADMIN_CONFIRMATION.ts +++ b/backend/src/event/EVENT_EMAIL_ADMIN_CONFIRMATION.ts @@ -1,5 +1,5 @@ -import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_EMAIL_CONFIRMATION.ts b/backend/src/event/EVENT_EMAIL_CONFIRMATION.ts index 44eb9323d..beb774632 100644 --- a/backend/src/event/EVENT_EMAIL_CONFIRMATION.ts +++ b/backend/src/event/EVENT_EMAIL_CONFIRMATION.ts @@ -1,5 +1,5 @@ -import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts b/backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts index 20eb5f1fe..a7d60e60f 100644 --- a/backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts +++ b/backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts @@ -1,5 +1,5 @@ -import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts b/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts index dd97a0641..64bc2f6e5 100644 --- a/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts +++ b/backend/src/event/EVENT_TRANSACTION_LINK_CREATE.ts @@ -1,7 +1,7 @@ -import { Decimal } from 'decimal.js-light' -import { User as DbUser } from '@entity/User' -import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { Event as DbEvent } from '@entity/Event' +import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' +import { User as DbUser } from '@entity/User' +import { Decimal } from 'decimal.js-light' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts b/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts index de4511b9e..7a6ee9576 100644 --- a/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts +++ b/backend/src/event/EVENT_TRANSACTION_LINK_DELETE.ts @@ -1,6 +1,6 @@ -import { User as DbUser } from '@entity/User' -import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { Event as DbEvent } from '@entity/Event' +import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' +import { User as DbUser } from '@entity/User' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts b/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts index d699f3d41..576811d25 100644 --- a/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts +++ b/backend/src/event/EVENT_TRANSACTION_LINK_REDEEM.ts @@ -1,7 +1,7 @@ -import { Decimal } from 'decimal.js-light' -import { User as DbUser } from '@entity/User' -import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { Event as DbEvent } from '@entity/Event' +import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' +import { User as DbUser } from '@entity/User' +import { Decimal } from 'decimal.js-light' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts b/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts index d82bbd31c..22a71bc25 100644 --- a/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts +++ b/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts @@ -1,7 +1,7 @@ -import { Decimal } from 'decimal.js-light' -import { User as DbUser } from '@entity/User' -import { Transaction as DbTransaction } from '@entity/Transaction' import { Event as DbEvent } from '@entity/Event' +import { Transaction as DbTransaction } from '@entity/Transaction' +import { User as DbUser } from '@entity/User' +import { Decimal } from 'decimal.js-light' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_TRANSACTION_SEND.ts b/backend/src/event/EVENT_TRANSACTION_SEND.ts index d2fd615a5..1327d739d 100644 --- a/backend/src/event/EVENT_TRANSACTION_SEND.ts +++ b/backend/src/event/EVENT_TRANSACTION_SEND.ts @@ -1,7 +1,7 @@ -import { Decimal } from 'decimal.js-light' -import { User as DbUser } from '@entity/User' -import { Transaction as DbTransaction } from '@entity/Transaction' import { Event as DbEvent } from '@entity/Event' +import { Transaction as DbTransaction } from '@entity/Transaction' +import { User as DbUser } from '@entity/User' +import { Decimal } from 'decimal.js-light' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts b/backend/src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts index 602acb880..0213f122f 100644 --- a/backend/src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts +++ b/backend/src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts @@ -1,5 +1,5 @@ -import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_USER_INFO_UPDATE.ts b/backend/src/event/EVENT_USER_INFO_UPDATE.ts index 080c68e2c..28b3fe237 100644 --- a/backend/src/event/EVENT_USER_INFO_UPDATE.ts +++ b/backend/src/event/EVENT_USER_INFO_UPDATE.ts @@ -1,5 +1,5 @@ -import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_USER_LOGIN.ts b/backend/src/event/EVENT_USER_LOGIN.ts index ba09bc02c..64d43b264 100644 --- a/backend/src/event/EVENT_USER_LOGIN.ts +++ b/backend/src/event/EVENT_USER_LOGIN.ts @@ -1,5 +1,5 @@ -import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_USER_LOGOUT.ts b/backend/src/event/EVENT_USER_LOGOUT.ts index 2e6c54841..4b00c9839 100644 --- a/backend/src/event/EVENT_USER_LOGOUT.ts +++ b/backend/src/event/EVENT_USER_LOGOUT.ts @@ -1,5 +1,5 @@ -import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' import { Event, EventType } from './Event' diff --git a/backend/src/event/EVENT_USER_REGISTER.ts b/backend/src/event/EVENT_USER_REGISTER.ts index 990ac396f..2d31299f1 100644 --- a/backend/src/event/EVENT_USER_REGISTER.ts +++ b/backend/src/event/EVENT_USER_REGISTER.ts @@ -1,5 +1,5 @@ -import { User as DbUser } from '@entity/User' import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' import { Event, EventType } from './Event' diff --git a/backend/src/event/Event.ts b/backend/src/event/Event.ts index 1ff8ba995..d3f515d51 100644 --- a/backend/src/event/Event.ts +++ b/backend/src/event/Event.ts @@ -1,10 +1,10 @@ +import { Contribution as DbContribution } from '@entity/Contribution' +import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' +import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { Event as DbEvent } from '@entity/Event' -import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' -import { Contribution as DbContribution } from '@entity/Contribution' -import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' -import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' +import { User as DbUser } from '@entity/User' import { Decimal } from 'decimal.js-light' import { EventType } from './EventType' diff --git a/backend/src/federation/client/1_0/FederationClient.ts b/backend/src/federation/client/1_0/FederationClient.ts index 7261bae45..c4063e4c5 100644 --- a/backend/src/federation/client/1_0/FederationClient.ts +++ b/backend/src/federation/client/1_0/FederationClient.ts @@ -1,12 +1,12 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ -import { gql } from 'graphql-request' import { Community as DbCommunity } from '@entity/Community' +import { gql } from 'graphql-request' import { GraphQLGetClient } from '@/federation/client/GraphQLGetClient' -import { backendLogger as logger } from '@/server/logger' import LogError from '@/server/LogError' +import { backendLogger as logger } from '@/server/logger' export async function requestGetPublicKey(dbCom: DbCommunity): Promise { let endpoint = dbCom.endPoint.endsWith('/') ? dbCom.endPoint : dbCom.endPoint + '/' diff --git a/backend/src/federation/client/1_1/FederationClient.ts b/backend/src/federation/client/1_1/FederationClient.ts index 7dca9b465..b29960407 100644 --- a/backend/src/federation/client/1_1/FederationClient.ts +++ b/backend/src/federation/client/1_1/FederationClient.ts @@ -1,12 +1,12 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ -import { gql } from 'graphql-request' import { Community as DbCommunity } from '@entity/Community' +import { gql } from 'graphql-request' import { GraphQLGetClient } from '@/federation/client/GraphQLGetClient' -import { backendLogger as logger } from '@/server/logger' import LogError from '@/server/LogError' +import { backendLogger as logger } from '@/server/logger' export async function requestGetPublicKey(dbCom: DbCommunity): Promise { let endpoint = dbCom.endPoint.endsWith('/') ? dbCom.endPoint : dbCom.endPoint + '/' diff --git a/backend/src/federation/validateCommunities.test.ts b/backend/src/federation/validateCommunities.test.ts index d46720ff8..d90664b63 100644 --- a/backend/src/federation/validateCommunities.test.ts +++ b/backend/src/federation/validateCommunities.test.ts @@ -7,8 +7,8 @@ import { Community as DbCommunity } from '@entity/Community' -import { logger } from '@test/testSetup' import { testEnvironment, cleanDB } from '@test/helpers' +import { logger } from '@test/testSetup' import { validateCommunities } from './validateCommunities' diff --git a/backend/src/federation/validateCommunities.ts b/backend/src/federation/validateCommunities.ts index 642e59929..fb6bda673 100644 --- a/backend/src/federation/validateCommunities.ts +++ b/backend/src/federation/validateCommunities.ts @@ -1,8 +1,8 @@ -import { Community as DbCommunity } from '@entity/Community' import { IsNull } from '@dbTools/typeorm' +import { Community as DbCommunity } from '@entity/Community' -import { backendLogger as logger } from '@/server/logger' import LogError from '@/server/LogError' +import { backendLogger as logger } from '@/server/logger' // eslint-disable-next-line camelcase import { requestGetPublicKey as v1_0_requestGetPublicKey } from './client/1_0/FederationClient' diff --git a/backend/src/graphql/arg/AdminCreateContributionArgs.ts b/backend/src/graphql/arg/AdminCreateContributionArgs.ts index 6259e672e..65aeb82e5 100644 --- a/backend/src/graphql/arg/AdminCreateContributionArgs.ts +++ b/backend/src/graphql/arg/AdminCreateContributionArgs.ts @@ -1,5 +1,5 @@ -import { ArgsType, Field, InputType } from 'type-graphql' import { Decimal } from 'decimal.js-light' +import { ArgsType, Field, InputType } from 'type-graphql' @InputType() @ArgsType() diff --git a/backend/src/graphql/arg/AdminUpdateContributionArgs.ts b/backend/src/graphql/arg/AdminUpdateContributionArgs.ts index 3b10acf1a..f3cf519b6 100644 --- a/backend/src/graphql/arg/AdminUpdateContributionArgs.ts +++ b/backend/src/graphql/arg/AdminUpdateContributionArgs.ts @@ -1,5 +1,5 @@ -import { ArgsType, Field, Int } from 'type-graphql' import { Decimal } from 'decimal.js-light' +import { ArgsType, Field, Int } from 'type-graphql' @ArgsType() export default class AdminUpdateContributionArgs { diff --git a/backend/src/graphql/arg/ContributionArgs.ts b/backend/src/graphql/arg/ContributionArgs.ts index dc4285e4d..cc8aea41e 100644 --- a/backend/src/graphql/arg/ContributionArgs.ts +++ b/backend/src/graphql/arg/ContributionArgs.ts @@ -1,5 +1,5 @@ -import { ArgsType, Field, InputType } from 'type-graphql' import { Decimal } from 'decimal.js-light' +import { ArgsType, Field, InputType } from 'type-graphql' @InputType() @ArgsType() diff --git a/backend/src/graphql/arg/ContributionLinkArgs.ts b/backend/src/graphql/arg/ContributionLinkArgs.ts index fac1eacc1..d28a7808f 100644 --- a/backend/src/graphql/arg/ContributionLinkArgs.ts +++ b/backend/src/graphql/arg/ContributionLinkArgs.ts @@ -1,5 +1,5 @@ -import { ArgsType, Field, Int } from 'type-graphql' import { Decimal } from 'decimal.js-light' +import { ArgsType, Field, Int } from 'type-graphql' @ArgsType() export default class ContributionLinkArgs { diff --git a/backend/src/graphql/arg/TransactionLinkArgs.ts b/backend/src/graphql/arg/TransactionLinkArgs.ts index 6c1c4654a..19720e321 100644 --- a/backend/src/graphql/arg/TransactionLinkArgs.ts +++ b/backend/src/graphql/arg/TransactionLinkArgs.ts @@ -1,5 +1,5 @@ -import { ArgsType, Field } from 'type-graphql' import { Decimal } from 'decimal.js-light' +import { ArgsType, Field } from 'type-graphql' @ArgsType() export default class TransactionLinkArgs { diff --git a/backend/src/graphql/arg/TransactionSendArgs.ts b/backend/src/graphql/arg/TransactionSendArgs.ts index c0faff850..d91cecbcd 100644 --- a/backend/src/graphql/arg/TransactionSendArgs.ts +++ b/backend/src/graphql/arg/TransactionSendArgs.ts @@ -1,5 +1,5 @@ -import { ArgsType, Field } from 'type-graphql' import { Decimal } from 'decimal.js-light' +import { ArgsType, Field } from 'type-graphql' @ArgsType() export default class TransactionSendArgs { diff --git a/backend/src/graphql/directive/isAuthorized.ts b/backend/src/graphql/directive/isAuthorized.ts index 09eac70a9..a018fd230 100644 --- a/backend/src/graphql/directive/isAuthorized.ts +++ b/backend/src/graphql/directive/isAuthorized.ts @@ -2,13 +2,13 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { AuthChecker } from 'type-graphql' import { User } from '@entity/User' +import { AuthChecker } from 'type-graphql' -import { decode, encode } from '@/auth/JWT' -import { ROLE_UNAUTHORIZED, ROLE_USER, ROLE_ADMIN } from '@/auth/ROLES' -import { RIGHTS } from '@/auth/RIGHTS' import { INALIENABLE_RIGHTS } from '@/auth/INALIENABLE_RIGHTS' +import { decode, encode } from '@/auth/JWT' +import { RIGHTS } from '@/auth/RIGHTS' +import { ROLE_UNAUTHORIZED, ROLE_USER, ROLE_ADMIN } from '@/auth/ROLES' import LogError from '@/server/LogError' const isAuthorized: AuthChecker = async ({ context }, rights) => { diff --git a/backend/src/graphql/model/AdminUpdateContribution.ts b/backend/src/graphql/model/AdminUpdateContribution.ts index d5cd4fc7f..b7c3df6bd 100644 --- a/backend/src/graphql/model/AdminUpdateContribution.ts +++ b/backend/src/graphql/model/AdminUpdateContribution.ts @@ -1,5 +1,5 @@ -import { ObjectType, Field } from 'type-graphql' import { Decimal } from 'decimal.js-light' +import { ObjectType, Field } from 'type-graphql' @ObjectType() export class AdminUpdateContribution { diff --git a/backend/src/graphql/model/Balance.ts b/backend/src/graphql/model/Balance.ts index d68237db9..162ccc3c0 100644 --- a/backend/src/graphql/model/Balance.ts +++ b/backend/src/graphql/model/Balance.ts @@ -1,5 +1,5 @@ -import { ObjectType, Field, Int, Float } from 'type-graphql' import { Decimal } from 'decimal.js-light' +import { ObjectType, Field, Int, Float } from 'type-graphql' @ObjectType() export class Balance { diff --git a/backend/src/graphql/model/Community.ts b/backend/src/graphql/model/Community.ts index ec91ad36f..22b2b1fc6 100644 --- a/backend/src/graphql/model/Community.ts +++ b/backend/src/graphql/model/Community.ts @@ -1,5 +1,5 @@ -import { ObjectType, Field, Int } from 'type-graphql' import { Community as DbCommunity } from '@entity/Community' +import { ObjectType, Field, Int } from 'type-graphql' @ObjectType() export class Community { diff --git a/backend/src/graphql/model/CommunityStatistics.ts b/backend/src/graphql/model/CommunityStatistics.ts index 1fb1ded46..775ad183b 100644 --- a/backend/src/graphql/model/CommunityStatistics.ts +++ b/backend/src/graphql/model/CommunityStatistics.ts @@ -1,5 +1,5 @@ -import { ObjectType, Field, Int } from 'type-graphql' import { Decimal } from 'decimal.js-light' +import { ObjectType, Field, Int } from 'type-graphql' @ObjectType() export class DynamicStatisticsFields { diff --git a/backend/src/graphql/model/Contribution.ts b/backend/src/graphql/model/Contribution.ts index a83adef4b..b19fae25b 100644 --- a/backend/src/graphql/model/Contribution.ts +++ b/backend/src/graphql/model/Contribution.ts @@ -1,7 +1,7 @@ -import { ObjectType, Field, Int } from 'type-graphql' -import { Decimal } from 'decimal.js-light' import { Contribution as dbContribution } from '@entity/Contribution' import { User } from '@entity/User' +import { Decimal } from 'decimal.js-light' +import { ObjectType, Field, Int } from 'type-graphql' @ObjectType() export class Contribution { diff --git a/backend/src/graphql/model/ContributionLink.ts b/backend/src/graphql/model/ContributionLink.ts index 0da2fd430..e47ffc6ed 100644 --- a/backend/src/graphql/model/ContributionLink.ts +++ b/backend/src/graphql/model/ContributionLink.ts @@ -1,6 +1,6 @@ -import { ObjectType, Field, Int } from 'type-graphql' -import { Decimal } from 'decimal.js-light' import { ContributionLink as dbContributionLink } from '@entity/ContributionLink' +import { Decimal } from 'decimal.js-light' +import { ObjectType, Field, Int } from 'type-graphql' import CONFIG from '@/config' diff --git a/backend/src/graphql/model/ContributionMessage.ts b/backend/src/graphql/model/ContributionMessage.ts index 6bd6a4715..6f70d5024 100644 --- a/backend/src/graphql/model/ContributionMessage.ts +++ b/backend/src/graphql/model/ContributionMessage.ts @@ -1,6 +1,6 @@ -import { Field, Int, ObjectType } from 'type-graphql' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { User } from '@entity/User' +import { Field, Int, ObjectType } from 'type-graphql' @ObjectType() export class ContributionMessage { diff --git a/backend/src/graphql/model/Decay.ts b/backend/src/graphql/model/Decay.ts index 3e8412dfa..0b710c234 100644 --- a/backend/src/graphql/model/Decay.ts +++ b/backend/src/graphql/model/Decay.ts @@ -1,5 +1,5 @@ -import { ObjectType, Field, Int } from 'type-graphql' import { Decimal } from 'decimal.js-light' +import { ObjectType, Field, Int } from 'type-graphql' interface DecayInterface { balance: Decimal diff --git a/backend/src/graphql/model/OpenCreation.ts b/backend/src/graphql/model/OpenCreation.ts index ed9ef731e..46ee8117f 100644 --- a/backend/src/graphql/model/OpenCreation.ts +++ b/backend/src/graphql/model/OpenCreation.ts @@ -1,5 +1,5 @@ -import { ObjectType, Field, Int } from 'type-graphql' import { Decimal } from 'decimal.js-light' +import { ObjectType, Field, Int } from 'type-graphql' @ObjectType() export class OpenCreation { diff --git a/backend/src/graphql/model/Transaction.ts b/backend/src/graphql/model/Transaction.ts index 3538260a5..1b857391b 100644 --- a/backend/src/graphql/model/Transaction.ts +++ b/backend/src/graphql/model/Transaction.ts @@ -1,6 +1,6 @@ -import { ObjectType, Field, Int } from 'type-graphql' import { Transaction as dbTransaction } from '@entity/Transaction' import { Decimal } from 'decimal.js-light' +import { ObjectType, Field, Int } from 'type-graphql' import { TransactionTypeId } from '@enum/TransactionTypeId' diff --git a/backend/src/graphql/model/TransactionLink.ts b/backend/src/graphql/model/TransactionLink.ts index 1e9c1a64d..7356e97c6 100644 --- a/backend/src/graphql/model/TransactionLink.ts +++ b/backend/src/graphql/model/TransactionLink.ts @@ -1,6 +1,6 @@ -import { ObjectType, Field, Int } from 'type-graphql' -import { Decimal } from 'decimal.js-light' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' +import { Decimal } from 'decimal.js-light' +import { ObjectType, Field, Int } from 'type-graphql' import CONFIG from '@/config' diff --git a/backend/src/graphql/model/TransactionList.ts b/backend/src/graphql/model/TransactionList.ts index 36e51242d..77f9f6481 100644 --- a/backend/src/graphql/model/TransactionList.ts +++ b/backend/src/graphql/model/TransactionList.ts @@ -1,7 +1,7 @@ import { ObjectType, Field } from 'type-graphql' -import { Transaction } from './Transaction' import { Balance } from './Balance' +import { Transaction } from './Transaction' @ObjectType() export class TransactionList { diff --git a/backend/src/graphql/model/UnconfirmedContribution.ts b/backend/src/graphql/model/UnconfirmedContribution.ts index 439f70a16..dece05781 100644 --- a/backend/src/graphql/model/UnconfirmedContribution.ts +++ b/backend/src/graphql/model/UnconfirmedContribution.ts @@ -1,7 +1,7 @@ -import { ObjectType, Field, Int } from 'type-graphql' -import { Decimal } from 'decimal.js-light' import { Contribution } from '@entity/Contribution' import { User } from '@entity/User' +import { Decimal } from 'decimal.js-light' +import { ObjectType, Field, Int } from 'type-graphql' @ObjectType() export class UnconfirmedContribution { diff --git a/backend/src/graphql/model/User.ts b/backend/src/graphql/model/User.ts index 6797b0767..c705ba912 100644 --- a/backend/src/graphql/model/User.ts +++ b/backend/src/graphql/model/User.ts @@ -1,5 +1,5 @@ -import { ObjectType, Field, Int } from 'type-graphql' import { User as dbUser } from '@entity/User' +import { ObjectType, Field, Int } from 'type-graphql' import { KlickTipp } from './KlickTipp' import { UserContact } from './UserContact' diff --git a/backend/src/graphql/model/UserAdmin.ts b/backend/src/graphql/model/UserAdmin.ts index 84512d812..3e7210874 100644 --- a/backend/src/graphql/model/UserAdmin.ts +++ b/backend/src/graphql/model/UserAdmin.ts @@ -1,6 +1,6 @@ -import { ObjectType, Field, Int } from 'type-graphql' -import { Decimal } from 'decimal.js-light' import { User } from '@entity/User' +import { Decimal } from 'decimal.js-light' +import { ObjectType, Field, Int } from 'type-graphql' @ObjectType() export class UserAdmin { diff --git a/backend/src/graphql/model/UserContact.ts b/backend/src/graphql/model/UserContact.ts index bb31d0745..4a6ed47b6 100644 --- a/backend/src/graphql/model/UserContact.ts +++ b/backend/src/graphql/model/UserContact.ts @@ -1,5 +1,5 @@ -import { ObjectType, Field, Int } from 'type-graphql' import { UserContact as dbUserContact } from '@entity/UserContact' +import { ObjectType, Field, Int } from 'type-graphql' @ObjectType() export class UserContact { diff --git a/backend/src/graphql/resolver/BalanceResolver.ts b/backend/src/graphql/resolver/BalanceResolver.ts index aca10ed0f..ff1fee9f6 100644 --- a/backend/src/graphql/resolver/BalanceResolver.ts +++ b/backend/src/graphql/resolver/BalanceResolver.ts @@ -1,19 +1,19 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ -import { Decimal } from 'decimal.js-light' -import { Resolver, Query, Ctx, Authorized } from 'type-graphql' import { getCustomRepository } from '@dbTools/typeorm' import { Transaction as dbTransaction } from '@entity/Transaction' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' +import { Decimal } from 'decimal.js-light' +import { Resolver, Query, Ctx, Authorized } from 'type-graphql' -import { TransactionLinkRepository } from '@repository/TransactionLink' -import { Balance } from '@model/Balance' -import { backendLogger as logger } from '@/server/logger' -import { Context, getUser } from '@/server/context' -import { calculateDecay } from '@/util/decay' import { RIGHTS } from '@/auth/RIGHTS' +import { Context, getUser } from '@/server/context' +import { backendLogger as logger } from '@/server/logger' +import { calculateDecay } from '@/util/decay' +import { Balance } from '@model/Balance' +import { TransactionLinkRepository } from '@repository/TransactionLink' -import { getLastTransaction } from './util/getLastTransaction' import { GdtResolver } from './GdtResolver' +import { getLastTransaction } from './util/getLastTransaction' @Resolver() export class BalanceResolver { diff --git a/backend/src/graphql/resolver/CommunityResolver.ts b/backend/src/graphql/resolver/CommunityResolver.ts index 74ba0e57b..5ffbe77c8 100644 --- a/backend/src/graphql/resolver/CommunityResolver.ts +++ b/backend/src/graphql/resolver/CommunityResolver.ts @@ -1,8 +1,8 @@ -import { Resolver, Query, Authorized } from 'type-graphql' import { Community as DbCommunity } from '@entity/Community' +import { Resolver, Query, Authorized } from 'type-graphql' -import { Community } from '@model/Community' import { RIGHTS } from '@/auth/RIGHTS' +import { Community } from '@model/Community' @Resolver() export class CommunityResolver { diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts index 6bd62fd9f..66c678be1 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts @@ -4,12 +4,13 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { Decimal } from 'decimal.js-light' -import { GraphQLError } from 'graphql' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' +import { Decimal } from 'decimal.js-light' +import { GraphQLError } from 'graphql' -import { logger } from '@test/testSetup' +import { EventType } from '@/event/Event' +import { userFactory } from '@/seeds/factory/user' import { login, createContributionLink, @@ -17,11 +18,10 @@ import { updateContributionLink, } from '@/seeds/graphql/mutations' import { listContributionLinks } from '@/seeds/graphql/queries' -import { cleanDB, testEnvironment, resetToken } from '@test/helpers' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' -import { userFactory } from '@/seeds/factory/user' -import { EventType } from '@/event/Event' +import { cleanDB, testEnvironment, resetToken } from '@test/helpers' +import { logger } from '@test/testSetup' let mutate: any, query: any, con: any let testEnv: any diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.ts b/backend/src/graphql/resolver/ContributionLinkResolver.ts index 815901f16..aca291e5d 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.ts @@ -1,31 +1,31 @@ -import { Decimal } from 'decimal.js-light' -import { Resolver, Args, Arg, Authorized, Mutation, Query, Int, Ctx } from 'type-graphql' import { MoreThan, IsNull } from '@dbTools/typeorm' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' +import { Decimal } from 'decimal.js-light' +import { Resolver, Args, Arg, Authorized, Mutation, Query, Int, Ctx } from 'type-graphql' -import { ContributionLinkList } from '@model/ContributionLinkList' -import { ContributionLink } from '@model/ContributionLink' -import ContributionLinkArgs from '@arg/ContributionLinkArgs' import { RIGHTS } from '@/auth/RIGHTS' -import { Order } from '@enum/Order' -import Paginated from '@arg/Paginated' -// TODO: this is a strange construct -import LogError from '@/server/LogError' -import { Context, getUser } from '@/server/context' import { EVENT_ADMIN_CONTRIBUTION_LINK_CREATE, EVENT_ADMIN_CONTRIBUTION_LINK_DELETE, EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE, } from '@/event/Event' +// TODO: this is a strange construct +import { Context, getUser } from '@/server/context' +import LogError from '@/server/LogError' +import ContributionLinkArgs from '@arg/ContributionLinkArgs' +import Paginated from '@arg/Paginated' +import { Order } from '@enum/Order' +import { ContributionLink } from '@model/ContributionLink' +import { ContributionLinkList } from '@model/ContributionLinkList' -import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver' -import { isStartEndDateValid } from './util/creations' import { CONTRIBUTIONLINK_NAME_MAX_CHARS, CONTRIBUTIONLINK_NAME_MIN_CHARS, MEMO_MAX_CHARS, MEMO_MIN_CHARS, } from './const/const' +import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver' +import { isStartEndDateValid } from './util/creations' @Resolver() export class ContributionLinkResolver { diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts index 357455250..dd8c61cf2 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts @@ -6,11 +6,12 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { GraphQLError } from 'graphql' import { Event as DbEvent } from '@entity/Event' +import { GraphQLError } from 'graphql' -import { cleanDB, resetToken, testEnvironment } from '@test/helpers' -import { logger, i18n as localization } from '@test/testSetup' +import { sendAddedContributionMessageEmail } from '@/emails/sendEmailVariants' +import { EventType } from '@/event/Event' +import { userFactory } from '@/seeds/factory/user' import { adminCreateContributionMessage, createContribution, @@ -18,11 +19,10 @@ import { login, } from '@/seeds/graphql/mutations' import { listContributionMessages } from '@/seeds/graphql/queries' -import { userFactory } from '@/seeds/factory/user' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' -import { sendAddedContributionMessageEmail } from '@/emails/sendEmailVariants' -import { EventType } from '@/event/Event' +import { cleanDB, resetToken, testEnvironment } from '@test/helpers' +import { logger, i18n as localization } from '@test/testSetup' jest.mock('@/emails/sendEmailVariants', () => { const originalModule = jest.requireActual('@/emails/sendEmailVariants') diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.ts b/backend/src/graphql/resolver/ContributionMessageResolver.ts index b78f441d5..346f8b39c 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.ts @@ -1,25 +1,25 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ -import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql' import { getConnection } from '@dbTools/typeorm' -import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { Contribution as DbContribution } from '@entity/Contribution' -import { UserContact as DbUserContact } from '@entity/UserContact' +import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { User as DbUser } from '@entity/User' +import { UserContact as DbUserContact } from '@entity/UserContact' +import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql' -import { ContributionMessage, ContributionMessageListResult } from '@model/ContributionMessage' -import ContributionMessageArgs from '@arg/ContributionMessageArgs' -import { ContributionMessageType } from '@enum/MessageType' -import { ContributionStatus } from '@enum/ContributionStatus' -import { Order } from '@enum/Order' -import Paginated from '@arg/Paginated' import { RIGHTS } from '@/auth/RIGHTS' -import { Context, getUser } from '@/server/context' import { sendAddedContributionMessageEmail } from '@/emails/sendEmailVariants' -import LogError from '@/server/LogError' import { EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE, EVENT_CONTRIBUTION_MESSAGE_CREATE, } from '@/event/Event' +import { Context, getUser } from '@/server/context' +import LogError from '@/server/LogError' +import ContributionMessageArgs from '@arg/ContributionMessageArgs' +import Paginated from '@arg/Paginated' +import { ContributionStatus } from '@enum/ContributionStatus' +import { ContributionMessageType } from '@enum/MessageType' +import { Order } from '@enum/Order' +import { ContributionMessage, ContributionMessageListResult } from '@model/ContributionMessage' @Resolver() export class ContributionMessageResolver { diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index d05060c7e..5291259b7 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -6,18 +6,23 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { Decimal } from 'decimal.js-light' -import { GraphQLError } from 'graphql' import { Contribution } from '@entity/Contribution' +import { Event as DbEvent } from '@entity/Event' import { Transaction as DbTransaction } from '@entity/Transaction' import { User } from '@entity/User' import { UserInputError } from 'apollo-server-express' -import { Event as DbEvent } from '@entity/Event' +import { Decimal } from 'decimal.js-light' +import { GraphQLError } from 'graphql' -import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' -import { bobBaumeister } from '@/seeds/users/bob-baumeister' -import { stephenHawking } from '@/seeds/users/stephen-hawking' -import { garrickOllivander } from '@/seeds/users/garrick-ollivander' +import { + sendContributionConfirmedEmail, + sendContributionDeletedEmail, + sendContributionDeniedEmail, +} from '@/emails/sendEmailVariants' +import { EventType } from '@/event/Event' +import { creations } from '@/seeds/creation/index' +import { creationFactory } from '@/seeds/factory/creation' +import { userFactory } from '@/seeds/factory/user' import { createContribution, updateContribution, @@ -36,11 +41,16 @@ import { listContributions, adminListContributions, } from '@/seeds/graphql/queries' -import { - sendContributionConfirmedEmail, - sendContributionDeletedEmail, - sendContributionDeniedEmail, -} from '@/emails/sendEmailVariants' +import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' +import { bobBaumeister } from '@/seeds/users/bob-baumeister' +import { garrickOllivander } from '@/seeds/users/garrick-ollivander' +import { peterLustig } from '@/seeds/users/peter-lustig' +import { raeuberHotzenplotz } from '@/seeds/users/raeuber-hotzenplotz' +import { stephenHawking } from '@/seeds/users/stephen-hawking' +import { ContributionStatus } from '@enum/ContributionStatus' +import { Order } from '@enum/Order' +import { ContributionListResult } from '@model/Contribution' +import { UnconfirmedContribution } from '@model/UnconfirmedContribution' import { cleanDB, resetToken, @@ -48,17 +58,7 @@ import { contributionDateFormatter, resetEntity, } from '@test/helpers' -import { userFactory } from '@/seeds/factory/user' -import { creationFactory } from '@/seeds/factory/creation' -import { creations } from '@/seeds/creation/index' -import { peterLustig } from '@/seeds/users/peter-lustig' -import { EventType } from '@/event/Event' import { logger, i18n as localization } from '@test/testSetup' -import { raeuberHotzenplotz } from '@/seeds/users/raeuber-hotzenplotz' -import { UnconfirmedContribution } from '@model/UnconfirmedContribution' -import { ContributionListResult } from '@model/Contribution' -import { ContributionStatus } from '@enum/ContributionStatus' -import { Order } from '@enum/Order' jest.mock('@/emails/sendEmailVariants') diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 28b393be5..5fdbd1a12 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -1,30 +1,19 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ -import { Decimal } from 'decimal.js-light' -import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql' import { IsNull, getConnection } from '@dbTools/typeorm' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionMessage } from '@entity/ContributionMessage' -import { UserContact } from '@entity/UserContact' -import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' +import { User as DbUser } from '@entity/User' +import { UserContact } from '@entity/UserContact' +import { Decimal } from 'decimal.js-light' +import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql' -import { AdminUpdateContribution } from '@model/AdminUpdateContribution' -import { Contribution, ContributionListResult } from '@model/Contribution' -import { Decay } from '@model/Decay' -import { OpenCreation } from '@model/OpenCreation' -import { UnconfirmedContribution } from '@model/UnconfirmedContribution' -import { TransactionTypeId } from '@enum/TransactionTypeId' -import { Order } from '@enum/Order' -import { ContributionType } from '@enum/ContributionType' -import { ContributionStatus } from '@enum/ContributionStatus' -import { ContributionMessageType } from '@enum/MessageType' -import ContributionArgs from '@arg/ContributionArgs' -import Paginated from '@arg/Paginated' -import AdminCreateContributionArgs from '@arg/AdminCreateContributionArgs' -import AdminUpdateContributionArgs from '@arg/AdminUpdateContributionArgs' import { RIGHTS } from '@/auth/RIGHTS' -import { Context, getUser, getClientTimezoneOffset } from '@/server/context' -import { backendLogger as logger } from '@/server/logger' +import { + sendContributionConfirmedEmail, + sendContributionDeletedEmail, + sendContributionDeniedEmail, +} from '@/emails/sendEmailVariants' import { EVENT_CONTRIBUTION_CREATE, EVENT_CONTRIBUTION_DELETE, @@ -35,15 +24,27 @@ import { EVENT_ADMIN_CONTRIBUTION_CONFIRM, EVENT_ADMIN_CONTRIBUTION_DENY, } from '@/event/Event' -import { calculateDecay } from '@/util/decay' -import { - sendContributionConfirmedEmail, - sendContributionDeletedEmail, - sendContributionDeniedEmail, -} from '@/emails/sendEmailVariants' -import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' +import { Context, getUser, getClientTimezoneOffset } from '@/server/context' import LogError from '@/server/LogError' +import { backendLogger as logger } from '@/server/logger' +import { calculateDecay } from '@/util/decay' +import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' +import AdminCreateContributionArgs from '@arg/AdminCreateContributionArgs' +import AdminUpdateContributionArgs from '@arg/AdminUpdateContributionArgs' +import ContributionArgs from '@arg/ContributionArgs' +import Paginated from '@arg/Paginated' +import { ContributionStatus } from '@enum/ContributionStatus' +import { ContributionType } from '@enum/ContributionType' +import { ContributionMessageType } from '@enum/MessageType' +import { Order } from '@enum/Order' +import { TransactionTypeId } from '@enum/TransactionTypeId' +import { AdminUpdateContribution } from '@model/AdminUpdateContribution' +import { Contribution, ContributionListResult } from '@model/Contribution' +import { Decay } from '@model/Decay' +import { OpenCreation } from '@model/OpenCreation' +import { UnconfirmedContribution } from '@model/UnconfirmedContribution' +import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' import { getUserCreation, validateContribution, @@ -53,7 +54,6 @@ import { } from './util/creations' import { findContributions } from './util/findContributions' import { getLastTransaction } from './util/getLastTransaction' -import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' @Resolver() export class ContributionResolver { diff --git a/backend/src/graphql/resolver/EmailOptinCodes.test.ts b/backend/src/graphql/resolver/EmailOptinCodes.test.ts index 0b6ebfbe4..9f234e73f 100644 --- a/backend/src/graphql/resolver/EmailOptinCodes.test.ts +++ b/backend/src/graphql/resolver/EmailOptinCodes.test.ts @@ -7,10 +7,10 @@ import { User as DbUser } from '@entity/User' import { GraphQLError } from 'graphql' -import { testEnvironment, cleanDB } from '@test/helpers' +import CONFIG from '@/config' import { createUser, setPassword, forgotPassword } from '@/seeds/graphql/mutations' import { queryOptIn } from '@/seeds/graphql/queries' -import CONFIG from '@/config' +import { testEnvironment, cleanDB } from '@test/helpers' let mutate: any, query: any, con: any let testEnv: any diff --git a/backend/src/graphql/resolver/GdtResolver.ts b/backend/src/graphql/resolver/GdtResolver.ts index 00b0aa1bf..68a2c2275 100644 --- a/backend/src/graphql/resolver/GdtResolver.ts +++ b/backend/src/graphql/resolver/GdtResolver.ts @@ -3,14 +3,14 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ import { Resolver, Query, Args, Ctx, Authorized, Arg, Int, Float } from 'type-graphql' -import { GdtEntryList } from '@model/GdtEntryList' -import { Order } from '@enum/Order' -import Paginated from '@arg/Paginated' -import { Context, getUser } from '@/server/context' -import CONFIG from '@/config' import { apiGet, apiPost } from '@/apis/HttpRequest' import { RIGHTS } from '@/auth/RIGHTS' +import CONFIG from '@/config' +import { Context, getUser } from '@/server/context' import LogError from '@/server/LogError' +import Paginated from '@arg/Paginated' +import { Order } from '@enum/Order' +import { GdtEntryList } from '@model/GdtEntryList' @Resolver() export class GdtResolver { diff --git a/backend/src/graphql/resolver/StatisticsResolver.ts b/backend/src/graphql/resolver/StatisticsResolver.ts index 3ddc8bfbc..056163811 100644 --- a/backend/src/graphql/resolver/StatisticsResolver.ts +++ b/backend/src/graphql/resolver/StatisticsResolver.ts @@ -1,14 +1,14 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-return */ -import { Decimal } from 'decimal.js-light' -import { Resolver, Query, Authorized, FieldResolver } from 'type-graphql' import { getConnection } from '@dbTools/typeorm' import { Transaction as DbTransaction } from '@entity/Transaction' import { User as DbUser } from '@entity/User' +import { Decimal } from 'decimal.js-light' +import { Resolver, Query, Authorized, FieldResolver } from 'type-graphql' -import { CommunityStatistics, DynamicStatisticsFields } from '@model/CommunityStatistics' import { RIGHTS } from '@/auth/RIGHTS' import { calculateDecay } from '@/util/decay' +import { CommunityStatistics, DynamicStatisticsFields } from '@model/CommunityStatistics' /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ @Resolver((of) => CommunityStatistics) diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index d9010b57a..13bb2c431 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -7,21 +7,18 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' +import { Event as DbEvent } from '@entity/Event' +import { Transaction } from '@entity/Transaction' import { User } from '@entity/User' +import { UserContact } from '@entity/UserContact' import { Decimal } from 'decimal.js-light' import { GraphQLError } from 'graphql' -import { Transaction } from '@entity/Transaction' -import { Event as DbEvent } from '@entity/Event' -import { UserContact } from '@entity/UserContact' -import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' -import { peterLustig } from '@/seeds/users/peter-lustig' -import { cleanDB, testEnvironment, resetToken, resetEntity } from '@test/helpers' -import { creationFactory } from '@/seeds/factory/creation' +import { EventType } from '@/event/Event' import { creations } from '@/seeds/creation/index' -import { userFactory } from '@/seeds/factory/user' +import { creationFactory } from '@/seeds/factory/creation' import { transactionLinkFactory } from '@/seeds/factory/transactionLink' -import { transactionLinks } from '@/seeds/transactionLink/index' +import { userFactory } from '@/seeds/factory/user' import { login, createContributionLink, @@ -33,10 +30,13 @@ import { confirmContribution, } from '@/seeds/graphql/mutations' import { listTransactionLinksAdmin } from '@/seeds/graphql/queries' -import { UnconfirmedContribution } from '@model/UnconfirmedContribution' +import { transactionLinks } from '@/seeds/transactionLink/index' +import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' +import { peterLustig } from '@/seeds/users/peter-lustig' import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' +import { UnconfirmedContribution } from '@model/UnconfirmedContribution' +import { cleanDB, testEnvironment, resetToken, resetEntity } from '@test/helpers' import { logger } from '@test/testSetup' -import { EventType } from '@/event/Event' import { transactionLinkCode } from './TransactionLinkResolver' diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.ts b/backend/src/graphql/resolver/TransactionLinkResolver.ts index 2131439d5..6365096cf 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.ts @@ -1,44 +1,44 @@ import { randomBytes } from 'crypto' -import { Decimal } from 'decimal.js-light' import { getConnection } from '@dbTools/typeorm' -import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' -import { User as DbUser } from '@entity/User' -import { Transaction as DbTransaction } from '@entity/Transaction' import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' +import { Transaction as DbTransaction } from '@entity/Transaction' +import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' +import { User as DbUser } from '@entity/User' +import { Decimal } from 'decimal.js-light' import { Resolver, Args, Arg, Authorized, Ctx, Mutation, Query, Int } from 'type-graphql' -import { User } from '@model/User' -import { ContributionLink } from '@model/ContributionLink' -import { Decay } from '@model/Decay' -import { TransactionLink, TransactionLinkResult } from '@model/TransactionLink' -import { ContributionType } from '@enum/ContributionType' -import { ContributionStatus } from '@enum/ContributionStatus' -import { TransactionTypeId } from '@enum/TransactionTypeId' -import { ContributionCycleType } from '@enum/ContributionCycleType' -import TransactionLinkArgs from '@arg/TransactionLinkArgs' -import Paginated from '@arg/Paginated' -import TransactionLinkFilters from '@arg/TransactionLinkFilters' -import { backendLogger as logger } from '@/server/logger' -import { Context, getUser, getClientTimezoneOffset } from '@/server/context' -import { calculateBalance } from '@/util/validate' import { RIGHTS } from '@/auth/RIGHTS' -import { calculateDecay } from '@/util/decay' -import QueryLinkResult from '@union/QueryLinkResult' -import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' -import LogError from '@/server/LogError' import { EVENT_CONTRIBUTION_LINK_REDEEM, EVENT_TRANSACTION_LINK_CREATE, EVENT_TRANSACTION_LINK_DELETE, EVENT_TRANSACTION_LINK_REDEEM, } from '@/event/Event' +import { Context, getUser, getClientTimezoneOffset } from '@/server/context' +import LogError from '@/server/LogError' +import { backendLogger as logger } from '@/server/logger' +import { calculateDecay } from '@/util/decay' +import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' +import { calculateBalance } from '@/util/validate' +import Paginated from '@arg/Paginated' +import TransactionLinkArgs from '@arg/TransactionLinkArgs' +import TransactionLinkFilters from '@arg/TransactionLinkFilters' +import { ContributionCycleType } from '@enum/ContributionCycleType' +import { ContributionStatus } from '@enum/ContributionStatus' +import { ContributionType } from '@enum/ContributionType' +import { TransactionTypeId } from '@enum/TransactionTypeId' +import { ContributionLink } from '@model/ContributionLink' +import { Decay } from '@model/Decay' +import { TransactionLink, TransactionLinkResult } from '@model/TransactionLink' +import { User } from '@model/User' +import QueryLinkResult from '@union/QueryLinkResult' -import transactionLinkList from './util/transactionLinkList' -import { getLastTransaction } from './util/getLastTransaction' import { executeTransaction } from './TransactionResolver' import { getUserCreation, validateContribution } from './util/creations' +import { getLastTransaction } from './util/getLastTransaction' +import transactionLinkList from './util/transactionLinkList' // TODO: do not export, test it inside the resolver export const transactionLinkCode = (date: Date): string => { diff --git a/backend/src/graphql/resolver/TransactionResolver.test.ts b/backend/src/graphql/resolver/TransactionResolver.test.ts index 558f0c315..7d855a1e6 100644 --- a/backend/src/graphql/resolver/TransactionResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionResolver.test.ts @@ -5,11 +5,11 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { Decimal } from 'decimal.js-light' +import { Event as DbEvent } from '@entity/Event' import { Transaction } from '@entity/Transaction' import { User } from '@entity/User' +import { Decimal } from 'decimal.js-light' import { GraphQLError } from 'graphql' -import { Event as DbEvent } from '@entity/Event' import { EventType } from '@/event/Event' import { userFactory } from '@/seeds/factory/user' diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index f36ac3d68..6e81a01c8 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -2,40 +2,40 @@ /* eslint-disable new-cap */ /* eslint-disable @typescript-eslint/no-non-null-assertion */ -import { Decimal } from 'decimal.js-light' -import { Resolver, Query, Args, Authorized, Ctx, Mutation } from 'type-graphql' import { getCustomRepository, getConnection, In } from '@dbTools/typeorm' -import { User as dbUser } from '@entity/User' import { Transaction as dbTransaction } from '@entity/Transaction' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' +import { User as dbUser } from '@entity/User' +import { Decimal } from 'decimal.js-light' +import { Resolver, Query, Args, Authorized, Ctx, Mutation } from 'type-graphql' -import { TransactionRepository } from '@repository/Transaction' -import { TransactionLinkRepository } from '@repository/TransactionLink' -import { User } from '@model/User' -import { Transaction } from '@model/Transaction' -import { TransactionList } from '@model/TransactionList' -import { Order } from '@enum/Order' -import { TransactionTypeId } from '@enum/TransactionTypeId' -import { calculateBalance } from '@/util/validate' -import TransactionSendArgs from '@arg/TransactionSendArgs' -import Paginated from '@arg/Paginated' -import { backendLogger as logger } from '@/server/logger' -import { Context, getUser } from '@/server/context' import { RIGHTS } from '@/auth/RIGHTS' -import { communityUser } from '@/util/communityUser' -import { virtualLinkTransaction, virtualDecayTransaction } from '@/util/virtualTransactions' import { sendTransactionLinkRedeemedEmail, sendTransactionReceivedEmail, } from '@/emails/sendEmailVariants' import { EVENT_TRANSACTION_RECEIVE, EVENT_TRANSACTION_SEND } from '@/event/Event' -import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' +import { Context, getUser } from '@/server/context' import LogError from '@/server/LogError' +import { backendLogger as logger } from '@/server/logger' +import { communityUser } from '@/util/communityUser' +import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' +import { calculateBalance } from '@/util/validate' +import { virtualLinkTransaction, virtualDecayTransaction } from '@/util/virtualTransactions' +import Paginated from '@arg/Paginated' +import TransactionSendArgs from '@arg/TransactionSendArgs' +import { Order } from '@enum/Order' +import { TransactionTypeId } from '@enum/TransactionTypeId' +import { Transaction } from '@model/Transaction' +import { TransactionList } from '@model/TransactionList' +import { User } from '@model/User' +import { TransactionRepository } from '@repository/Transaction' +import { TransactionLinkRepository } from '@repository/TransactionLink' -import { getLastTransaction } from './util/getLastTransaction' -import { findUserByEmail } from './UserResolver' -import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' import { BalanceResolver } from './BalanceResolver' +import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' +import { findUserByEmail } from './UserResolver' +import { getLastTransaction } from './util/getLastTransaction' export const executeTransaction = async ( amount: Decimal, diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index ccf56a285..f9f0dcdb3 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -6,22 +6,25 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { GraphQLError } from 'graphql' -import { User } from '@entity/User' -import { TransactionLink } from '@entity/TransactionLink' -import { validate as validateUUID, version as versionUUID } from 'uuid' -import { UserContact } from '@entity/UserContact' import { Event as DbEvent } from '@entity/Event' +import { TransactionLink } from '@entity/TransactionLink' +import { User } from '@entity/User' +import { UserContact } from '@entity/UserContact' +import { GraphQLError } from 'graphql' +import { validate as validateUUID, version as versionUUID } from 'uuid' -import { OptInType } from '@enum/OptInType' -import { UserContactType } from '@enum/UserContactType' -import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' -import { objectValuesToArray } from '@/util/utilities' -import { testEnvironment, headerPushMock, resetToken, cleanDB } from '@test/helpers' -import { logger, i18n as localization } from '@test/testSetup' -import { printTimeDuration } from '@/util/time' +import CONFIG from '@/config' +import { + sendAccountActivationEmail, + sendAccountMultiRegistrationEmail, + sendResetPasswordEmail, +} from '@/emails/sendEmailVariants' +import { EventType } from '@/event/Event' +import { SecretKeyCryptographyCreateKey } from '@/password/EncryptorUtils' +import { encryptPassword } from '@/password/PasswordEncryptor' +import { contributionLinkFactory } from '@/seeds/factory/contributionLink' +import { transactionLinkFactory } from '@/seeds/factory/transactionLink' import { userFactory } from '@/seeds/factory/user' -import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { login, logout, @@ -37,22 +40,19 @@ import { sendActivationEmail, } from '@/seeds/graphql/mutations' import { verifyLogin, queryOptIn, searchAdminUsers, searchUsers } from '@/seeds/graphql/queries' -import CONFIG from '@/config' -import { - sendAccountActivationEmail, - sendAccountMultiRegistrationEmail, - sendResetPasswordEmail, -} from '@/emails/sendEmailVariants' -import { contributionLinkFactory } from '@/seeds/factory/contributionLink' -import { transactionLinkFactory } from '@/seeds/factory/transactionLink' -import { ContributionLink } from '@model/ContributionLink' -import { EventType } from '@/event/Event' -import { peterLustig } from '@/seeds/users/peter-lustig' +import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { bobBaumeister } from '@/seeds/users/bob-baumeister' -import { stephenHawking } from '@/seeds/users/stephen-hawking' import { garrickOllivander } from '@/seeds/users/garrick-ollivander' -import { encryptPassword } from '@/password/PasswordEncryptor' -import { SecretKeyCryptographyCreateKey } from '@/password/EncryptorUtils' +import { peterLustig } from '@/seeds/users/peter-lustig' +import { stephenHawking } from '@/seeds/users/stephen-hawking' +import { printTimeDuration } from '@/util/time' +import { objectValuesToArray } from '@/util/utilities' +import { OptInType } from '@enum/OptInType' +import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' +import { UserContactType } from '@enum/UserContactType' +import { ContributionLink } from '@model/ContributionLink' +import { testEnvironment, headerPushMock, resetToken, cleanDB } from '@test/helpers' +import { logger, i18n as localization } from '@test/testSetup' // import { klicktippSignIn } from '@/apis/KlicktippController' diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 0be376bd6..fb8f7568c 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -2,8 +2,12 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/restrict-template-expressions */ +import { getConnection, getCustomRepository, IsNull, Not } from '@dbTools/typeorm' +import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' +import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' +import { User as DbUser } from '@entity/User' +import { UserContact as DbUserContact } from '@entity/UserContact' import i18n from 'i18n' -import { v4 as uuidv4 } from 'uuid' import { Resolver, Query, @@ -15,40 +19,17 @@ import { Mutation, Int, } from 'type-graphql' -import { getConnection, getCustomRepository, IsNull, Not } from '@dbTools/typeorm' -import { User as DbUser } from '@entity/User' -import { UserContact as DbUserContact } from '@entity/UserContact' -import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' -import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' +import { v4 as uuidv4 } from 'uuid' -import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' -import { UserRepository } from '@repository/User' -import { User } from '@model/User' -import { SearchAdminUsersResult } from '@model/AdminUser' -import { UserAdmin, SearchUsersResult } from '@model/UserAdmin' -import { OptInType } from '@enum/OptInType' -import { Order } from '@enum/Order' -import { UserContactType } from '@enum/UserContactType' +import { klicktippSignIn } from '@/apis/KlicktippController' +import { encode } from '@/auth/JWT' +import { RIGHTS } from '@/auth/RIGHTS' +import CONFIG from '@/config' import { sendAccountActivationEmail, sendAccountMultiRegistrationEmail, sendResetPasswordEmail, } from '@/emails/sendEmailVariants' -import { getTimeDurationObject, printTimeDuration } from '@/util/time' -import CreateUserArgs from '@arg/CreateUserArgs' -import UnsecureLoginArgs from '@arg/UnsecureLoginArgs' -import UpdateUserInfosArgs from '@arg/UpdateUserInfosArgs' -import Paginated from '@arg/Paginated' -import SearchUsersArgs from '@arg/SearchUsersArgs' -import { backendLogger as logger } from '@/server/logger' -import { Context, getUser, getClientTimezoneOffset } from '@/server/context' -import CONFIG from '@/config' -import { communityDbUser } from '@/util/communityUser' -import { encode } from '@/auth/JWT' -import { klicktippNewsletterStateMiddleware } from '@/middleware/klicktippMiddleware' -import { klicktippSignIn } from '@/apis/KlicktippController' -import { RIGHTS } from '@/auth/RIGHTS' -import { hasElopageBuys } from '@/util/hasElopageBuys' import { Event, EventType, @@ -65,17 +46,36 @@ import { EVENT_ADMIN_USER_DELETE, EVENT_ADMIN_USER_UNDELETE, } from '@/event/Event' +import { klicktippNewsletterStateMiddleware } from '@/middleware/klicktippMiddleware' import { isValidPassword } from '@/password/EncryptorUtils' import { encryptPassword, verifyPassword } from '@/password/PasswordEncryptor' +import { Context, getUser, getClientTimezoneOffset } from '@/server/context' import LogError from '@/server/LogError' +import { backendLogger as logger } from '@/server/logger' +import { communityDbUser } from '@/util/communityUser' +import { hasElopageBuys } from '@/util/hasElopageBuys' +import { getTimeDurationObject, printTimeDuration } from '@/util/time' +import CreateUserArgs from '@arg/CreateUserArgs' +import Paginated from '@arg/Paginated' +import SearchUsersArgs from '@arg/SearchUsersArgs' +import UnsecureLoginArgs from '@arg/UnsecureLoginArgs' +import UpdateUserInfosArgs from '@arg/UpdateUserInfosArgs' +import { OptInType } from '@enum/OptInType' +import { Order } from '@enum/Order' +import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' +import { UserContactType } from '@enum/UserContactType' +import { SearchAdminUsersResult } from '@model/AdminUser' +import { User } from '@model/User' +import { UserAdmin, SearchUsersResult } from '@model/UserAdmin' +import { UserRepository } from '@repository/User' import { FULL_CREATION_AVAILABLE } from './const/const' import { getUserCreations } from './util/creations' -// eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs -const sodium = require('sodium-native') // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs const random = require('random-bigint') +// eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs +const sodium = require('sodium-native') const LANGUAGES = ['de', 'en', 'es', 'fr', 'nl'] const DEFAULT_LANGUAGE = 'de' diff --git a/backend/src/graphql/resolver/semaphore.test.ts b/backend/src/graphql/resolver/semaphore.test.ts index 0fb355676..4aa76ab01 100644 --- a/backend/src/graphql/resolver/semaphore.test.ts +++ b/backend/src/graphql/resolver/semaphore.test.ts @@ -6,12 +6,8 @@ import { Decimal } from 'decimal.js-light' -import { userFactory } from '@/seeds/factory/user' -import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' -import { bobBaumeister } from '@/seeds/users/bob-baumeister' -import { peterLustig } from '@/seeds/users/peter-lustig' import { creationFactory, nMonthsBefore } from '@/seeds/factory/creation' -import { cleanDB, testEnvironment, contributionDateFormatter } from '@test/helpers' +import { userFactory } from '@/seeds/factory/user' import { confirmContribution, createContribution, @@ -21,6 +17,10 @@ import { createContributionLink, sendCoins, } from '@/seeds/graphql/mutations' +import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' +import { bobBaumeister } from '@/seeds/users/bob-baumeister' +import { peterLustig } from '@/seeds/users/peter-lustig' +import { cleanDB, testEnvironment, contributionDateFormatter } from '@test/helpers' let mutate: any, con: any let testEnv: any diff --git a/backend/src/graphql/resolver/util/creations.test.ts b/backend/src/graphql/resolver/util/creations.test.ts index 37bdb742c..56e37a39b 100644 --- a/backend/src/graphql/resolver/util/creations.test.ts +++ b/backend/src/graphql/resolver/util/creations.test.ts @@ -4,14 +4,14 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { User } from '@entity/User' import { Contribution } from '@entity/Contribution' +import { User } from '@entity/User' -import { testEnvironment, cleanDB, contributionDateFormatter } from '@test/helpers' -import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' -import { peterLustig } from '@/seeds/users/peter-lustig' import { userFactory } from '@/seeds/factory/user' import { login, createContribution, adminCreateContribution } from '@/seeds/graphql/mutations' +import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' +import { peterLustig } from '@/seeds/users/peter-lustig' +import { testEnvironment, cleanDB, contributionDateFormatter } from '@test/helpers' import { getUserCreation } from './creations' diff --git a/backend/src/graphql/resolver/util/creations.ts b/backend/src/graphql/resolver/util/creations.ts index 44b675de4..3903eef19 100644 --- a/backend/src/graphql/resolver/util/creations.ts +++ b/backend/src/graphql/resolver/util/creations.ts @@ -5,9 +5,9 @@ import { Contribution } from '@entity/Contribution' import { Decimal } from 'decimal.js-light' import { FULL_CREATION_AVAILABLE, MAX_CREATION_AMOUNT } from '@/graphql/resolver/const/const' +import LogError from '@/server/LogError' import { backendLogger as logger } from '@/server/logger' import { OpenCreation } from '@model/OpenCreation' -import LogError from '@/server/LogError' interface CreationMap { id: number diff --git a/backend/src/graphql/resolver/util/findContributions.ts b/backend/src/graphql/resolver/util/findContributions.ts index 5c70fafe7..a08631e2c 100644 --- a/backend/src/graphql/resolver/util/findContributions.ts +++ b/backend/src/graphql/resolver/util/findContributions.ts @@ -1,5 +1,5 @@ -import { Contribution as DbContribution } from '@entity/Contribution' import { In } from '@dbTools/typeorm' +import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionStatus } from '@enum/ContributionStatus' import { Order } from '@enum/Order' diff --git a/backend/src/graphql/resolver/util/transactionLinkList.ts b/backend/src/graphql/resolver/util/transactionLinkList.ts index ed90cc852..b7bf9eb5e 100644 --- a/backend/src/graphql/resolver/util/transactionLinkList.ts +++ b/backend/src/graphql/resolver/util/transactionLinkList.ts @@ -2,11 +2,11 @@ import { MoreThan } from '@dbTools/typeorm' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { User as DbUser } from '@entity/User' -import { Order } from '@enum/Order' +import { User } from '@/graphql/model/User' import Paginated from '@arg/Paginated' import TransactionLinkFilters from '@arg/TransactionLinkFilters' +import { Order } from '@enum/Order' import { TransactionLink, TransactionLinkResult } from '@model/TransactionLink' -import { User } from '@/graphql/model/User' export default async function transactionLinkList( { currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated, diff --git a/backend/src/graphql/scalar/Decimal.ts b/backend/src/graphql/scalar/Decimal.ts index 586481a6d..e46446cee 100644 --- a/backend/src/graphql/scalar/Decimal.ts +++ b/backend/src/graphql/scalar/Decimal.ts @@ -1,5 +1,5 @@ -import { GraphQLScalarType, Kind } from 'graphql' import { Decimal } from 'decimal.js-light' +import { GraphQLScalarType, Kind } from 'graphql' const DecimalType = new GraphQLScalarType({ name: 'Decimal', diff --git a/backend/src/graphql/schema.ts b/backend/src/graphql/schema.ts index 1aae117d0..c6097f027 100644 --- a/backend/src/graphql/schema.ts +++ b/backend/src/graphql/schema.ts @@ -1,8 +1,8 @@ import path from 'path' +import { Decimal } from 'decimal.js-light' import { GraphQLSchema } from 'graphql' import { buildSchema } from 'type-graphql' -import { Decimal } from 'decimal.js-light' import isAuthorized from './directive/isAuthorized' import DecimalScalar from './scalar/Decimal' diff --git a/backend/src/graphql/union/QueryLinkResult.ts b/backend/src/graphql/union/QueryLinkResult.ts index 775320bdd..390175d1d 100644 --- a/backend/src/graphql/union/QueryLinkResult.ts +++ b/backend/src/graphql/union/QueryLinkResult.ts @@ -1,7 +1,7 @@ import { createUnionType } from 'type-graphql' -import { TransactionLink } from '@model/TransactionLink' import { ContributionLink } from '@model/ContributionLink' +import { TransactionLink } from '@model/TransactionLink' export default createUnionType({ name: 'QueryLinkResult', // the name of the GraphQL union diff --git a/backend/src/index.ts b/backend/src/index.ts index d3ebc42cf..353b77616 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import createServer from './server/createServer' // config import CONFIG from './config' import { startValidateCommunities } from './federation/validateCommunities' +import createServer from './server/createServer' async function main() { const { app } = await createServer() diff --git a/backend/src/middleware/klicktippMiddleware.ts b/backend/src/middleware/klicktippMiddleware.ts index e133977ee..ac0dff0d9 100644 --- a/backend/src/middleware/klicktippMiddleware.ts +++ b/backend/src/middleware/klicktippMiddleware.ts @@ -5,9 +5,9 @@ import { MiddlewareFn } from 'type-graphql' import { /* klicktippSignIn, */ getKlickTippUser } from '@/apis/KlicktippController' -import { KlickTipp } from '@model/KlickTipp' import CONFIG from '@/config' import { klickTippLogger as logger } from '@/server/logger' +import { KlickTipp } from '@model/KlickTipp' // export const klicktippRegistrationMiddleware: MiddlewareFn = async ( // // Only for demo diff --git a/backend/src/seeds/factory/contributionLink.ts b/backend/src/seeds/factory/contributionLink.ts index 565669dad..865e844b2 100644 --- a/backend/src/seeds/factory/contributionLink.ts +++ b/backend/src/seeds/factory/contributionLink.ts @@ -3,9 +3,9 @@ /* eslint-disable @typescript-eslint/unbound-method */ import { ApolloServerTestClient } from 'apollo-server-testing' +import { ContributionLinkInterface } from '@/seeds/contributionLink/ContributionLinkInterface' import { login, createContributionLink } from '@/seeds/graphql/mutations' import { ContributionLink } from '@model/ContributionLink' -import { ContributionLinkInterface } from '@/seeds/contributionLink/ContributionLinkInterface' export const contributionLinkFactory = async ( client: ApolloServerTestClient, diff --git a/backend/src/seeds/factory/creation.ts b/backend/src/seeds/factory/creation.ts index d0ca131c7..6a3aaa3e7 100644 --- a/backend/src/seeds/factory/creation.ts +++ b/backend/src/seeds/factory/creation.ts @@ -5,13 +5,13 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { ApolloServerTestClient } from 'apollo-server-testing' -import { Transaction } from '@entity/Transaction' import { Contribution } from '@entity/Contribution' +import { Transaction } from '@entity/Transaction' +import { ApolloServerTestClient } from 'apollo-server-testing' +import { findUserByEmail } from '@/graphql/resolver/UserResolver' import { CreationInterface } from '@/seeds/creation/CreationInterface' import { login, createContribution, confirmContribution } from '@/seeds/graphql/mutations' -import { findUserByEmail } from '@/graphql/resolver/UserResolver' // import CONFIG from '@/config/index' export const nMonthsBefore = (date: Date, months = 1): string => { diff --git a/backend/src/seeds/factory/transactionLink.ts b/backend/src/seeds/factory/transactionLink.ts index fa4478074..cab478c4b 100644 --- a/backend/src/seeds/factory/transactionLink.ts +++ b/backend/src/seeds/factory/transactionLink.ts @@ -1,11 +1,11 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/unbound-method */ -import { ApolloServerTestClient } from 'apollo-server-testing' import { TransactionLink } from '@entity/TransactionLink' +import { ApolloServerTestClient } from 'apollo-server-testing' +import { transactionLinkExpireDate } from '@/graphql/resolver/TransactionLinkResolver' import { login, createTransactionLink } from '@/seeds/graphql/mutations' import { TransactionLinkInterface } from '@/seeds/transactionLink/TransactionLinkInterface' -import { transactionLinkExpireDate } from '@/graphql/resolver/TransactionLinkResolver' export const transactionLinkFactory = async ( client: ApolloServerTestClient, diff --git a/backend/src/seeds/index.ts b/backend/src/seeds/index.ts index 0d972abb3..d1960eea9 100644 --- a/backend/src/seeds/index.ts +++ b/backend/src/seeds/index.ts @@ -5,22 +5,22 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +import { entities } from '@entity/index' import { createTestClient } from 'apollo-server-testing' import { name, internet, datatype } from 'faker' -import { entities } from '@entity/index' +import CONFIG from '@/config' import createServer from '@/server/createServer' import { backendLogger as logger } from '@/server/logger' -import CONFIG from '@/config' -import { users } from './users/index' -import { creations } from './creation/index' -import { transactionLinks } from './transactionLink/index' import { contributionLinks } from './contributionLink/index' -import { userFactory } from './factory/user' +import { creations } from './creation/index' +import { contributionLinkFactory } from './factory/contributionLink' import { creationFactory } from './factory/creation' import { transactionLinkFactory } from './factory/transactionLink' -import { contributionLinkFactory } from './factory/contributionLink' +import { userFactory } from './factory/user' +import { transactionLinks } from './transactionLink/index' +import { users } from './users/index' CONFIG.EMAIL = false diff --git a/backend/src/seeds/users/index.ts b/backend/src/seeds/users/index.ts index 7a6dbe519..beb6c6f25 100644 --- a/backend/src/seeds/users/index.ts +++ b/backend/src/seeds/users/index.ts @@ -1,9 +1,9 @@ -import { peterLustig } from './peter-lustig' import { bibiBloxberg } from './bibi-bloxberg' import { bobBaumeister } from './bob-baumeister' +import { garrickOllivander } from './garrick-ollivander' +import { peterLustig } from './peter-lustig' import { raeuberHotzenplotz } from './raeuber-hotzenplotz' import { stephenHawking } from './stephen-hawking' -import { garrickOllivander } from './garrick-ollivander' export const users = [ peterLustig, diff --git a/backend/src/server/context.ts b/backend/src/server/context.ts index 4b631bd9c..f0e63daea 100644 --- a/backend/src/server/context.ts +++ b/backend/src/server/context.ts @@ -1,7 +1,7 @@ -import { User as dbUser } from '@entity/User' import { Transaction as dbTransaction } from '@entity/Transaction' -import { Decimal } from 'decimal.js-light' +import { User as dbUser } from '@entity/User' import { ExpressContext } from 'apollo-server-express' +import { Decimal } from 'decimal.js-light' import { Role } from '@/auth/Role' diff --git a/backend/src/server/createServer.ts b/backend/src/server/createServer.ts index 6ffd18c50..8a94ef3eb 100644 --- a/backend/src/server/createServer.ts +++ b/backend/src/server/createServer.ts @@ -1,22 +1,22 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/restrict-template-expressions */ /* eslint-disable @typescript-eslint/unbound-method */ +import { Connection } from '@dbTools/typeorm' import { ApolloServer } from 'apollo-server-express' import express, { Express, json, urlencoded } from 'express' -import { Connection } from '@dbTools/typeorm' import { Logger } from 'log4js' -import connection from '@/typeorm/connection' -import { checkDBVersion } from '@/typeorm/DBVersion' import CONFIG from '@/config' import schema from '@/graphql/schema' +import connection from '@/typeorm/connection' +import { checkDBVersion } from '@/typeorm/DBVersion' import { elopageWebhook } from '@/webhook/elopage' -import cors from './cors' import serverContext from './context' -import plugins from './plugins' -import { apolloLogger } from './logger' +import cors from './cors' import { i18n } from './localization' +import { apolloLogger } from './logger' +import plugins from './plugins' // TODO implement // import queryComplexity, { simpleEstimator, fieldConfigEstimator } from "graphql-query-complexity"; diff --git a/backend/src/util/decay.ts b/backend/src/util/decay.ts index 5e2bdb5c6..924e64895 100644 --- a/backend/src/util/decay.ts +++ b/backend/src/util/decay.ts @@ -1,8 +1,8 @@ import { Decimal } from 'decimal.js-light' import CONFIG from '@/config' -import { Decay } from '@model/Decay' import LogError from '@/server/LogError' +import { Decay } from '@model/Decay' // TODO: externalize all those definitions and functions into an external decay library diff --git a/backend/src/util/klicktipp.ts b/backend/src/util/klicktipp.ts index 02bfa1044..4d90be134 100644 --- a/backend/src/util/klicktipp.ts +++ b/backend/src/util/klicktipp.ts @@ -1,8 +1,8 @@ import { User } from '@entity/User' -import connection from '@/typeorm/connection' import { getKlickTippUser } from '@/apis/KlicktippController' import LogError from '@/server/LogError' +import connection from '@/typeorm/connection' export async function retrieveNotRegisteredEmails(): Promise { const con = await connection() diff --git a/backend/src/util/validate.ts b/backend/src/util/validate.ts index 628b00d43..cd4841b9b 100644 --- a/backend/src/util/validate.ts +++ b/backend/src/util/validate.ts @@ -1,10 +1,10 @@ -import { Decimal } from 'decimal.js-light' import { getCustomRepository } from '@dbTools/typeorm' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' +import { Decimal } from 'decimal.js-light' import { getLastTransaction } from '@/graphql/resolver/util/getLastTransaction' -import { TransactionLinkRepository } from '@repository/TransactionLink' import { Decay } from '@model/Decay' +import { TransactionLinkRepository } from '@repository/TransactionLink' import { calculateDecay } from './decay' diff --git a/backend/src/util/virtualTransactions.ts b/backend/src/util/virtualTransactions.ts index f9f13afbc..68a37746b 100644 --- a/backend/src/util/virtualTransactions.ts +++ b/backend/src/util/virtualTransactions.ts @@ -3,8 +3,8 @@ import { SaveOptions, RemoveOptions } from '@dbTools/typeorm' import { Transaction as dbTransaction } from '@entity/Transaction' import { Decimal } from 'decimal.js-light' -import { Transaction } from '@model/Transaction' import { TransactionTypeId } from '@enum/TransactionTypeId' +import { Transaction } from '@model/Transaction' import { User } from '@model/User' import { calculateDecay } from './decay' diff --git a/backend/test/helpers.ts b/backend/test/helpers.ts index f68c15cb8..f440adc02 100644 --- a/backend/test/helpers.ts +++ b/backend/test/helpers.ts @@ -6,9 +6,9 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { createTestClient } from 'apollo-server-testing' import { initialize } from '@dbTools/helpers' import { entities } from '@entity/index' +import { createTestClient } from 'apollo-server-testing' import createServer from '@/server/createServer' diff --git a/backend/test/testSetup.ts b/backend/test/testSetup.ts index b13e3cf26..4e8a67e3f 100644 --- a/backend/test/testSetup.ts +++ b/backend/test/testSetup.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-return */ import CONFIG from '@/config' -import { backendLogger as logger } from '@/server/logger' import { i18n } from '@/server/localization' +import { backendLogger as logger } from '@/server/logger' CONFIG.EMAIL = true CONFIG.EMAIL_TEST_MODUS = false From 7d7eb34aeb364a2c3b0d0f773e8917ddb5bb8a03 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 30 Mar 2023 18:04:43 +0200 Subject: [PATCH 89/91] fix order --- backend/.eslintrc.js | 7 ++++- .../src/emails/sendEmailTranslated.test.ts | 3 +- backend/src/emails/sendEmailVariants.test.ts | 3 +- .../src/graphql/resolver/BalanceResolver.ts | 5 ++-- .../resolver/CommunityResolver.test.ts | 3 +- .../src/graphql/resolver/CommunityResolver.ts | 3 +- .../resolver/ContributionLinkResolver.test.ts | 5 ++-- .../resolver/ContributionLinkResolver.ts | 13 +++++---- .../ContributionMessageResolver.test.ts | 5 ++-- .../resolver/ContributionMessageResolver.ts | 13 +++++---- .../resolver/ContributionResolver.test.ts | 25 ++++++++-------- .../graphql/resolver/ContributionResolver.ts | 29 ++++++++++--------- .../graphql/resolver/EmailOptinCodes.test.ts | 3 +- backend/src/graphql/resolver/GdtResolver.ts | 7 +++-- .../graphql/resolver/StatisticsResolver.ts | 3 +- .../resolver/TransactionLinkResolver.test.ts | 7 +++-- .../resolver/TransactionLinkResolver.ts | 25 ++++++++-------- .../resolver/TransactionResolver.test.ts | 5 ++-- .../graphql/resolver/TransactionResolver.ts | 19 ++++++------ .../src/graphql/resolver/UserResolver.test.ts | 13 +++++---- backend/src/graphql/resolver/UserResolver.ts | 27 ++++++++--------- .../src/graphql/resolver/semaphore.test.ts | 3 +- .../graphql/resolver/util/creations.test.ts | 3 +- .../src/graphql/resolver/util/creations.ts | 3 +- .../resolver/util/transactionLinkList.ts | 3 +- backend/src/middleware/klicktippMiddleware.ts | 3 +- backend/src/password/EncryptorUtils.ts | 3 +- backend/src/seeds/factory/contributionLink.ts | 3 +- backend/src/util/communityUser.ts | 3 +- backend/src/util/decay.ts | 3 +- backend/src/util/validate.ts | 3 +- 31 files changed, 144 insertions(+), 109 deletions(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index 4cb3d3cf1..99b8baa24 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -83,7 +83,12 @@ module.exports = { 'newlines-between': 'always', pathGroups: [ { - pattern: '@*/**', + pattern: '@?*/**', + group: 'external', + position: 'after', + }, + { + pattern: '@/**', group: 'external', position: 'after', }, diff --git a/backend/src/emails/sendEmailTranslated.test.ts b/backend/src/emails/sendEmailTranslated.test.ts index b930939cf..85074344a 100644 --- a/backend/src/emails/sendEmailTranslated.test.ts +++ b/backend/src/emails/sendEmailTranslated.test.ts @@ -2,9 +2,10 @@ /* eslint-disable @typescript-eslint/unbound-method */ import { createTransport } from 'nodemailer' -import CONFIG from '@/config' import { logger, i18n } from '@test/testSetup' +import CONFIG from '@/config' + import { sendEmailTranslated } from './sendEmailTranslated' CONFIG.EMAIL = false diff --git a/backend/src/emails/sendEmailVariants.test.ts b/backend/src/emails/sendEmailVariants.test.ts index 141319ac0..44d996fa8 100644 --- a/backend/src/emails/sendEmailVariants.test.ts +++ b/backend/src/emails/sendEmailVariants.test.ts @@ -5,10 +5,11 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { Decimal } from 'decimal.js-light' -import CONFIG from '@/config' import { testEnvironment } from '@test/helpers' import { logger, i18n as localization } from '@test/testSetup' +import CONFIG from '@/config' + import { sendEmailTranslated } from './sendEmailTranslated' import { sendAddedContributionMessageEmail, diff --git a/backend/src/graphql/resolver/BalanceResolver.ts b/backend/src/graphql/resolver/BalanceResolver.ts index ff1fee9f6..deedb9dff 100644 --- a/backend/src/graphql/resolver/BalanceResolver.ts +++ b/backend/src/graphql/resolver/BalanceResolver.ts @@ -5,12 +5,13 @@ import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' import { Decimal } from 'decimal.js-light' import { Resolver, Query, Ctx, Authorized } from 'type-graphql' +import { Balance } from '@model/Balance' +import { TransactionLinkRepository } from '@repository/TransactionLink' + import { RIGHTS } from '@/auth/RIGHTS' import { Context, getUser } from '@/server/context' import { backendLogger as logger } from '@/server/logger' import { calculateDecay } from '@/util/decay' -import { Balance } from '@model/Balance' -import { TransactionLinkRepository } from '@repository/TransactionLink' import { GdtResolver } from './GdtResolver' import { getLastTransaction } from './util/getLastTransaction' diff --git a/backend/src/graphql/resolver/CommunityResolver.test.ts b/backend/src/graphql/resolver/CommunityResolver.test.ts index b78d419f9..5b4b26cad 100644 --- a/backend/src/graphql/resolver/CommunityResolver.test.ts +++ b/backend/src/graphql/resolver/CommunityResolver.test.ts @@ -7,9 +7,10 @@ import { Community as DbCommunity } from '@entity/Community' -import { getCommunities } from '@/seeds/graphql/queries' import { testEnvironment } from '@test/helpers' +import { getCommunities } from '@/seeds/graphql/queries' + let query: any // to do: We need a setup for the tests that closes the connection diff --git a/backend/src/graphql/resolver/CommunityResolver.ts b/backend/src/graphql/resolver/CommunityResolver.ts index 5ffbe77c8..86e55ad1f 100644 --- a/backend/src/graphql/resolver/CommunityResolver.ts +++ b/backend/src/graphql/resolver/CommunityResolver.ts @@ -1,9 +1,10 @@ import { Community as DbCommunity } from '@entity/Community' import { Resolver, Query, Authorized } from 'type-graphql' -import { RIGHTS } from '@/auth/RIGHTS' import { Community } from '@model/Community' +import { RIGHTS } from '@/auth/RIGHTS' + @Resolver() export class CommunityResolver { @Authorized([RIGHTS.COMMUNITIES]) diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts index 66c678be1..2247318a3 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts @@ -9,6 +9,9 @@ import { Event as DbEvent } from '@entity/Event' import { Decimal } from 'decimal.js-light' import { GraphQLError } from 'graphql' +import { cleanDB, testEnvironment, resetToken } from '@test/helpers' +import { logger } from '@test/testSetup' + import { EventType } from '@/event/Event' import { userFactory } from '@/seeds/factory/user' import { @@ -20,8 +23,6 @@ import { import { listContributionLinks } from '@/seeds/graphql/queries' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' -import { cleanDB, testEnvironment, resetToken } from '@test/helpers' -import { logger } from '@test/testSetup' let mutate: any, query: any, con: any let testEnv: any diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.ts b/backend/src/graphql/resolver/ContributionLinkResolver.ts index aca291e5d..af76856c4 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.ts @@ -3,20 +3,21 @@ import { ContributionLink as DbContributionLink } from '@entity/ContributionLink import { Decimal } from 'decimal.js-light' import { Resolver, Args, Arg, Authorized, Mutation, Query, Int, Ctx } from 'type-graphql' +// TODO: this is a strange construct +import ContributionLinkArgs from '@arg/ContributionLinkArgs' +import Paginated from '@arg/Paginated' +import { Order } from '@enum/Order' +import { ContributionLink } from '@model/ContributionLink' +import { ContributionLinkList } from '@model/ContributionLinkList' + import { RIGHTS } from '@/auth/RIGHTS' import { EVENT_ADMIN_CONTRIBUTION_LINK_CREATE, EVENT_ADMIN_CONTRIBUTION_LINK_DELETE, EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE, } from '@/event/Event' -// TODO: this is a strange construct import { Context, getUser } from '@/server/context' import LogError from '@/server/LogError' -import ContributionLinkArgs from '@arg/ContributionLinkArgs' -import Paginated from '@arg/Paginated' -import { Order } from '@enum/Order' -import { ContributionLink } from '@model/ContributionLink' -import { ContributionLinkList } from '@model/ContributionLinkList' import { CONTRIBUTIONLINK_NAME_MAX_CHARS, diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts index dd8c61cf2..189cb6e44 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts @@ -9,6 +9,9 @@ import { Event as DbEvent } from '@entity/Event' import { GraphQLError } from 'graphql' +import { cleanDB, resetToken, testEnvironment } from '@test/helpers' +import { logger, i18n as localization } from '@test/testSetup' + import { sendAddedContributionMessageEmail } from '@/emails/sendEmailVariants' import { EventType } from '@/event/Event' import { userFactory } from '@/seeds/factory/user' @@ -21,8 +24,6 @@ import { import { listContributionMessages } from '@/seeds/graphql/queries' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' -import { cleanDB, resetToken, testEnvironment } from '@test/helpers' -import { logger, i18n as localization } from '@test/testSetup' jest.mock('@/emails/sendEmailVariants', () => { const originalModule = jest.requireActual('@/emails/sendEmailVariants') diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.ts b/backend/src/graphql/resolver/ContributionMessageResolver.ts index 346f8b39c..adfb40f89 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.ts @@ -6,6 +6,13 @@ import { User as DbUser } from '@entity/User' import { UserContact as DbUserContact } from '@entity/UserContact' import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql' +import ContributionMessageArgs from '@arg/ContributionMessageArgs' +import Paginated from '@arg/Paginated' +import { ContributionStatus } from '@enum/ContributionStatus' +import { ContributionMessageType } from '@enum/MessageType' +import { Order } from '@enum/Order' +import { ContributionMessage, ContributionMessageListResult } from '@model/ContributionMessage' + import { RIGHTS } from '@/auth/RIGHTS' import { sendAddedContributionMessageEmail } from '@/emails/sendEmailVariants' import { @@ -14,12 +21,6 @@ import { } from '@/event/Event' import { Context, getUser } from '@/server/context' import LogError from '@/server/LogError' -import ContributionMessageArgs from '@arg/ContributionMessageArgs' -import Paginated from '@arg/Paginated' -import { ContributionStatus } from '@enum/ContributionStatus' -import { ContributionMessageType } from '@enum/MessageType' -import { Order } from '@enum/Order' -import { ContributionMessage, ContributionMessageListResult } from '@model/ContributionMessage' @Resolver() export class ContributionMessageResolver { diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 5291259b7..14d3fe73e 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -14,6 +14,19 @@ import { UserInputError } from 'apollo-server-express' import { Decimal } from 'decimal.js-light' import { GraphQLError } from 'graphql' +import { ContributionStatus } from '@enum/ContributionStatus' +import { Order } from '@enum/Order' +import { ContributionListResult } from '@model/Contribution' +import { UnconfirmedContribution } from '@model/UnconfirmedContribution' +import { + cleanDB, + resetToken, + testEnvironment, + contributionDateFormatter, + resetEntity, +} from '@test/helpers' +import { logger, i18n as localization } from '@test/testSetup' + import { sendContributionConfirmedEmail, sendContributionDeletedEmail, @@ -47,18 +60,6 @@ import { garrickOllivander } from '@/seeds/users/garrick-ollivander' import { peterLustig } from '@/seeds/users/peter-lustig' import { raeuberHotzenplotz } from '@/seeds/users/raeuber-hotzenplotz' import { stephenHawking } from '@/seeds/users/stephen-hawking' -import { ContributionStatus } from '@enum/ContributionStatus' -import { Order } from '@enum/Order' -import { ContributionListResult } from '@model/Contribution' -import { UnconfirmedContribution } from '@model/UnconfirmedContribution' -import { - cleanDB, - resetToken, - testEnvironment, - contributionDateFormatter, - resetEntity, -} from '@test/helpers' -import { logger, i18n as localization } from '@test/testSetup' jest.mock('@/emails/sendEmailVariants') diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 5fdbd1a12..79e21b49e 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -8,6 +8,21 @@ import { UserContact } from '@entity/UserContact' import { Decimal } from 'decimal.js-light' import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql' +import AdminCreateContributionArgs from '@arg/AdminCreateContributionArgs' +import AdminUpdateContributionArgs from '@arg/AdminUpdateContributionArgs' +import ContributionArgs from '@arg/ContributionArgs' +import Paginated from '@arg/Paginated' +import { ContributionStatus } from '@enum/ContributionStatus' +import { ContributionType } from '@enum/ContributionType' +import { ContributionMessageType } from '@enum/MessageType' +import { Order } from '@enum/Order' +import { TransactionTypeId } from '@enum/TransactionTypeId' +import { AdminUpdateContribution } from '@model/AdminUpdateContribution' +import { Contribution, ContributionListResult } from '@model/Contribution' +import { Decay } from '@model/Decay' +import { OpenCreation } from '@model/OpenCreation' +import { UnconfirmedContribution } from '@model/UnconfirmedContribution' + import { RIGHTS } from '@/auth/RIGHTS' import { sendContributionConfirmedEmail, @@ -29,20 +44,6 @@ import LogError from '@/server/LogError' import { backendLogger as logger } from '@/server/logger' import { calculateDecay } from '@/util/decay' import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' -import AdminCreateContributionArgs from '@arg/AdminCreateContributionArgs' -import AdminUpdateContributionArgs from '@arg/AdminUpdateContributionArgs' -import ContributionArgs from '@arg/ContributionArgs' -import Paginated from '@arg/Paginated' -import { ContributionStatus } from '@enum/ContributionStatus' -import { ContributionType } from '@enum/ContributionType' -import { ContributionMessageType } from '@enum/MessageType' -import { Order } from '@enum/Order' -import { TransactionTypeId } from '@enum/TransactionTypeId' -import { AdminUpdateContribution } from '@model/AdminUpdateContribution' -import { Contribution, ContributionListResult } from '@model/Contribution' -import { Decay } from '@model/Decay' -import { OpenCreation } from '@model/OpenCreation' -import { UnconfirmedContribution } from '@model/UnconfirmedContribution' import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' import { diff --git a/backend/src/graphql/resolver/EmailOptinCodes.test.ts b/backend/src/graphql/resolver/EmailOptinCodes.test.ts index 9f234e73f..cc8d4e534 100644 --- a/backend/src/graphql/resolver/EmailOptinCodes.test.ts +++ b/backend/src/graphql/resolver/EmailOptinCodes.test.ts @@ -7,10 +7,11 @@ import { User as DbUser } from '@entity/User' import { GraphQLError } from 'graphql' +import { testEnvironment, cleanDB } from '@test/helpers' + import CONFIG from '@/config' import { createUser, setPassword, forgotPassword } from '@/seeds/graphql/mutations' import { queryOptIn } from '@/seeds/graphql/queries' -import { testEnvironment, cleanDB } from '@test/helpers' let mutate: any, query: any, con: any let testEnv: any diff --git a/backend/src/graphql/resolver/GdtResolver.ts b/backend/src/graphql/resolver/GdtResolver.ts index 68a2c2275..53fc23295 100644 --- a/backend/src/graphql/resolver/GdtResolver.ts +++ b/backend/src/graphql/resolver/GdtResolver.ts @@ -3,14 +3,15 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ import { Resolver, Query, Args, Ctx, Authorized, Arg, Int, Float } from 'type-graphql' +import Paginated from '@arg/Paginated' +import { Order } from '@enum/Order' +import { GdtEntryList } from '@model/GdtEntryList' + import { apiGet, apiPost } from '@/apis/HttpRequest' import { RIGHTS } from '@/auth/RIGHTS' import CONFIG from '@/config' import { Context, getUser } from '@/server/context' import LogError from '@/server/LogError' -import Paginated from '@arg/Paginated' -import { Order } from '@enum/Order' -import { GdtEntryList } from '@model/GdtEntryList' @Resolver() export class GdtResolver { diff --git a/backend/src/graphql/resolver/StatisticsResolver.ts b/backend/src/graphql/resolver/StatisticsResolver.ts index 056163811..21cf81e97 100644 --- a/backend/src/graphql/resolver/StatisticsResolver.ts +++ b/backend/src/graphql/resolver/StatisticsResolver.ts @@ -6,9 +6,10 @@ import { User as DbUser } from '@entity/User' import { Decimal } from 'decimal.js-light' import { Resolver, Query, Authorized, FieldResolver } from 'type-graphql' +import { CommunityStatistics, DynamicStatisticsFields } from '@model/CommunityStatistics' + import { RIGHTS } from '@/auth/RIGHTS' import { calculateDecay } from '@/util/decay' -import { CommunityStatistics, DynamicStatisticsFields } from '@model/CommunityStatistics' /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ @Resolver((of) => CommunityStatistics) diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index 13bb2c431..8fd5c35de 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -14,6 +14,10 @@ import { UserContact } from '@entity/UserContact' import { Decimal } from 'decimal.js-light' import { GraphQLError } from 'graphql' +import { UnconfirmedContribution } from '@model/UnconfirmedContribution' +import { cleanDB, testEnvironment, resetToken, resetEntity } from '@test/helpers' +import { logger } from '@test/testSetup' + import { EventType } from '@/event/Event' import { creations } from '@/seeds/creation/index' import { creationFactory } from '@/seeds/factory/creation' @@ -34,9 +38,6 @@ import { transactionLinks } from '@/seeds/transactionLink/index' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' -import { UnconfirmedContribution } from '@model/UnconfirmedContribution' -import { cleanDB, testEnvironment, resetToken, resetEntity } from '@test/helpers' -import { logger } from '@test/testSetup' import { transactionLinkCode } from './TransactionLinkResolver' diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.ts b/backend/src/graphql/resolver/TransactionLinkResolver.ts index 6365096cf..a5f8c0ee6 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.ts @@ -9,6 +9,19 @@ import { User as DbUser } from '@entity/User' import { Decimal } from 'decimal.js-light' import { Resolver, Args, Arg, Authorized, Ctx, Mutation, Query, Int } from 'type-graphql' +import Paginated from '@arg/Paginated' +import TransactionLinkArgs from '@arg/TransactionLinkArgs' +import TransactionLinkFilters from '@arg/TransactionLinkFilters' +import { ContributionCycleType } from '@enum/ContributionCycleType' +import { ContributionStatus } from '@enum/ContributionStatus' +import { ContributionType } from '@enum/ContributionType' +import { TransactionTypeId } from '@enum/TransactionTypeId' +import { ContributionLink } from '@model/ContributionLink' +import { Decay } from '@model/Decay' +import { TransactionLink, TransactionLinkResult } from '@model/TransactionLink' +import { User } from '@model/User' +import QueryLinkResult from '@union/QueryLinkResult' + import { RIGHTS } from '@/auth/RIGHTS' import { EVENT_CONTRIBUTION_LINK_REDEEM, @@ -22,18 +35,6 @@ import { backendLogger as logger } from '@/server/logger' import { calculateDecay } from '@/util/decay' import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' import { calculateBalance } from '@/util/validate' -import Paginated from '@arg/Paginated' -import TransactionLinkArgs from '@arg/TransactionLinkArgs' -import TransactionLinkFilters from '@arg/TransactionLinkFilters' -import { ContributionCycleType } from '@enum/ContributionCycleType' -import { ContributionStatus } from '@enum/ContributionStatus' -import { ContributionType } from '@enum/ContributionType' -import { TransactionTypeId } from '@enum/TransactionTypeId' -import { ContributionLink } from '@model/ContributionLink' -import { Decay } from '@model/Decay' -import { TransactionLink, TransactionLinkResult } from '@model/TransactionLink' -import { User } from '@model/User' -import QueryLinkResult from '@union/QueryLinkResult' import { executeTransaction } from './TransactionResolver' import { getUserCreation, validateContribution } from './util/creations' diff --git a/backend/src/graphql/resolver/TransactionResolver.test.ts b/backend/src/graphql/resolver/TransactionResolver.test.ts index 7d855a1e6..a2e2e7e75 100644 --- a/backend/src/graphql/resolver/TransactionResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionResolver.test.ts @@ -11,6 +11,9 @@ import { User } from '@entity/User' import { Decimal } from 'decimal.js-light' import { GraphQLError } from 'graphql' +import { cleanDB, testEnvironment } from '@test/helpers' +import { logger } from '@test/testSetup' + import { EventType } from '@/event/Event' import { userFactory } from '@/seeds/factory/user' import { @@ -23,8 +26,6 @@ import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { garrickOllivander } from '@/seeds/users/garrick-ollivander' import { peterLustig } from '@/seeds/users/peter-lustig' import { stephenHawking } from '@/seeds/users/stephen-hawking' -import { cleanDB, testEnvironment } from '@test/helpers' -import { logger } from '@test/testSetup' import { findUserByEmail } from './UserResolver' diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 6e81a01c8..430cdb363 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -9,6 +9,16 @@ import { User as dbUser } from '@entity/User' import { Decimal } from 'decimal.js-light' import { Resolver, Query, Args, Authorized, Ctx, Mutation } from 'type-graphql' +import Paginated from '@arg/Paginated' +import TransactionSendArgs from '@arg/TransactionSendArgs' +import { Order } from '@enum/Order' +import { TransactionTypeId } from '@enum/TransactionTypeId' +import { Transaction } from '@model/Transaction' +import { TransactionList } from '@model/TransactionList' +import { User } from '@model/User' +import { TransactionRepository } from '@repository/Transaction' +import { TransactionLinkRepository } from '@repository/TransactionLink' + import { RIGHTS } from '@/auth/RIGHTS' import { sendTransactionLinkRedeemedEmail, @@ -22,15 +32,6 @@ import { communityUser } from '@/util/communityUser' import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' import { calculateBalance } from '@/util/validate' import { virtualLinkTransaction, virtualDecayTransaction } from '@/util/virtualTransactions' -import Paginated from '@arg/Paginated' -import TransactionSendArgs from '@arg/TransactionSendArgs' -import { Order } from '@enum/Order' -import { TransactionTypeId } from '@enum/TransactionTypeId' -import { Transaction } from '@model/Transaction' -import { TransactionList } from '@model/TransactionList' -import { User } from '@model/User' -import { TransactionRepository } from '@repository/Transaction' -import { TransactionLinkRepository } from '@repository/TransactionLink' import { BalanceResolver } from './BalanceResolver' import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index f9f0dcdb3..69a5f824f 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -13,6 +13,13 @@ import { UserContact } from '@entity/UserContact' import { GraphQLError } from 'graphql' import { validate as validateUUID, version as versionUUID } from 'uuid' +import { OptInType } from '@enum/OptInType' +import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' +import { UserContactType } from '@enum/UserContactType' +import { ContributionLink } from '@model/ContributionLink' +import { testEnvironment, headerPushMock, resetToken, cleanDB } from '@test/helpers' +import { logger, i18n as localization } from '@test/testSetup' + import CONFIG from '@/config' import { sendAccountActivationEmail, @@ -47,12 +54,6 @@ import { peterLustig } from '@/seeds/users/peter-lustig' import { stephenHawking } from '@/seeds/users/stephen-hawking' import { printTimeDuration } from '@/util/time' import { objectValuesToArray } from '@/util/utilities' -import { OptInType } from '@enum/OptInType' -import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' -import { UserContactType } from '@enum/UserContactType' -import { ContributionLink } from '@model/ContributionLink' -import { testEnvironment, headerPushMock, resetToken, cleanDB } from '@test/helpers' -import { logger, i18n as localization } from '@test/testSetup' // import { klicktippSignIn } from '@/apis/KlicktippController' diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index fb8f7568c..a01719775 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -21,6 +21,20 @@ import { } from 'type-graphql' import { v4 as uuidv4 } from 'uuid' +import CreateUserArgs from '@arg/CreateUserArgs' +import Paginated from '@arg/Paginated' +import SearchUsersArgs from '@arg/SearchUsersArgs' +import UnsecureLoginArgs from '@arg/UnsecureLoginArgs' +import UpdateUserInfosArgs from '@arg/UpdateUserInfosArgs' +import { OptInType } from '@enum/OptInType' +import { Order } from '@enum/Order' +import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' +import { UserContactType } from '@enum/UserContactType' +import { SearchAdminUsersResult } from '@model/AdminUser' +import { User } from '@model/User' +import { UserAdmin, SearchUsersResult } from '@model/UserAdmin' +import { UserRepository } from '@repository/User' + import { klicktippSignIn } from '@/apis/KlicktippController' import { encode } from '@/auth/JWT' import { RIGHTS } from '@/auth/RIGHTS' @@ -55,19 +69,6 @@ import { backendLogger as logger } from '@/server/logger' import { communityDbUser } from '@/util/communityUser' import { hasElopageBuys } from '@/util/hasElopageBuys' import { getTimeDurationObject, printTimeDuration } from '@/util/time' -import CreateUserArgs from '@arg/CreateUserArgs' -import Paginated from '@arg/Paginated' -import SearchUsersArgs from '@arg/SearchUsersArgs' -import UnsecureLoginArgs from '@arg/UnsecureLoginArgs' -import UpdateUserInfosArgs from '@arg/UpdateUserInfosArgs' -import { OptInType } from '@enum/OptInType' -import { Order } from '@enum/Order' -import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' -import { UserContactType } from '@enum/UserContactType' -import { SearchAdminUsersResult } from '@model/AdminUser' -import { User } from '@model/User' -import { UserAdmin, SearchUsersResult } from '@model/UserAdmin' -import { UserRepository } from '@repository/User' import { FULL_CREATION_AVAILABLE } from './const/const' import { getUserCreations } from './util/creations' diff --git a/backend/src/graphql/resolver/semaphore.test.ts b/backend/src/graphql/resolver/semaphore.test.ts index 4aa76ab01..6963c980e 100644 --- a/backend/src/graphql/resolver/semaphore.test.ts +++ b/backend/src/graphql/resolver/semaphore.test.ts @@ -6,6 +6,8 @@ import { Decimal } from 'decimal.js-light' +import { cleanDB, testEnvironment, contributionDateFormatter } from '@test/helpers' + import { creationFactory, nMonthsBefore } from '@/seeds/factory/creation' import { userFactory } from '@/seeds/factory/user' import { @@ -20,7 +22,6 @@ import { import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { peterLustig } from '@/seeds/users/peter-lustig' -import { cleanDB, testEnvironment, contributionDateFormatter } from '@test/helpers' let mutate: any, con: any let testEnv: any diff --git a/backend/src/graphql/resolver/util/creations.test.ts b/backend/src/graphql/resolver/util/creations.test.ts index 56e37a39b..1e3460b30 100644 --- a/backend/src/graphql/resolver/util/creations.test.ts +++ b/backend/src/graphql/resolver/util/creations.test.ts @@ -7,11 +7,12 @@ import { Contribution } from '@entity/Contribution' import { User } from '@entity/User' +import { testEnvironment, cleanDB, contributionDateFormatter } from '@test/helpers' + import { userFactory } from '@/seeds/factory/user' import { login, createContribution, adminCreateContribution } from '@/seeds/graphql/mutations' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' -import { testEnvironment, cleanDB, contributionDateFormatter } from '@test/helpers' import { getUserCreation } from './creations' diff --git a/backend/src/graphql/resolver/util/creations.ts b/backend/src/graphql/resolver/util/creations.ts index 3903eef19..dbf0650a6 100644 --- a/backend/src/graphql/resolver/util/creations.ts +++ b/backend/src/graphql/resolver/util/creations.ts @@ -4,10 +4,11 @@ import { getConnection } from '@dbTools/typeorm' import { Contribution } from '@entity/Contribution' import { Decimal } from 'decimal.js-light' +import { OpenCreation } from '@model/OpenCreation' + import { FULL_CREATION_AVAILABLE, MAX_CREATION_AMOUNT } from '@/graphql/resolver/const/const' import LogError from '@/server/LogError' import { backendLogger as logger } from '@/server/logger' -import { OpenCreation } from '@model/OpenCreation' interface CreationMap { id: number diff --git a/backend/src/graphql/resolver/util/transactionLinkList.ts b/backend/src/graphql/resolver/util/transactionLinkList.ts index b7bf9eb5e..544d35114 100644 --- a/backend/src/graphql/resolver/util/transactionLinkList.ts +++ b/backend/src/graphql/resolver/util/transactionLinkList.ts @@ -2,12 +2,13 @@ import { MoreThan } from '@dbTools/typeorm' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { User as DbUser } from '@entity/User' -import { User } from '@/graphql/model/User' import Paginated from '@arg/Paginated' import TransactionLinkFilters from '@arg/TransactionLinkFilters' import { Order } from '@enum/Order' import { TransactionLink, TransactionLinkResult } from '@model/TransactionLink' +import { User } from '@/graphql/model/User' + export default async function transactionLinkList( { currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated, filters: TransactionLinkFilters | null, diff --git a/backend/src/middleware/klicktippMiddleware.ts b/backend/src/middleware/klicktippMiddleware.ts index ac0dff0d9..481094752 100644 --- a/backend/src/middleware/klicktippMiddleware.ts +++ b/backend/src/middleware/klicktippMiddleware.ts @@ -4,10 +4,11 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ import { MiddlewareFn } from 'type-graphql' +import { KlickTipp } from '@model/KlickTipp' + import { /* klicktippSignIn, */ getKlickTippUser } from '@/apis/KlicktippController' import CONFIG from '@/config' import { klickTippLogger as logger } from '@/server/logger' -import { KlickTipp } from '@model/KlickTipp' // export const klicktippRegistrationMiddleware: MiddlewareFn = async ( // // Only for demo diff --git a/backend/src/password/EncryptorUtils.ts b/backend/src/password/EncryptorUtils.ts index 9537fb59e..eb25edda6 100644 --- a/backend/src/password/EncryptorUtils.ts +++ b/backend/src/password/EncryptorUtils.ts @@ -3,10 +3,11 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { User } from '@entity/User' +import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' + import CONFIG from '@/config' import LogError from '@/server/LogError' import { backendLogger as logger } from '@/server/logger' -import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs const sodium = require('sodium-native') diff --git a/backend/src/seeds/factory/contributionLink.ts b/backend/src/seeds/factory/contributionLink.ts index 865e844b2..51e970a5c 100644 --- a/backend/src/seeds/factory/contributionLink.ts +++ b/backend/src/seeds/factory/contributionLink.ts @@ -3,9 +3,10 @@ /* eslint-disable @typescript-eslint/unbound-method */ import { ApolloServerTestClient } from 'apollo-server-testing' +import { ContributionLink } from '@model/ContributionLink' + import { ContributionLinkInterface } from '@/seeds/contributionLink/ContributionLinkInterface' import { login, createContributionLink } from '@/seeds/graphql/mutations' -import { ContributionLink } from '@model/ContributionLink' export const contributionLinkFactory = async ( client: ApolloServerTestClient, diff --git a/backend/src/util/communityUser.ts b/backend/src/util/communityUser.ts index 0c9480118..f96c33470 100644 --- a/backend/src/util/communityUser.ts +++ b/backend/src/util/communityUser.ts @@ -4,9 +4,10 @@ import { SaveOptions, RemoveOptions } from '@dbTools/typeorm' import { User as dbUser } from '@entity/User' import { UserContact } from '@entity/UserContact' +import { User } from '@model/User' + import { PasswordEncryptionType } from '@/graphql/enum/PasswordEncryptionType' // import { UserContact as EmailContact } from '@entity/UserContact' -import { User } from '@model/User' const communityDbUser: dbUser = { id: -1, diff --git a/backend/src/util/decay.ts b/backend/src/util/decay.ts index 924e64895..77157e203 100644 --- a/backend/src/util/decay.ts +++ b/backend/src/util/decay.ts @@ -1,8 +1,9 @@ import { Decimal } from 'decimal.js-light' +import { Decay } from '@model/Decay' + import CONFIG from '@/config' import LogError from '@/server/LogError' -import { Decay } from '@model/Decay' // TODO: externalize all those definitions and functions into an external decay library diff --git a/backend/src/util/validate.ts b/backend/src/util/validate.ts index cd4841b9b..22a6ee5db 100644 --- a/backend/src/util/validate.ts +++ b/backend/src/util/validate.ts @@ -2,10 +2,11 @@ import { getCustomRepository } from '@dbTools/typeorm' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' import { Decimal } from 'decimal.js-light' -import { getLastTransaction } from '@/graphql/resolver/util/getLastTransaction' import { Decay } from '@model/Decay' import { TransactionLinkRepository } from '@repository/TransactionLink' +import { getLastTransaction } from '@/graphql/resolver/util/getLastTransaction' + import { calculateDecay } from './decay' function isStringBoolean(value: string): boolean { From 6dff07a7baf761e33bdd6e4828ba4b4d30f8099f Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 30 Mar 2023 18:25:47 +0200 Subject: [PATCH 90/91] Revert "do not allow user to edit admin contributions" This reverts commit 43e2f5fbc839921b5b0fe3deadc85c15baeb104f. --- .../src/graphql/resolver/BalanceResolver.ts | 1 + .../resolver/CommunityResolver.test.ts | 2 +- .../resolver/ContributionLinkResolver.test.ts | 2 +- .../resolver/ContributionLinkResolver.ts | 6 +- .../resolver/ContributionResolver.test.ts | 68 ++++--------------- .../graphql/resolver/ContributionResolver.ts | 9 +-- .../resolver/TransactionLinkResolver.test.ts | 6 +- .../resolver/TransactionLinkResolver.ts | 8 +-- .../resolver/TransactionResolver.test.ts | 4 +- .../graphql/resolver/TransactionResolver.ts | 8 +-- .../src/graphql/resolver/UserResolver.test.ts | 4 +- backend/src/graphql/resolver/UserResolver.ts | 15 ++-- .../src/graphql/resolver/semaphore.test.ts | 2 +- .../src/graphql/resolver/util/creations.ts | 2 +- backend/src/middleware/klicktippMiddleware.ts | 2 +- backend/src/password/EncryptorUtils.ts | 2 +- backend/src/seeds/factory/contributionLink.ts | 2 +- backend/src/util/communityUser.ts | 2 +- backend/src/util/decay.ts | 2 +- backend/src/util/validate.ts | 2 +- 20 files changed, 52 insertions(+), 97 deletions(-) diff --git a/backend/src/graphql/resolver/BalanceResolver.ts b/backend/src/graphql/resolver/BalanceResolver.ts index 31e2384d4..7600f12b9 100644 --- a/backend/src/graphql/resolver/BalanceResolver.ts +++ b/backend/src/graphql/resolver/BalanceResolver.ts @@ -9,6 +9,7 @@ import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' import { GdtResolver } from './GdtResolver' import { getLastTransaction } from './util/getLastTransaction' import { TransactionLinkRepository } from '@repository/TransactionLink' + import { Balance } from '@model/Balance' import { backendLogger as logger } from '@/server/logger' diff --git a/backend/src/graphql/resolver/CommunityResolver.test.ts b/backend/src/graphql/resolver/CommunityResolver.test.ts index 5513a73b8..f4352c095 100644 --- a/backend/src/graphql/resolver/CommunityResolver.test.ts +++ b/backend/src/graphql/resolver/CommunityResolver.test.ts @@ -6,8 +6,8 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Community as DbCommunity } from '@entity/Community' -import { testEnvironment } from '@test/helpers' import { getCommunities } from '@/seeds/graphql/queries' +import { testEnvironment } from '@test/helpers' let query: any diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts index 7dfb44e55..6a69e257e 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts @@ -9,7 +9,6 @@ import { GraphQLError } from 'graphql' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Event as DbEvent } from '@entity/Event' import { logger } from '@test/testSetup' -import { cleanDB, testEnvironment, resetToken } from '@test/helpers' import { login, createContributionLink, @@ -17,6 +16,7 @@ import { updateContributionLink, } from '@/seeds/graphql/mutations' import { listContributionLinks } from '@/seeds/graphql/queries' +import { cleanDB, testEnvironment, resetToken } from '@test/helpers' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' import { userFactory } from '@/seeds/factory/user' diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.ts b/backend/src/graphql/resolver/ContributionLinkResolver.ts index 4b19c36e1..55a23187f 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.ts @@ -3,20 +3,20 @@ import { Resolver, Args, Arg, Authorized, Mutation, Query, Int, Ctx } from 'type import { MoreThan, IsNull } from '@dbTools/typeorm' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' -import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver' -import { isStartEndDateValid } from './util/creations' import { CONTRIBUTIONLINK_NAME_MAX_CHARS, CONTRIBUTIONLINK_NAME_MIN_CHARS, MEMO_MAX_CHARS, MEMO_MIN_CHARS, } from './const/const' +import { isStartEndDateValid } from './util/creations' +import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver' import { ContributionLinkList } from '@model/ContributionLinkList' import { ContributionLink } from '@model/ContributionLink' import ContributionLinkArgs from '@arg/ContributionLinkArgs' +import { RIGHTS } from '@/auth/RIGHTS' import { Order } from '@enum/Order' import Paginated from '@arg/Paginated' -import { RIGHTS } from '@/auth/RIGHTS' // TODO: this is a strange construct import LogError from '@/server/LogError' diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 5570f953f..201d04db1 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -13,18 +13,6 @@ import { Transaction as DbTransaction } from '@entity/Transaction' import { User } from '@entity/User' import { UserInputError } from 'apollo-server-express' import { Event as DbEvent } from '@entity/Event' -import { - cleanDB, - resetToken, - testEnvironment, - contributionDateFormatter, - resetEntity, -} from '@test/helpers' -import { logger, i18n as localization } from '@test/testSetup' -import { UnconfirmedContribution } from '@model/UnconfirmedContribution' -import { ContributionListResult } from '@model/Contribution' -import { ContributionStatus } from '@enum/ContributionStatus' -import { Order } from '@enum/Order' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { stephenHawking } from '@/seeds/users/stephen-hawking' @@ -52,12 +40,24 @@ import { sendContributionDeletedEmail, sendContributionDeniedEmail, } from '@/emails/sendEmailVariants' +import { + cleanDB, + resetToken, + testEnvironment, + contributionDateFormatter, + resetEntity, +} from '@test/helpers' import { userFactory } from '@/seeds/factory/user' import { creationFactory } from '@/seeds/factory/creation' import { creations } from '@/seeds/creation/index' import { peterLustig } from '@/seeds/users/peter-lustig' import { EventType } from '@/event/Event' +import { logger, i18n as localization } from '@test/testSetup' import { raeuberHotzenplotz } from '@/seeds/users/raeuber-hotzenplotz' +import { UnconfirmedContribution } from '@model/UnconfirmedContribution' +import { ContributionListResult } from '@model/Contribution' +import { ContributionStatus } from '@enum/ContributionStatus' +import { Order } from '@enum/Order' jest.mock('@/emails/sendEmailVariants') @@ -2040,50 +2040,6 @@ describe('ContributionResolver', () => { }), ) }) - - describe('user tries to update admin contribution', () => { - beforeAll(async () => { - await mutate({ - mutation: login, - variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, - }) - }) - - afterAll(async () => { - await mutate({ - mutation: login, - variables: { email: 'peter@lustig.de', password: 'Aa12345_' }, - }) - }) - - it('logs and throws "Cannot update contribution of moderator" error', async () => { - jest.clearAllMocks() - const adminContribution = await Contribution.findOne({ - where: { - moderatorId: admin.id, - userId: bibi.id, - }, - }) - await expect( - mutate({ - mutation: updateContribution, - variables: { - contributionId: (adminContribution && adminContribution.id) || -1, - amount: 100.0, - memo: 'Test Test Test', - creationDate: new Date().toString(), - }, - }), - ).resolves.toMatchObject({ - errors: [new GraphQLError('Cannot update contribution of moderator')], - }) - expect(logger.error).toBeCalledWith( - 'Cannot update contribution of moderator', - expect.any(Object), - bibi.id, - ) - }) - }) }) describe('second creation surpasses the available amount ', () => { diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index f756b3a0d..a9446db7f 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -9,6 +9,9 @@ import { UserContact } from '@entity/UserContact' import { User as DbUser } from '@entity/User' import { Transaction as DbTransaction } from '@entity/Transaction' +import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' +import { getLastTransaction } from './util/getLastTransaction' +import { findContributions } from './util/findContributions' import { getUserCreation, validateContribution, @@ -16,9 +19,6 @@ import { isValidDateString, getOpenCreations, } from './util/creations' -import { findContributions } from './util/findContributions' -import { getLastTransaction } from './util/getLastTransaction' -import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' import { AdminUpdateContribution } from '@model/AdminUpdateContribution' import { Contribution, ContributionListResult } from '@model/Contribution' import { Decay } from '@model/Decay' @@ -201,9 +201,6 @@ export class ContributionResolver { user.id, ) } - if (contributionToUpdate.moderatorId) { - throw new LogError('Cannot update contribution of moderator', contributionToUpdate, user.id) - } if ( contributionToUpdate.contributionStatus !== ContributionStatus.IN_PROGRESS && contributionToUpdate.contributionStatus !== ContributionStatus.PENDING diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index 4f72276d4..fd2a44b4b 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -14,11 +14,9 @@ import { Transaction } from '@entity/Transaction' import { Event as DbEvent } from '@entity/Event' import { UserContact } from '@entity/UserContact' import { transactionLinkCode } from './TransactionLinkResolver' -import { cleanDB, testEnvironment, resetToken, resetEntity } from '@test/helpers' -import { UnconfirmedContribution } from '@model/UnconfirmedContribution' -import { logger } from '@test/testSetup' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' +import { cleanDB, testEnvironment, resetToken, resetEntity } from '@test/helpers' import { creationFactory } from '@/seeds/factory/creation' import { creations } from '@/seeds/creation/index' import { userFactory } from '@/seeds/factory/user' @@ -35,7 +33,9 @@ import { confirmContribution, } from '@/seeds/graphql/mutations' import { listTransactionLinksAdmin } from '@/seeds/graphql/queries' +import { UnconfirmedContribution } from '@model/UnconfirmedContribution' import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' +import { logger } from '@test/testSetup' import { EventType } from '@/event/Event' // mock semaphore to allow use fake timers diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.ts b/backend/src/graphql/resolver/TransactionLinkResolver.ts index 3ff6fd36a..6aa829ac1 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.ts @@ -10,10 +10,10 @@ import { Contribution as DbContribution } from '@entity/Contribution' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Resolver, Args, Arg, Authorized, Ctx, Mutation, Query, Int } from 'type-graphql' -import transactionLinkList from './util/transactionLinkList' -import { getLastTransaction } from './util/getLastTransaction' -import { executeTransaction } from './TransactionResolver' import { getUserCreation, validateContribution } from './util/creations' +import { executeTransaction } from './TransactionResolver' +import { getLastTransaction } from './util/getLastTransaction' +import transactionLinkList from './util/transactionLinkList' import { User } from '@model/User' import { ContributionLink } from '@model/ContributionLink' import { Decay } from '@model/Decay' @@ -25,12 +25,12 @@ import { ContributionCycleType } from '@enum/ContributionCycleType' import TransactionLinkArgs from '@arg/TransactionLinkArgs' import Paginated from '@arg/Paginated' import TransactionLinkFilters from '@arg/TransactionLinkFilters' -import QueryLinkResult from '@union/QueryLinkResult' import { backendLogger as logger } from '@/server/logger' import { Context, getUser, getClientTimezoneOffset } from '@/server/context' import { calculateBalance } from '@/util/validate' import { RIGHTS } from '@/auth/RIGHTS' import { calculateDecay } from '@/util/decay' +import QueryLinkResult from '@union/QueryLinkResult' import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK' import LogError from '@/server/LogError' import { diff --git a/backend/src/graphql/resolver/TransactionResolver.test.ts b/backend/src/graphql/resolver/TransactionResolver.test.ts index 6d039784e..f26234363 100644 --- a/backend/src/graphql/resolver/TransactionResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionResolver.test.ts @@ -11,8 +11,6 @@ import { User } from '@entity/User' import { GraphQLError } from 'graphql' import { Event as DbEvent } from '@entity/Event' import { findUserByEmail } from './UserResolver' -import { cleanDB, testEnvironment } from '@test/helpers' -import { logger } from '@test/testSetup' import { EventType } from '@/event/Event' import { userFactory } from '@/seeds/factory/user' import { @@ -25,6 +23,8 @@ import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { garrickOllivander } from '@/seeds/users/garrick-ollivander' import { peterLustig } from '@/seeds/users/peter-lustig' import { stephenHawking } from '@/seeds/users/stephen-hawking' +import { cleanDB, testEnvironment } from '@test/helpers' +import { logger } from '@test/testSetup' let mutate: any, query: any, con: any let testEnv: any diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index a699e7291..f38a4a07b 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -9,10 +9,10 @@ import { getCustomRepository, getConnection, In } from '@dbTools/typeorm' import { User as dbUser } from '@entity/User' import { Transaction as dbTransaction } from '@entity/Transaction' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' -import { getLastTransaction } from './util/getLastTransaction' -import { findUserByEmail } from './UserResolver' -import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' import { BalanceResolver } from './BalanceResolver' +import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' +import { findUserByEmail } from './UserResolver' +import { getLastTransaction } from './util/getLastTransaction' import { TransactionRepository } from '@repository/Transaction' import { TransactionLinkRepository } from '@repository/TransactionLink' @@ -21,9 +21,9 @@ import { Transaction } from '@model/Transaction' import { TransactionList } from '@model/TransactionList' import { Order } from '@enum/Order' import { TransactionTypeId } from '@enum/TransactionTypeId' +import { calculateBalance } from '@/util/validate' import TransactionSendArgs from '@arg/TransactionSendArgs' import Paginated from '@arg/Paginated' -import { calculateBalance } from '@/util/validate' import { backendLogger as logger } from '@/server/logger' import { Context, getUser } from '@/server/context' diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index 1b6239fea..aebd0f0eb 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -15,10 +15,9 @@ import { Event as DbEvent } from '@entity/Event' import { OptInType } from '@enum/OptInType' import { UserContactType } from '@enum/UserContactType' import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' +import { objectValuesToArray } from '@/util/utilities' import { testEnvironment, headerPushMock, resetToken, cleanDB } from '@test/helpers' import { logger, i18n as localization } from '@test/testSetup' -import { ContributionLink } from '@model/ContributionLink' -import { objectValuesToArray } from '@/util/utilities' import { printTimeDuration } from '@/util/time' import { userFactory } from '@/seeds/factory/user' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' @@ -45,6 +44,7 @@ import { } from '@/emails/sendEmailVariants' import { contributionLinkFactory } from '@/seeds/factory/contributionLink' import { transactionLinkFactory } from '@/seeds/factory/transactionLink' +import { ContributionLink } from '@model/ContributionLink' import { EventType } from '@/event/Event' import { peterLustig } from '@/seeds/users/peter-lustig' import { bobBaumeister } from '@/seeds/users/bob-baumeister' diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 0c1cefd12..54d4f583f 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -21,8 +21,8 @@ import { User as DbUser } from '@entity/User' import { UserContact as DbUserContact } from '@entity/UserContact' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' -import { FULL_CREATION_AVAILABLE } from './const/const' import { getUserCreations } from './util/creations' +import { FULL_CREATION_AVAILABLE } from './const/const' import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' import { UserRepository } from '@repository/User' @@ -33,18 +33,19 @@ import { OptInType } from '@enum/OptInType' import { Order } from '@enum/Order' import { UserContactType } from '@enum/UserContactType' -import CreateUserArgs from '@arg/CreateUserArgs' -import UnsecureLoginArgs from '@arg/UnsecureLoginArgs' -import UpdateUserInfosArgs from '@arg/UpdateUserInfosArgs' -import Paginated from '@arg/Paginated' -import SearchUsersArgs from '@arg/SearchUsersArgs' -import { getTimeDurationObject, printTimeDuration } from '@/util/time' import { sendAccountActivationEmail, sendAccountMultiRegistrationEmail, sendResetPasswordEmail, } from '@/emails/sendEmailVariants' +import { getTimeDurationObject, printTimeDuration } from '@/util/time' +import CreateUserArgs from '@arg/CreateUserArgs' +import UnsecureLoginArgs from '@arg/UnsecureLoginArgs' +import UpdateUserInfosArgs from '@arg/UpdateUserInfosArgs' +import Paginated from '@arg/Paginated' +import SearchUsersArgs from '@arg/SearchUsersArgs' + import { backendLogger as logger } from '@/server/logger' import { Context, getUser, getClientTimezoneOffset } from '@/server/context' import CONFIG from '@/config' diff --git a/backend/src/graphql/resolver/semaphore.test.ts b/backend/src/graphql/resolver/semaphore.test.ts index cc4d589dc..6b1976021 100644 --- a/backend/src/graphql/resolver/semaphore.test.ts +++ b/backend/src/graphql/resolver/semaphore.test.ts @@ -5,12 +5,12 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { Decimal } from 'decimal.js-light' -import { cleanDB, testEnvironment, contributionDateFormatter } from '@test/helpers' import { userFactory } from '@/seeds/factory/user' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { peterLustig } from '@/seeds/users/peter-lustig' import { creationFactory, nMonthsBefore } from '@/seeds/factory/creation' +import { cleanDB, testEnvironment, contributionDateFormatter } from '@test/helpers' import { confirmContribution, createContribution, diff --git a/backend/src/graphql/resolver/util/creations.ts b/backend/src/graphql/resolver/util/creations.ts index dba0c8c81..6ebeae8b9 100644 --- a/backend/src/graphql/resolver/util/creations.ts +++ b/backend/src/graphql/resolver/util/creations.ts @@ -3,9 +3,9 @@ import { getConnection } from '@dbTools/typeorm' import { Contribution } from '@entity/Contribution' import { Decimal } from 'decimal.js-light' -import { OpenCreation } from '@model/OpenCreation' import { FULL_CREATION_AVAILABLE, MAX_CREATION_AMOUNT } from '@/graphql/resolver/const/const' import { backendLogger as logger } from '@/server/logger' +import { OpenCreation } from '@model/OpenCreation' import LogError from '@/server/LogError' interface CreationMap { diff --git a/backend/src/middleware/klicktippMiddleware.ts b/backend/src/middleware/klicktippMiddleware.ts index 568120fe8..0469b4ccc 100644 --- a/backend/src/middleware/klicktippMiddleware.ts +++ b/backend/src/middleware/klicktippMiddleware.ts @@ -3,8 +3,8 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/restrict-template-expressions */ import { MiddlewareFn } from 'type-graphql' -import { KlickTipp } from '@model/KlickTipp' import { /* klicktippSignIn, */ getKlickTippUser } from '@/apis/KlicktippController' +import { KlickTipp } from '@model/KlickTipp' import CONFIG from '@/config' import { klickTippLogger as logger } from '@/server/logger' diff --git a/backend/src/password/EncryptorUtils.ts b/backend/src/password/EncryptorUtils.ts index ab8a333d2..b4531b3bb 100644 --- a/backend/src/password/EncryptorUtils.ts +++ b/backend/src/password/EncryptorUtils.ts @@ -2,10 +2,10 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { User } from '@entity/User' -import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' import CONFIG from '@/config' import LogError from '@/server/LogError' import { backendLogger as logger } from '@/server/logger' +import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs const sodium = require('sodium-native') diff --git a/backend/src/seeds/factory/contributionLink.ts b/backend/src/seeds/factory/contributionLink.ts index 6e1d9bd50..5925cdcfe 100644 --- a/backend/src/seeds/factory/contributionLink.ts +++ b/backend/src/seeds/factory/contributionLink.ts @@ -2,8 +2,8 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/unbound-method */ import { ApolloServerTestClient } from 'apollo-server-testing' -import { ContributionLink } from '@model/ContributionLink' import { login, createContributionLink } from '@/seeds/graphql/mutations' +import { ContributionLink } from '@model/ContributionLink' import { ContributionLinkInterface } from '@/seeds/contributionLink/ContributionLinkInterface' export const contributionLinkFactory = async ( diff --git a/backend/src/util/communityUser.ts b/backend/src/util/communityUser.ts index d086727bf..dfa477da9 100644 --- a/backend/src/util/communityUser.ts +++ b/backend/src/util/communityUser.ts @@ -3,9 +3,9 @@ import { SaveOptions, RemoveOptions } from '@dbTools/typeorm' import { User as dbUser } from '@entity/User' import { UserContact } from '@entity/UserContact' -import { User } from '@model/User' import { PasswordEncryptionType } from '@/graphql/enum/PasswordEncryptionType' // import { UserContact as EmailContact } from '@entity/UserContact' +import { User } from '@model/User' const communityDbUser: dbUser = { id: -1, diff --git a/backend/src/util/decay.ts b/backend/src/util/decay.ts index 3c76b0995..d35eb83a4 100644 --- a/backend/src/util/decay.ts +++ b/backend/src/util/decay.ts @@ -1,6 +1,6 @@ import { Decimal } from 'decimal.js-light' -import { Decay } from '@model/Decay' import CONFIG from '@/config' +import { Decay } from '@model/Decay' import LogError from '@/server/LogError' // TODO: externalize all those definitions and functions into an external decay library diff --git a/backend/src/util/validate.ts b/backend/src/util/validate.ts index aaadbdd31..ec28dfa13 100644 --- a/backend/src/util/validate.ts +++ b/backend/src/util/validate.ts @@ -2,9 +2,9 @@ import { Decimal } from 'decimal.js-light' import { getCustomRepository } from '@dbTools/typeorm' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' import { calculateDecay } from './decay' +import { getLastTransaction } from '@/graphql/resolver/util/getLastTransaction' import { TransactionLinkRepository } from '@repository/TransactionLink' import { Decay } from '@model/Decay' -import { getLastTransaction } from '@/graphql/resolver/util/getLastTransaction' function isStringBoolean(value: string): boolean { const lowerValue = value.toLowerCase() From 695d037a2dfaffe815b1555075a7fe45fa9d4c82 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 30 Mar 2023 18:33:36 +0200 Subject: [PATCH 91/91] do not allow edit contribution for admin contributions in backend --- .../resolver/ContributionResolver.test.ts | 44 +++++++++++++++++++ .../graphql/resolver/ContributionResolver.ts | 3 ++ 2 files changed, 47 insertions(+) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 6d3f29280..490f5a4a7 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -2042,6 +2042,50 @@ describe('ContributionResolver', () => { }), ) }) + + describe('user tries to update admin contribution', () => { + beforeAll(async () => { + await mutate({ + mutation: login, + variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, + }) + }) + + afterAll(async () => { + await mutate({ + mutation: login, + variables: { email: 'peter@lustig.de', password: 'Aa12345_' }, + }) + }) + + it('logs and throws "Cannot update contribution of moderator" error', async () => { + jest.clearAllMocks() + const adminContribution = await Contribution.findOne({ + where: { + moderatorId: admin.id, + userId: bibi.id, + }, + }) + await expect( + mutate({ + mutation: updateContribution, + variables: { + contributionId: (adminContribution && adminContribution.id) || -1, + amount: 100.0, + memo: 'Test Test Test', + creationDate: new Date().toString(), + }, + }), + ).resolves.toMatchObject({ + errors: [new GraphQLError('Cannot update contribution of moderator')], + }) + expect(logger.error).toBeCalledWith( + 'Cannot update contribution of moderator', + expect.any(Object), + bibi.id, + ) + }) + }) }) describe('second creation surpasses the available amount ', () => { diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 1d3274b79..5969eaef2 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -201,6 +201,9 @@ export class ContributionResolver { user.id, ) } + if (contributionToUpdate.moderatorId) { + throw new LogError('Cannot update contribution of moderator', contributionToUpdate, user.id) + } if ( contributionToUpdate.contributionStatus !== ContributionStatus.IN_PROGRESS && contributionToUpdate.contributionStatus !== ContributionStatus.PENDING