Export folder scanning (#5544)

# Description of Changes

<!--
Please provide a summary of the changes, including:

- What was changed
- Why the change was made
- Any challenges encountered

Closes #(issue_number)
-->

---

## Checklist

### General

- [ ] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [ ] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md)
(if applicable)
- [ ] I have performed a self-review of my own code
- [ ] My changes generate no new warnings

### Documentation

- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)

### Translations (if applicable)

- [ ] I ran
[`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md)

### UI Changes (if applicable)

- [ ] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)

### Testing (if applicable)

- [ ] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing)
for more details.
This commit is contained in:
Anthony Stirling
2026-01-23 22:34:39 +00:00
committed by GitHub
parent 188408fc1e
commit b76f3662e4
9 changed files with 130 additions and 13 deletions
@@ -0,0 +1,68 @@
/**
* Utility functions for converting between automation formats
*/
import { AutomationConfig } from '@app/types/automation';
/**
* Pipeline configuration format used by folder scanning
*/
interface FolderScanningPipeline {
name: string;
pipeline: Array<{
operation: string;
parameters: Record<string, any>;
}>;
_examples: {
outputDir: string;
outputFileName: string;
};
outputDir: string;
outputFileName: string;
}
/**
* Converts an AutomationConfig to a folder scanning pipeline configuration
* @param automation The automation configuration to convert
* @returns Folder scanning pipeline configuration
*/
export function convertToFolderScanningConfig(automation: AutomationConfig): FolderScanningPipeline {
return {
name: automation.name,
pipeline: automation.operations.map(op => ({
operation: op.operation,
parameters: {
...op.parameters,
fileInput: "automated"
}
})),
_examples: {
outputDir: "{outputFolder}/{folderName}",
outputFileName: "{filename}-{pipelineName}-{date}-{time}"
},
outputDir: "{outputFolder}",
outputFileName: "{filename}"
};
}
/**
* Downloads a folder scanning configuration as a JSON file
* @param automation The automation configuration to export
*/
export function downloadFolderScanningConfig(automation: AutomationConfig): void {
const config = convertToFolderScanningConfig(automation);
const json = JSON.stringify(config, null, 2);
const blob = new Blob([json], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `${automation.name}.json`;
a.style.display = 'none';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}