import { DataFetcher } from "../../../../lib/http/data-fetcher/DataFetcher";
const SERVICE_ACTION_EXECUTE_STP = 'ActionButtonsSP.executeSTP';
export default class ProcedureExecutor {
  execute(action) {
    var _a, _b, _c;
    const procName = (_a = action.actionConfig.dbCall) === null || _a === void 0 ? void 0 : _a.name;
    const rootEntity = (_b = action.actionConfig.dbCall) === null || _b === void 0 ? void 0 : _b.rootEntity;
    const execSource = {
      actionID: action.actionID,
      refreshType: (_c = action.actionConfig.dbCall) === null || _c === void 0 ? void 0 : _c.refreshType,
      procName: procName,
      rootEntity: rootEntity
    };
    return new Promise((resolve) => {
      resolve({ execSource, callback: this.callExecProcedure });
    });
  }
  async callExecProcedure(execSource) {
    const request = {
      requestBody: {
        stpCall: execSource
      }
    };
    await DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_STP, JSON.stringify(request));
  }
}
