/**
 * @aurora-catalyst-generated
 * @source cliter/iam/bounded-context.aurora.yaml
 */
import { IamCreateBoundedContextInput } from '@api/graphql';
import { IamCreateBoundedContextsService } from '@app/iam/bounded-context';
import { IamBoundedContextFieldSchema } from '@app/iam/bounded-context/domain';
import { ApplySchema, EmitEvent, HandlerMeta } from '@aurorajs.dev/core-back';
import { Injectable } from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';

@Injectable()
export class IamCreateBoundedContextsHandler {
  constructor(
    private readonly eventEmitter: EventEmitter2,
    private readonly createService: IamCreateBoundedContextsService,
  ) {}

  @EmitEvent('iam.boundedContext.created', { returnInputPayload: true })
  @ApplySchema(IamBoundedContextFieldSchema)
  async main(payload: IamCreateBoundedContextInput[], handlerMeta?: HandlerMeta): Promise<boolean> {
    await this.createService.main(payload, handlerMeta);

    return true;
  }
}
