/**
 * @aurora-catalyst-generated
 * @source cliter/o-auth/access-token.aurora.yaml
 */
import { OAuthSequelizeAccessTokenRepository } from '@app/o-auth/access-token';
import { HandlerMeta } from '@aurorajs.dev/core-back';
import { QueryStatement } from '@aurorajs.dev/core-common';
import { Injectable } from '@nestjs/common';

@Injectable()
export class OAuthDeleteAccessTokenByIdService {
  constructor(private readonly repository: OAuthSequelizeAccessTokenRepository) {}

  async main(id: string, constraint?: QueryStatement, handlerMeta?: HandlerMeta): Promise<void> {
    const accessToken = await this.repository.findById(id, {
      constraint,
      handlerMeta,
    });

    await this.repository.deleteById(accessToken.id, {
      deleteOptions: handlerMeta?.repositoryOptions,
      handlerMeta,
    });
  }
}
