| 9 | 9 | | import type { PackagesApi } from "./packages"; |
| 10 | 10 | | import type { WebhooksApi } from "./webhooks"; |
| 11 | 11 | | import type { RepoPath, ReposApi } from "./repos"; |
| 12 | | − | import { threadArgs, type CommentScope, type PullDetail, type WorkApi } from "./work"; |
| 12 | + | import type { CommentScope, PullDetail, Thread, WorkApi } from "./work"; |
| 13 | 13 | | import type { Result } from "./result"; |
| 14 | 14 | | import type { RunnersAdminApi, RunnersApi } from "./runners"; |
| 15 | 15 | | |
| ⋯ |
| 39 | 39 | | return (await response.json()) as T; |
| 40 | 40 | | } |
| 41 | 41 | | |
| 42 | + | /** The thread's fields as the work service reads them. */ |
| 43 | + | function threadArgs(thread: Thread): { repo: RepoPath | null; workspace: string; number: number } { |
| 44 | + | return "repo" in thread |
| 45 | + | ? { repo: thread.repo, workspace: "", number: thread.number } |
| 46 | + | : { repo: null, workspace: thread.workspace, number: thread.number }; |
| 47 | + | } |
| 48 | + | |
| 42 | 49 | | export function identityClient(service: ServiceBinding): IdentityApi { |
| 43 | 50 | | const call = <T>(method: string, args: object) => rpc<T>(service, method, args); |
| 44 | 51 | | return { |