| 1 | import { Injectable } from '@nestjs/common'; |
| 2 | |
| 3 | import { ImportDispatcherService } |
| 4 | import { ImportWriterService } |
| 5 | import type { |
| 6 | FinishImportRequestDTO, |
| 7 | ImportCommentsRequestDTO, |
| 8 | ImportIssuesRequestDTO, |
| 9 | ImportReleasesRequestDTO, |
| 10 | } from './dto/importer-callback.dto.js'; |
| 11 | |
| 12 | /** What `apps/importer` reports back. Each report renews the attempt's lease first, so a working importer never looks silent and a stale attempt writes nothing. */ |
| 13 | @Injectable() |
| 14 | export class ImporterCallbacksService |
| 15 | constructor( |
| 16 | private readonly dispatcher |
| 17 | private readonly writer |
| 18 | ) {} |
| 19 | |
| 20 | async heartbeat(importId |
| 21 | await this.dispatcher |
| 22 | } |
| 23 | |
| 24 | async releases( |
| 25 | importId: string, |
| 26 | { attempt, releases |
| 27 | ) { |
| 28 | const repositoryId = |
| 29 | await this.writer |
| 30 | } |
| 31 | |
| 32 | async issues(importId |
| 33 | const repositoryId = |
| 34 | await this.writer |
| 35 | } |
| 36 | |
| 37 | async comments( |
| 38 | importId: string, |
| 39 | { attempt, comments |
| 40 | ) { |
| 41 | const repositoryId = |
| 42 | await this.writer |
| 43 | } |
| 44 | |
| 45 | finish(importId: |
| 46 | return this.dispatcher |
| 47 | importId, |
| 48 | body.attempt, |
| 49 | body.succeeded |
| 50 | ? { succeeded: true, |
| 51 | : { succeeded: false, |
| 52 | ); |
| 53 | } |
| 54 | } |