import gql from 'graphql-tag';
import { client } from '@operato/graphql';
export async function fetchProcessGroup(id) {
    const response = await client.query({
        query: gql `
      query FetchProcessGroupById($id: String!) {
        processGroup(id: $id) {
          id
          name
          description
          createdAt
          creator {
            id
            name
          }
          updatedAt
          updater {
            id
            name
          }
        }
      }
    `,
        variables: { id }
    });
    return response.data;
}
export async function updateProcessGroup(group) {
    var { id, name, description } = group;
    const response = await client.mutate({
        mutation: gql `
      mutation UpdateGroup($id: String!, $patch: GroupPatch!) {
        updateProcessGroup(id: $id, patch: $patch) {
          id
          name
          description
          createdAt
          updatedAt
        }
      }
    `,
        variables: {
            id,
            patch: { name, description }
        }
    });
    return response.data;
}
export async function deleteProcessGroup(id) {
    const response = await client.mutate({
        mutation: gql `
      mutation ($id: String!) {
        deleteProcessGroup(id: $id)
      }
    `,
        variables: {
            id
        }
    });
    return response.data;
}
export async function fetchProcessGroupList() {
    const response = await client.query({
        query: gql `
      {
        processGroups {
          items {
            id
            name
            description
            createdAt
            updatedAt
          }
          total
        }
      }
    `
    });
    return response.data;
}
export async function createProcessGroup(group) {
    const response = await client.mutate({
        mutation: gql `
      mutation CreateProcessGroup($group: NewGroup!) {
        createProcessGroup(group: $group) {
          id
          name
          description
          createdAt
          updatedAt
        }
      }
    `,
        variables: { group }
    });
    return response.data;
}
export async function joinProcessGroup(processId, groupId) {
    const response = await client.mutate({
        mutation: gql `
      mutation JoinProcessGroup($id: String!, $processIds: [String!]!) {
        joinProcessGroup(id: $id, processIds: $processIds) {
          id
          name
          description
          processes {
            id
            name
            description
            createdAt
            updatedAt
          }
          createdAt
          updatedAt
        }
      }
    `,
        variables: {
            id: groupId,
            processIds: [processId]
        }
    });
    return response.data;
}
//# sourceMappingURL=group.js.map