import { IamCreatePermissionsHandler } from '@app/iam/permission';
import type { RepositoryOptions, SeederPermission } from '@aurorajs.dev/core-back';
import type { IIamPermissionSeeder } from '@bridges/iam/permission/ports';
import { Injectable } from '@nestjs/common';

@Injectable()
export class IamPermissionSeederAdapter implements IIamPermissionSeeder {
  constructor(private readonly handler: IamCreatePermissionsHandler) {}

  async seedAll(items: SeederPermission[], options: RepositoryOptions): Promise<void> {
    await this.handler.main(items, {
      timezone: process.env.TZ,
      repositoryOptions: options,
    });
  }
}
