Skip to content

Commit

Permalink
Merge branch 'main' into BC-5583-display-pdf-preview
Browse files Browse the repository at this point in the history
  • Loading branch information
SevenWaysDP authored Nov 21, 2023
2 parents 4225c0e + bbd7075 commit 13bd2e2
Show file tree
Hide file tree
Showing 413 changed files with 3,356 additions and 1,583 deletions.
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@
- naming of dtos and dto-files: api vs domain, we leave out "dto" suffix for simplicity (we know that they are dtos) and instead append a specific suffix:
e.g.
api: <PaginationParams, pagination.params.ts>, <CreatNewsParams, create-news.params.ts>, <NewsResponse, news.response.ts>
domain: <ICreateNews, create-news.interface.ts>, <News, news.entity.ts>
domain: <CreateNews, create-news.interface.ts>, <News, news.entity.ts>
2 changes: 1 addition & 1 deletion apps/server/src/core/error/filter/global-error.filter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IError, RpcMessage } from '@infra/rabbitmq/rpc-message';
import { ArgumentsHost, Catch, ExceptionFilter, HttpException, InternalServerErrorException } from '@nestjs/common';
import { ApiValidationError, BusinessError } from '@shared/common';
import { IError, RpcMessage } from '@infra/rabbitmq/rpc-message';
import { ErrorLogger, Loggable } from '@src/core/logger';
import { LoggingUtils } from '@src/core/logger/logging.utils';
import { Response } from 'express';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface IErrorType {
export interface ErrorType {
readonly type: string;
readonly title: string;
readonly defaultMessage: string;
Expand Down
10 changes: 5 additions & 5 deletions apps/server/src/core/error/server-error-types.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/**
* all errors defined in the application require a definition,
* implementing the @IErrorType where their type is unambigious within of the application.
* implementing the @ErrorType where their type is unambigious within of the application.
* */

import legacyErrorTypes = require('../../../../../src/errors/commonErrorTypes');
import { IErrorType } from './interface/error-type.interface';
import { ErrorType } from './interface/error-type.interface';

// check legacy error typing is matching IErrorType
const serverErrorTypes: { [index: string]: IErrorType } = legacyErrorTypes;
// check legacy error typing is matching ErrorType
const serverErrorTypes: { [index: string]: ErrorType } = legacyErrorTypes;

// re-use legacy error types
export const { INTERNAL_SERVER_ERROR_TYPE, ASSERTION_ERROR_TYPE, API_VALIDATION_ERROR_TYPE, FORBIDDEN_ERROR_TYPE } =
serverErrorTypes;

// further error types

export const NOT_FOUND_ERROR_TYPE: IErrorType = {
export const NOT_FOUND_ERROR_TYPE: ErrorType = {
type: 'NOT_FOUND_ERROR',
title: 'Not Found',
defaultMessage: 'The requested ressource has not been found.',
Expand Down
6 changes: 3 additions & 3 deletions apps/server/src/core/interceptor/interceptor.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ClassSerializerInterceptor, Module } from '@nestjs/common';
import { APP_INTERCEPTOR } from '@nestjs/core';
import { IInterceptorConfig, TimeoutInterceptor } from '@shared/common';
import { ConfigService } from '@nestjs/config';
import { APP_INTERCEPTOR } from '@nestjs/core';
import { InterceptorConfig, TimeoutInterceptor } from '@shared/common';

/** *********************************************
* Global Interceptor setup
Expand All @@ -18,7 +18,7 @@ import { ConfigService } from '@nestjs/config';
},
{
provide: APP_INTERCEPTOR, // TODO remove (for testing)
useFactory: (configService: ConfigService<IInterceptorConfig, true>) => {
useFactory: (configService: ConfigService<InterceptorConfig, true>) => {
const timeout = configService.get<number>('INCOMING_REQUEST_TIMEOUT');
return new TimeoutInterceptor(timeout);
},
Expand Down
6 changes: 3 additions & 3 deletions apps/server/src/core/interfaces/core-module-config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IInterceptorConfig } from '@shared/common';
import { ILoggerConfig } from '../logger';
import { InterceptorConfig } from '@shared/common';
import { LoggerConfig } from '../logger';

export interface ICoreModuleConfig extends IInterceptorConfig, ILoggerConfig {}
export interface CoreModuleConfig extends InterceptorConfig, LoggerConfig {}
2 changes: 1 addition & 1 deletion apps/server/src/core/logger/interfaces/logger-config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export interface ILoggerConfig {
export interface LoggerConfig {
NEST_LOG_LEVEL: string;
}
4 changes: 2 additions & 2 deletions apps/server/src/core/logger/logger.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { ConfigService } from '@nestjs/config';
import { utilities, WinstonModule } from 'nest-winston';
import winston from 'winston';
import { ErrorLogger } from './error-logger';
import { ILoggerConfig } from './interfaces';
import { LoggerConfig } from './interfaces';
import { LegacyLogger } from './legacy-logger.service';
import { Logger } from './logger';

@Module({
imports: [
WinstonModule.forRootAsync({
useFactory: (configService: ConfigService<ILoggerConfig, true>) => {
useFactory: (configService: ConfigService<LoggerConfig, true>) => {
return {
levels: winston.config.syslog.levels,
level: configService.get<string>('NEST_LOG_LEVEL'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface ICalendarEvent {
export interface CalendarEvent {
data: {
attributes: {
summary: string;
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/infra/calendar/mapper/calendar.mapper.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ICalendarEvent } from '@infra/calendar/interface/calendar-event.interface';
import { CalendarEvent } from '@infra/calendar/interface/calendar-event.interface';
import { Test, TestingModule } from '@nestjs/testing';
import { CalendarMapper } from './calendar.mapper';

describe('CalendarMapper', () => {
let module: TestingModule;
let mapper: CalendarMapper;

const event: ICalendarEvent = {
const event: CalendarEvent = {
data: [
{
attributes: {
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/infra/calendar/mapper/calendar.mapper.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ICalendarEvent } from '@infra/calendar/interface/calendar-event.interface';
import { CalendarEvent } from '@infra/calendar/interface/calendar-event.interface';
import { Injectable } from '@nestjs/common';
import { CalendarEventDto } from '../dto/calendar-event.dto';

@Injectable()
export class CalendarMapper {
mapToDto(event: ICalendarEvent): CalendarEventDto {
mapToDto(event: CalendarEvent): CalendarEventDto {
const { attributes } = event.data[0];
return new CalendarEventDto({
teamId: attributes['x-sc-teamid'],
Expand Down
10 changes: 5 additions & 5 deletions apps/server/src/infra/calendar/service/calendar.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { DeepMocked, createMock } from '@golevelup/ts-jest';
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { Configuration } from '@hpi-schul-cloud/commons/lib';
import { CalendarEventDto, CalendarService } from '@infra/calendar';
import { HttpService } from '@nestjs/axios';
import { InternalServerErrorException } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { CalendarEventDto, CalendarService } from '@infra/calendar';
import { axiosResponseFactory } from '@shared/testing';
import { AxiosResponse } from 'axios';
import { of, throwError } from 'rxjs';
import { CalendarEvent } from '../interface/calendar-event.interface';
import { CalendarMapper } from '../mapper/calendar.mapper';
import { ICalendarEvent } from '../interface/calendar-event.interface';

describe('CalendarServiceSpec', () => {
let module: TestingModule;
Expand Down Expand Up @@ -56,7 +56,7 @@ describe('CalendarServiceSpec', () => {
const title = 'eventTitle';
const teamId = 'teamId';

const event: ICalendarEvent = {
const event: CalendarEvent = {
data: [
{
attributes: {
Expand All @@ -66,7 +66,7 @@ describe('CalendarServiceSpec', () => {
},
],
};
const axiosResponse: AxiosResponse<ICalendarEvent> = axiosResponseFactory.build({
const axiosResponse: AxiosResponse<CalendarEvent> = axiosResponseFactory.build({
data: event,
});
httpService.get.mockReturnValue(of(axiosResponse));
Expand Down
10 changes: 5 additions & 5 deletions apps/server/src/infra/calendar/service/calendar.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { Injectable, InternalServerErrorException } from '@nestjs/common';
import { EntityId } from '@shared/domain';
import { ErrorUtils } from '@src/core/error/utils';
import { AxiosRequestConfig, AxiosResponse } from 'axios';
import { Observable, firstValueFrom } from 'rxjs';
import { firstValueFrom, Observable } from 'rxjs';
import { URL, URLSearchParams } from 'url';
import { CalendarMapper } from '../mapper/calendar.mapper';
import { CalendarEventDto } from '../dto/calendar-event.dto';
import { ICalendarEvent } from '../interface/calendar-event.interface';
import { CalendarEvent } from '../interface/calendar-event.interface';
import { CalendarMapper } from '../mapper/calendar.mapper';

@Injectable()
export class CalendarService {
Expand All @@ -34,7 +34,7 @@ export class CalendarService {
timeout: this.timeoutMs,
})
)
.then((resp: AxiosResponse<ICalendarEvent>) => this.calendarMapper.mapToDto(resp.data))
.then((resp: AxiosResponse<CalendarEvent>) => this.calendarMapper.mapToDto(resp.data))
.catch((error) => {
throw new InternalServerErrorException(
null,
Expand All @@ -47,7 +47,7 @@ export class CalendarService {
path: string,
queryParams: URLSearchParams,
config: AxiosRequestConfig
): Observable<AxiosResponse<ICalendarEvent>> {
): Observable<AxiosResponse<CalendarEvent>> {
const url: URL = new URL(this.baseURL);
url.pathname = path;
url.search = queryParams.toString();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { Configuration } from '@hpi-schul-cloud/commons/lib';
import { PseudonymModule } from '@modules/pseudonym';
import { ToolModule } from '@modules/tool';
import { UserModule } from '@modules/user';
import { HttpModule } from '@nestjs/axios';
import { Module, Provider } from '@nestjs/common';
import { LtiToolRepo } from '@shared/repo/ltitool/';
import { LoggerModule } from '@src/core/logger';
import { ToolModule } from '@modules/tool';
import { PseudonymModule } from '@modules/pseudonym';
import { UserModule } from '@modules/user';
import { NextcloudStrategy } from './strategy/nextcloud/nextcloud.strategy';
import { NextcloudClient } from './strategy/nextcloud/nextcloud.client';
import { CollaborativeStorageAdapterMapper } from './mapper';
import { CollaborativeStorageAdapter } from './collaborative-storage.adapter';
import { CollaborativeStorageAdapterMapper } from './mapper';
import { NextcloudClient } from './strategy/nextcloud/nextcloud.client';
import { NextcloudStrategy } from './strategy/nextcloud/nextcloud.strategy';

const storageStrategy: Provider = {
provide: 'ICollaborativeStorageStrategy',
provide: 'CollaborativeStorageStrategy',
useExisting: NextcloudStrategy,
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { createMock } from '@golevelup/ts-jest';
import { ObjectId } from '@mikro-orm/mongodb';
import { TeamDto } from '@modules/collaborative-storage/services/dto/team.dto'; // invalid import please fix
import { Test, TestingModule } from '@nestjs/testing';
import { RoleName } from '@shared/domain';
import { LegacyLogger } from '@src/core/logger';
import { TeamDto } from '@modules/collaborative-storage/services/dto/team.dto'; // invalid import please fix
import { CollaborativeStorageAdapter } from './collaborative-storage.adapter';
import { CollaborativeStorageAdapterMapper } from './mapper/collaborative-storage-adapter.mapper';
import { ICollaborativeStorageStrategy } from './strategy/base.interface.strategy';
import { CollaborativeStorageStrategy } from './strategy/base.interface.strategy';

class TestStrategy implements ICollaborativeStorageStrategy {
class TestStrategy implements CollaborativeStorageStrategy {
baseURL: string;

constructor() {
Expand Down Expand Up @@ -38,7 +38,7 @@ class TestStrategy implements ICollaborativeStorageStrategy {
describe('CollaborativeStorage Adapter', () => {
let module: TestingModule;
let adapter: CollaborativeStorageAdapter;
let strategy: ICollaborativeStorageStrategy;
let strategy: CollaborativeStorageStrategy;

beforeAll(async () => {
module = await Test.createTestingModule({
Expand All @@ -50,8 +50,8 @@ describe('CollaborativeStorage Adapter', () => {
useValue: createMock<LegacyLogger>(),
},
{
provide: 'ICollaborativeStorageStrategy',
useValue: createMock<ICollaborativeStorageStrategy>(),
provide: 'CollaborativeStorageStrategy',
useValue: createMock<CollaborativeStorageStrategy>(),
},
],
}).compile();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { TeamPermissionsDto } from '@modules/collaborative-storage/services/dto/team-permissions.dto';
import { TeamDto } from '@modules/collaborative-storage/services/dto/team.dto';
import { RoleDto } from '@modules/role/service/dto/role.dto';
import { Inject, Injectable } from '@nestjs/common';
import { LegacyLogger } from '@src/core/logger';
import { RoleDto } from '@modules/role/service/dto/role.dto';
import { CollaborativeStorageAdapterMapper } from './mapper/collaborative-storage-adapter.mapper';
import { ICollaborativeStorageStrategy } from './strategy/base.interface.strategy';
import { CollaborativeStorageStrategy } from './strategy/base.interface.strategy';

/**
* Provides an Adapter to an external collaborative storage.
* It loads an appropriate strategy and applies that to the given data.
*/
@Injectable()
export class CollaborativeStorageAdapter {
strategy: ICollaborativeStorageStrategy;
strategy: CollaborativeStorageStrategy;

constructor(
@Inject('ICollaborativeStorageStrategy') strategy: ICollaborativeStorageStrategy,
@Inject('CollaborativeStorageStrategy') strategy: CollaborativeStorageStrategy,
private mapper: CollaborativeStorageAdapterMapper,
private logger: LegacyLogger
) {
Expand All @@ -27,7 +27,7 @@ export class CollaborativeStorageAdapter {
* Set the strategy that should be used by the adapter
* @param strategy The strategy
*/
setStrategy(strategy: ICollaborativeStorageStrategy) {
setStrategy(strategy: CollaborativeStorageStrategy) {
this.strategy = strategy;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TeamRolePermissionsDto } from '../dto/team-role-permissions.dto';
/**
* base interface for all CollaborativeStorage Strategies
*/
export interface ICollaborativeStorageStrategy {
export interface CollaborativeStorageStrategy {
/**
* Updates The Permissions for the given Role in the given Team
* @param dto The DTO to be processed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { TeamDto, TeamUserDto } from '@modules/collaborative-storage';
import { PseudonymService } from '@modules/pseudonym';
import { ExternalTool } from '@modules/tool/external-tool/domain';
import { ExternalToolService } from '@modules/tool/external-tool/service';
import { UserService } from '@modules/user';
import { Injectable, UnprocessableEntityException } from '@nestjs/common';
import { Pseudonym, UserDO } from '@shared/domain/';
import { LtiToolDO } from '@shared/domain/domainobject/ltitool.do';
import { LtiToolRepo } from '@shared/repo/ltitool/';
import { LegacyLogger } from '@src/core/logger';
import { TeamDto, TeamUserDto } from '@modules/collaborative-storage';
import { PseudonymService } from '@modules/pseudonym';
import { UserService } from '@modules/user';
import { ExternalToolService } from '@modules/tool/external-tool/service';
import { ExternalTool } from '@modules/tool/external-tool/domain';
import { TeamRolePermissionsDto } from '../../dto/team-role-permissions.dto';
import { ICollaborativeStorageStrategy } from '../base.interface.strategy';
import { CollaborativeStorageStrategy } from '../base.interface.strategy';
import { NextcloudClient } from './nextcloud.client';

/**
* Nextcloud Strategy Implementation for Collaborative Storage
*
* @implements {ICollaborativeStorageStrategy}
* @implements {CollaborativeStorageStrategy}
*/
@Injectable()
export class NextcloudStrategy implements ICollaborativeStorageStrategy {
export class NextcloudStrategy implements CollaborativeStorageStrategy {
constructor(
private readonly logger: LegacyLogger,
private readonly client: NextcloudClient,
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/infra/encryption/encryption.interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const DefaultEncryptionService = Symbol('DefaultEncryptionService');
export const LdapEncryptionService = Symbol('LdapEncryptionService');

export interface IEncryptionService {
export interface EncryptionService {
encrypt(data: string): string;
decrypt(data: string): string;
}
6 changes: 3 additions & 3 deletions apps/server/src/infra/encryption/encryption.module.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ConfigModule } from '@nestjs/config';
import { Test, TestingModule } from '@nestjs/testing';
import { DefaultEncryptionService, EncryptionModule, IEncryptionService, LdapEncryptionService } from '.';
import { DefaultEncryptionService, EncryptionModule, EncryptionService, LdapEncryptionService } from '.';

describe('EncryptionModule', () => {
let module: TestingModule;
let defaultService: IEncryptionService;
let ldapService: IEncryptionService;
let defaultService: EncryptionService;
let ldapService: EncryptionService;

beforeAll(async () => {
module = await Test.createTestingModule({
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/infra/encryption/encryption.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import CryptoJs from 'crypto-js';

import { Injectable } from '@nestjs/common';
import { LegacyLogger } from '@src/core/logger';
import { IEncryptionService } from './encryption.interface';
import { EncryptionService } from './encryption.interface';

@Injectable()
export class SymetricKeyEncryptionService implements IEncryptionService {
export class SymetricKeyEncryptionService implements EncryptionService {
constructor(private logger: LegacyLogger, private key?: string) {
if (!this.key) {
this.logger.warn('No AES key defined. Encryption will no work');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface IIdentityManagementConfig {
export interface IdentityManagementConfig {
FEATURE_IDENTITY_MANAGEMENT_ENABLED: boolean;
FEATURE_IDENTITY_MANAGEMENT_STORE_ENABLED: boolean;
FEATURE_IDENTITY_MANAGEMENT_LOGIN_ENABLED: boolean;
Expand Down
Loading

0 comments on commit 13bd2e2

Please sign in to comment.