Skip to content

Commit

Permalink
chore(workflows-service): update subproject commits and refactor imports
Browse files Browse the repository at this point in the history
- Update subproject commit reference from 1b7508555 to f7a992675
- Refactor import statements for clarity and consistency
- Ensure correct await usage in local authentication guard

(your code organization is so chaotic, even a tornado couldn't sort it out)
  • Loading branch information
alonp99 committed Dec 15, 2024
1 parent 34b9f95 commit c914267
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 21 deletions.
2 changes: 1 addition & 1 deletion services/workflows-service/prisma/data-migrations
9 changes: 6 additions & 3 deletions services/workflows-service/src/auth/local/local-auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ export class LocalAuthGuard extends AuthGuard('local') implements CanActivate {
async canActivate(context: ExecutionContext): Promise<boolean> {
const result = super.canActivate(context) as boolean;
const request = context.switchToHttp().getRequest();

if (result && request.user) {
const fullUrl = request.protocol + '://' + request.get('host') + request.originalUrl;
this.supabaseService.logSignIn(fullUrl);
void this.supabaseService.logSignIn(fullUrl);
}
super.logIn(request);
return Promise.resolve(result);

await super.logIn(request);

return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ import {
} from '@nestjs/common';
import { ApiExcludeController, ApiForbiddenResponse, ApiOkResponse } from '@nestjs/swagger';
import { EndUserService } from '@/end-user/end-user.service';
import { StateTag, TStateTag } from '@ballerine/common';
import { StateTag, TStateTag, EndUserAmlHitsSchema } from '@ballerine/common';
import { AlertService } from '@/alert/alert.service';
import { ZodValidationPipe } from '@/common/pipes/zod.pipe';
import { ListIndividualsProfilesSchema } from '@/case-management/dtos/list-individuals-profiles.dto';
import { z } from 'zod';
import { EndUserAmlHitsSchema } from '@ballerine/common';
import { Business, EndUsersOnBusinesses } from '@prisma/client';

@Controller('case-management')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { isRecordNotFoundError } from '@/prisma/prisma.util';
import { ProjectScopeService } from '@/project/project-scope.service';
import type { InputJsonValue, TProjectId, TProjectIds } from '@/types';
import { CurrentProject } from '@/common/decorators/current-project.decorator';
import { UseCustomerAuthGuard } from '@/common/decorators/use-customer-auth-guard.decorator';

@swagger.ApiBearerAuth()
@swagger.ApiTags('Filters')
Expand Down
11 changes: 6 additions & 5 deletions services/workflows-service/src/supabase/supabase.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Injectable, Logger } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { createClient, SupabaseClient } from '@supabase/supabase-js';
import { ISupabaseService } from './types';
import { SentryService } from '../sentry/sentry.service';
import { SentryService } from '@/sentry/sentry.service';

@Injectable()
export class SupabaseService implements ISupabaseService {
Expand All @@ -12,11 +12,12 @@ export class SupabaseService implements ISupabaseService {

constructor(
private readonly configService: ConfigService,
private readonly SentryService: SentryService,
private readonly sentry: SentryService,
) {
const telemetryEnabled = this.configService.get('TELEMETRY_ENABLED');
const supabaseUrl = this.configService.get<string>('TELEMETRY_SUPABASE_URL');
const supabaseApiKey = this.configService.get<string>('TELEMETRY_SUPABASE_API_KEY');

if (telemetryEnabled) {
if (!supabaseUrl || !supabaseApiKey) {
throw new Error('Supabase URL or API key is missing in configuration');
Expand All @@ -34,7 +35,7 @@ export class SupabaseService implements ISupabaseService {
} catch (error: Error | any) {
if (error.code === 'MODULE_NOT_FOUND') {
this.logger.error(`file not present: ${error.message}`);
this.SentryService.captureException(error.message);
this.sentry.captureException(error.message);
} else {
this.logger.error(`Exception infra data not present: ${error.message}`);
}
Expand All @@ -56,7 +57,7 @@ export class SupabaseService implements ISupabaseService {
}
} catch (error: Error | any) {
this.logger.error(`Exception to log sign in data: ${error.message}`);
this.SentryService.captureException(error.message);
this.sentry.captureException(error.message);
}
}

Expand All @@ -71,7 +72,7 @@ export class SupabaseService implements ISupabaseService {
}
} catch (error: Error | any) {
this.logger.error(`Exception to log infra data: ${error.message}`);
this.SentryService.captureException(error.message);
this.sentry.captureException(error.message);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,10 @@ import {
} from '@prisma/client';
import { createProject } from '@/test/helpers/create-project';
import { TransactionModule } from '@/transaction/transaction.module';
import { TransactionControllerExternal } from '@/transaction/transaction.controller.external';
import { TransactionCreateDto } from '@/transaction/dtos/transaction-create.dto';
import { generateBusiness, generateEndUser } from '../../scripts/generate-end-user';
import { BulkStatus } from '@/alert/types';
import { ProjectScopeService } from '@/project/project-scope.service';
import { AlertRepository } from '@/alert/alert.repository';
import { AlertDefinitionRepository } from '@/alert-definition/alert-definition.repository';
import { DataAnalyticsService } from '@/data-analytics/data-analytics.service';
import { ConfigService } from '@nestjs/config';
import { AlertService } from '@/alert/alert.service';
import { MerchantMonitoringClient } from '@/business-report/merchant-monitoring-client';
import { DataAnalyticsModule } from '@/data-analytics/data-analytics.module';
import { AlertModule } from '@/alert/alert.module';

const getBusinessCounterpartyData = (business?: Business) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { GetTransactionsDto } from './dtos/get-transactions.dto';
import { DateTimeFilter } from '@/common/query-filters/date-time-filter';
import { toPrismaOrderByGeneric } from '@/workflow/utils/toPrismaOrderBy';
import deepmerge from 'deepmerge';
import { PageDto } from '@/common/dto';

const DEFAULT_TRANSACTION_ORDER = {
transactionDate: Prisma.SortOrder.desc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export class WorkflowDefinitionRepository {
if (workflowDefinition?.isPublic) {
throw new Error('Cannot delete public workflow definition templates');
}

return await this.prisma.workflowDefinition.delete(
this.scopeService.scopeDelete(
{
Expand Down

0 comments on commit c914267

Please sign in to comment.