refactor(core): More decouplings from internal hooks (no-changelog) (#10099)

This commit is contained in:
Iván Ovejero
2024-07-19 10:33:13 +02:00
committed by GitHub
parent 11db5a5b51
commit 5eca7c8e28
11 changed files with 106 additions and 52 deletions

View File

@@ -1,18 +1,19 @@
import { Container, Service } from 'typedi';
import type { Variables } from '@db/entities/Variables';
import { InternalHooks } from '@/InternalHooks';
import { generateNanoId } from '@db/utils/generators';
import { canCreateNewVariable } from './environmentHelpers';
import { CacheService } from '@/services/cache/cache.service';
import { VariablesRepository } from '@db/repositories/variables.repository';
import { VariableCountLimitReachedError } from '@/errors/variable-count-limit-reached.error';
import { VariableValidationError } from '@/errors/variable-validation.error';
import { EventRelay } from '@/eventbus/event-relay.service';
@Service()
export class VariablesService {
constructor(
protected cacheService: CacheService,
protected variablesRepository: VariablesRepository,
private readonly eventRelay: EventRelay,
) {}
async getAllCached(): Promise<Variables[]> {
@@ -70,7 +71,7 @@ export class VariablesService {
}
this.validateVariable(variable);
void Container.get(InternalHooks).onVariableCreated({ variable_type: variable.type });
this.eventRelay.emit('variable-created', { variableType: variable.type });
const saveResult = await this.variablesRepository.save(
{
...variable,