/**
* Image Sync Orchestration
*
* Hooks `image-handler` + `image-manifest` + `WorkItemService.downloadAttachment`
* into the work-item pull/push pipelines.
*
* - On pull: scan all string fields + comment bodies for ADO attachment
* refs, download each binary into `{folder}/{id}/attachments/`, rewrite the
* src to the local relative path, and write the manifest.
*
* - On push: read the manifest, scan content for image refs, rewrite local
* paths back to original ADO URLs, upload any new local files, append to
* the manifest.
*/
import { type AttachmentManifest } from './image-manifest.js';
interface ImageDownloadService {
downloadAttachment(project: string, attachmentGuid: string, urlFileName: string, outputDir: string, outputFileName?: string): Promise<{
filePath: string;
fileName: string;
size: number;
guid: string;
}>;
}
interface ImageUploadService {
uploadAttachment(project: string, filePath: string, fileName?: string): Promise<{
id: string;
url: string;
fileName: string;
size: number;
}>;
}
export interface PullImageResult {
downloaded: number;
reused: number;
failed: Array<{
guid: string;
fileName: string;
error: string;
}>;
manifest: AttachmentManifest;
}
/**
* Process all string fields on a work item, downloading attachments and
* rewriting srcs. Mutates `workItem.fields` in place. Persists the manifest.
*/
export declare function pullWorkItemImages(workItem: any, project: string, syncFolder: string, service: ImageDownloadService): Promise;
/**
* Process comment bodies for image refs. Mutates `comments[i].text` in place.
* Uses the same manifest as the parent work item so attachments are tracked
* together. Returns aggregated counts.
*/
export declare function pullCommentImages(workItemId: number, comments: Array<{
text?: string;
content?: string;
}>, project: string, syncFolder: string, service: ImageDownloadService): Promise;
export interface PushImageResult {
uploaded: number;
reused: number;
failed: Array<{
src: string;
error: string;
}>;
manifest: AttachmentManifest;
}
/**
* Apply image push processing to a parsed work item file's body fields.
* Iterates every refname in `bodyFieldMap`, so custom body fields (not just
* the historical Description/ReproSteps/AC/custom-four) get image handling.
* Mutates the parsed object in-place and persists the manifest.
*/
export declare function pushWorkItemImages(parsed: {
bodyFieldMap: Record;
description?: string;
reproSteps?: string;
acceptanceCriteria?: string;
additionalFields?: any;
}, workItemId: number, project: string, syncFolder: string, service: ImageUploadService): Promise;
/**
* Append a manually-uploaded attachment to a work item's manifest.
* Used by the standalone `upload-work-item-attachment` tool.
*/
export declare function recordExternalUpload(syncFolder: string, workItemId: number, uploaded: {
id: string;
url: string;
fileName: string;
}, localPath: string): Promise;
export {};
//# sourceMappingURL=image-sync.d.ts.map