/**
 * @aurora-catalyst-generated
 * @source cliter/o-auth/application-client.aurora.yaml
 */
import { OAuthCreateApplicationClientInput } from '@api/graphql';
import { OAuthCreateApplicationsClientsService } from '@app/o-auth/application-client';
import { OAuthApplicationClientFieldSchema } from '@app/o-auth/application-client/domain';
import { ApplySchema, EmitEvent, HandlerMeta } from '@aurorajs.dev/core-back';
import { Injectable } from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';

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

  @EmitEvent('oAuth.applicationClient.created', { returnInputPayload: true })
  @ApplySchema(OAuthApplicationClientFieldSchema)
  async main(
    payload: OAuthCreateApplicationClientInput[],
    handlerMeta?: HandlerMeta,
  ): Promise<boolean> {
    await this.createService.main(payload, handlerMeta);

    return true;
  }
}
