Skip to content

Commit

Permalink
fix(*): lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Omri-Levy committed Mar 4, 2024
1 parent d3f8903 commit 6ede415
Show file tree
Hide file tree
Showing 69 changed files with 130 additions and 82 deletions.
2 changes: 1 addition & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-unused-imports": "^3.0.0",
"eslint-plugin-prefer-arrow": "^1.2.3",
"@stylistic/eslint-plugin": "^1.6.2"
"@stylistic/eslint-plugin-ts": "^1.6.2"
}
}
72 changes: 8 additions & 64 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sdks/workflow-browser-sdk/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import dts from 'rollup-plugin-dts';
import json from '@rollup/plugin-json';

import visualizer from 'rollup-plugin-visualizer';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const size = require('rollup-plugin-size');

Expand Down
1 change: 1 addition & 0 deletions sdks/workflow-browser-sdk/src/lib/tests/msw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { sleep } from '@ballerine/common';
import { DefaultBodyType, PathParams, ResponseResolver, rest, RestContext, RestRequest } from 'msw';
import { setupServer } from 'msw/node';
import { backendOptions } from '../backend-options';

export let response:
| {
method: string;
Expand Down
2 changes: 1 addition & 1 deletion services/workflows-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
},
"devDependencies": {
"@ballerine/config": "^1.0.6",
"@ballerine/eslint-config": "^1.0.6",
"@ballerine/eslint-config": "^1.0.7",
"@cspell/cspell-types": "^6.31.1",
"@nestjs/cli": "9.3.0",
"@nestjs/swagger": "6.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ module.exports = {
);

const UNSCOPED_METHOD_NAMES = ['unscoped', 'create', 'update'];

return {
MethodDefinition: node => {
if (!isRepository || node.key.name === 'constructor') return;

const isUnscoped = UNSCOPED_METHOD_NAMES.some(name =>
node.key.name.toLowerCase().includes(name),
);
Expand Down
2 changes: 2 additions & 0 deletions services/workflows-service/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ export class AuthService {

const { id, firstName, lastName, roles } = user;
const roleList = roles as string[];

return { id, email, firstName, lastName, roles: roleList };
}

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const userService = {
if (email === VALID_CREDENTIALS.email) {
return USER;
}

return null;
},
getByEmailUnscoped(email: any) {
Expand Down
2 changes: 2 additions & 0 deletions services/workflows-service/src/auth/basic/basic.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ export class BasicStrategy extends PassportStrategy(Strategy) implements IAuthSt

async validate(email: string, password: string): Promise<UserInfo> {
const user = await this.authService.validateUser(email, password);

if (!user) {
throw new UnauthorizedException();
}

return user;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('Testing the basicStrategyBase.validate()', () => {
authService.validateUser.mockReturnValue(Promise.resolve(null));
//ACT
const result = basicStrategy.validate('noUsername', TEST_PASSWORD);

//ASSERT
return expect(result).rejects.toThrowError(UnauthorizedException);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class LocalStrategy extends PassportStrategy(Strategy) implements IAuthSt

async validate(email: string, password: string): Promise<UserInfo> {
const user = await this.authService.validateUser(email, password);

if (!user) {
throw new UnauthorizedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('Testing the localStrategyBase.validate()', () => {
authService.validateUser.mockReturnValue(Promise.resolve(null));
//ACT
const result = localStrategy.validate('noUsername', TEST_PASSWORD);

//ASSERT
return expect(result).rejects.toThrowError(UnauthorizedException);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class BusinessControllerExternal {
@ProjectIds() projectIds: TProjectIds,
): Promise<BusinessModel[]> {
const args = plainToClass(BusinessFindManyArgs, request.query);

return this.service.list(args, projectIds);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class BusinessControllerExternal {
@ProjectIds() projectIds: TProjectIds,
): Promise<BusinessModel[]> {
const args = plainToClass(BusinessFindManyArgs, request.query);

return this.service.list(args, projectIds);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { UiDefinitionService } from '@/ui-definition/ui-definition.service';
import { WorkflowDefinitionRepository } from '@/workflow-defintion/workflow-definition.repository';
import { WorkflowRuntimeDataRepository } from '@/workflow/workflow-runtime-data.repository';
import { WorkflowService } from '@/workflow/workflow.service';
import { AnyRecord, DefaultContextSchema } from '@ballerine/common';
import { AnyRecord } from '@ballerine/common';
import { Injectable } from '@nestjs/common';
import { Customer, EndUser, UiDefinitionContext, WorkflowRuntimeData } from '@prisma/client';
import { plainToClass } from 'class-transformer';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class ColectionFlowController {

try {
const adapter = this.adapterManager.getAdapter(activeWorkflow.workflowDefinitionId);

return {
result: activeWorkflow ? adapter.serialize(activeWorkflow) : null,
};
Expand All @@ -56,6 +57,7 @@ export class ColectionFlowController {
`${activeWorkflow.workflowDefinitionId as string} is not supported.`,
);
}

throw error;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class CollectionFlowFilesController {
if (error.includes('expected size')) {
throw new UnprocessableEntityException(FILE_SIZE_EXCEEDED_MSG);
}

throw new UnprocessableEntityException(error);
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export const getInvalidAttributes = (
data: Record<string, unknown>,
): string[] => {
const filteredData = permission.filter(data) as Record<string, unknown>;

return Object.keys(data).filter(key => !(key in filteredData));
};
1 change: 1 addition & 0 deletions services/workflows-service/src/common/ajv/ajv.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const ajv = new Ajv({
strict: false,
coerceTypes: true,
});

addFormats(ajv, {
formats: ['email', 'uri', 'date', 'date-time'],
keywords: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ export class AppLoggerService implements LoggerService, OnModuleDestroy {
};

const reqId = this.cls.get('requestId');

if (reqId) {
metadata.reqId = reqId;
}

const entity = this.cls.get('entity');

if (entity && entity.type !== 'admin') {
if (entity.type === 'customer') {
// @ts-ignore
Expand All @@ -49,6 +51,7 @@ export class AppLoggerService implements LoggerService, OnModuleDestroy {
metadata.entity = entity.endUser;
}
}

return metadata;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export class AllExceptionsFilter extends BaseExceptionFilter {
} else if (status >= 500) {
message = message + ' - Server Error:';
}

return message;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class HttpExceptionFilter extends BaseExceptionFilter {
catch(exception: Prisma.PrismaClientKnownRequestError, host: ArgumentsHost) {
const statusCode = this.errorCodesStatusMapping[exception.code] ?? 500;
let message = '';

if (host.getType() === 'http') {
// for http requests (REST)
// Todo : Add all other exception types and also add mapping
Expand All @@ -50,12 +51,14 @@ export class HttpExceptionFilter extends BaseExceptionFilter {
} else {
message = `[${exception.code}]: ` + this.exceptionShortMessage(exception.message);
}

if (!Object.keys(this.errorCodesStatusMapping).includes(exception.code)) {
return super.catch(exception, host);
}

throw new HttpException(message, statusCode);
}

throw new HttpException(message, statusCode);
}

Expand All @@ -65,6 +68,7 @@ export class HttpExceptionFilter extends BaseExceptionFilter {
*/
exceptionShortMessage(message: string): string {
const shortMessage = message.substring(message.indexOf('→'));

return shortMessage.substring(shortMessage.indexOf('\n')).replace(/\n/g, '').trim();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class InvalidArgumentParser extends IParser {

parse(): IParserResult {
const { message } = this;

if (!message) return {};

return this.execPattern(this.pattern, (result, match) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('UnknownArgumentParser', () => {
params.failedAtPath,
params.type,
);

return result;
}, {} as Record<string, string>);
});
Expand Down
Loading

0 comments on commit 6ede415

Please sign in to comment.