"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProcessGroupSubscriber = void 0;
const tslib_1 = require("tslib");
const typeorm_1 = require("typeorm");
const shell_1 = require("@things-factory/shell");
const process_group_1 = require("./process-group");
let ProcessGroupSubscriber = class ProcessGroupSubscriber {
    listenTo() {
        return process_group_1.ProcessGroup;
    }
    // afterInsert(event: InsertEvent<ProcessGroup>): Promise<any> | void {
    //   const processGroup = event.entity
    //   pubsub.publish('processGroup', {
    //     processGroup
    //   })
    // }
    async afterUpdate(event) {
        var processGroup = event.entity;
        processGroup = await (0, shell_1.getRepository)(process_group_1.ProcessGroup).findOne({
            where: { domain: { id: processGroup.domainId }, id: processGroup.id },
            relations: ['domain']
        });
        shell_1.pubsub.publish('process-group', {
            processGroup
        });
    }
};
ProcessGroupSubscriber = tslib_1.__decorate([
    (0, typeorm_1.EventSubscriber)()
], ProcessGroupSubscriber);
exports.ProcessGroupSubscriber = ProcessGroupSubscriber;
//# sourceMappingURL=event-subscriber.js.map