Что это за код и что он делает?

import { exec } from 'child_process';
import dayjs from 'dayjs';
import util from 'util';
import testEnv from '../../constants/testEnv';
import generateRandomInt from '../../helpers/generator';

class DatabusClient {
    exec = util.promisify(exec);

    public async produceServiceActivatedEvent(orderItemId: string, serviceId: number, durationInDays?: number): Promise<void> {
        const flags = this.flagsStringify({
            orderItemId,
            serviceId,
            durationInDays,
            event: 'service_activated',
        });

        await this.produceEvent(flags);
    }

    public async produceServiceAppliedEvent(orderItemId: string, externalId?: number, serviceId?: number): Promise<any> {
        const flags = this.flagsStringify({
            orderItemId,
            serviceId: serviceId || null,
            externalId: externalId || generateRandomInt(),
            event: 'service_applied',
        });

        await this.produceEvent(flags);
    }

    public async produceServiceCancelledEvent(orderItemId: string, externalId?: number): Promise<any> {
        const flags = this.flagsStringify({
            orderItemId,
            externalId: externalId || generateRandomInt(),
            event: 'service_cancelled',
        });

        await this.produceEvent(flags);
    }

    public async produceServiceExpiredEvent(orderItemId: string, externalId?: number): Promise<any> {
        const flags = this.flagsStringify({
            orderItemId,
            externalId: externalId || generateRandomInt(),
            event: 'service_expired',
        });

        await this.produceEvent(flags);
    }

    public async produceCpaAdvancedEvent(amount: number, userId: number, advanceId: string): Promise<any> {
        const flags = this.flagsStringify({
            amount,
            userId,
            advanceId,
            event: 'cpa_advanced',
        });

        await this.produceEvent(flags);
    }

    public async produceCpaAdvancedRefundedEvent(amount: number, userId: number, advanceRefundId: string): Promise<any> {
        const flags = this.flagsStringify({
            amount,
            userId,
            advanceRefundId,
            event: 'cpa_advance_refunded',
        });

        await this.produceEvent(flags);
    }

    public async produceCpaWriteOffEvent(amount: number, userId: number, actionId: string, maxBonusRate?: number, verticalId?: number): Promise<any> {
        const flags = this.flagsStringify({
            amount,
            userId,
            actionId,
            maxBonusRate: maxBonusRate || 0,
            verticalId: verticalId || 0,
            event: 'cpa_write_off',
        });

        await this.produceEvent(flags);
    }

    public async produceCpaRefundEvent(actionId: string, userId: number): Promise<any> {
        const flags = this.flagsStringify({
            actionId,
            userId,
            event: 'cpa_refund',
        });

        await this.produceEvent(flags);
    }

    public async produceCpaRepayEvent(amount: number, userId: number, repayId: string): Promise<any> {
        const flags = this.flagsStringify({
            amount,
            userId,
            repayId,
            event: 'cpa_repay',
        });

        await this.produceEvent(flags);
    }

    public async produceHfServicesWriteOffEvent(externalId: string, serviceId: number, userId: number, amount: number, maxBonusRate: number, verticalId?: number): Promise<any> {
        const flags = this.flagsStringify({
            externalId,
            serviceId,
            userId,
            amount,
            maxBonusRate,
            verticalId: verticalId || 0,
            event: 'hf_services.write_off',
        });

        await this.produceEvent(flags);
    }

    public async produceHfServicesHoldEvent(externalId: string, serviceId: number, userId: number, amount: number, maxBonusRate: number, verticalId?: number): Promise<any> {
        const flags = this.flagsStringify({
            externalId,
            serviceId,
            userId,
            amount,
            maxBonusRate,
            verticalId: verticalId || 0,
            event: 'hf_services.hold',
        });

        await this.produceEvent(flags);
    }

    public async produceHfServicesUnholdEvent(externalId: string, serviceId: number, userId: number): Promise<any> {
        const flags = this.flagsStringify({
            externalId,
            serviceId,
            userId,
            event: 'hf_services.unhold',
        });

        await this.produceEvent(flags);
    }

    public async produceHfServicesRefundEvent(externalId: string, serviceId: number, userId: number): Promise<any> {
        const flags = this.flagsStringify({
            externalId,
            serviceId,
            userId,
            event: 'hf_services.refund',
        });

        await this.produceEvent(flags);
    }

    public async produceHfServicesWriteOffHoldEvent(externalId: string, serviceId: number, userId: number): Promise<any> {
        const flags = this.flagsStringify({
            externalId,
            serviceId,
            userId,
            event: 'hf_services.write_off_hold',
        });

        await this.produceEvent(flags);
    }

    public async produceAutotekaPaymentNotification(transactionId: number, orderId: number, providerId: number, status: string, type: string): Promise<any> {
        const flags = this.flagsStringify({
            transactionId,
            orderId,
            providerId,
            status,
            type,
            event: 'payment_notification_autoteka',
        });

        await this.produceEvent(flags);
    }

    private async produceEvent(flags: string) {
        const { stdout, stderr } = await this.exec(`$(pwd)/${testEnv.DATABUS_GO_CLIENT_PATH} ${flags}`, {
            shell: '/bin/bash',
        });
        this.stdoutHandle(stdout, stderr);
    }

    private stdoutHandle(stdout: string, stderr: string): void {
        if (stderr) {
            throw new Error(`error: ${stderr}`);
        }
        // eslint-disable-next-line no-console
        console.log(`${dayjs().format('HH:mm:ss')} - ${stdout.replace('\n', '')}`);
    }

    private flagsStringify(flags: any): string {
        // eslint-disable-next-line no-console
        console.log(Object.keys(flags).map((key) => `-${key}=${flags[key]}`).join(' '));
        return Object.keys(flags).map((key) => `-${key}=${flags[key]}`).join(' ');
    }
}

export default DatabusClient;