import { useContentGqlHandler } from "./useContentGqlHandler" ; import { GQLHandlerCallableParams } from "./useGqlHandler" ; const bugFields = `
    id
    createdOn
    createdBy {
        id
        displayName
        type
    }
    savedOn
    meta {
        title
        modelId
        version
        locked
        publishedOn
        status
    }
    # user defined fields
    name
    bugType
    bugValue
    bugFixed
` ; const errorFields = `
    error {
        code
        message
        data
    }
` ; const getBugQuery = `
    query GetBug($revision: ID!) {
        getBug(revision: $revision) {
            data {
                ${ bugFields }
            }
            ${ errorFields }
        }
    }
` ; const getBugsByIdsQuery = `
    query GetBugs($revisions: [ID!]!) {
        getBugsByIds(revisions: $revisions) {
            data {
                ${ bugFields }
            }
            ${ errorFields }
        }
    }
` ; const listBugsQuery = `
    query ListBugs(
        $where: BugListWhereInput
        $sort: [BugListSorter]
        $limit: Int
        $after: String
    ) {
        listBugs(where: $where, sort: $sort, limit: $limit, after: $after) {
            data {
                ${ bugFields }
            }
            meta {
                cursor
                hasMoreItems
                totalCount
            }
            ${ errorFields }
        }
    }
` ; const createBugMutation = `
    mutation CreateBug($data: BugInput!) {
        createBug(data: $data) {
            data {
                ${ bugFields }
            }
            ${ errorFields }
        }
    }
` ; const createBugFromMutation = `
    mutation CreateBugFrom($revision: ID!) {
        createBugFrom(revision: $revision) {
            data {
                ${ bugFields }
            }
            ${ errorFields }
        }
    }
` ; const updateBugMutation = `
    mutation UpdateBug($revision: ID!, $data: BugInput!) {
        updateBug(revision: $revision, data: $data) {
            data {
                ${ bugFields }
            }
            ${ errorFields }
        }
    }
` ; const deleteBugMutation = `
    mutation DeleteBug($revision: ID!) {
        deleteBug(revision: $revision) {
            data
            ${ errorFields }
        }
    }
` ; const publishBugMutation = `
    mutation PublishBug($revision: ID!) {
        publishBug(revision: $revision) {
            data {
                ${ bugFields }
            }
            ${ errorFields }
        }
    }
` ; const unpublishBugMutation = `
    mutation UnpublishBug($revision: ID!) {
        unpublishBug(revision: $revision) {
            data {
                ${ bugFields }
            }
            ${ errorFields }
        }
    }
` ; export const useBugManageHandler = ( params ) => { const contentHandler = useContentGqlHandler ( params ) ; return { ... contentHandler , async getBug ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : getBugQuery , variables } , headers } ) ; } , async getBugsByIds ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : getBugsByIdsQuery , variables } , headers } ) ; } , async listBugs ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : listBugsQuery , variables } , headers } ) ; } , async createBug ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : createBugMutation , variables } , headers } ) ; } , async createBugFrom ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : createBugFromMutation , variables } , headers } ) ; } , async updateBug ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : updateBugMutation , variables } , headers } ) ; } , async deleteBug ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : deleteBugMutation , variables } , headers } ) ; } , async publishBug ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : publishBugMutation , variables } , headers } ) ; } , async unpublishBug ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : unpublishBugMutation , variables } , headers } ) ; } } ; } ;