import { useContentGqlHandler } from "./useContentGqlHandler" ; import { GQLHandlerCallableParams } from "./useGqlHandler" ; const authorFields = `
    id
    entryId
    createdOn
    createdBy {
        id
        displayName
        type
    }
    savedOn
    meta {
        title
        modelId
        version
        locked
        publishedOn
        status
        revisions {
            id
            fullName
        }
    }
    # user defined fields
    fullName
` ; const errorFields = `
    error {
        code
        message
        data
    }
` ; const getAuthorQuery = `
    query GetAuthor($revision: ID!) {
        getAuthor(revision: $revision) {
            data {
                ${ authorFields }
            }
            ${ errorFields }
        }
    }
` ; const getAuthorsByIdsQuery = `
    query GetAuthors($revisions: [ID!]!) {
        getAuthorsByIds(revisions: $revisions) {
            data {
                ${ authorFields }
            }
            ${ errorFields }
        }
    }
` ; const listAuthorsQuery = `
    query ListAuthors(
        $where: AuthorListWhereInput
        $sort: [AuthorListSorter]
        $limit: Int
        $after: String
    ) {
        listAuthors(where: $where, sort: $sort, limit: $limit, after: $after) {
            data {
                ${ authorFields }
            }
            meta {
                cursor
                hasMoreItems
                totalCount
            }
            ${ errorFields }
        }
    }
` ; const createAuthorMutation = `
    mutation CreateAuthor($data: AuthorInput!) {
        createAuthor(data: $data) {
            data {
                ${ authorFields }
            }
            ${ errorFields }
        }
    }
` ; const createAuthorFromMutation = `
    mutation CreateAuthorFrom($revision: ID!) {
        createAuthorFrom(revision: $revision) {
            data {
                ${ authorFields }
            }
            ${ errorFields }
        }
    }
` ; const updateAuthorMutation = `
    mutation UpdateAuthor($revision: ID!, $data: AuthorInput!) {
        updateAuthor(revision: $revision, data: $data) {
            data {
                ${ authorFields }
            }
            ${ errorFields }
        }
    }
` ; const deleteAuthorMutation = `
    mutation DeleteAuthor($revision: ID!) {
        deleteAuthor(revision: $revision) {
            data
            ${ errorFields }
        }
    }
` ; const publishAuthorMutation = `
    mutation PublishAuthor($revision: ID!) {
        publishAuthor(revision: $revision) {
            data {
                ${ authorFields }
            }
            ${ errorFields }
        }
    }
` ; const unpublishAuthorMutation = `
    mutation UnpublishAuthor($revision: ID!) {
        unpublishAuthor(revision: $revision) {
            data {
                ${ authorFields }
            }
            ${ errorFields }
        }
    }
` ; export const useAuthorManageHandler = ( params ) => { const contentHandler = useContentGqlHandler ( params ) ; return { ... contentHandler , async getAuthor ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : getAuthorQuery , variables } , headers } ) ; } , async getAuthorsByIds ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : getAuthorsByIdsQuery , variables } , headers } ) ; } , async listAuthors ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : listAuthorsQuery , variables } , headers } ) ; } , async createAuthor ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : createAuthorMutation , variables } , headers } ) ; } , async createAuthorFrom ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : createAuthorFromMutation , variables } , headers } ) ; } , async updateAuthor ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : updateAuthorMutation , variables } , headers } ) ; } , async deleteAuthor ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : deleteAuthorMutation , variables } , headers } ) ; } , async publishAuthor ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : publishAuthorMutation , variables } , headers } ) ; } , async unpublishAuthor ( variables , headers = { } ) { return await contentHandler . invoke ( { body : { query : unpublishAuthorMutation , variables } , headers } ) ; } } ; } ;