Files
DemonGatanjieu-Anomalous_Mo…/web/modules/ui_recipe_metadata.js
T

18 lines
779 B
JavaScript

/** Persistence for inline Workflow Recipe edits. */
export async function updateRecipeMetadata(owner, recipe, changes) {
const filename = owner?.recipeDetailFilename;
if (!filename) throw new Error('recipe metadata filename missing');
const next = JSON.parse(JSON.stringify({ ...recipe, ...changes }));
const response = await fetch('/anomalous/update_recipe', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ filename, ...next }),
});
const payload = await response.json();
if (!response.ok || payload.status !== 'success') throw new Error('recipe metadata update failed');
Object.assign(recipe, changes, { updated_timestamp: Date.now() });
await owner.refreshRecipes?.();
}