// (C) 2021-2026 GoodData Corporation
import { serializeObjRef, } from "@gooddata/sdk-model";
function upsertExecutionResult(id, envelopeData, correlationId) {
    return {
        type: "GDC.DASH/CMD.EXECUTION_RESULT.UPSERT",
        correlationId,
        payload: {
            ...envelopeData,
            id: typeof id === "string" ? id : serializeObjRef(id),
        },
    };
}
/**
 * Creates an {@link IUpsertExecutionResult} command that makes the relevant execution result indicate it is loading.
 *
 * @beta
 */
export function setExecutionResultLoading(id, correlationId) {
    return upsertExecutionResult(id, {
        isLoading: true,
        executionResult: undefined,
        error: undefined,
        warnings: undefined,
        limitBreaks: undefined,
    }, correlationId);
}
/**
 * Creates an {@link IUpsertExecutionResult} command that makes the relevant execution result indicate an error and stop loading.
 *
 * @beta
 */
export function setExecutionResultError(id, error, correlationId) {
    return upsertExecutionResult(id, {
        isLoading: false,
        error,
        warnings: undefined,
        limitBreaks: undefined,
    }, correlationId);
}
/**
 * Creates an {@link IUpsertExecutionResult} command that makes the relevant execution result set new result data and stop loading.
 *
 * @beta
 */
export function setExecutionResultData(id, executionResult, executionWarnings, limitBreaks, correlationId) {
    return upsertExecutionResult(id, {
        isLoading: false,
        error: undefined,
        executionResult,
        warnings: executionWarnings,
        limitBreaks,
    }, correlationId);
}
