mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-14 10:34:06 +02:00
pipeline fixes for naming issues (#5570)
# 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:
@@ -223,7 +223,7 @@ export default function AutomationCreation({ mode, existingAutomation, onBack, o
|
|||||||
createdAt: existingAutomation?.createdAt || new Date().toISOString(),
|
createdAt: existingAutomation?.createdAt || new Date().toISOString(),
|
||||||
updatedAt: new Date().toISOString()
|
updatedAt: new Date().toISOString()
|
||||||
};
|
};
|
||||||
downloadFolderScanningConfig(tempAutomation);
|
downloadFolderScanningConfig(tempAutomation, toolRegistry);
|
||||||
}}
|
}}
|
||||||
disabled={!canSaveAutomation()}
|
disabled={!canSaveAutomation()}
|
||||||
variant="light"
|
variant="light"
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export default function AutomationSelection({
|
|||||||
onClick={() => onRun(automation)}
|
onClick={() => onRun(automation)}
|
||||||
showMenu={true}
|
showMenu={true}
|
||||||
onEdit={() => onEdit(automation)}
|
onEdit={() => onEdit(automation)}
|
||||||
onExport={() => downloadFolderScanningConfig(automation)}
|
onExport={() => downloadFolderScanningConfig(automation, toolRegistry)}
|
||||||
onDelete={() => onDelete(automation)}
|
onDelete={() => onDelete(automation)}
|
||||||
toolRegistry={toolRegistry}
|
toolRegistry={toolRegistry}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { AutomationConfig } from '@app/types/automation';
|
import { AutomationConfig } from '@app/types/automation';
|
||||||
|
import { ToolRegistry } from '@app/data/toolsTaxonomy';
|
||||||
|
import { ToolId } from '@app/types/toolId';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pipeline configuration format used by folder scanning
|
* Pipeline configuration format used by folder scanning
|
||||||
@@ -24,18 +26,54 @@ interface FolderScanningPipeline {
|
|||||||
/**
|
/**
|
||||||
* Converts an AutomationConfig to a folder scanning pipeline configuration
|
* Converts an AutomationConfig to a folder scanning pipeline configuration
|
||||||
* @param automation The automation configuration to convert
|
* @param automation The automation configuration to convert
|
||||||
|
* @param toolRegistry The tool registry to map operation types to endpoints
|
||||||
* @returns Folder scanning pipeline configuration
|
* @returns Folder scanning pipeline configuration
|
||||||
*/
|
*/
|
||||||
export function convertToFolderScanningConfig(automation: AutomationConfig): FolderScanningPipeline {
|
export function convertToFolderScanningConfig(
|
||||||
|
automation: AutomationConfig,
|
||||||
|
toolRegistry: Partial<ToolRegistry>
|
||||||
|
): FolderScanningPipeline {
|
||||||
return {
|
return {
|
||||||
name: automation.name,
|
name: automation.name,
|
||||||
pipeline: automation.operations.map(op => ({
|
pipeline: automation.operations.map(op => {
|
||||||
operation: op.operation,
|
// Map operationType to full API endpoint path
|
||||||
parameters: {
|
const toolId = op.operation as ToolId;
|
||||||
...op.parameters,
|
const toolEntry = toolRegistry[toolId];
|
||||||
fileInput: "automated"
|
const endpointConfig = toolEntry?.operationConfig?.endpoint;
|
||||||
|
|
||||||
|
let endpoint: string | undefined;
|
||||||
|
|
||||||
|
if (typeof endpointConfig === 'string') {
|
||||||
|
endpoint = endpointConfig;
|
||||||
|
} else if (typeof endpointConfig === 'function') {
|
||||||
|
// For dynamic endpoints, call with the saved parameters
|
||||||
|
try {
|
||||||
|
endpoint = endpointConfig(op.parameters);
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(
|
||||||
|
`Failed to resolve dynamic endpoint for operation "${op.operation}". ` +
|
||||||
|
`This may happen if the tool requires specific parameters. ` +
|
||||||
|
`Error: ${error}`
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})),
|
|
||||||
|
if (!endpoint) {
|
||||||
|
console.warn(
|
||||||
|
`No endpoint found for operation "${op.operation}". ` +
|
||||||
|
`This operation may fail in folder scanning. ` +
|
||||||
|
`Using operation type as fallback.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
operation: endpoint || op.operation,
|
||||||
|
parameters: {
|
||||||
|
...op.parameters,
|
||||||
|
fileInput: "automated"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}),
|
||||||
_examples: {
|
_examples: {
|
||||||
outputDir: "{outputFolder}/{folderName}",
|
outputDir: "{outputFolder}/{folderName}",
|
||||||
outputFileName: "{filename}-{pipelineName}-{date}-{time}"
|
outputFileName: "{filename}-{pipelineName}-{date}-{time}"
|
||||||
@@ -48,9 +86,13 @@ export function convertToFolderScanningConfig(automation: AutomationConfig): Fol
|
|||||||
/**
|
/**
|
||||||
* Downloads a folder scanning configuration as a JSON file
|
* Downloads a folder scanning configuration as a JSON file
|
||||||
* @param automation The automation configuration to export
|
* @param automation The automation configuration to export
|
||||||
|
* @param toolRegistry The tool registry to map operation types to endpoints
|
||||||
*/
|
*/
|
||||||
export function downloadFolderScanningConfig(automation: AutomationConfig): void {
|
export function downloadFolderScanningConfig(
|
||||||
const config = convertToFolderScanningConfig(automation);
|
automation: AutomationConfig,
|
||||||
|
toolRegistry: Partial<ToolRegistry>
|
||||||
|
): void {
|
||||||
|
const config = convertToFolderScanningConfig(automation, toolRegistry);
|
||||||
const json = JSON.stringify(config, null, 2);
|
const json = JSON.stringify(config, null, 2);
|
||||||
const blob = new Blob([json], { type: 'application/json' });
|
const blob = new Blob([json], { type: 'application/json' });
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
|
|||||||
Reference in New Issue
Block a user