// (C) 2024-2026 GoodData Corporation
import { call } from "redux-saga/effects";
import { isObjRef } from "@gooddata/sdk-model";
import { alertSaved } from "../../events/alerts.js";
function saveAlert(ctx, alert) {
    const { backend, workspace } = ctx;
    if (!isObjRef(alert)) {
        throw new Error("Cannot save alert not referencing to an persisted object");
    }
    return backend.workspace(workspace).automations().updateAutomation(alert);
}
export function* saveAlertHandler(ctx, cmd) {
    yield call(saveAlert, ctx, cmd.payload.alert);
    return alertSaved(ctx, cmd.payload.alert, cmd.correlationId);
}
//# sourceMappingURL=saveAlertHandler.js.map