Files
task-stream/libs/web/tracker/infrastructure/src/lib/adapters/graphql-automations.gateway.ts
Josep Piguillem 8994590b54 feat: automation rules
Owners and admins can set rules of the kind «when a ticket is created,
moves, gets assigned, gets a comment or its pull request merges; if it is
of this type, priority, area or label; then move it, assign it, label it,
change its priority, comment or put it in the active sprint». Rules act as
TaskStream within the workflow, run once per event and trigger no others.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 15:53:31 +02:00

53 lines
1.5 KiB
TypeScript

import { inject, Injectable } from '@angular/core';
import {
Automation,
AutomationInput,
AutomationsGateway,
} from '@task-stream/web/tracker/domain';
import { map, Observable } from 'rxjs';
import {
AutomationsDocument,
CreateAutomationDocument,
DeleteAutomationDocument,
UpdateAutomationDocument,
} from '../graphql/generated';
import { GraphqlOperations } from './graphql-operations';
@Injectable()
export class GraphqlAutomationsGateway extends AutomationsGateway {
private readonly gql = inject(GraphqlOperations);
list(projectId: string): Observable<Automation[]> {
return this.gql
.query(AutomationsDocument, { projectId })
.pipe(map((d) => d.automations as Automation[]));
}
create(projectId: string, rule: AutomationInput): Observable<Automation> {
return this.gql
.mutate(CreateAutomationDocument, {
input: { projectId, ...rule } as never,
})
.pipe(map((d) => d.createAutomation as Automation));
}
update(
automationId: string,
changes: { name?: string; active?: boolean },
): Observable<Automation> {
return this.gql
.mutate(UpdateAutomationDocument, {
automationId,
name: changes.name ?? null,
active: changes.active ?? null,
})
.pipe(map((d) => d.updateAutomation as Automation));
}
remove(automationId: string): Observable<void> {
return this.gql
.mutate(DeleteAutomationDocument, { automationId })
.pipe(map(() => undefined));
}
}