<commit_before>import React, { Component } from "react";
import { Form } from "semantic-ui-react/index";

type Props = {
  match: any;
  isFetching: boolean;
  sessionId: string;
  operations: Array<string>;
  defaultPayloads: { [string]: Object };
  execute: ({ entityName: string, method: string, payload: string }) => any;
};

type State = {
  method: string; // FIXME: enum
  payload: string;
};

class OperationEditor extends Component<Props, State> {
  state: State = {
    method: null,
    payload: null
  };

  handleChangeOperation = (event, { value }) => {
    if (!this.props.defaultPayloads[value]) {
      throw new Error(`Unknown method: ${value}`);
    }

    const payload = this.props.defaultPayloads[value];

    this.setState({
      method: value,
      payload: JSON.stringify(payload, null, 2)
    });
  };

  handleChangePayload = (event, { value }) => {
    this.setState({ payload: value });
  };

  handleRun = () => {<commit_msg>fix type error of operation editor<commit_after>import React, { Component } from "react";
import { Form } from "semantic-ui-react/index";

type Props = {
  match: any;
  isFetching: boolean;
  sessionId: string;
  operations: Array<string>;
  defaultPayloads: { [key: string]: Object };
  execute: (
    params: {
      sessionId: string;
      entityName: string;
      method: string;
      payload: string;
    }
  ) => any;
};

type State = {
  method: string;
  payload: string;
};

class OperationEditor extends Component<Props, State> {
  state: State = {
    method: "",
    payload: ""
  };

  handleChangeOperation = (event: any, _payload: { value: string }) => {
    if (!this.props.defaultPayloads[_payload.value]) {
      throw new Error(`Unknown method: ${_payload.value}`);
    }

    const payload = this.props.defaultPayloads[_payload.value];

    this.setState({
      method: _payload.value,
      payload: JSON.stringify(payload, null, 2)
    });
  };

  handleChangePayload = (event: any, _payload: { value: string }) => {
    this.setState({ payload: _payload.value });
  };

  handleRun = () => {
{'fraction_non_alphanumeric': 0.1498073217726397, 'fraction_numerical': 0.0009633911368015414, 'mean_word_length': 3.291322314049587, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2893261', 'n_tokens_mistral': 646, 'n_tokens_neox': 642, 'n_words': 163}