Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BC-5835 Add Task to KNL Deletion module #4667

Merged
merged 28 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
bfec4ab
add service in task, modify DomainModel interface
WojciechGrancow Dec 27, 2023
9a71631
Merge branch 'main' into BC-5835-Add-Task-to-KNLDeletion
WojciechGrancow Dec 27, 2023
cefceb2
add test for domainOperatioNuilder, taskEntity
WojciechGrancow Dec 27, 2023
6a1cf11
fix in deletion module imports&exports
WojciechGrancow Dec 27, 2023
daa7b46
fix in deletionController
WojciechGrancow Dec 27, 2023
f181ba4
add tests in taskRepo
WojciechGrancow Dec 27, 2023
93799cf
add test for taskScope
WojciechGrancow Dec 27, 2023
a5f4288
add test for taskService
WojciechGrancow Dec 28, 2023
93df751
Merge branch 'main' into BC-5835-Add-Task-to-KNLDeletion
WojciechGrancow Dec 28, 2023
0e9c89e
fixes in Task entity
WojciechGrancow Dec 28, 2023
24acc6d
connect deletion module with taskService
WojciechGrancow Dec 28, 2023
15883e4
some fixes in task entity
WojciechGrancow Dec 28, 2023
4f7f0b2
change in task entity
WojciechGrancow Dec 28, 2023
11fd1a6
Update apps/server/src/modules/deletion/deletion-api.module.ts
WojciechGrancow Jan 2, 2024
69aff64
move builder, fix imports
WojciechGrancow Jan 3, 2024
e21ee86
fix in taskService
WojciechGrancow Jan 3, 2024
7df7071
splitting the removeCreatorId method
WojciechGrancow Jan 3, 2024
f6f1052
fix in deletion module, delete removeUserFromTasks from taskService
WojciechGrancow Jan 4, 2024
90df3e8
Merge branch 'main' into BC-5835-Add-Task-to-KNLDeletion
WojciechGrancow Jan 4, 2024
dcda093
add findByUserIdInFinished method in repo and test cases for it
WojciechGrancow Jan 4, 2024
2943bdf
fix testcases in deletion UC
WojciechGrancow Jan 4, 2024
e75fd0f
modify task services to delete user data
WojciechGrancow Jan 4, 2024
46016f2
Update apps/server/src/modules/task/service/task.service.ts
WojciechGrancow Jan 5, 2024
b59ce36
Merge branch 'main' into BC-5835-Add-Task-to-KNLDeletion
WojciechGrancow Jan 5, 2024
9adea9a
fix after review
WojciechGrancow Jan 5, 2024
4c22954
fix imports and add logger to services in TaskService
WojciechGrancow Jan 5, 2024
5318123
Merge branch 'main' into BC-5835-Add-Task-to-KNLDeletion
WojciechGrancow Jan 5, 2024
aa0425b
fix in imports
WojciechGrancow Jan 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeletionDomainModel } from '../domain/types';
import { DomainModel } from '@shared/domain/types';
import { DeletionLogStatisticBuilder } from '.';

describe(DeletionLogStatisticBuilder.name, () => {
Expand All @@ -8,7 +8,7 @@ describe(DeletionLogStatisticBuilder.name, () => {

it('should build generic deletionLogStatistic with all attributes', () => {
// Arrange
const domain = DeletionDomainModel.PSEUDONYMS;
const domain = DomainModel.PSEUDONYMS;
const modifiedCount = 0;
const deletedCount = 2;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { DeletionDomainModel } from '../domain/types';
import { DeletionLogStatistic } from '../interface';
import { DomainOperation } from '@shared/domain/interface';
import { DomainModel } from '@shared/domain/types';

export class DeletionLogStatisticBuilder {
static build(domain: DeletionDomainModel, modifiedCount?: number, deletedCount?: number): DeletionLogStatistic {
const deletionLogStatistic = { domain, modifiedCount, deletedCount };
static build(
domain: DomainModel,
modifiedCount: number,
deletedCount: number,
modifiedRef?: string[],
deletedRef?: string[]
): DomainOperation {
const deletionLogStatistic = { domain, modifiedCount, deletedCount, modifiedRef, deletedRef };

return deletionLogStatistic;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ObjectId } from 'bson';
import { DeletionDomainModel } from '../domain/types';
import { DomainModel } from '@shared/domain/types';
import { DeletionRequestBodyPropsBuilder } from './deletion-request-body-props.builder';

describe(DeletionRequestBodyPropsBuilder.name, () => {
Expand All @@ -8,7 +8,7 @@ describe(DeletionRequestBodyPropsBuilder.name, () => {
});
describe('when create deletionRequestBodyParams', () => {
const setup = () => {
const domain = DeletionDomainModel.PSEUDONYMS;
const domain = DomainModel.PSEUDONYMS;
const refId = new ObjectId().toHexString();
const deleteInMinutes = 1000;
return { domain, refId, deleteInMinutes };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { EntityId } from '@shared/domain/types';
import { DomainModel, EntityId } from '@shared/domain/types';
import { DeletionRequestBodyProps } from '../controller/dto';
import { DeletionDomainModel } from '../domain/types';

export class DeletionRequestBodyPropsBuilder {
static build(domain: DeletionDomainModel, id: EntityId, deleteInMinutes?: number): DeletionRequestBodyProps {
static build(domain: DomainModel, id: EntityId, deleteInMinutes?: number): DeletionRequestBodyProps {
const deletionRequestItem = {
targetRef: { domain, id },
deleteInMinutes,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeletionDomainModel } from '../domain/types';
import { DomainModel } from '@shared/domain/types';
import { DeletionLogStatisticBuilder, DeletionRequestLogResponseBuilder, DeletionTargetRefBuilder } from '.';

describe(DeletionRequestLogResponseBuilder, () => {
Expand All @@ -8,7 +8,7 @@ describe(DeletionRequestLogResponseBuilder, () => {

it('should build generic deletionRequestLog with all attributes', () => {
// Arrange
const targetRefDomain = DeletionDomainModel.PSEUDONYMS;
const targetRefDomain = DomainModel.PSEUDONYMS;
const targetRefId = '653e4833cc39e5907a1e18d2';
const targetRef = DeletionTargetRefBuilder.build(targetRefDomain, targetRefId);
const deletionPlannedAt = new Date();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { DomainOperation } from '@shared/domain/interface';
import { DeletionRequestLogResponse } from '../controller/dto';
import { DeletionLogStatistic, DeletionTargetRef } from '../interface';
import { DeletionTargetRef } from '../interface';

export class DeletionRequestLogResponseBuilder {
static build(
targetRef: DeletionTargetRef,
deletionPlannedAt: Date,
statistics?: DeletionLogStatistic[]
statistics?: DomainOperation[]
): DeletionRequestLogResponse {
const deletionRequestLog = { targetRef, deletionPlannedAt, statistics };

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeletionDomainModel } from '../domain/types';
import { DomainModel } from '@shared/domain/types';
import { DeletionTargetRefBuilder } from './index';

describe(DeletionTargetRefBuilder.name, () => {
Expand All @@ -8,7 +8,7 @@ describe(DeletionTargetRefBuilder.name, () => {

it('should build generic deletionTargetRef with all attributes', () => {
// Arrange
const domain = DeletionDomainModel.PSEUDONYMS;
const domain = DomainModel.PSEUDONYMS;
const refId = '653e4833cc39e5907a1e18d2';

const result = DeletionTargetRefBuilder.build(domain, refId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { EntityId } from '@shared/domain/types';
import { DeletionDomainModel } from '../domain/types';
import { DomainModel, EntityId } from '@shared/domain/types';
import { DeletionTargetRef } from '../interface';

export class DeletionTargetRefBuilder {
static build(domain: DeletionDomainModel, id: EntityId): DeletionTargetRef {
static build(domain: DomainModel, id: EntityId): DeletionTargetRef {
const deletionTargetRef = { domain, id };

return deletionTargetRef;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { AuthGuard } from '@nestjs/passport';
import { EntityManager } from '@mikro-orm/mongodb';
import { TestXApiKeyClient } from '@shared/testing';
import { AdminApiServerTestModule } from '@modules/server/admin-api.server.module';
import { DomainModel } from '@shared/domain/types';
import { DeletionRequestBodyProps, DeletionRequestResponse } from '../dto';
import { DeletionDomainModel } from '../../domain/types';
import { DeletionRequestEntity } from '../../entity';

const baseRouteName = '/deletionRequests';
Expand Down Expand Up @@ -86,14 +86,14 @@ describe(`deletionRequest create (api)`, () => {
const setup = () => {
const deletionRequestToCreate: DeletionRequestBodyProps = {
targetRef: {
domain: DeletionDomainModel.USER,
domain: DomainModel.USER,
id: '653e4833cc39e5907a1e18d2',
},
};

const deletionRequestToImmediateRemoval: DeletionRequestBodyProps = {
targetRef: {
domain: DeletionDomainModel.USER,
domain: DomainModel.USER,
id: '653e4833cc39e5907a1e18d2',
},
deleteInMinutes: 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ObjectId } from 'bson';
import { DeletionDomainModel } from '../../domain/types';
import { DomainModel } from '@shared/domain/types';
import { DeletionLogStatisticBuilder, DeletionTargetRefBuilder } from '../../builder';
import { DeletionRequestLogResponse } from './index';

describe(DeletionRequestLogResponse.name, () => {
describe('constructor', () => {
describe('when passed properties', () => {
const setup = () => {
const targetRefDomain = DeletionDomainModel.PSEUDONYMS;
const targetRefDomain = DomainModel.PSEUDONYMS;
const targetRefId = new ObjectId().toHexString();
const targetRef = DeletionTargetRefBuilder.build(targetRefDomain, targetRefId);
const deletionPlannedAt = new Date();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsOptional } from 'class-validator';
import { DeletionLogStatistic, DeletionTargetRef } from '../../interface';
import { DomainOperation } from '@shared/domain/interface';
import { DeletionTargetRef } from '../../interface';

export class DeletionRequestLogResponse {
@ApiProperty()
Expand All @@ -11,7 +12,7 @@ export class DeletionRequestLogResponse {

@ApiProperty()
@IsOptional()
statistics?: DeletionLogStatistic[];
statistics?: DomainOperation[];

constructor(response: DeletionRequestLogResponse) {
this.targetRef = response.targetRef;
Expand Down
2 changes: 2 additions & 0 deletions apps/server/src/modules/deletion/deletion-api.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { RocketChatUserModule } from '@modules/rocketchat-user';
import { Configuration } from '@hpi-schul-cloud/commons';
import { RocketChatModule } from '@modules/rocketchat';
import { RegistrationPinModule } from '@modules/registration-pin';
import { TaskModule } from '@modules/task';
import { DeletionRequestsController } from './controller/deletion-requests.controller';
import { DeletionExecutionsController } from './controller/deletion-executions.controller';
import { DeletionRequestUc } from './uc';
Expand All @@ -35,6 +36,7 @@ import { FilesStorageClientModule } from '../files-storage-client';
RocketChatUserModule,
RegistrationPinModule,
FilesStorageClientModule,
TaskModule,
RocketChatModule.forRoot({
uri: Configuration.get('ROCKET_CHAT_URI') as string,
adminId: Configuration.get('ROCKET_CHAT_ADMIN_ID') as string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ObjectId } from '@mikro-orm/mongodb';
import { DomainModel } from '@shared/domain/types';
import { deletionLogFactory } from './testing/factory/deletion-log.factory';
import { DeletionLog } from './deletion-log.do';
import { DeletionOperationModel, DeletionDomainModel } from './types';
import { DeletionOperationModel } from './types';

describe(DeletionLog.name, () => {
describe('constructor', () => {
Expand Down Expand Up @@ -35,7 +36,7 @@ describe(DeletionLog.name, () => {
const setup = () => {
const props = {
id: new ObjectId().toHexString(),
domain: DeletionDomainModel.USER,
domain: DomainModel.USER,
operation: DeletionOperationModel.DELETE,
modifiedCount: 0,
deletedCount: 1,
Expand Down
16 changes: 8 additions & 8 deletions apps/server/src/modules/deletion/domain/deletion-log.do.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { EntityId } from '@shared/domain/types';
import { DomainModel, EntityId } from '@shared/domain/types';
import { AuthorizableObject, DomainObject } from '@shared/domain/domain-object';
import { DeletionDomainModel, DeletionOperationModel } from './types';
import { DeletionOperationModel } from './types';

export interface DeletionLogProps extends AuthorizableObject {
createdAt?: Date;
updatedAt?: Date;
domain: DeletionDomainModel;
domain: DomainModel;
operation?: DeletionOperationModel;
modifiedCount?: number;
deletedCount?: number;
modifiedCount: number;
deletedCount: number;
deletionRequestId?: EntityId;
performedAt?: Date;
}
Expand All @@ -22,19 +22,19 @@ export class DeletionLog extends DomainObject<DeletionLogProps> {
return this.props.updatedAt;
}

get domain(): DeletionDomainModel {
get domain(): DomainModel {
return this.props.domain;
}

get operation(): DeletionOperationModel | undefined {
return this.props.operation;
}

get modifiedCount(): number | undefined {
get modifiedCount(): number {
return this.props.modifiedCount;
}

get deletedCount(): number | undefined {
get deletedCount(): number {
return this.props.deletedCount;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ObjectId } from '@mikro-orm/mongodb';
import { DomainModel } from '@shared/domain/types';
import { DeletionRequest } from './deletion-request.do';
import { DeletionDomainModel, DeletionStatusModel } from './types';
import { DeletionStatusModel } from './types';
import { deletionRequestFactory } from './testing/factory/deletion-request.factory';

describe(DeletionRequest.name, () => {
Expand Down Expand Up @@ -35,7 +36,7 @@ describe(DeletionRequest.name, () => {
const setup = () => {
const props = {
id: new ObjectId().toHexString(),
targetRefDomain: DeletionDomainModel.USER,
targetRefDomain: DomainModel.USER,
deleteAfter: new Date(),
targetRefId: new ObjectId().toHexString(),
status: DeletionStatusModel.REGISTERED,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { EntityId } from '@shared/domain/types';
import { DomainModel, EntityId } from '@shared/domain/types';
import { AuthorizableObject, DomainObject } from '@shared/domain/domain-object';
import { DeletionDomainModel, DeletionStatusModel } from './types';
import { DeletionStatusModel } from './types';

export interface DeletionRequestProps extends AuthorizableObject {
createdAt?: Date;
updatedAt?: Date;
targetRefDomain: DeletionDomainModel;
targetRefDomain: DomainModel;
deleteAfter: Date;
targetRefId: EntityId;
status: DeletionStatusModel;
Expand All @@ -20,7 +20,7 @@ export class DeletionRequest extends DomainObject<DeletionRequestProps> {
return this.props.updatedAt;
}

get targetRefDomain(): DeletionDomainModel {
get targetRefDomain(): DomainModel {
return this.props.targetRefDomain;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { DoBaseFactory } from '@shared/testing';
import { ObjectId } from '@mikro-orm/mongodb';
import { DomainModel } from '@shared/domain/types';
import { DeletionLog, DeletionLogProps } from '../../deletion-log.do';
import { DeletionOperationModel, DeletionDomainModel } from '../../types';
import { DeletionOperationModel } from '../../types';

export const deletionLogFactory = DoBaseFactory.define<DeletionLog, DeletionLogProps>(DeletionLog, () => {
return {
id: new ObjectId().toHexString(),
domain: DeletionDomainModel.USER,
domain: DomainModel.USER,
operation: DeletionOperationModel.DELETE,
modifiedCount: 0,
deletedCount: 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { DoBaseFactory } from '@shared/testing';
import { ObjectId } from '@mikro-orm/mongodb';
import { DeepPartial } from 'fishery';
import { DomainModel } from '@shared/domain/types';
import { DeletionRequest, DeletionRequestProps } from '../../deletion-request.do';
import { DeletionDomainModel, DeletionStatusModel } from '../../types';
import { DeletionStatusModel } from '../../types';

class DeletionRequestFactory extends DoBaseFactory<DeletionRequest, DeletionRequestProps> {
withUserIds(id: string): this {
Expand All @@ -17,7 +18,7 @@ class DeletionRequestFactory extends DoBaseFactory<DeletionRequest, DeletionRequ
export const deletionRequestFactory = DeletionRequestFactory.define(DeletionRequest, () => {
return {
id: new ObjectId().toHexString(),
targetRefDomain: DeletionDomainModel.USER,
targetRefDomain: DomainModel.USER,
deleteAfter: new Date(),
targetRefId: new ObjectId().toHexString(),
status: DeletionStatusModel.REGISTERED,
Expand Down
1 change: 0 additions & 1 deletion apps/server/src/modules/deletion/domain/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './deletion-domain-model.enum';
export * from './deletion-operation-model.enum';
export * from './deletion-status-model.enum';
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { setupEntities } from '@shared/testing';
import { ObjectId } from '@mikro-orm/mongodb';
import { DomainModel } from '@shared/domain/types';
import { DeletionLogEntity } from './deletion-log.entity';
import { DeletionOperationModel, DeletionDomainModel } from '../domain/types';
import { DeletionOperationModel } from '../domain/types';

describe(DeletionLogEntity.name, () => {
beforeAll(async () => {
Expand All @@ -13,7 +14,7 @@ describe(DeletionLogEntity.name, () => {
const setup = () => {
const props = {
id: new ObjectId().toHexString(),
domain: DeletionDomainModel.USER,
domain: DomainModel.USER,
operation: DeletionOperationModel.DELETE,
modifiedCount: 0,
deletedCount: 1,
Expand Down
Loading
Loading