| 150 | } |
| 151 | |
| 152 | export async function loadIssues(props?: { labels: string | string[] }) { |
| 153 | const CustomOctokit = Octokit.plugin(paginateRest, restEndpointMethods) |
| 154 | const octokit = new CustomOctokit() |
| 155 | |
| 156 | let labels = '' |
| 157 | if (props && props.labels) { |
| 158 | labels = Array.isArray(props.labels) ? props.labels.join(',') : props.labels |
| 159 | } |
| 160 | let issues: object[] = [] |
| 161 | if (TESTING) { |
| 162 | issues = (await import('../tests/__data__/input/issues.js')).default |
| 163 | } else { |
| 164 | issues = await octokit.paginate(octokit.rest.issues.listForRepo, { |
| 165 | owner: OWNER, |
| 166 | repo: REPO, |
| 167 | per_page: 100, |
| 168 | labels, |
| 169 | status: 'open', |
| 170 | direction: 'asc', |
| 171 | headers: { |
| 172 | 'X-GitHub-Api-Version': '2022-11-28' |
| 173 | } |
| 174 | }) |
| 175 | } |
| 176 | |
| 177 | return new Collection(issues).map(parseIssue) |
| 178 | } |
| 179 | |
| 180 | function parseIssue(issue: { number: number; body: string; labels: { name: string }[] }): Issue { |
| 181 | const FIELDS = new Dictionary({ |