/**
 * @aurora-catalyst-generated
 * @source cliter/iam/permission-role.aurora.yaml
 */
import { IamCreatePermissionRoleInput } from '@api/graphql';
import { IamCreatePermissionsRolesService } from '@app/iam/permission-role';
import { IamPermissionRoleFieldSchema } from '@app/iam/permission-role/domain';
import { ApplySchema, EmitEvent, HandlerMeta } from '@aurorajs.dev/core-back';
import { Injectable } from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';

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

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

    return true;
  }
}
