{"version":3,"sources":["/home/renatorib/p/publissue/packages/api/dist/__chunks/ITORP2H5.cjs","../../src/publissue/getComments.ts"],"names":["GetCommentsByPostNumberQuery","operation","graphql","data","_a","_b","issue","e","edge","Comment","GetCommentsByPostIdQuery","getComments","props","common","__spreadValues","buildPager","__spreadProps"],"mappings":"AAAA,sHAAkC,6CAAmC,6CAAmC,6CAAmC,6CAA0C,ICM/KA,CAAAA,CAA+BC,4BAAAA,4BACnCC,CAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA,CA+BP,CACH,CAAA,CAAE,OAAA,CAASC,CAAAA,EAAS,CAvCpB,IAAAC,CAAAA,CAAAC,CAAAA,CAwCE,IAAMC,CAAAA,CAAAA,CAAQF,CAAAA,CAAAD,CAAAA,CAAK,UAAA,CAAA,EAAL,IAAA,CAAA,KAAA,CAAA,CAAAC,CAAAA,CAAiB,KAAA,CAE/B,OAAKE,CAAAA,CAEE,CACL,UAAA,CAAYA,CAAAA,CAAM,QAAA,CAAS,UAAA,CAC3B,QAAA,CAAUA,CAAAA,CAAM,QAAA,CAAS,QAAA,CACzB,KAAA,CAAA,CAAOD,CAAAA,CAAAC,CAAAA,CAAM,QAAA,CAAS,KAAA,CAAA,EAAf,IAAA,CAAA,KAAA,CAAA,CAAAD,CAAAA,CACH,MAAA,CAAQE,CAAAA,EAAMA,CAAAA,EAAK,IAAA,CAAA,CACpB,GAAA,CAAKC,CAAAA,EAAAA,CACG,CACL,MAAA,CAAQA,CAAAA,CAAK,MAAA,CACb,OAAA,CAASC,cAAAA,CAAQ,MAAA,CAAOD,CAAAA,CAAK,IAAI,CACnC,CAAA,CAAA,CAEN,CAAA,CAbmB,CAAC,CActB,CAAC,CAAA,CAEKE,CAAAA,CAA2B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QD,CAAAA,CAAM,UAAW,CAAA,CAAC,CAAA,CAG5F,IAAA,CAAK,OAAA,CAAQF,CAAwB,CAAA,CAAE,OAAA,CAAQM,4BAAAA,4BAAAF,CAAA,CAAA,CAAKD,CAAAA,CAAAA,CAAL,CAAa,EAAA,CAAID,CAAAA,CAAM,MAAO,CAAA,CAAC,CACvF,CAAA,cAAA","file":"/home/renatorib/p/publissue/packages/api/dist/__chunks/ITORP2H5.cjs","sourcesContent":[null,"import { graphql, operation } from \"../lib/graphql\";\nimport { buildPager, PagerParams } from \"../lib/pager\";\nimport { Publissue } from \".\";\nimport { Comment } from \"../types/Comment\";\nimport { Flatten } from \"../lib/types\";\n\nconst GetCommentsByPostNumberQuery = operation(\n  graphql(`\n    query getCommentsByPostNumber(\n      $owner: String!\n      $name: String!\n      $number: Int!\n      $first: Int\n      $last: Int\n      $before: String\n      $after: String\n    ) {\n      repository(owner: $owner, name: $name) {\n        issue(number: $number) {\n          number\n          comments(first: $first, last: $last, before: $before, after: $after) {\n            totalCount\n            pageInfo {\n              endCursor\n              startCursor\n              hasNextPage\n              hasPreviousPage\n            }\n            edges {\n              cursor\n              node {\n                ...Comment_IssueComment\n              }\n            }\n          }\n        }\n      }\n    }\n  `),\n).withMap((data) => {\n  const issue = data.repository?.issue;\n\n  if (!issue) return {};\n\n  return {\n    totalCount: issue.comments.totalCount,\n    pageInfo: issue.comments.pageInfo,\n    edges: issue.comments.edges\n      ?.filter((e) => e != null)\n      .map((edge) => {\n        return {\n          cursor: edge.cursor,\n          comment: Comment.unmask(edge.node),\n        };\n      }),\n  };\n});\n\nconst GetCommentsByPostIdQuery = operation(\n  graphql(`\n    query getCommentsByPostId(\n      $owner: String!\n      $name: String!\n      $id: ID!\n      $first: Int\n      $last: Int\n      $before: String\n      $after: String\n    ) {\n      node(id: $id) {\n        ... on Issue {\n          id\n          number\n          comments(first: $first, last: $last, before: $before, after: $after) {\n            totalCount\n            pageInfo {\n              endCursor\n              startCursor\n              hasNextPage\n              hasPreviousPage\n            }\n            edges {\n              cursor\n              node {\n                ...Comment_IssueComment\n              }\n            }\n          }\n        }\n      }\n    }\n  `),\n).withMap((data) => {\n  const issue = data.node;\n\n  if (!issue || issue.__typename !== \"Issue\") return {};\n\n  return {\n    totalCount: issue.comments.totalCount,\n    pageInfo: issue.comments.pageInfo,\n    edges: issue.comments.edges\n      ?.filter((e) => e != null)\n      .map((edge) => {\n        return {\n          cursor: edge.cursor,\n          comment: Comment.unmask(edge.node),\n        };\n      }),\n  };\n});\n\nexport async function getComments(\n  this: Publissue,\n  props: ({ postNumber: number } & PagerParams) | ({ postId: string } & PagerParams),\n) {\n  const common = { ...this.repo, ...buildPager(props) };\n\n  if (\"postNumber\" in props) {\n    return this.graphql(GetCommentsByPostNumberQuery).execute({ ...common, number: props.postNumber });\n  }\n\n  return this.graphql(GetCommentsByPostIdQuery).execute({ ...common, id: props.postId });\n}\n"]}