From 84c0c6f10b7cc07083f6b4ea439035257a28f68f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 26 May 2022 02:56:38 +0200 Subject: [PATCH 01/45] start creating contributionLinks table --- .../ContributionLinks.ts | 108 ++++++++++++++++++ database/entity/ContributionLinks.ts | 1 + 2 files changed, 109 insertions(+) create mode 100644 database/entity/0038-add_contribution_links_table/ContributionLinks.ts create mode 100644 database/entity/ContributionLinks.ts diff --git a/database/entity/0038-add_contribution_links_table/ContributionLinks.ts b/database/entity/0038-add_contribution_links_table/ContributionLinks.ts new file mode 100644 index 000000000..5f78a7450 --- /dev/null +++ b/database/entity/0038-add_contribution_links_table/ContributionLinks.ts @@ -0,0 +1,108 @@ +import Decimal from 'decimal.js-light' +import { BaseEntity, Entity, PrimaryGeneratedColumn, Column } from 'typeorm' +import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' + +export enum CycleTypes { + ONCE = 1, + HOUR = 2, + TWOHOURS = 3, + FOURHOURS = 4, + EIGHTHOURS = 5, + HALFDAY = 6, + DAY = 7, + TWODAYS = 8, + THREEDAYS = 9, + FOURDAYS = 10, + FIVEDAYS = 11, + SIXDAYS = 12, + WEEK = 13, + TWOWEEKS = 14, + MONTH = 15, + TWOMONTH = 16, + QUARTER = 17, + HALFYEAR = 18, + YEAR = 19, +} + +@Entity('contribution_links') +export class ContributionLinks extends BaseEntity { + @PrimaryGeneratedColumn('increment', { unsigned: true }) + id: number + + @Column({ length: 100, nullable: false, collation: 'utf8mb4_unicode_ci' }) + name: string + + @Column({ length: 255, nullable: false, collation: 'utf8mb4_unicode_ci' }) + description: string + + @Column({ name: 'valid_from', type: 'datetime', nullable: true, default: null }) + validFrom: Date | null + + @Column({ name: 'valid_to', type: 'datetime', nullable: true, default: null }) + validTo: Date | null + + @Column({ + type: 'decimal', + precision: 40, + scale: 20, + nullable: false, + transformer: DecimalTransformer, + }) + amount: Decimal + + @Column({ name: 'cycle', unsigned: true, nullable: false }) + cycle: number + + @Column({ name: 'max_per_cycle', unsigned: true, nullable: false, default: 1 }) + maxPerCycle: number + + @Column({ + name: 'max_amount_per_month', + type: 'decimal', + precision: 40, + scale: 20, + nullable: true, + default: null, + transformer: DecimalTransformer, + }) + maxAmountPerMonth: Decimal + + @Column({ + name: 'total_max_count_of_contribution', + unsigned: true, + nullable: true, + default: null, + }) + totalMaxCountOfContribution: number | null + + @Column({ + name: 'max_account_balance', + type: 'decimal', + precision: 40, + scale: 20, + nullable: true, + default: null, + transformer: DecimalTransformer, + }) + maxAccountBalance: Decimal + + @Column({ + name: 'min_gap_hours', + unsigned: true, + nullable: true, + default: null, + }) + minGapHours: number | null + + @Column({ name: 'created_at', type: 'datetime', nullable: true, default: null }) + createdAt: Date | null + + @Column({ name: 'deleted_at', type: 'datetime', nullable: true, default: null }) + deletedAt: Date | null + + @Column({ length: 24, nullable: false, collation: 'utf8mb4_unicode_ci' }) + code: string + + @Column({ name: 'link_enabled', type: 'boolean', nullable: true, default: null }) + linkEnabled: boolean | null +} diff --git a/database/entity/ContributionLinks.ts b/database/entity/ContributionLinks.ts new file mode 100644 index 000000000..721dfd2b3 --- /dev/null +++ b/database/entity/ContributionLinks.ts @@ -0,0 +1 @@ +export { ContributionLinks } from './0038-add_contribution_links_table/ContributionLinks' From 2444c94af9f6d3869e65721317ffd58a29a408a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Wed, 1 Jun 2022 01:19:44 +0200 Subject: [PATCH 02/45] create migration and entity for new contribution_links table --- .../ContributionLinks.ts | 2 +- database/entity/ContributionLinks.ts | 2 +- .../0037-add_contribution_links_table.ts | 35 +++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) rename database/entity/{0038-add_contribution_links_table => 0037-add_contribution_links_table}/ContributionLinks.ts (97%) create mode 100644 database/migrations/0037-add_contribution_links_table.ts diff --git a/database/entity/0038-add_contribution_links_table/ContributionLinks.ts b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts similarity index 97% rename from database/entity/0038-add_contribution_links_table/ContributionLinks.ts rename to database/entity/0037-add_contribution_links_table/ContributionLinks.ts index 5f78a7450..2fb4e2801 100644 --- a/database/entity/0038-add_contribution_links_table/ContributionLinks.ts +++ b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts @@ -100,7 +100,7 @@ export class ContributionLinks extends BaseEntity { @Column({ name: 'deleted_at', type: 'datetime', nullable: true, default: null }) deletedAt: Date | null - @Column({ length: 24, nullable: false, collation: 'utf8mb4_unicode_ci' }) + @Column({ length: 24, nullable: true, collation: 'utf8mb4_unicode_ci' }) code: string @Column({ name: 'link_enabled', type: 'boolean', nullable: true, default: null }) diff --git a/database/entity/ContributionLinks.ts b/database/entity/ContributionLinks.ts index 721dfd2b3..de26c1c4a 100644 --- a/database/entity/ContributionLinks.ts +++ b/database/entity/ContributionLinks.ts @@ -1 +1 @@ -export { ContributionLinks } from './0038-add_contribution_links_table/ContributionLinks' +export { ContributionLinks } from './0037-add_contribution_links_table/ContributionLinks' diff --git a/database/migrations/0037-add_contribution_links_table.ts b/database/migrations/0037-add_contribution_links_table.ts new file mode 100644 index 000000000..79bcdf5ce --- /dev/null +++ b/database/migrations/0037-add_contribution_links_table.ts @@ -0,0 +1,35 @@ +/* MIGRATION TO ADD CONTRIBUTION_LINKS + * + * This migration adds the table `contribution_links` in order to store all sorts of contribution_links data + */ + +/* 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(` + CREATE TABLE IF NOT EXISTS \`contribution_links\` ( + \`id\` int(10) unsigned NOT NULL AUTO_INCREMENT, + \`name\` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, + \`decsription\` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + \`valid_from\` datetime NULL, + \`valid_to\` datetime NULL, + \`amount\` bigint(20) NOT NULL, + \`cycle\` int(10) unsigned NOT NULL DEFAULT '1', + \`max_per_cycle\` int(10) unsigned NOT NULL DEFAULT '1', + \`max_amount_per_month\` bigint(20) NULL DEFAULT NULL, + \`total_max_count_of_contribution\` int(10) unsigned NULL DEFAULT NULL, + \`max_account_balance\` bigint(20) NULL DEFAULT NULL, + \`min_gap_hours\` int(10) unsigned NULL DEFAULT NULL, + \`created_at\` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + \`deleted_at\` datetime NULL DEFAULT NULL, + \`code\` varchar(24) COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, + \`link_enabled\` tinyint(4) NOT NULL DEFAULT '0', + PRIMARY KEY (\`id\`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`) +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + // write downgrade logic as parameter of queryFn + await queryFn(`DROP TABLE IF EXISTS \`contribution_links\`;`) +} From 772bf82000630bb9d9ac22fa3436e9197c0ecad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 1 Jun 2022 11:09:21 +0200 Subject: [PATCH 03/45] Fix linting in database README.md --- database/README.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/database/README.md b/database/README.md index d6cf84518..e951f4530 100644 --- a/database/README.md +++ b/database/README.md @@ -1,32 +1,39 @@ # database ## Project setup -``` + +```bash yarn install ``` ## Upgrade migrations production -``` + +```bash yarn up ``` ## Upgrade migrations development -``` + +```bash yarn dev_up ``` ## Downgrade migrations production -``` + +```bash yarn down ``` ## Downgrade migrations development -``` + +```bash yarn dev_down ``` ## Reset database -``` + +```bash yarn dev_reset ``` + Runs all down migrations and after this all up migrations. From dbc98e8490daf9fc11c38cb8e931912e0fe028b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 1 Jun 2022 12:03:42 +0200 Subject: [PATCH 04/45] Remove 'user_setting' table from db - Add migration 0037-drop_server_user_table.ts --- .../migrations/0037-drop_server_user_table.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 database/migrations/0037-drop_server_user_table.ts diff --git a/database/migrations/0037-drop_server_user_table.ts b/database/migrations/0037-drop_server_user_table.ts new file mode 100644 index 000000000..50a78e104 --- /dev/null +++ b/database/migrations/0037-drop_server_user_table.ts @@ -0,0 +1,19 @@ +/* MIGRATION DROP user_setting TABLE */ + +/* 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('DROP TABLE `user_setting`;') +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn(` + CREATE TABLE IF NOT EXISTS \`user_setting\` ( + \`id\` int(10) unsigned NOT NULL AUTO_INCREMENT, + \`userId\` int(11) NOT NULL, + \`key\` varchar(255) NOT NULL, + \`value\` varchar(255) NOT NULL, + PRIMARY KEY (\`id\`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`) +} From 71595428b3567f6e71fbfccfa343113efb8d2400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 1 Jun 2022 12:39:57 +0200 Subject: [PATCH 05/45] Set DB_VERSION to '0037-drop_server_user_table.ts' --- backend/src/config/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 28318ed6b..2015eb6cc 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0036-unique_previous_in_transactions', + DB_VERSION: '0037-drop_server_user_table.ts', 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 1e0e6e24b97c7929b52d40496b13d2458aa79a3e Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 2 Jun 2022 21:46:18 +0200 Subject: [PATCH 06/45] locales link german, english navbar --- frontend/src/components/Auth/AuthNavbar.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Auth/AuthNavbar.vue b/frontend/src/components/Auth/AuthNavbar.vue index 7b3eed0e3..8063dd330 100644 --- a/frontend/src/components/Auth/AuthNavbar.vue +++ b/frontend/src/components/Auth/AuthNavbar.vue @@ -20,7 +20,7 @@ - + {{ $t('auth.navbar.aboutGradido') }} {{ $t('signup') }} From 74bcdaf8c4f11e3f2746c8d2f33e0b1bbd1d0a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Fri, 3 Jun 2022 00:06:14 +0200 Subject: [PATCH 07/45] add .project and correct .gitignore --- .gitignore | 2 -- .project | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .project diff --git a/.gitignore b/.gitignore index 08ccd2b30..6ac3a32c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -.dbeaver -.project *.log /node_modules/* messages.pot diff --git a/.project b/.project new file mode 100644 index 000000000..5d9663f32 --- /dev/null +++ b/.project @@ -0,0 +1,18 @@ + + + Gradido + + + + + + org.eclipse.wst.validation.validationbuilder + + + + + + org.jkiss.dbeaver.DBeaverNature + org.eclipse.wst.jsdt.core.jsNature + + From d958cfdfde0d045e1d8e92b1753c8e70455bcfd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 7 Jun 2022 10:33:46 +0200 Subject: [PATCH 08/45] Fix DB_VERSION --- backend/src/config/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 2015eb6cc..1adc68981 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0037-drop_server_user_table.ts', + DB_VERSION: '0037-drop_server_user_table', 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 6abb399ab9398e441b196d97de499701ee41e674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 7 Jun 2022 11:33:47 +0200 Subject: [PATCH 09/45] Removed UserSetting from backend --- .../repository/UserSettingRepository.ts | 25 ------- backend/src/util/communityUser.ts | 1 - database/entity/0002-add_settings/User.ts | 2 +- .../entity/0002-add_settings/UserSetting.ts | 2 +- .../entity/0017-combine_user_tables/User.ts | 2 +- .../User.ts | 2 +- .../User.ts | 2 +- .../0020-rename_and_clean_state_users/User.ts | 2 +- .../0023-users_disabled_soft_delete/User.ts | 2 +- database/entity/0033-add_referrer_id/User.ts | 2 +- .../0034-drop_server_user_table/User.ts | 2 +- .../0037-drop_server_user_table/User.ts | 70 +++++++++++++++++++ database/entity/User.ts | 2 +- database/entity/UserSetting.ts | 1 - database/entity/index.ts | 2 - 15 files changed, 80 insertions(+), 39 deletions(-) delete mode 100644 backend/src/typeorm/repository/UserSettingRepository.ts create mode 100644 database/entity/0037-drop_server_user_table/User.ts delete mode 100644 database/entity/UserSetting.ts diff --git a/backend/src/typeorm/repository/UserSettingRepository.ts b/backend/src/typeorm/repository/UserSettingRepository.ts deleted file mode 100644 index f911cfd1a..000000000 --- a/backend/src/typeorm/repository/UserSettingRepository.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { EntityRepository, Repository } from '@dbTools/typeorm' -import { UserSetting } from '@entity/UserSetting' -import { isStringBoolean } from '@/util/validate' - -@EntityRepository(UserSetting) -export class UserSettingRepository extends Repository { - async setOrUpdate(userId: number, value: string): Promise { - let entity = await this.findOne({ userId: userId }) - - if (!entity) { - entity = new UserSetting() - entity.userId = userId - } - entity.value = value - return this.save(entity) - } - - async readBoolean(userId: number): Promise { - const entity = await this.findOne({ userId: userId }) - if (!entity || !isStringBoolean(entity.value)) { - return true - } - return entity.value.toLowerCase() === 'true' - } -} diff --git a/backend/src/util/communityUser.ts b/backend/src/util/communityUser.ts index 0d0d12f6c..1a84c2cdf 100644 --- a/backend/src/util/communityUser.ts +++ b/backend/src/util/communityUser.ts @@ -20,7 +20,6 @@ const communityDbUser: dbUser = { isAdmin: null, publisherId: 0, passphrase: '', - settings: [], hasId: function (): boolean { throw new Error('Function not implemented.') }, diff --git a/database/entity/0002-add_settings/User.ts b/database/entity/0002-add_settings/User.ts index a756cbbd5..4f333fd50 100644 --- a/database/entity/0002-add_settings/User.ts +++ b/database/entity/0002-add_settings/User.ts @@ -1,5 +1,5 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm' -import { UserSetting } from '../UserSetting' +import { UserSetting } from '../0002-add_settings/UserSetting' // Moriz: I do not like the idea of having two user tables @Entity('state_users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) diff --git a/database/entity/0002-add_settings/UserSetting.ts b/database/entity/0002-add_settings/UserSetting.ts index 006d63e3e..6103f67b5 100644 --- a/database/entity/0002-add_settings/UserSetting.ts +++ b/database/entity/0002-add_settings/UserSetting.ts @@ -1,5 +1,5 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm' -import { User } from '../User' +import { User } from '../0034-drop_server_user_table/User' // Wolle: last fitting one or old was correct? @Entity() export class UserSetting extends BaseEntity { diff --git a/database/entity/0017-combine_user_tables/User.ts b/database/entity/0017-combine_user_tables/User.ts index a9bf29d24..7281c4773 100644 --- a/database/entity/0017-combine_user_tables/User.ts +++ b/database/entity/0017-combine_user_tables/User.ts @@ -1,5 +1,5 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm' -import { UserSetting } from '../UserSetting' +import { UserSetting } from '../0002-add_settings/UserSetting' @Entity('state_users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) export class User extends BaseEntity { diff --git a/database/entity/0018-combine_login_user_backups_and_user_table/User.ts b/database/entity/0018-combine_login_user_backups_and_user_table/User.ts index 2ae351e47..347f51a8d 100644 --- a/database/entity/0018-combine_login_user_backups_and_user_table/User.ts +++ b/database/entity/0018-combine_login_user_backups_and_user_table/User.ts @@ -1,5 +1,5 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm' -import { UserSetting } from '../UserSetting' +import { UserSetting } from '../0002-add_settings/UserSetting' @Entity('state_users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) export class User extends BaseEntity { diff --git a/database/entity/0019-replace_login_user_id_with_state_user_id/User.ts b/database/entity/0019-replace_login_user_id_with_state_user_id/User.ts index b469a55a7..8c00ec5c3 100644 --- a/database/entity/0019-replace_login_user_id_with_state_user_id/User.ts +++ b/database/entity/0019-replace_login_user_id_with_state_user_id/User.ts @@ -1,5 +1,5 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm' -import { UserSetting } from '../UserSetting' +import { UserSetting } from '../0002-add_settings/UserSetting' @Entity('state_users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) export class User extends BaseEntity { diff --git a/database/entity/0020-rename_and_clean_state_users/User.ts b/database/entity/0020-rename_and_clean_state_users/User.ts index 3d3b4d7b1..5501bccba 100644 --- a/database/entity/0020-rename_and_clean_state_users/User.ts +++ b/database/entity/0020-rename_and_clean_state_users/User.ts @@ -1,5 +1,5 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm' -import { UserSetting } from '../UserSetting' +import { UserSetting } from '../0002-add_settings/UserSetting' @Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) export class User extends BaseEntity { diff --git a/database/entity/0023-users_disabled_soft_delete/User.ts b/database/entity/0023-users_disabled_soft_delete/User.ts index 95fe1b3f7..950e74aeb 100644 --- a/database/entity/0023-users_disabled_soft_delete/User.ts +++ b/database/entity/0023-users_disabled_soft_delete/User.ts @@ -6,7 +6,7 @@ import { OneToMany, DeleteDateColumn, } from 'typeorm' -import { UserSetting } from '../UserSetting' +import { UserSetting } from '../0002-add_settings/UserSetting' @Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) export class User extends BaseEntity { diff --git a/database/entity/0033-add_referrer_id/User.ts b/database/entity/0033-add_referrer_id/User.ts index 48c804b63..353c6a830 100644 --- a/database/entity/0033-add_referrer_id/User.ts +++ b/database/entity/0033-add_referrer_id/User.ts @@ -6,7 +6,7 @@ import { OneToMany, DeleteDateColumn, } from 'typeorm' -import { UserSetting } from '../UserSetting' +import { UserSetting } from '../0002-add_settings/UserSetting' @Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) export class User extends BaseEntity { diff --git a/database/entity/0034-drop_server_user_table/User.ts b/database/entity/0034-drop_server_user_table/User.ts index 1f56d13d2..82fd72009 100644 --- a/database/entity/0034-drop_server_user_table/User.ts +++ b/database/entity/0034-drop_server_user_table/User.ts @@ -6,7 +6,7 @@ import { OneToMany, DeleteDateColumn, } from 'typeorm' -import { UserSetting } from '../UserSetting' +import { UserSetting } from '../0002-add_settings/UserSetting' @Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) export class User extends BaseEntity { diff --git a/database/entity/0037-drop_server_user_table/User.ts b/database/entity/0037-drop_server_user_table/User.ts new file mode 100644 index 000000000..528cef32b --- /dev/null +++ b/database/entity/0037-drop_server_user_table/User.ts @@ -0,0 +1,70 @@ +import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, DeleteDateColumn } from 'typeorm' + +@Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) +export class User extends BaseEntity { + @PrimaryGeneratedColumn('increment', { unsigned: true }) + id: number + + @Column({ name: 'public_key', type: 'binary', length: 32, default: null, nullable: true }) + pubKey: Buffer + + @Column({ name: 'privkey', type: 'binary', length: 80, default: null, nullable: true }) + privKey: Buffer + + @Column({ length: 255, unique: true, nullable: false, collation: 'utf8mb4_unicode_ci' }) + email: string + + @Column({ + name: 'first_name', + length: 255, + nullable: true, + default: null, + collation: 'utf8mb4_unicode_ci', + }) + firstName: string + + @Column({ + name: 'last_name', + length: 255, + nullable: true, + default: null, + collation: 'utf8mb4_unicode_ci', + }) + lastName: string + + @DeleteDateColumn() + deletedAt: Date | null + + @Column({ type: 'bigint', default: 0, unsigned: true }) + password: BigInt + + @Column({ name: 'email_hash', type: 'binary', length: 32, default: null, nullable: true }) + emailHash: Buffer + + @Column({ name: 'created', default: () => 'CURRENT_TIMESTAMP', nullable: false }) + createdAt: Date + + @Column({ name: 'email_checked', type: 'bool', nullable: false, default: false }) + emailChecked: boolean + + @Column({ length: 4, default: 'de', collation: 'utf8mb4_unicode_ci', nullable: false }) + language: string + + @Column({ name: 'is_admin', type: 'datetime', nullable: true, default: null }) + isAdmin: Date | null + + @Column({ name: 'referrer_id', type: 'int', unsigned: true, nullable: true, default: null }) + referrerId?: number | null + + @Column({ name: 'publisher_id', default: 0 }) + publisherId: number + + @Column({ + type: 'text', + name: 'passphrase', + collation: 'utf8mb4_unicode_ci', + nullable: true, + default: null, + }) + passphrase: string +} diff --git a/database/entity/User.ts b/database/entity/User.ts index 4cd68174c..6983f293b 100644 --- a/database/entity/User.ts +++ b/database/entity/User.ts @@ -1 +1 @@ -export { User } from './0034-drop_server_user_table/User' +export { User } from './0037-drop_server_user_table/User' diff --git a/database/entity/UserSetting.ts b/database/entity/UserSetting.ts deleted file mode 100644 index 38da380f9..000000000 --- a/database/entity/UserSetting.ts +++ /dev/null @@ -1 +0,0 @@ -export { UserSetting } from './0002-add_settings/UserSetting' diff --git a/database/entity/index.ts b/database/entity/index.ts index 542333755..46d9ef31a 100644 --- a/database/entity/index.ts +++ b/database/entity/index.ts @@ -4,7 +4,6 @@ import { Migration } from './Migration' import { Transaction } from './Transaction' import { TransactionLink } from './TransactionLink' import { User } from './User' -import { UserSetting } from './UserSetting' import { AdminPendingCreation } from './AdminPendingCreation' export const entities = [ @@ -15,5 +14,4 @@ export const entities = [ Transaction, TransactionLink, User, - UserSetting, ] From 338c1591cb1cd5954e5665ac45d25fd8384dbb16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 7 Jun 2022 11:45:07 +0200 Subject: [PATCH 10/45] Cleanup --- database/entity/0002-add_settings/UserSetting.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/entity/0002-add_settings/UserSetting.ts b/database/entity/0002-add_settings/UserSetting.ts index 6103f67b5..9da036954 100644 --- a/database/entity/0002-add_settings/UserSetting.ts +++ b/database/entity/0002-add_settings/UserSetting.ts @@ -1,5 +1,5 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm' -import { User } from '../0034-drop_server_user_table/User' // Wolle: last fitting one or old was correct? +import { User } from '../0034-drop_server_user_table/User' @Entity() export class UserSetting extends BaseEntity { From bb35332e2ed6c0bf66b3cd4ec29b82a679c97db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Tue, 7 Jun 2022 22:13:27 +0200 Subject: [PATCH 11/45] change Cycle Type in tabel ContributionLinks --- .dbeaver/.credentials-config.json.bak | 2 ++ .dbeaver/.data-sources.json.bak | 33 +++++++++++++++++++ .dbeaver/credentials-config.json | 3 ++ .dbeaver/data-sources.json | 32 ++++++++++++++++++ .../ContributionLinks.ts | 26 ++------------- .../0037-add_contribution_links_table.ts | 2 +- 6 files changed, 73 insertions(+), 25 deletions(-) create mode 100644 .dbeaver/.credentials-config.json.bak create mode 100644 .dbeaver/.data-sources.json.bak create mode 100644 .dbeaver/credentials-config.json create mode 100644 .dbeaver/data-sources.json diff --git a/.dbeaver/.credentials-config.json.bak b/.dbeaver/.credentials-config.json.bak new file mode 100644 index 000000000..2eca1988d --- /dev/null +++ b/.dbeaver/.credentials-config.json.bak @@ -0,0 +1,2 @@ +'U[V$8%kQN, +`W-T3NvU{ɆHK~,DXpX.g/:?B9|GZn>/ \ No newline at end of file diff --git a/.dbeaver/.data-sources.json.bak b/.dbeaver/.data-sources.json.bak new file mode 100644 index 000000000..7d9528f01 --- /dev/null +++ b/.dbeaver/.data-sources.json.bak @@ -0,0 +1,33 @@ +{ + "folders": {}, + "connections": { + "mariaDB-1813fbbc7bc-107c0b3aeaeb91ab": { + "provider": "mysql", + "driver": "mariaDB", + "name": "gradido", + "save-password": true, + "read-only": false, + "configuration": { + "host": "localhost", + "port": "3306", + "database": "gradido", + "url": "jdbc:mariadb://localhost:3306/gradido", + "home": "mysql_client", + "type": "dev", + "auth-model": "native", + "handlers": {} + } + } + }, + "connection-types": { + "dev": { + "name": "Development", + "color": "255,255,255", + "description": "Regular development database", + "auto-commit": true, + "confirm-execute": false, + "confirm-data-change": false, + "auto-close-transactions": false + } + } +} \ No newline at end of file diff --git a/.dbeaver/credentials-config.json b/.dbeaver/credentials-config.json new file mode 100644 index 000000000..d814bdfcf --- /dev/null +++ b/.dbeaver/credentials-config.json @@ -0,0 +1,3 @@ +4k1,fbAqĬc##s8-1&;"7djM?bljfBq= +my +vV \ No newline at end of file diff --git a/.dbeaver/data-sources.json b/.dbeaver/data-sources.json new file mode 100644 index 000000000..096f0d57e --- /dev/null +++ b/.dbeaver/data-sources.json @@ -0,0 +1,32 @@ +{ + "folders": {}, + "connections": { + "mariaDB-1813fbbc7bc-107c0b3aeaeb91ab": { + "provider": "mysql", + "driver": "mariaDB", + "name": "gradido", + "save-password": true, + "read-only": false, + "configuration": { + "host": "localhost", + "port": "3306", + "url": "jdbc:mariadb://localhost:3306/", + "home": "mysql_client", + "type": "dev", + "auth-model": "native", + "handlers": {} + } + } + }, + "connection-types": { + "dev": { + "name": "Development", + "color": "255,255,255", + "description": "Regular development database", + "auto-commit": true, + "confirm-execute": false, + "confirm-data-change": false, + "auto-close-transactions": false + } + } +} \ No newline at end of file diff --git a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts index 2fb4e2801..0626a5067 100644 --- a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts +++ b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts @@ -2,28 +2,6 @@ import Decimal from 'decimal.js-light' import { BaseEntity, Entity, PrimaryGeneratedColumn, Column } from 'typeorm' import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' -export enum CycleTypes { - ONCE = 1, - HOUR = 2, - TWOHOURS = 3, - FOURHOURS = 4, - EIGHTHOURS = 5, - HALFDAY = 6, - DAY = 7, - TWODAYS = 8, - THREEDAYS = 9, - FOURDAYS = 10, - FIVEDAYS = 11, - SIXDAYS = 12, - WEEK = 13, - TWOWEEKS = 14, - MONTH = 15, - TWOMONTH = 16, - QUARTER = 17, - HALFYEAR = 18, - YEAR = 19, -} - @Entity('contribution_links') export class ContributionLinks extends BaseEntity { @PrimaryGeneratedColumn('increment', { unsigned: true }) @@ -50,8 +28,8 @@ export class ContributionLinks extends BaseEntity { }) amount: Decimal - @Column({ name: 'cycle', unsigned: true, nullable: false }) - cycle: number + @Column({ length: 12, nullable: false, collation: 'utf8mb4_unicode_ci' }) + cycle: string @Column({ name: 'max_per_cycle', unsigned: true, nullable: false, default: 1 }) maxPerCycle: number diff --git a/database/migrations/0037-add_contribution_links_table.ts b/database/migrations/0037-add_contribution_links_table.ts index 79bcdf5ce..42f03184b 100644 --- a/database/migrations/0037-add_contribution_links_table.ts +++ b/database/migrations/0037-add_contribution_links_table.ts @@ -15,7 +15,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis \`valid_from\` datetime NULL, \`valid_to\` datetime NULL, \`amount\` bigint(20) NOT NULL, - \`cycle\` int(10) unsigned NOT NULL DEFAULT '1', + \`cycle\` varchar(12) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'NONE', \`max_per_cycle\` int(10) unsigned NOT NULL DEFAULT '1', \`max_amount_per_month\` bigint(20) NULL DEFAULT NULL, \`total_max_count_of_contribution\` int(10) unsigned NULL DEFAULT NULL, From 698f13078e73472186f15651094674e3fef4ff58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Tue, 7 Jun 2022 22:14:02 +0200 Subject: [PATCH 12/45] define enum for ContributionLinks cycles --- .../src/graphql/enum/ContributionCycleType.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 backend/src/graphql/enum/ContributionCycleType.ts diff --git a/backend/src/graphql/enum/ContributionCycleType.ts b/backend/src/graphql/enum/ContributionCycleType.ts new file mode 100644 index 000000000..05084a669 --- /dev/null +++ b/backend/src/graphql/enum/ContributionCycleType.ts @@ -0,0 +1,29 @@ +import { registerEnumType } from 'type-graphql' + +export enum ContributionCycleType { + NONE = 'none', + ONCE = 'once', + HOUR = 'hour', + TWO_HOURS = 'two_hours', + FOUR_HOURS = 'four_hours', + EIGHT_HOURS = 'eight_hours', + HALF_DAY = 'half_day', + DAY = 'day', + TWO_DAYS = 'two_days', + THREE_DAYS = 'three_days', + FOUR_DAYS = 'four_days', + FIVE_DAYS = 'five_days', + SIX_DAYS = 'six_days', + WEEK = 'week', + TWO_WEEKS = 'two_weeks', + MONTH = 'month', + TWO_MONTH = 'two_month', + QUARTER = 'quarter', + HALF_YEAR = 'half_year', + YEAR = 'year', +} + +registerEnumType(ContributionCycleType, { + name: 'ContributionCycleType', // this one is mandatory + description: 'Name of the Type of the ContributionCycle', // this one is optional +}) From e71725686c03c2e459081ef90ecd90db5205ffb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Tue, 7 Jun 2022 22:21:40 +0200 Subject: [PATCH 13/45] change backend config for db-version 0037 --- backend/src/config/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 28318ed6b..ec469c183 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0036-unique_previous_in_transactions', + DB_VERSION: '0037-add_contribution_links_table/ContributionLinks', 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 a881103c5f70f0e67c394e447436085808309f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Tue, 7 Jun 2022 22:52:08 +0200 Subject: [PATCH 14/45] add softdelete feature to contributionlinks --- .../0037-add_contribution_links_table/ContributionLinks.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts index 0626a5067..6539716c6 100644 --- a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts +++ b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts @@ -1,5 +1,5 @@ import Decimal from 'decimal.js-light' -import { BaseEntity, Entity, PrimaryGeneratedColumn, Column } from 'typeorm' +import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, DeleteDateColumn } from 'typeorm' import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' @Entity('contribution_links') @@ -75,7 +75,7 @@ export class ContributionLinks extends BaseEntity { @Column({ name: 'created_at', type: 'datetime', nullable: true, default: null }) createdAt: Date | null - @Column({ name: 'deleted_at', type: 'datetime', nullable: true, default: null }) + @DeleteDateColumn() deletedAt: Date | null @Column({ length: 24, nullable: true, collation: 'utf8mb4_unicode_ci' }) From 605a6757a35f8600c7df8b311e075ea4a4b750ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Wed, 8 Jun 2022 21:32:42 +0200 Subject: [PATCH 15/45] change default cycle-value to ONCE --- database/migrations/0037-add_contribution_links_table.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/0037-add_contribution_links_table.ts b/database/migrations/0037-add_contribution_links_table.ts index 42f03184b..5e55f4ff1 100644 --- a/database/migrations/0037-add_contribution_links_table.ts +++ b/database/migrations/0037-add_contribution_links_table.ts @@ -15,7 +15,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis \`valid_from\` datetime NULL, \`valid_to\` datetime NULL, \`amount\` bigint(20) NOT NULL, - \`cycle\` varchar(12) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'NONE', + \`cycle\` varchar(12) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'ONCE', \`max_per_cycle\` int(10) unsigned NOT NULL DEFAULT '1', \`max_amount_per_month\` bigint(20) NULL DEFAULT NULL, \`total_max_count_of_contribution\` int(10) unsigned NULL DEFAULT NULL, From fd352602ec3ecbed5dcb15bbe9811a519df669fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Wed, 8 Jun 2022 21:33:26 +0200 Subject: [PATCH 16/45] delete value NONE from enum --- backend/src/graphql/enum/ContributionCycleType.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/src/graphql/enum/ContributionCycleType.ts b/backend/src/graphql/enum/ContributionCycleType.ts index 05084a669..5fe494a02 100644 --- a/backend/src/graphql/enum/ContributionCycleType.ts +++ b/backend/src/graphql/enum/ContributionCycleType.ts @@ -1,7 +1,6 @@ import { registerEnumType } from 'type-graphql' export enum ContributionCycleType { - NONE = 'none', ONCE = 'once', HOUR = 'hour', TWO_HOURS = 'two_hours', From 114465c23490b985848f359d0f86e4f4935b8cc3 Mon Sep 17 00:00:00 2001 From: clauspeterhuebner <86960882+clauspeterhuebner@users.noreply.github.com> Date: Thu, 9 Jun 2022 22:24:22 +0200 Subject: [PATCH 17/45] Update backend/src/config/index.ts Co-authored-by: Moriz Wahl --- backend/src/config/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index ec469c183..f4999c4a8 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0037-add_contribution_links_table/ContributionLinks', + DB_VERSION: '0037-add_contribution_links_table', 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 b65aa5cefccbf315844c4820fd03f7b869362933 Mon Sep 17 00:00:00 2001 From: clauspeterhuebner <86960882+clauspeterhuebner@users.noreply.github.com> Date: Thu, 9 Jun 2022 22:26:30 +0200 Subject: [PATCH 18/45] Update database/entity/0037-add_contribution_links_table/ContributionLinks.ts Co-authored-by: Moriz Wahl --- .../0037-add_contribution_links_table/ContributionLinks.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts index 6539716c6..fde67eef3 100644 --- a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts +++ b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts @@ -72,8 +72,8 @@ export class ContributionLinks extends BaseEntity { }) minGapHours: number | null - @Column({ name: 'created_at', type: 'datetime', nullable: true, default: null }) - createdAt: Date | null + @Column({ name: 'created_at', type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) + createdAt: Date @DeleteDateColumn() deletedAt: Date | null From 83c66d052a969cab0c1af0a7ecc2823adf8ab8ec Mon Sep 17 00:00:00 2001 From: clauspeterhuebner <86960882+clauspeterhuebner@users.noreply.github.com> Date: Thu, 9 Jun 2022 22:27:54 +0200 Subject: [PATCH 19/45] Update database/entity/0037-add_contribution_links_table/ContributionLinks.ts Co-authored-by: Moriz Wahl --- .../0037-add_contribution_links_table/ContributionLinks.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts index fde67eef3..16500b06b 100644 --- a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts +++ b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts @@ -81,6 +81,6 @@ export class ContributionLinks extends BaseEntity { @Column({ length: 24, nullable: true, collation: 'utf8mb4_unicode_ci' }) code: string - @Column({ name: 'link_enabled', type: 'boolean', nullable: true, default: null }) - linkEnabled: boolean | null + @Column({ name: 'link_enabled', type: 'boolean', default: true }) + linkEnabled: boolean } From 3328c200d8d067d2e727495e6a727f65a6c791ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 9 Jun 2022 22:28:56 +0200 Subject: [PATCH 20/45] rework PR comments --- .gitignore | 1 + database/migrations/0037-add_contribution_links_table.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6ac3a32c2..ced6746aa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.log +*.bak /node_modules/* messages.pot nbproject diff --git a/database/migrations/0037-add_contribution_links_table.ts b/database/migrations/0037-add_contribution_links_table.ts index 5e55f4ff1..4d3527ef5 100644 --- a/database/migrations/0037-add_contribution_links_table.ts +++ b/database/migrations/0037-add_contribution_links_table.ts @@ -24,7 +24,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis \`created_at\` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, \`deleted_at\` datetime NULL DEFAULT NULL, \`code\` varchar(24) COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, - \`link_enabled\` tinyint(4) NOT NULL DEFAULT '0', + \`link_enabled\` tinyint(4) NOT NULL DEFAULT '1', PRIMARY KEY (\`id\`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`) } From e76817ebdbde036eaad068743d1edff60d704819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 9 Jun 2022 22:55:52 +0200 Subject: [PATCH 21/45] column validFrom NOT NULL --- database/migrations/0037-add_contribution_links_table.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/0037-add_contribution_links_table.ts b/database/migrations/0037-add_contribution_links_table.ts index 4d3527ef5..e05bfd5e7 100644 --- a/database/migrations/0037-add_contribution_links_table.ts +++ b/database/migrations/0037-add_contribution_links_table.ts @@ -12,7 +12,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis \`id\` int(10) unsigned NOT NULL AUTO_INCREMENT, \`name\` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, \`decsription\` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, - \`valid_from\` datetime NULL, + \`valid_from\` datetime NOT NULL, \`valid_to\` datetime NULL, \`amount\` bigint(20) NOT NULL, \`cycle\` varchar(12) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'ONCE', From 94a48173e0f023b5b1f371678572ef293e5ae52f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 9 Jun 2022 23:20:05 +0200 Subject: [PATCH 22/45] remove *.bak files from repo Merge remote-tracking branch 'origin/1920-feature-create-contribution-link-table' into 1920-feature-create-contribution-link-table --- .dbeaver/.credentials-config.json.bak | 2 -- .dbeaver/.data-sources.json.bak | 33 --------------------------- 2 files changed, 35 deletions(-) delete mode 100644 .dbeaver/.credentials-config.json.bak delete mode 100644 .dbeaver/.data-sources.json.bak diff --git a/.dbeaver/.credentials-config.json.bak b/.dbeaver/.credentials-config.json.bak deleted file mode 100644 index 2eca1988d..000000000 --- a/.dbeaver/.credentials-config.json.bak +++ /dev/null @@ -1,2 +0,0 @@ -'U[V$8%kQN, -`W-T3NvU{ɆHK~,DXpX.g/:?B9|GZn>/ \ No newline at end of file diff --git a/.dbeaver/.data-sources.json.bak b/.dbeaver/.data-sources.json.bak deleted file mode 100644 index 7d9528f01..000000000 --- a/.dbeaver/.data-sources.json.bak +++ /dev/null @@ -1,33 +0,0 @@ -{ - "folders": {}, - "connections": { - "mariaDB-1813fbbc7bc-107c0b3aeaeb91ab": { - "provider": "mysql", - "driver": "mariaDB", - "name": "gradido", - "save-password": true, - "read-only": false, - "configuration": { - "host": "localhost", - "port": "3306", - "database": "gradido", - "url": "jdbc:mariadb://localhost:3306/gradido", - "home": "mysql_client", - "type": "dev", - "auth-model": "native", - "handlers": {} - } - } - }, - "connection-types": { - "dev": { - "name": "Development", - "color": "255,255,255", - "description": "Regular development database", - "auto-commit": true, - "confirm-execute": false, - "confirm-data-change": false, - "auto-close-transactions": false - } - } -} \ No newline at end of file From d7ff6446d994735e1468b18979943099fd4ecc00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 9 Jun 2022 23:52:40 +0200 Subject: [PATCH 23/45] evaluate nullable columns vs entity --- .../ContributionLinks.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts index 16500b06b..7b391606f 100644 --- a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts +++ b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts @@ -11,10 +11,10 @@ export class ContributionLinks extends BaseEntity { name: string @Column({ length: 255, nullable: false, collation: 'utf8mb4_unicode_ci' }) - description: string + memo: string - @Column({ name: 'valid_from', type: 'datetime', nullable: true, default: null }) - validFrom: Date | null + @Column({ name: 'valid_from', type: 'datetime', nullable: false }) + validFrom: Date @Column({ name: 'valid_to', type: 'datetime', nullable: true, default: null }) validTo: Date | null @@ -43,7 +43,7 @@ export class ContributionLinks extends BaseEntity { default: null, transformer: DecimalTransformer, }) - maxAmountPerMonth: Decimal + maxAmountPerMonth: Decimal | null @Column({ name: 'total_max_count_of_contribution', @@ -62,7 +62,7 @@ export class ContributionLinks extends BaseEntity { default: null, transformer: DecimalTransformer, }) - maxAccountBalance: Decimal + maxAccountBalance: Decimal | null @Column({ name: 'min_gap_hours', @@ -79,7 +79,7 @@ export class ContributionLinks extends BaseEntity { deletedAt: Date | null @Column({ length: 24, nullable: true, collation: 'utf8mb4_unicode_ci' }) - code: string + code: string | null @Column({ name: 'link_enabled', type: 'boolean', default: true }) linkEnabled: boolean From 8a0147c8117f38d23f3c02b29ff0bf81858370b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 9 Jun 2022 23:54:06 +0200 Subject: [PATCH 24/45] shift enum in ticket #1921 --- .../src/graphql/enum/ContributionCycleType.ts | 28 ------------------- 1 file changed, 28 deletions(-) delete mode 100644 backend/src/graphql/enum/ContributionCycleType.ts diff --git a/backend/src/graphql/enum/ContributionCycleType.ts b/backend/src/graphql/enum/ContributionCycleType.ts deleted file mode 100644 index 5fe494a02..000000000 --- a/backend/src/graphql/enum/ContributionCycleType.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { registerEnumType } from 'type-graphql' - -export enum ContributionCycleType { - ONCE = 'once', - HOUR = 'hour', - TWO_HOURS = 'two_hours', - FOUR_HOURS = 'four_hours', - EIGHT_HOURS = 'eight_hours', - HALF_DAY = 'half_day', - DAY = 'day', - TWO_DAYS = 'two_days', - THREE_DAYS = 'three_days', - FOUR_DAYS = 'four_days', - FIVE_DAYS = 'five_days', - SIX_DAYS = 'six_days', - WEEK = 'week', - TWO_WEEKS = 'two_weeks', - MONTH = 'month', - TWO_MONTH = 'two_month', - QUARTER = 'quarter', - HALF_YEAR = 'half_year', - YEAR = 'year', -} - -registerEnumType(ContributionCycleType, { - name: 'ContributionCycleType', // this one is mandatory - description: 'Name of the Type of the ContributionCycle', // this one is optional -}) From 5121910c836dfe975a93487d1eaf181a43401245 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 13 Jun 2022 12:03:15 +0200 Subject: [PATCH 25/45] rename ContributionLinks to ContributionLink, add CL entity to index --- .../0038-add_contribution_links_table/ContributionLink.ts | 2 +- database/entity/ContributionLink.ts | 2 +- database/entity/ContributionLinks.ts | 1 + database/entity/index.ts | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 database/entity/ContributionLinks.ts diff --git a/database/entity/0038-add_contribution_links_table/ContributionLink.ts b/database/entity/0038-add_contribution_links_table/ContributionLink.ts index 7b391606f..490ca3868 100644 --- a/database/entity/0038-add_contribution_links_table/ContributionLink.ts +++ b/database/entity/0038-add_contribution_links_table/ContributionLink.ts @@ -3,7 +3,7 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, DeleteDateColumn } import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' @Entity('contribution_links') -export class ContributionLinks extends BaseEntity { +export class ContributionLink extends BaseEntity { @PrimaryGeneratedColumn('increment', { unsigned: true }) id: number diff --git a/database/entity/ContributionLink.ts b/database/entity/ContributionLink.ts index de26c1c4a..721dfd2b3 100644 --- a/database/entity/ContributionLink.ts +++ b/database/entity/ContributionLink.ts @@ -1 +1 @@ -export { ContributionLinks } from './0037-add_contribution_links_table/ContributionLinks' +export { ContributionLinks } from './0038-add_contribution_links_table/ContributionLinks' diff --git a/database/entity/ContributionLinks.ts b/database/entity/ContributionLinks.ts new file mode 100644 index 000000000..c7e4e2b7e --- /dev/null +++ b/database/entity/ContributionLinks.ts @@ -0,0 +1 @@ +export { ContributionLink } from './0038-add_contribution_links_table/ContributionLink' diff --git a/database/entity/index.ts b/database/entity/index.ts index 46d9ef31a..991e482e9 100644 --- a/database/entity/index.ts +++ b/database/entity/index.ts @@ -1,3 +1,4 @@ +import { ContributionLink } from './ContributionLink' import { LoginElopageBuys } from './LoginElopageBuys' import { LoginEmailOptIn } from './LoginEmailOptIn' import { Migration } from './Migration' @@ -8,6 +9,7 @@ import { AdminPendingCreation } from './AdminPendingCreation' export const entities = [ AdminPendingCreation, + ContributionLink, LoginElopageBuys, LoginEmailOptIn, Migration, From 83c8f9731e87749de795968905b45287f3bb2981 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 13 Jun 2022 12:05:13 +0200 Subject: [PATCH 26/45] remove duplicate file --- database/entity/ContributionLink.ts | 2 +- database/entity/ContributionLinks.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 database/entity/ContributionLinks.ts diff --git a/database/entity/ContributionLink.ts b/database/entity/ContributionLink.ts index 721dfd2b3..c7e4e2b7e 100644 --- a/database/entity/ContributionLink.ts +++ b/database/entity/ContributionLink.ts @@ -1 +1 @@ -export { ContributionLinks } from './0038-add_contribution_links_table/ContributionLinks' +export { ContributionLink } from './0038-add_contribution_links_table/ContributionLink' diff --git a/database/entity/ContributionLinks.ts b/database/entity/ContributionLinks.ts deleted file mode 100644 index c7e4e2b7e..000000000 --- a/database/entity/ContributionLinks.ts +++ /dev/null @@ -1 +0,0 @@ -export { ContributionLink } from './0038-add_contribution_links_table/ContributionLink' From 795d3393981ccead3ab0b4645f0b6266e5e4dbee Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 13 Jun 2022 12:23:57 +0200 Subject: [PATCH 27/45] add type definitions, make code required (not null) --- .../0038-add_contribution_links_table/ContributionLink.ts | 8 +++++--- database/migrations/0038-add_contribution_links_table.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/database/entity/0038-add_contribution_links_table/ContributionLink.ts b/database/entity/0038-add_contribution_links_table/ContributionLink.ts index 490ca3868..496f57d71 100644 --- a/database/entity/0038-add_contribution_links_table/ContributionLink.ts +++ b/database/entity/0038-add_contribution_links_table/ContributionLink.ts @@ -47,6 +47,7 @@ export class ContributionLink extends BaseEntity { @Column({ name: 'total_max_count_of_contribution', + type: 'int', unsigned: true, nullable: true, default: null, @@ -66,6 +67,7 @@ export class ContributionLink extends BaseEntity { @Column({ name: 'min_gap_hours', + type: 'int', unsigned: true, nullable: true, default: null, @@ -75,11 +77,11 @@ export class ContributionLink extends BaseEntity { @Column({ name: 'created_at', type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) createdAt: Date - @DeleteDateColumn() + @DeleteDateColumn({ name: 'deleted_at' }) deletedAt: Date | null - @Column({ length: 24, nullable: true, collation: 'utf8mb4_unicode_ci' }) - code: string | null + @Column({ length: 24, nullable: false, collation: 'utf8mb4_unicode_ci' }) + code: string @Column({ name: 'link_enabled', type: 'boolean', default: true }) linkEnabled: boolean diff --git a/database/migrations/0038-add_contribution_links_table.ts b/database/migrations/0038-add_contribution_links_table.ts index 3ac6821d6..f983644cc 100644 --- a/database/migrations/0038-add_contribution_links_table.ts +++ b/database/migrations/0038-add_contribution_links_table.ts @@ -23,7 +23,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis \`min_gap_hours\` int(10) unsigned NULL DEFAULT NULL, \`created_at\` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, \`deleted_at\` datetime NULL DEFAULT NULL, - \`code\` varchar(24) COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, + \`code\` varchar(24) COLLATE utf8mb4_unicode_ci NOT NULL, \`link_enabled\` tinyint(4) NOT NULL DEFAULT '1', PRIMARY KEY (\`id\`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`) From a84f11880f3108d5cb2496a44b5576d78e51cdee Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 13 Jun 2022 12:31:40 +0200 Subject: [PATCH 28/45] rename migration 0037 to what it acutally does --- .../User.ts | 0 database/entity/User.ts | 2 +- ...rop_server_user_table.ts => 0037-drop_user_setting_table.ts} | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename database/entity/{0037-drop_server_user_table => 0037-drop_user_setting_table}/User.ts (100%) rename database/migrations/{0037-drop_server_user_table.ts => 0037-drop_user_setting_table.ts} (100%) diff --git a/database/entity/0037-drop_server_user_table/User.ts b/database/entity/0037-drop_user_setting_table/User.ts similarity index 100% rename from database/entity/0037-drop_server_user_table/User.ts rename to database/entity/0037-drop_user_setting_table/User.ts diff --git a/database/entity/User.ts b/database/entity/User.ts index 6983f293b..2d434799e 100644 --- a/database/entity/User.ts +++ b/database/entity/User.ts @@ -1 +1 @@ -export { User } from './0037-drop_server_user_table/User' +export { User } from './0037-drop_user_setting_table/User' diff --git a/database/migrations/0037-drop_server_user_table.ts b/database/migrations/0037-drop_user_setting_table.ts similarity index 100% rename from database/migrations/0037-drop_server_user_table.ts rename to database/migrations/0037-drop_user_setting_table.ts From 5456e6dae4e3eaf33aa6290b46419588bd3fb90c Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 13 Jun 2022 13:19:03 +0200 Subject: [PATCH 29/45] add ContributionLink graphQL model --- backend/src/graphql/model/ContributionLink.ts | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 backend/src/graphql/model/ContributionLink.ts diff --git a/backend/src/graphql/model/ContributionLink.ts b/backend/src/graphql/model/ContributionLink.ts new file mode 100644 index 000000000..b60df37e2 --- /dev/null +++ b/backend/src/graphql/model/ContributionLink.ts @@ -0,0 +1,56 @@ +import { ObjectType, Field, Int } from 'type-graphql' +import Decimal from 'decimal.js-light' +import { ContributionLink as dbContributionLink } from '@entity/ContributionLink' + +@ObjectType() +export class ContributionLink { + constructor(contributionLink: dbContributionLink) { + this.id = contributionLink.id + this.amount = contributionLink.amount + this.name = contributionLink.name + this.memo = contributionLink.memo + this.createdAt = contributionLink.createdAt + this.deletedAt = contributionLink.deletedAt + this.validFrom = contributionLink.validFrom + this.validTo = contributionLink.validTo + this.maxAmountPerMonth = contributionLink.maxAmountPerMonth + this.cycle = contributionLink.cycle + this.maxPerCycle = contributionLink.maxPerCycle + } + + @Field(() => Number) + id: number + + @Field(() => Decimal) + amount: Decimal + + @Field(() => String) + name: string + + @Field(() => String) + memo: string + + @Field(() => String) + code: string + + @Field(() => Date) + createdAt: Date + + @Field(() => Date, { nullable: true }) + deletedAt: Date | null + + @Field(() => Date, { nullable: true }) + validFrom: Date | null + + @Field(() => Date, { nullable: true }) + validTo: Date | null + + @Field(() => Decimal) + maxAmountPerMonth: Decimal | null + + @Field(() => string) + cycle: string + + @Field(() => Int) + maxPerCycle: number +} From bd593e96ae3d4acb6ff3285d40b91e0ad607d373 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 14 Jun 2022 09:23:51 +0200 Subject: [PATCH 30/45] roles and args for contribution links --- backend/src/auth/RIGHTS.ts | 1 + .../src/graphql/arg/ContributionLinkArgs.ts | 29 +++++++++++++++++++ backend/src/graphql/model/ContributionLink.ts | 2 +- backend/src/graphql/resolver/AdminResolver.ts | 11 +++++++ 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 backend/src/graphql/arg/ContributionLinkArgs.ts diff --git a/backend/src/auth/RIGHTS.ts b/backend/src/auth/RIGHTS.ts index 8188b3daa..dcd0e44d6 100644 --- a/backend/src/auth/RIGHTS.ts +++ b/backend/src/auth/RIGHTS.ts @@ -37,4 +37,5 @@ export enum RIGHTS { UNDELETE_USER = 'UNDELETE_USER', CREATION_TRANSACTION_LIST = 'CREATION_TRANSACTION_LIST', LIST_TRANSACTION_LINKS_ADMIN = 'LIST_TRANSACTION_LINKS_ADMIN', + CREATE_CONTRIBUTION_LINK = 'CREATE_CONTRIBUTION_LINK', } diff --git a/backend/src/graphql/arg/ContributionLinkArgs.ts b/backend/src/graphql/arg/ContributionLinkArgs.ts new file mode 100644 index 000000000..f3d3f91df --- /dev/null +++ b/backend/src/graphql/arg/ContributionLinkArgs.ts @@ -0,0 +1,29 @@ +import { ArgsType, Field, Int } from 'type-graphql' +import Decimal from 'decimal.js-light' + +@ArgsType() +export default class ContributionLinkArgs { + @Field(() => Decimal) + amount: Decimal + + @Field(() => String) + name: string + + @Field(() => String) + memo: string + + @Field(() => String) + cycle: string + + @Field(() => Date, { nullable: true }) + validFrom?: Date | null + + @Field(() => Date, { nullable: true }) + validTo?: Date | null + + @Field(() => Decimal, { nullable: true }) + maxAmountPerMonth: Decimal | null + + @Field(() => Int, { default: 1 }) + maxPerCycle: number +} diff --git a/backend/src/graphql/model/ContributionLink.ts b/backend/src/graphql/model/ContributionLink.ts index b60df37e2..df28bb0e5 100644 --- a/backend/src/graphql/model/ContributionLink.ts +++ b/backend/src/graphql/model/ContributionLink.ts @@ -45,7 +45,7 @@ export class ContributionLink { @Field(() => Date, { nullable: true }) validTo: Date | null - @Field(() => Decimal) + @Field(() => Decimal, { nullable: true }) maxAmountPerMonth: Decimal | null @Field(() => string) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 4c94e48c8..d9945a617 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -14,12 +14,15 @@ import { UserAdmin, SearchUsersResult } from '@model/UserAdmin' import { PendingCreation } from '@model/PendingCreation' import { CreatePendingCreations } from '@model/CreatePendingCreations' import { UpdatePendingCreation } from '@model/UpdatePendingCreation' +import { ContributionLink } from '@model/ContributionLink' import { RIGHTS } from '@/auth/RIGHTS' import { UserRepository } from '@repository/User' import CreatePendingCreationArgs from '@arg/CreatePendingCreationArgs' import UpdatePendingCreationArgs from '@arg/UpdatePendingCreationArgs' import SearchUsersArgs from '@arg/SearchUsersArgs' +import ContributionLinkArgs from '@arg/ContributionLinkArgs' import { Transaction as DbTransaction } from '@entity/Transaction' +import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { Transaction } from '@model/Transaction' import { TransactionLink, TransactionLinkResult } from '@model/TransactionLink' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' @@ -460,6 +463,14 @@ export class AdminResolver { linkList: transactionLinks.map((tl) => new TransactionLink(tl, new User(user))), } } + + @Authorized([RIGHTS.CREATE_CONTRIBUTION_LINK]) + @Mutation(() => ContributionLink) + async createContributionLink( + @Args() + { amount, name, memo, cycle, validFrom, validTo, maxAmountPerMonth, maxPerCycle }: ContributionLinkArgs, + ) + } interface CreationMap { From 1e0b246252b426db52d4ff19c7b0a7e5ee9b26d1 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 14 Jun 2022 09:44:37 +0200 Subject: [PATCH 31/45] simple createContributionLink mutation --- .../src/graphql/arg/ContributionLinkArgs.ts | 2 +- backend/src/graphql/model/ContributionLink.ts | 2 +- backend/src/graphql/resolver/AdminResolver.ts | 27 ++++++++++++++++--- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/backend/src/graphql/arg/ContributionLinkArgs.ts b/backend/src/graphql/arg/ContributionLinkArgs.ts index f3d3f91df..809ce89c4 100644 --- a/backend/src/graphql/arg/ContributionLinkArgs.ts +++ b/backend/src/graphql/arg/ContributionLinkArgs.ts @@ -24,6 +24,6 @@ export default class ContributionLinkArgs { @Field(() => Decimal, { nullable: true }) maxAmountPerMonth: Decimal | null - @Field(() => Int, { default: 1 }) + @Field(() => Int) maxPerCycle: number } diff --git a/backend/src/graphql/model/ContributionLink.ts b/backend/src/graphql/model/ContributionLink.ts index df28bb0e5..9fb60e4aa 100644 --- a/backend/src/graphql/model/ContributionLink.ts +++ b/backend/src/graphql/model/ContributionLink.ts @@ -48,7 +48,7 @@ export class ContributionLink { @Field(() => Decimal, { nullable: true }) maxAmountPerMonth: Decimal | null - @Field(() => string) + @Field(() => String) cycle: string @Field(() => Int) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index d9945a617..d99bf6c6f 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -468,9 +468,30 @@ export class AdminResolver { @Mutation(() => ContributionLink) async createContributionLink( @Args() - { amount, name, memo, cycle, validFrom, validTo, maxAmountPerMonth, maxPerCycle }: ContributionLinkArgs, - ) - + { + amount, + name, + memo, + cycle, + validFrom, + validTo, + maxAmountPerMonth, + maxPerCycle, + }: ContributionLinkArgs, + ): Promise { + const dbContributionLink = new DbContributionLink() + dbContributionLink.amount = amount + dbContributionLink.name = name + dbContributionLink.memo = memo + dbContributionLink.createdAt = new Date() + dbContributionLink.cycle = cycle + if (validFrom) dbContributionLink.validFrom = validFrom + if (validTo) dbContributionLink.validTo = validTo + dbContributionLink.maxAmountPerMonth = maxAmountPerMonth + dbContributionLink.maxPerCycle = maxPerCycle + dbContributionLink.save() + return new ContributionLink(dbContributionLink) + } } interface CreationMap { From f258f63ee74f3535a661f1e5e8c57e890eb89f08 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 14 Jun 2022 10:43:03 +0200 Subject: [PATCH 32/45] test createContributionLink --- .../src/graphql/arg/ContributionLinkArgs.ts | 8 +- backend/src/graphql/model/ContributionLink.ts | 6 + .../graphql/resolver/AdminResolver.test.ts | 118 ++++++++++++++++++ backend/src/graphql/resolver/AdminResolver.ts | 6 +- backend/src/seeds/graphql/mutations.ts | 36 ++++++ 5 files changed, 168 insertions(+), 6 deletions(-) diff --git a/backend/src/graphql/arg/ContributionLinkArgs.ts b/backend/src/graphql/arg/ContributionLinkArgs.ts index 809ce89c4..7344a28ff 100644 --- a/backend/src/graphql/arg/ContributionLinkArgs.ts +++ b/backend/src/graphql/arg/ContributionLinkArgs.ts @@ -15,11 +15,11 @@ export default class ContributionLinkArgs { @Field(() => String) cycle: string - @Field(() => Date, { nullable: true }) - validFrom?: Date | null + @Field(() => String, { nullable: true }) + validFrom?: string | null - @Field(() => Date, { nullable: true }) - validTo?: Date | null + @Field(() => String, { nullable: true }) + validTo?: string | null @Field(() => Decimal, { nullable: true }) maxAmountPerMonth: Decimal | null diff --git a/backend/src/graphql/model/ContributionLink.ts b/backend/src/graphql/model/ContributionLink.ts index 9fb60e4aa..e4b37ad59 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() export class ContributionLink { @@ -16,6 +17,8 @@ export class ContributionLink { this.maxAmountPerMonth = contributionLink.maxAmountPerMonth this.cycle = contributionLink.cycle this.maxPerCycle = contributionLink.maxPerCycle + this.code = 'CL-' + contributionLink.code + this.link = CONFIG.COMMUNITY_REDEEM_URL.replace(/{code}/g, this.code) } @Field(() => Number) @@ -33,6 +36,9 @@ export class ContributionLink { @Field(() => String) code: string + @Field(() => String) + link: string + @Field(() => Date) createdAt: Date diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index acf880efb..6b0f295c7 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -20,6 +20,7 @@ import { updatePendingCreation, deletePendingCreation, confirmPendingCreation, + createContributionLink, } from '@/seeds/graphql/mutations' import { getPendingCreations, @@ -34,6 +35,7 @@ import { sendAccountActivationEmail } from '@/mailer/sendAccountActivationEmail' import Decimal from 'decimal.js-light' import { AdminPendingCreation } from '@entity/AdminPendingCreation' import { Transaction as DbTransaction } from '@entity/Transaction' +import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' // mock account activation email to avoid console spam jest.mock('@/mailer/sendAccountActivationEmail', () => { @@ -1593,4 +1595,120 @@ describe('AdminResolver', () => { }) }) }) + + describe('Contribution Links', () => { + const variables = { + amount: new Decimal(200), + name: 'Dokumenta 2022', + memo: 'Danke für deine Teilnahme an der Dokumenta 2022', + cycle: 'once', + validFrom: new Date(2022, 5, 18).toISOString(), + validTo: new Date(2022, 7, 14).toISOString(), + maxAmountPerMonth: new Decimal(200), + maxPerCycle: 1, + } + + describe('unauthenticated', () => { + describe('createContributionLink', () => { + it.only('returns an error', async () => { + await expect(mutate({ mutation: createContributionLink, variables })).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('401 Unauthorized')], + }), + ) + }) + }) + }) + + describe('authenticated', () => { + describe('without admin rights', () => { + beforeAll(async () => { + user = await userFactory(testEnv, bibiBloxberg) + await query({ + query: login, + variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, + }) + }) + + afterAll(async () => { + await cleanDB() + resetToken() + }) + + describe('createContributionLink', () => { + it.only('returns an error', async () => { + await expect(mutate({ mutation: createContributionLink, variables })).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('401 Unauthorized')], + }), + ) + }) + }) + }) + + describe('with admin rights', () => { + beforeAll(async () => { + user = await userFactory(testEnv, peterLustig) + await query({ + query: login, + variables: { email: 'peter@lustig.de', password: 'Aa12345_' }, + }) + }) + + afterAll(async () => { + await cleanDB() + resetToken() + }) + + describe('createContributionLink', () => { + it.only('returns a contribution link object', async () => { + await expect(mutate({ mutation: createContributionLink, variables })).resolves.toEqual( + expect.objectContaining({ + data: { + createContributionLink: expect.objectContaining({ + amount: '200', + code: expect.stringMatching(/^CL-[0-9a-f]{24,24}$/), + link: expect.any(String), + createdAt: expect.any(String), + name: 'Dokumenta 2022', + memo: 'Danke für deine Teilnahme an der Dokumenta 2022', + validFrom: expect.any(String), + validTo: expect.any(String), + maxAmountPerMonth: '200', + cycle: 'once', + maxPerCycle: 1, + }), + }, + }), + ) + }) + + it.only('has a contribution link stored in db', async () => { + const cls = await DbContributionLink.find() + expect(cls).toHaveLength(1) + expect(cls[0]).toEqual( + expect.objectContaining({ + id: expect.any(Number), + name: 'Dokumenta 2022', + memo: 'Danke für deine Teilnahme an der Dokumenta 2022', + validFrom: new Date('2022-06-18T00:00:00.000Z'), + validTo: new Date('2022-08-14T00:00:00.000Z'), + cycle: 'once', + maxPerCycle: 1, + totalMaxCountOfContribution: null, + maxAccountBalance: null, + minGapHours: null, + createdAt: expect.any(Date), + deletedAt: null, + code: expect.stringMatching(/^[0-9a-f]{24,24}$/), + linkEnabled: true, + // amount: '200', + // maxAmountPerMonth: '200', + }), + ) + }) + }) + }) + }) + }) }) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index d99bf6c6f..d7c843611 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -42,6 +42,7 @@ import { Order } from '@enum/Order' import { communityUser } from '@/util/communityUser' import { checkOptInCode, activationLink, printTimeDuration } from './UserResolver' import { sendAccountActivationEmail } from '@/mailer/sendAccountActivationEmail' +import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver' import CONFIG from '@/config' // const EMAIL_OPT_IN_REGISTER = 1 @@ -484,9 +485,10 @@ export class AdminResolver { dbContributionLink.name = name dbContributionLink.memo = memo dbContributionLink.createdAt = new Date() + dbContributionLink.code = contributionLinkCode(dbContributionLink.createdAt) dbContributionLink.cycle = cycle - if (validFrom) dbContributionLink.validFrom = validFrom - if (validTo) dbContributionLink.validTo = validTo + if (validFrom) dbContributionLink.validFrom = new Date(validFrom) + if (validTo) dbContributionLink.validTo = new Date(validTo) dbContributionLink.maxAmountPerMonth = maxAmountPerMonth dbContributionLink.maxPerCycle = maxPerCycle dbContributionLink.save() diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index e66827566..355b5aa79 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -137,3 +137,39 @@ export const deletePendingCreation = gql` deletePendingCreation(id: $id) } ` + +export const createContributionLink = gql` + mutation ( + $amount: Decimal! + $name: String! + $memo: String! + $cycle: String! + $validFrom: String + $validTo: String + $maxAmountPerMonth: Decimal + $maxPerCycle: Int! = 1 + ) { + createContributionLink( + amount: $amount + name: $name + memo: $memo + cycle: $cycle + validFrom: $validFrom + validTo: $validTo + maxAmountPerMonth: $maxAmountPerMonth + maxPerCycle: $maxPerCycle + ) { + amount + name + memo + code + link + createdAt + validFrom + validTo + maxAmountPerMonth + cycle + maxPerCycle + } + } +` From e1a84eb52e0313247b8185a7a69b5da23b11b090 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 14 Jun 2022 10:45:10 +0200 Subject: [PATCH 33/45] add enum cycle type for contribution links --- .../src/graphql/enum/ContributionCycleType.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 backend/src/graphql/enum/ContributionCycleType.ts diff --git a/backend/src/graphql/enum/ContributionCycleType.ts b/backend/src/graphql/enum/ContributionCycleType.ts new file mode 100644 index 000000000..5fe494a02 --- /dev/null +++ b/backend/src/graphql/enum/ContributionCycleType.ts @@ -0,0 +1,28 @@ +import { registerEnumType } from 'type-graphql' + +export enum ContributionCycleType { + ONCE = 'once', + HOUR = 'hour', + TWO_HOURS = 'two_hours', + FOUR_HOURS = 'four_hours', + EIGHT_HOURS = 'eight_hours', + HALF_DAY = 'half_day', + DAY = 'day', + TWO_DAYS = 'two_days', + THREE_DAYS = 'three_days', + FOUR_DAYS = 'four_days', + FIVE_DAYS = 'five_days', + SIX_DAYS = 'six_days', + WEEK = 'week', + TWO_WEEKS = 'two_weeks', + MONTH = 'month', + TWO_MONTH = 'two_month', + QUARTER = 'quarter', + HALF_YEAR = 'half_year', + YEAR = 'year', +} + +registerEnumType(ContributionCycleType, { + name: 'ContributionCycleType', // this one is mandatory + description: 'Name of the Type of the ContributionCycle', // this one is optional +}) From fd2f6a16b7b22cc61d8a7778728bc61f155443c5 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 14 Jun 2022 12:10:16 +0200 Subject: [PATCH 34/45] lsit contribution links query --- backend/src/auth/RIGHTS.ts | 1 + .../src/graphql/model/ContributionLinkList.ts | 11 ++++ .../graphql/resolver/AdminResolver.test.ts | 52 +++++++++++++++++++ backend/src/graphql/resolver/AdminResolver.ts | 18 +++++++ backend/src/seeds/graphql/queries.ts | 22 ++++++++ 5 files changed, 104 insertions(+) create mode 100644 backend/src/graphql/model/ContributionLinkList.ts diff --git a/backend/src/auth/RIGHTS.ts b/backend/src/auth/RIGHTS.ts index dcd0e44d6..a9270cd36 100644 --- a/backend/src/auth/RIGHTS.ts +++ b/backend/src/auth/RIGHTS.ts @@ -38,4 +38,5 @@ export enum RIGHTS { CREATION_TRANSACTION_LIST = 'CREATION_TRANSACTION_LIST', LIST_TRANSACTION_LINKS_ADMIN = 'LIST_TRANSACTION_LINKS_ADMIN', CREATE_CONTRIBUTION_LINK = 'CREATE_CONTRIBUTION_LINK', + LIST_CONTRIBUTION_LINKS = 'LIST_CONTRIBUTION_LINKS', } diff --git a/backend/src/graphql/model/ContributionLinkList.ts b/backend/src/graphql/model/ContributionLinkList.ts new file mode 100644 index 000000000..412d0bf7b --- /dev/null +++ b/backend/src/graphql/model/ContributionLinkList.ts @@ -0,0 +1,11 @@ +import { ObjectType, Field } from 'type-graphql' +import { ContributionLink } from '@model/ContributionLink' + +@ObjectType() +export class ContributionLinkList { + @Field(() => [ContributionLink]) + links: ContributionLink[] + + @Field(() => Number) + count: number +} diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index 6b0f295c7..8e700ce9b 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -27,6 +27,7 @@ import { login, searchUsers, listTransactionLinksAdmin, + listContributionLinks, } from '@/seeds/graphql/queries' import { GraphQLError } from 'graphql' import { User } from '@entity/User' @@ -1618,6 +1619,16 @@ describe('AdminResolver', () => { ) }) }) + + describe('listContributionLinks', () => { + it.only('returns an error', async () => { + await expect(query({ query: listContributionLinks })).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('401 Unauthorized')], + }), + ) + }) + }) }) describe('authenticated', () => { @@ -1644,6 +1655,16 @@ describe('AdminResolver', () => { ) }) }) + + describe('listContributionLinks', () => { + it.only('returns an error', async () => { + await expect(query({ query: listContributionLinks })).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('401 Unauthorized')], + }), + ) + }) + }) }) describe('with admin rights', () => { @@ -1708,6 +1729,37 @@ describe('AdminResolver', () => { ) }) }) + + describe('listContributionLinks', () => { + describe('one link in DB', () => { + it.only('returns the link and count 1', async () => { + await expect(query({ query: listContributionLinks })).resolves.toEqual( + expect.objectContaining({ + data: { + listContributionLinks: { + links: expect.arrayContaining([ + expect.objectContaining({ + amount: '200', + code: expect.stringMatching(/^CL-[0-9a-f]{24,24}$/), + link: expect.any(String), + createdAt: expect.any(String), + name: 'Dokumenta 2022', + memo: 'Danke für deine Teilnahme an der Dokumenta 2022', + validFrom: expect.any(String), + validTo: expect.any(String), + maxAmountPerMonth: '200', + cycle: 'once', + maxPerCycle: 1, + }), + ]), + count: 1, + }, + }, + }), + ) + }) + }) + }) }) }) }) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index d7c843611..e13a013b6 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -15,6 +15,7 @@ import { PendingCreation } from '@model/PendingCreation' import { CreatePendingCreations } from '@model/CreatePendingCreations' import { UpdatePendingCreation } from '@model/UpdatePendingCreation' import { ContributionLink } from '@model/ContributionLink' +import { ContributionLinkList } from '@model/ContributionLinkList' import { RIGHTS } from '@/auth/RIGHTS' import { UserRepository } from '@repository/User' import CreatePendingCreationArgs from '@arg/CreatePendingCreationArgs' @@ -494,6 +495,23 @@ export class AdminResolver { dbContributionLink.save() return new ContributionLink(dbContributionLink) } + + @Authorized([RIGHTS.LIST_CONTRIBUTION_LINKS]) + @Query(() => ContributionLinkList) + async listContributionLinks( + @Args() + { currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated, + ): Promise { + const [links, count] = await DbContributionLink.findAndCount({ + order: { createdAt: order }, + skip: (currentPage - 1) * pageSize, + take: pageSize, + }) + return { + links: links.map((link: DbContributionLink) => new ContributionLink(link)), + count, + } + } } interface CreationMap { diff --git a/backend/src/seeds/graphql/queries.ts b/backend/src/seeds/graphql/queries.ts index 03ee3b53e..9a0e00be3 100644 --- a/backend/src/seeds/graphql/queries.ts +++ b/backend/src/seeds/graphql/queries.ts @@ -217,3 +217,25 @@ export const listTransactionLinksAdmin = gql` } } ` + +export const listContributionLinks = gql` + query ($pageSize: Int = 25, $currentPage: Int = 1, $order: Order) { + listContributionLinks(pageSize: $pageSize, currentPage: $currentPage, order: $order) { + links { + id + amount + name + memo + code + link + createdAt + validFrom + validTo + maxAmountPerMonth + cycle + maxPerCycle + } + count + } + } +` From 8ba0a4af7c27c3d4fef0c54b452fa58bef9943e9 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 14 Jun 2022 12:11:43 +0200 Subject: [PATCH 35/45] no only in admin resolver tests --- backend/src/graphql/resolver/AdminResolver.test.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index 8e700ce9b..362a5b90b 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -1611,7 +1611,7 @@ describe('AdminResolver', () => { describe('unauthenticated', () => { describe('createContributionLink', () => { - it.only('returns an error', async () => { + it('returns an error', async () => { await expect(mutate({ mutation: createContributionLink, variables })).resolves.toEqual( expect.objectContaining({ errors: [new GraphQLError('401 Unauthorized')], @@ -1621,7 +1621,7 @@ describe('AdminResolver', () => { }) describe('listContributionLinks', () => { - it.only('returns an error', async () => { + it('returns an error', async () => { await expect(query({ query: listContributionLinks })).resolves.toEqual( expect.objectContaining({ errors: [new GraphQLError('401 Unauthorized')], @@ -1647,7 +1647,7 @@ describe('AdminResolver', () => { }) describe('createContributionLink', () => { - it.only('returns an error', async () => { + it('returns an error', async () => { await expect(mutate({ mutation: createContributionLink, variables })).resolves.toEqual( expect.objectContaining({ errors: [new GraphQLError('401 Unauthorized')], @@ -1657,7 +1657,7 @@ describe('AdminResolver', () => { }) describe('listContributionLinks', () => { - it.only('returns an error', async () => { + it('returns an error', async () => { await expect(query({ query: listContributionLinks })).resolves.toEqual( expect.objectContaining({ errors: [new GraphQLError('401 Unauthorized')], @@ -1682,7 +1682,7 @@ describe('AdminResolver', () => { }) describe('createContributionLink', () => { - it.only('returns a contribution link object', async () => { + it('returns a contribution link object', async () => { await expect(mutate({ mutation: createContributionLink, variables })).resolves.toEqual( expect.objectContaining({ data: { @@ -1704,7 +1704,7 @@ describe('AdminResolver', () => { ) }) - it.only('has a contribution link stored in db', async () => { + it('has a contribution link stored in db', async () => { const cls = await DbContributionLink.find() expect(cls).toHaveLength(1) expect(cls[0]).toEqual( @@ -1732,7 +1732,7 @@ describe('AdminResolver', () => { describe('listContributionLinks', () => { describe('one link in DB', () => { - it.only('returns the link and count 1', async () => { + it('returns the link and count 1', async () => { await expect(query({ query: listContributionLinks })).resolves.toEqual( expect.objectContaining({ data: { From fa30b871b71e848c624226e1477a5d6e2b27b02e Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 14 Jun 2022 13:12:41 +0200 Subject: [PATCH 36/45] delete contribution link mutation --- backend/src/auth/RIGHTS.ts | 1 + .../graphql/resolver/AdminResolver.test.ts | 72 +++++++++++++++++++ backend/src/graphql/resolver/AdminResolver.ts | 16 ++++- backend/src/seeds/graphql/mutations.ts | 6 ++ 4 files changed, 94 insertions(+), 1 deletion(-) diff --git a/backend/src/auth/RIGHTS.ts b/backend/src/auth/RIGHTS.ts index a9270cd36..f8fa38616 100644 --- a/backend/src/auth/RIGHTS.ts +++ b/backend/src/auth/RIGHTS.ts @@ -39,4 +39,5 @@ export enum RIGHTS { LIST_TRANSACTION_LINKS_ADMIN = 'LIST_TRANSACTION_LINKS_ADMIN', CREATE_CONTRIBUTION_LINK = 'CREATE_CONTRIBUTION_LINK', LIST_CONTRIBUTION_LINKS = 'LIST_CONTRIBUTION_LINKS', + DELETE_CONTRIBUTION_LINK = 'DELETE_CONTRIBUTION_LINK', } diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index 362a5b90b..32227f257 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -21,6 +21,7 @@ import { deletePendingCreation, confirmPendingCreation, createContributionLink, + deleteContributionLink, } from '@/seeds/graphql/mutations' import { getPendingCreations, @@ -1629,6 +1630,18 @@ describe('AdminResolver', () => { ) }) }) + + describe('deleteContributionLink', () => { + it('returns an error', async () => { + await expect( + mutate({ mutation: deleteContributionLink, variables: { id: -1 } }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('401 Unauthorized')], + }), + ) + }) + }) }) describe('authenticated', () => { @@ -1665,6 +1678,18 @@ describe('AdminResolver', () => { ) }) }) + + describe('deleteContributionLink', () => { + it('returns an error', async () => { + await expect( + mutate({ mutation: deleteContributionLink, variables: { id: -1 } }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('401 Unauthorized')], + }), + ) + }) + }) }) describe('with admin rights', () => { @@ -1760,6 +1785,53 @@ describe('AdminResolver', () => { }) }) }) + + describe('deleteContributionLink', () => { + describe('no valid id', () => { + it('returns an error', async () => { + await expect( + mutate({ mutation: deleteContributionLink, variables: { id: -1 } }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('Contribution Link not found to given id.')], + }), + ) + }) + }) + + describe('valid id', () => { + let linkId: number + beforeAll(async () => { + const links = await query({ query: listContributionLinks }) + linkId = links.data.listContributionLinks.links[0].id + }) + + it('returns a date string', async () => { + await expect( + mutate({ mutation: deleteContributionLink, variables: { id: linkId } }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + deleteContributionLink: expect.any(String), + }, + }), + ) + }) + + it('does not list this contribution link anymore', async () => { + await expect(query({ query: listContributionLinks })).resolves.toEqual( + expect.objectContaining({ + data: { + listContributionLinks: { + links: [], + count: 0, + }, + }, + }), + ) + }) + }) + }) }) }) }) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index e13a013b6..715d09d35 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -1,4 +1,5 @@ import { Context, getUser } from '@/server/context' +import { backendLogger as logger } from '@/server/logger' import { Resolver, Query, Arg, Args, Authorized, Mutation, Ctx, Int } from 'type-graphql' import { getCustomRepository, @@ -492,7 +493,7 @@ export class AdminResolver { if (validTo) dbContributionLink.validTo = new Date(validTo) dbContributionLink.maxAmountPerMonth = maxAmountPerMonth dbContributionLink.maxPerCycle = maxPerCycle - dbContributionLink.save() + await dbContributionLink.save() return new ContributionLink(dbContributionLink) } @@ -512,6 +513,19 @@ export class AdminResolver { count, } } + + @Authorized([RIGHTS.DELETE_CONTRIBUTION_LINK]) + @Mutation(() => Date, { nullable: true }) + async deleteContributionLink(@Arg('id', () => Int) id: number): Promise { + const contributionLink = await DbContributionLink.findOne(id) + if (!contributionLink) { + logger.error(`Contribution Link not found to given id: ${id}`) + throw new Error('Contribution Link not found to given id.') + } + await contributionLink.softRemove() + const newContributionLink = await DbContributionLink.findOne({ id }, { withDeleted: true }) + return newContributionLink ? newContributionLink.deletedAt : null + } } interface CreationMap { diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index 355b5aa79..7c334796e 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -173,3 +173,9 @@ export const createContributionLink = gql` } } ` + +export const deleteContributionLink = gql` + mutation ($id: Int!) { + deleteContributionLink(id: $id) + } +` From dc46f4e78c5d26af13871d4773e4c102c30238fe Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 14 Jun 2022 15:29:34 +0200 Subject: [PATCH 37/45] add update contribution link mutation --- backend/src/auth/RIGHTS.ts | 1 + .../graphql/resolver/AdminResolver.test.ts | 118 ++++++++++++++++++ backend/src/graphql/resolver/AdminResolver.ts | 33 +++++ backend/src/seeds/graphql/mutations.ts | 39 ++++++ 4 files changed, 191 insertions(+) diff --git a/backend/src/auth/RIGHTS.ts b/backend/src/auth/RIGHTS.ts index f8fa38616..8ac2c78cc 100644 --- a/backend/src/auth/RIGHTS.ts +++ b/backend/src/auth/RIGHTS.ts @@ -40,4 +40,5 @@ export enum RIGHTS { CREATE_CONTRIBUTION_LINK = 'CREATE_CONTRIBUTION_LINK', LIST_CONTRIBUTION_LINKS = 'LIST_CONTRIBUTION_LINKS', DELETE_CONTRIBUTION_LINK = 'DELETE_CONTRIBUTION_LINK', + UPDATE_CONTRIBUTION_LINK = 'UPDATE_CONTRIBUTION_LINK', } diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index 32227f257..d08c52320 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -22,6 +22,7 @@ import { confirmPendingCreation, createContributionLink, deleteContributionLink, + updateContributionLink, } from '@/seeds/graphql/mutations' import { getPendingCreations, @@ -1631,6 +1632,27 @@ describe('AdminResolver', () => { }) }) + describe('updateContributionLink', () => { + it('returns an error', async () => { + await expect( + mutate({ + mutation: updateContributionLink, + variables: { + ...variables, + id: -1, + amount: new Decimal(400), + name: 'Dokumenta 2023', + memo: 'Danke für deine Teilnahme an der Dokumenta 2023', + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('401 Unauthorized')], + }), + ) + }) + }) + describe('deleteContributionLink', () => { it('returns an error', async () => { await expect( @@ -1679,6 +1701,27 @@ describe('AdminResolver', () => { }) }) + describe('updateContributionLink', () => { + it('returns an error', async () => { + await expect( + mutate({ + mutation: updateContributionLink, + variables: { + ...variables, + id: -1, + amount: new Decimal(400), + name: 'Dokumenta 2023', + memo: 'Danke für deine Teilnahme an der Dokumenta 2023', + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('401 Unauthorized')], + }), + ) + }) + }) + describe('deleteContributionLink', () => { it('returns an error', async () => { await expect( @@ -1786,6 +1829,81 @@ describe('AdminResolver', () => { }) }) + describe('updateContributionLink', () => { + describe('no valid id', () => { + it('returns an error', async () => { + await expect( + mutate({ + mutation: updateContributionLink, + variables: { + ...variables, + id: -1, + amount: new Decimal(400), + name: 'Dokumenta 2023', + memo: 'Danke für deine Teilnahme an der Dokumenta 2023', + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('Contribution Link not found to given id.')], + }), + ) + }) + }) + + describe('valid id', () => { + let linkId: number + beforeAll(async () => { + const links = await query({ query: listContributionLinks }) + linkId = links.data.listContributionLinks.links[0].id + }) + + it('returns updated contribution link object', async () => { + await expect( + mutate({ + mutation: updateContributionLink, + variables: { + ...variables, + id: linkId, + amount: new Decimal(400), + name: 'Dokumenta 2023', + memo: 'Danke für deine Teilnahme an der Dokumenta 2023', + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + updateContributionLink: { + id: linkId, + amount: '400', + code: expect.stringMatching(/^CL-[0-9a-f]{24,24}$/), + link: expect.any(String), + createdAt: expect.any(String), + name: 'Dokumenta 2023', + memo: 'Danke für deine Teilnahme an der Dokumenta 2023', + validFrom: expect.any(String), + validTo: expect.any(String), + maxAmountPerMonth: '200', + cycle: 'once', + maxPerCycle: 1, + }, + }, + }), + ) + }) + + it('updated the DB record', async () => { + await expect(DbContributionLink.findOne(linkId)).resolves.toEqual( + expect.objectContaining({ + id: linkId, + name: 'Dokumenta 2023', + memo: 'Danke für deine Teilnahme an der Dokumenta 2023', + }), + ) + }) + }) + }) + describe('deleteContributionLink', () => { describe('no valid id', () => { it('returns an error', async () => { diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 715d09d35..785a7de02 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -526,6 +526,39 @@ export class AdminResolver { const newContributionLink = await DbContributionLink.findOne({ id }, { withDeleted: true }) return newContributionLink ? newContributionLink.deletedAt : null } + + @Authorized([RIGHTS.UPDATE_CONTRIBUTION_LINK]) + @Mutation(() => ContributionLink) + async updateContributionLink( + @Args() + { + amount, + name, + memo, + cycle, + validFrom, + validTo, + maxAmountPerMonth, + maxPerCycle, + }: ContributionLinkArgs, + @Arg('id', () => Int) id: number, + ): Promise { + const dbContributionLink = await DbContributionLink.findOne(id) + if (!dbContributionLink) { + logger.error(`Contribution Link not found to given id: ${id}`) + throw new Error('Contribution Link not found to given id.') + } + dbContributionLink.amount = amount + dbContributionLink.name = name + dbContributionLink.memo = memo + dbContributionLink.cycle = cycle + if (validFrom) dbContributionLink.validFrom = new Date(validFrom) + if (validTo) dbContributionLink.validTo = new Date(validTo) + dbContributionLink.maxAmountPerMonth = maxAmountPerMonth + dbContributionLink.maxPerCycle = maxPerCycle + await dbContributionLink.save() + return new ContributionLink(dbContributionLink) + } } interface CreationMap { diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index 7c334796e..c0f0fa6e4 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -174,6 +174,45 @@ export const createContributionLink = gql` } ` +export const updateContributionLink = gql` + mutation ( + $amount: Decimal! + $name: String! + $memo: String! + $cycle: String! + $validFrom: String + $validTo: String + $maxAmountPerMonth: Decimal + $maxPerCycle: Int! = 1 + $id: Int! + ) { + updateContributionLink( + amount: $amount + name: $name + memo: $memo + cycle: $cycle + validFrom: $validFrom + validTo: $validTo + maxAmountPerMonth: $maxAmountPerMonth + maxPerCycle: $maxPerCycle + id: $id + ) { + id + amount + name + memo + code + link + createdAt + validFrom + validTo + maxAmountPerMonth + cycle + maxPerCycle + } + } +` + export const deleteContributionLink = gql` mutation ($id: Int!) { deleteContributionLink(id: $id) From 26a653fd7db50ce239e3d457ef4dc38e246d96c8 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 14 Jun 2022 17:14:09 +0200 Subject: [PATCH 38/45] coverage backend to 70% --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b7000100e..b935ef8f4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -528,7 +528,7 @@ jobs: report_name: Coverage Backend type: lcov result_path: ./backend/coverage/lcov.info - min_coverage: 68 + min_coverage: 70 token: ${{ github.token }} ########################################################################## From 7640680c421b1205e195723abe06fe45e5c43fe2 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 14 Jun 2022 18:04:20 +0200 Subject: [PATCH 39/45] seed two ContributionLinks --- .../graphql/resolver/AdminResolver.test.ts | 1 + .../ContributionLinkInterface.ts | 7 +++++ backend/src/seeds/contributionLink/index.ts | 18 +++++++++++++ backend/src/seeds/factory/contributionLink.ts | 27 +++++++++++++++++++ backend/src/seeds/index.ts | 7 +++++ 5 files changed, 60 insertions(+) create mode 100644 backend/src/seeds/contributionLink/ContributionLinkInterface.ts create mode 100644 backend/src/seeds/contributionLink/index.ts create mode 100644 backend/src/seeds/factory/contributionLink.ts diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index d08c52320..a1a92dace 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -1898,6 +1898,7 @@ describe('AdminResolver', () => { id: linkId, name: 'Dokumenta 2023', memo: 'Danke für deine Teilnahme an der Dokumenta 2023', + // amount: '400', }), ) }) diff --git a/backend/src/seeds/contributionLink/ContributionLinkInterface.ts b/backend/src/seeds/contributionLink/ContributionLinkInterface.ts new file mode 100644 index 000000000..d213bff23 --- /dev/null +++ b/backend/src/seeds/contributionLink/ContributionLinkInterface.ts @@ -0,0 +1,7 @@ +export interface ContributionLinkInterface { + amount: number + name: string + memo: string + validFrom?: date + validTo?: date +} diff --git a/backend/src/seeds/contributionLink/index.ts b/backend/src/seeds/contributionLink/index.ts new file mode 100644 index 000000000..41d28eb60 --- /dev/null +++ b/backend/src/seeds/contributionLink/index.ts @@ -0,0 +1,18 @@ +import { ContributionLinkInterface } from './ContributionLinkInterface' + +export const contributionLinks: ContributionLinkInterface[] = [ + { + name: 'Dokumenta 2017', + memo: 'Vielen Dank für deinen Besuch bei der Dokumenta 2017', + amount: 200, + validFrom: new Date(2017, 3, 8), + validTo: new Date(2017, 6, 16), + }, + { + name: 'Dokumenta 2022', + memo: 'Vielen Dank für deinen Besuch bei der Dokumenta 2022', + amount: 200, + validFrom: new Date(2022, 5, 18), + validTo: new Date(2022, 8, 25), + }, +] diff --git a/backend/src/seeds/factory/contributionLink.ts b/backend/src/seeds/factory/contributionLink.ts new file mode 100644 index 000000000..7e34b9d20 --- /dev/null +++ b/backend/src/seeds/factory/contributionLink.ts @@ -0,0 +1,27 @@ +import { ApolloServerTestClient } from 'apollo-server-testing' +import { createContributionLink } from '@/seeds/graphql/mutations' +import { login } from '@/seeds/graphql/queries' +import { ContributionLinkInterface } from '@/seeds/contributionLink/ContributionLinkInterface' + +export const contributionLinkFactory = async ( + client: ApolloServerTestClient, + contributionLink: ContributionLinkInterface, +): Promise => { + const { mutate, query } = client + + // login as admin + await query({ query: login, variables: { email: 'peter@lustig.de', password: 'Aa12345_' } }) + + const variables = { + amount: contributionLink.amount, + memo: contributionLink.memo, + name: contributionLink.name, + cycle: 'ONCE', + maxPerCycle: 1, + maxAmountPerMonth: 200, + validFrom: contributionLink.validFrom ? contributionLink.validFrom.toISOString() : undefined, + validTo: contributionLink.validTo ? contributionLink.validTo.toISOString() : undefined, + } + + await mutate({ mutation: createContributionLink, variables }) +} diff --git a/backend/src/seeds/index.ts b/backend/src/seeds/index.ts index 710f255ee..8e9a4e2d8 100644 --- a/backend/src/seeds/index.ts +++ b/backend/src/seeds/index.ts @@ -9,9 +9,11 @@ import { name, internet, datatype } from 'faker' 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 { creationFactory } from './factory/creation' import { transactionLinkFactory } from './factory/transactionLink' +import { contributionLinkFactory } from './factory/contributionLink' import { entities } from '@entity/index' import CONFIG from '@/config' @@ -77,6 +79,11 @@ const run = async () => { await transactionLinkFactory(seedClient, transactionLinks[i]) } + // create Contribution Links + for (let i = 0; i < contributionLinks.length; i++) { + await contributionLinkFactory(seedClient, contributionLinks[i]) + } + await con.close() } From dcc1e9c2e7f9efe7d3f9ee98c845cd5d402bee2d Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 14 Jun 2022 19:19:12 +0200 Subject: [PATCH 40/45] proper type in seed --- .../src/seeds/contributionLink/ContributionLinkInterface.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/seeds/contributionLink/ContributionLinkInterface.ts b/backend/src/seeds/contributionLink/ContributionLinkInterface.ts index d213bff23..15ba4b72d 100644 --- a/backend/src/seeds/contributionLink/ContributionLinkInterface.ts +++ b/backend/src/seeds/contributionLink/ContributionLinkInterface.ts @@ -2,6 +2,6 @@ export interface ContributionLinkInterface { amount: number name: string memo: string - validFrom?: date - validTo?: date + validFrom?: Date + validTo?: Date } From ad3bb58d433251f437b65f8bef2b3df889e85758 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 15 Jun 2022 15:19:29 +0200 Subject: [PATCH 41/45] createContributionLink response contains contribution id --- backend/src/graphql/resolver/AdminResolver.test.ts | 1 + backend/src/seeds/graphql/mutations.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index a1a92dace..06a11d8c2 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -1755,6 +1755,7 @@ describe('AdminResolver', () => { expect.objectContaining({ data: { createContributionLink: expect.objectContaining({ + id: expect.any(Number), amount: '200', code: expect.stringMatching(/^CL-[0-9a-f]{24,24}$/), link: expect.any(String), diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index c0f0fa6e4..253f78e2a 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -159,6 +159,7 @@ export const createContributionLink = gql` maxAmountPerMonth: $maxAmountPerMonth maxPerCycle: $maxPerCycle ) { + id amount name memo From 4d58320426e11980d3078a174c63759db62aa369 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 15 Jun 2022 15:29:10 +0200 Subject: [PATCH 42/45] new backend config version to have COMMUNITY_REDEEM_CONTRIBUTION_URL --- backend/.env.dist | 3 ++- backend/.env.template | 1 + backend/src/config/index.ts | 4 +++- backend/src/graphql/model/ContributionLink.ts | 2 +- deployment/bare_metal/.env.dist | 3 ++- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/.env.dist b/backend/.env.dist index 62b786456..41eeeaf58 100644 --- a/backend/.env.dist +++ b/backend/.env.dist @@ -1,4 +1,4 @@ -CONFIG_VERSION=v6.2022-04-21 +CONFIG_VERSION=v7.2022-06-15 # Server PORT=4000 @@ -28,6 +28,7 @@ COMMUNITY_NAME=Gradido Entwicklung COMMUNITY_URL=http://localhost/ COMMUNITY_REGISTER_URL=http://localhost/register COMMUNITY_REDEEM_URL=http://localhost/redeem/{code} +COMMUNITY_REDEEM_CONTRIBUTION_URL=http://localhost/redeem/CL-{code} COMMUNITY_DESCRIPTION=Die lokale Entwicklungsumgebung von Gradido. # Login Server diff --git a/backend/.env.template b/backend/.env.template index 140ec67e9..284abc204 100644 --- a/backend/.env.template +++ b/backend/.env.template @@ -27,6 +27,7 @@ COMMUNITY_NAME=$COMMUNITY_NAME COMMUNITY_URL=$COMMUNITY_URL COMMUNITY_REGISTER_URL=$COMMUNITY_REGISTER_URL COMMUNITY_REDEEM_URL=$COMMUNITY_REDEEM_URL +COMMUNITY_REDEEM_CONTRIBUTION_URL=$COMMUNITY_REDEEM_CONTRIBUTION_URL COMMUNITY_DESCRIPTION=$COMMUNITY_DESCRIPTION # Login Server diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 5736e6d8a..dafcd4bf0 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -17,7 +17,7 @@ const constants = { LOG_LEVEL: process.env.LOG_LEVEL || 'info', CONFIG_VERSION: { DEFAULT: 'DEFAULT', - EXPECTED: 'v6.2022-04-21', + EXPECTED: 'v7.2022-06-15', CURRENT: '', }, } @@ -54,6 +54,8 @@ const community = { COMMUNITY_URL: process.env.COMMUNITY_URL || 'http://localhost/', COMMUNITY_REGISTER_URL: process.env.COMMUNITY_REGISTER_URL || 'http://localhost/register', COMMUNITY_REDEEM_URL: process.env.COMMUNITY_REDEEM_URL || 'http://localhost/redeem/{code}', + COMMUNITY_REDEEM_CONTRIBUTION_URL: + process.env.COMMUNITY_REDEEM_CONTRIBUTION_URL || 'http://localhost/redeem/CL-{code}', COMMUNITY_DESCRIPTION: process.env.COMMUNITY_DESCRIPTION || 'Die lokale Entwicklungsumgebung von Gradido.', } diff --git a/backend/src/graphql/model/ContributionLink.ts b/backend/src/graphql/model/ContributionLink.ts index e4b37ad59..87c3f7824 100644 --- a/backend/src/graphql/model/ContributionLink.ts +++ b/backend/src/graphql/model/ContributionLink.ts @@ -18,7 +18,7 @@ export class ContributionLink { this.cycle = contributionLink.cycle this.maxPerCycle = contributionLink.maxPerCycle this.code = 'CL-' + contributionLink.code - this.link = CONFIG.COMMUNITY_REDEEM_URL.replace(/{code}/g, this.code) + this.link = CONFIG.COMMUNITY_REDEEM_CONTRIBUTION_URL.replace(/{code}/g, this.code) } @Field(() => Number) diff --git a/deployment/bare_metal/.env.dist b/deployment/bare_metal/.env.dist index a1751a859..d9e159382 100644 --- a/deployment/bare_metal/.env.dist +++ b/deployment/bare_metal/.env.dist @@ -22,10 +22,11 @@ COMMUNITY_NAME="Gradido Development Stage1" COMMUNITY_URL=https://stage1.gradido.net/ COMMUNITY_REGISTER_URL=https://stage1.gradido.net/register COMMUNITY_REDEEM_URL=https://stage1.gradido.net/redeem/{code} +COMMUNITY_REDEEM_CONTRIBUTION_URL=https://stage1.gradido.net/redeem/CL-{code} COMMUNITY_DESCRIPTION="Gradido Development Stage1 Test Community" # backend -BACKEND_CONFIG_VERSION=v6.2022-04-21 +BACKEND_CONFIG_VERSION=v7.2022-06-15 JWT_EXPIRES_IN=30m GDT_API_URL=https://gdt.gradido.net From fbb629cac5fe9a581280d3e24dc1cbd050c46427 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 15 Jun 2022 15:52:11 +0200 Subject: [PATCH 43/45] remove CL-prefix --- backend/src/graphql/model/ContributionLink.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/graphql/model/ContributionLink.ts b/backend/src/graphql/model/ContributionLink.ts index 87c3f7824..9fe9eccd6 100644 --- a/backend/src/graphql/model/ContributionLink.ts +++ b/backend/src/graphql/model/ContributionLink.ts @@ -17,7 +17,7 @@ export class ContributionLink { this.maxAmountPerMonth = contributionLink.maxAmountPerMonth this.cycle = contributionLink.cycle this.maxPerCycle = contributionLink.maxPerCycle - this.code = 'CL-' + contributionLink.code + this.code = contributionLink.code this.link = CONFIG.COMMUNITY_REDEEM_CONTRIBUTION_URL.replace(/{code}/g, this.code) } From 64a7f4aa6ff9f20b6559c1f5104630caf5ce1956 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 15 Jun 2022 16:04:14 +0200 Subject: [PATCH 44/45] remove CL-prefix for contribution links in tests --- backend/src/graphql/resolver/AdminResolver.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index 06a11d8c2..d55795f6e 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -1757,7 +1757,7 @@ describe('AdminResolver', () => { createContributionLink: expect.objectContaining({ id: expect.any(Number), amount: '200', - code: expect.stringMatching(/^CL-[0-9a-f]{24,24}$/), + code: expect.stringMatching(/^[0-9a-f]{24,24}$/), link: expect.any(String), createdAt: expect.any(String), name: 'Dokumenta 2022', @@ -1809,7 +1809,7 @@ describe('AdminResolver', () => { links: expect.arrayContaining([ expect.objectContaining({ amount: '200', - code: expect.stringMatching(/^CL-[0-9a-f]{24,24}$/), + code: expect.stringMatching(/^[0-9a-f]{24,24}$/), link: expect.any(String), createdAt: expect.any(String), name: 'Dokumenta 2022', @@ -1877,7 +1877,7 @@ describe('AdminResolver', () => { updateContributionLink: { id: linkId, amount: '400', - code: expect.stringMatching(/^CL-[0-9a-f]{24,24}$/), + code: expect.stringMatching(/^[0-9a-f]{24,24}$/), link: expect.any(String), createdAt: expect.any(String), name: 'Dokumenta 2023', From 5b7cb5cdf45e472f12fd8262d7d3548ea216a7fd Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 15 Jun 2022 16:08:16 +0200 Subject: [PATCH 45/45] test CL-prefix on contribution links --- backend/src/graphql/resolver/AdminResolver.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index d55795f6e..7417b529e 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -1758,7 +1758,7 @@ describe('AdminResolver', () => { id: expect.any(Number), amount: '200', code: expect.stringMatching(/^[0-9a-f]{24,24}$/), - link: expect.any(String), + link: expect.stringMatching(/^.*?\/CL-[0-9a-f]{24,24}$/), createdAt: expect.any(String), name: 'Dokumenta 2022', memo: 'Danke für deine Teilnahme an der Dokumenta 2022', @@ -1810,7 +1810,7 @@ describe('AdminResolver', () => { expect.objectContaining({ amount: '200', code: expect.stringMatching(/^[0-9a-f]{24,24}$/), - link: expect.any(String), + link: expect.stringMatching(/^.*?\/CL-[0-9a-f]{24,24}$/), createdAt: expect.any(String), name: 'Dokumenta 2022', memo: 'Danke für deine Teilnahme an der Dokumenta 2022', @@ -1878,7 +1878,7 @@ describe('AdminResolver', () => { id: linkId, amount: '400', code: expect.stringMatching(/^[0-9a-f]{24,24}$/), - link: expect.any(String), + link: expect.stringMatching(/^.*?\/CL-[0-9a-f]{24,24}$/), createdAt: expect.any(String), name: 'Dokumenta 2023', memo: 'Danke für deine Teilnahme an der Dokumenta 2023',