export const simpleDiagram = {
  updateTime: 1646331692036,
  name: "image_convert_resize_jim",
  description: "Image Processing Workflow",
  version: 1,
  tasks: [
    {
      name: "image_convert_resize_jim",
      taskReferenceName: "image_convert_resize_ref",
      inputParameters: {
        fileLocation: "${workflow.input.fileLocation}",
        outputFormat: "${workflow.input.recipeParameters.outputFormat}",
        outputWidth: "${workflow.input.recipeParameters.outputSize.width}",
        outputHeight: "${workflow.input.recipeParameters.outputSize.height}",
      },
      type: "SIMPLE",
      decisionCases: {},
      defaultCase: [],
      forkTasks: [],
      startDelay: 0,
      joinOn: [],
      optional: false,
      defaultExclusiveJoinTask: [],
      asyncComplete: false,
      loopOver: [],
    },
    {
      name: "upload_toS3_jim",
      taskReferenceName: "upload_toS3_ref",
      inputParameters: {
        fileLocation: "${image_convert_resize_ref.output.fileLocation}",
      },
      type: "SIMPLE",
      decisionCases: {},
      defaultCase: [],
      forkTasks: [],
      startDelay: 0,
      joinOn: [],
      optional: false,
      defaultExclusiveJoinTask: [],
      asyncComplete: false,
      loopOver: [],
    },
  ],
  inputParameters: [],
  outputParameters: {
    fileLocation: "${upload_toS3_ref.output.fileLocation}",
  },
  schemaVersion: 2,
  restartable: true,
  workflowStatusListenerEnabled: true,
  ownerEmail: "devrel@orkes.io",
  timeoutPolicy: "ALERT_ONLY",
  timeoutSeconds: 0,
  failureWorkflow: "",
  variables: {},
  inputTemplate: {},
};

export const populationMinMax = {
  updateTime: 1645990260050,
  name: "PopulationMinMax",
  description: "Min Max Population",
  version: 1,
  tasks: [
    {
      name: "get_population_data",
      taskReferenceName: "get_population_data_ref",
      inputParameters: {
        http_request: {
          uri: "https://datausa.io/api/data?drilldowns=State&measures=Population&year=latest",
          method: "GET",
        },
      },
      type: "HTTP",
      decisionCases: {},
      defaultCase: [],
      forkTasks: [],
      startDelay: 0,
      joinOn: [],
      optional: false,
      defaultExclusiveJoinTask: [],
      asyncComplete: false,
      loopOver: [],
    },
    {
      name: "fork_join",
      taskReferenceName: "fork_ref",
      inputParameters: {},
      type: "FORK_JOIN",
      decisionCases: {},
      defaultCase: [],
      forkTasks: [
        [
          {
            name: "process_population_max",
            taskReferenceName: "process_population_max_ref",
            inputParameters: {
              body: "${get_population_data_ref.output.response.body}",
              queryExpression: "[.body.data[]] | max_by(.Population)",
            },
            type: "JSON_JQ_TRANSFORM",
            decisionCases: {},
            defaultCase: [],
            forkTasks: [],
            startDelay: 0,
            joinOn: [],
            optional: false,
            defaultExclusiveJoinTask: [],
            asyncComplete: false,
            loopOver: [],
          },
        ],
        [
          {
            name: "process_population_min",
            taskReferenceName: "process_population_min_ref",
            inputParameters: {
              body: "${get_population_data_ref.output.response.body}",
              queryExpression: "[.body.data[]] | min_by(.Population)",
            },
            type: "JSON_JQ_TRANSFORM",
            decisionCases: {},
            defaultCase: [],
            forkTasks: [],
            startDelay: 0,
            joinOn: [],
            optional: false,
            defaultExclusiveJoinTask: [],
            asyncComplete: false,
            loopOver: [],
          },
        ],
      ],
      startDelay: 0,
      joinOn: [],
      optional: false,
      defaultExclusiveJoinTask: [],
      asyncComplete: false,
      loopOver: [],
    },
    {
      name: "join",
      taskReferenceName: "join_ref",
      inputParameters: {},
      type: "JOIN",
      decisionCases: {},
      defaultCase: [],
      forkTasks: [],
      startDelay: 0,
      joinOn: ["process_population_max_ref", "process_population_min_ref"],
      optional: false,
      defaultExclusiveJoinTask: [],
      asyncComplete: false,
      loopOver: [],
    },
  ],
  inputParameters: [],
  outputParameters: {
    maxPopulation: "${process_population_max_ref.output.result}",
    minPopulation: "${process_population_min_ref.output.result}",
  },
  schemaVersion: 2,
  restartable: true,
  workflowStatusListenerEnabled: false,
  ownerEmail: "developers@orkes.io",
  timeoutPolicy: "ALERT_ONLY",
  timeoutSeconds: 0,
  failureWorkflow: "",
  variables: {},
  inputTemplate: {},
};

export const decisionSample = {
  updateTime: 1636597950018,
  name: "exclusive_join",
  description: "Exclusive Join Example",
  version: 1,
  tasks: [
    {
      type: "TERMINAL",
      name: "start",
      taskReferenceName: "__start",
    },
    {
      name: "api_decision",
      taskReferenceName: "api_decision_ref",
      inputParameters: {
        case_value_param: "${workflow.input.type}",
      },
      type: "DECISION",
      caseValueParam: "case_value_param",
      decisionCases: {
        POST: [
          {
            name: "get_posts",
            taskReferenceName: "get_posts_ref",
            inputParameters: {
              http_request: {
                uri: "https://jsonplaceholder.typicode.com/posts/1",
                method: "GET",
              },
            },
            type: "HTTP",
            decisionCases: {},
            defaultCase: [],
            forkTasks: [],
            startDelay: 0,
            joinOn: [],
            optional: false,
            defaultExclusiveJoinTask: [],
            asyncComplete: false,
            loopOver: [],
          },
        ],
        COMMENT: [
          {
            name: "get_post_comments",
            taskReferenceName: "get_post_comments_ref",
            inputParameters: {
              http_request: {
                uri: "https://jsonplaceholder.typicode.com/comments?postId=1",
                method: "GET",
              },
            },
            type: "HTTP",
            decisionCases: {},
            defaultCase: [],
            forkTasks: [],
            startDelay: 0,
            joinOn: [],
            optional: false,
            defaultExclusiveJoinTask: [],
            asyncComplete: false,
            loopOver: [],
          },
        ],
        USER: [
          {
            name: "get_user_posts",
            taskReferenceName: "get_user_posts_ref",
            inputParameters: {
              http_request: {
                uri: "https://jsonplaceholder.typicode.com/posts?userId=1",
                method: "GET",
              },
            },
            type: "HTTP",
            decisionCases: {},
            defaultCase: [],
            forkTasks: [],
            startDelay: 0,
            joinOn: [],
            optional: false,
            defaultExclusiveJoinTask: [],
            asyncComplete: false,
            loopOver: [],
          },
        ],
      },
      defaultCase: [],
      forkTasks: [],
      startDelay: 0,
      joinOn: [],
      optional: false,
      defaultExclusiveJoinTask: [],
      asyncComplete: false,
      loopOver: [],
    },
    {
      name: "notification_join",
      taskReferenceName: "notification_join_ref",
      inputParameters: {},
      type: "EXCLUSIVE_JOIN",
      decisionCases: {},
      defaultCase: [],
      forkTasks: [],
      startDelay: 0,
      joinOn: ["get_posts_ref", "get_post_comments_ref"],
      optional: false,
      defaultExclusiveJoinTask: [],
      asyncComplete: false,
      loopOver: [],
    },
    {
      type: "TERMINAL",
      name: "final",
      taskReferenceName: "__final",
    },
  ],
  inputParameters: [],
  outputParameters: {},
  schemaVersion: 2,
  restartable: true,
  workflowStatusListenerEnabled: true,
  ownerEmail: "encode_admin@test.com",
  timeoutPolicy: "ALERT_ONLY",
  timeoutSeconds: 0,
  failureWorkflow: "",
  variables: {},
  inputTemplate: {},
};

export const complexDiagram = {
  createTime: 1639691367677,
  updateTime: 1641859692443,
  name: "port_in_wf",
  description: "Port In Workflow",
  version: 1,
  tasks: [
    {
      type: "TERMINAL",
      name: "start",
      taskReferenceName: "__start",
    },
    {
      name: "Submit To ITG with Retry",
      taskReferenceName: "submit_to_itg_with_retry",
      inputParameters: {
        value: "${workflow.input.iterations}",
        terminate: "${workflow.variables.terminate_loop}",
      },
      type: "DO_WHILE",
      decisionCases: {},
      defaultCase: [],
      forkTasks: [],
      startDelay: 0,
      joinOn: [],
      optional: false,
      defaultExclusiveJoinTask: [],
      asyncComplete: false,
      loopCondition:
        "if ( ($.submit_to_itg_with_retry['iteration'] < $.value) && !$.terminate) { true; } else { false; }",
      loopOver: [
        {
          name: "Submit to ITG",
          taskReferenceName: "submit_to_itg",
          inputParameters: {
            http_request: {
              uri: "https://jsonplaceholder.typicode.com/todos/${$.workflow.input.iterations}",
              method: "GET",
            },
          },
          type: "HTTP",
          decisionCases: {},
          defaultCase: [],
          forkTasks: [],
          startDelay: 0,
          joinOn: [],
          optional: true,
          defaultExclusiveJoinTask: [],
          asyncComplete: false,
          loopOver: [],
        },
        {
          name: "Check Status",
          taskReferenceName: "check_status",
          inputParameters: {
            prev_task_result: "${submit_to_itg.output}",
            switchCaseValue: "${submit_to_itg.status}",
          },
          type: "DECISION",
          caseValueParam: "switchCaseValue",
          decisionCases: {
            COMPLETED: [
              {
                name: "Complete Request Loop",
                taskReferenceName: "complete_loop_success",
                inputParameters: {
                  terminate_loop: true,
                  success: true,
                },
                type: "SET_VARIABLE",
                decisionCases: {},
                defaultCase: [],
                forkTasks: [],
                startDelay: 0,
                joinOn: [],
                optional: false,
                defaultExclusiveJoinTask: [],
                asyncComplete: false,
                loopOver: [],
              },
            ],
            COMPLETED_WITH_ERRORS: [
              {
                name: "Retry HTTP Request",
                taskReferenceName: "retry_http_request",
                inputParameters: {
                  terminate_loop: false,
                  success: false,
                },
                type: "SET_VARIABLE",
                decisionCases: {},
                defaultCase: [],
                forkTasks: [],
                startDelay: 0,
                joinOn: [],
                optional: false,
                defaultExclusiveJoinTask: [],
                asyncComplete: false,
                loopOver: [],
              },
              {
                name: "Update Records",
                taskReferenceName: "update_records_on_retry",
                inputParameters: {
                  update_records_on_retry: 1,
                },
                type: "SET_VARIABLE",
                decisionCases: {},
                defaultCase: [],
                forkTasks: [],
                startDelay: 0,
                joinOn: [],
                optional: false,
                defaultExclusiveJoinTask: [],
                asyncComplete: false,
                loopOver: [],
              },
            ],
          },
          defaultCase: [
            {
              name: "Permanent Failure",
              taskReferenceName: "terminate_loop",
              inputParameters: {
                terminate_loop: true,
                success: false,
              },
              type: "SET_VARIABLE",
              decisionCases: {},
              defaultCase: [],
              forkTasks: [],
              startDelay: 0,
              joinOn: [],
              optional: false,
              defaultExclusiveJoinTask: [],
              asyncComplete: false,
              loopOver: [],
            },
            {
              name: "Update Records Terminate",
              taskReferenceName: "update_records_on_failure",
              inputParameters: {
                update_records_on_retry: 1,
              },
              type: "SET_VARIABLE",
              decisionCases: {},
              defaultCase: [],
              forkTasks: [],
              startDelay: 0,
              joinOn: [],
              optional: false,
              defaultExclusiveJoinTask: [],
              asyncComplete: false,
              loopOver: [],
            },
            {
              name: "Terminate Workflow",
              taskReferenceName: "terminate_on_perm_failure",
              inputParameters: {
                terminationStatus: "FAILED",
                workflowOutput:
                  "Failing workflow as retries exhausted and failures are marked as permenant",
              },
              type: "TERMINATE",
              decisionCases: {},
              defaultCase: [],
              forkTasks: [],
              startDelay: 0,
              joinOn: [],
              optional: false,
              defaultExclusiveJoinTask: [],
              asyncComplete: false,
              loopOver: [],
            },
          ],
          forkTasks: [],
          startDelay: 0,
          joinOn: [],
          optional: false,
          defaultExclusiveJoinTask: [],
          asyncComplete: false,
          loopOver: [],
        },
      ],
    },
    {
      name: "Check If Success",
      taskReferenceName: "check_success",
      inputParameters: {
        switchCaseValue: "${workflow.variables.success}",
      },
      type: "DECISION",
      caseValueParam: "switchCaseValue",
      decisionCases: {
        false: [
          {
            name: "Update Records on Failure",
            taskReferenceName: "update_records_on_failure",
            inputParameters: {
              update_records_on_retry: 2,
            },
            type: "SET_VARIABLE",
            decisionCases: {},
            defaultCase: [],
            forkTasks: [],
            startDelay: 0,
            joinOn: [],
            optional: false,
            defaultExclusiveJoinTask: [],
            asyncComplete: false,
            loopOver: [],
          },
          {
            name: "Terminate Workflow",
            taskReferenceName: "terminate_on_perm_failure2",
            inputParameters: {
              terminationStatus: "FAILED",
              workflowOutput:
                "Failing workflow as retries exhausted and failures are marked as permenant",
            },
            type: "TERMINATE",
            decisionCases: {},
            defaultCase: [],
            forkTasks: [],
            startDelay: 0,
            joinOn: [],
            optional: false,
            defaultExclusiveJoinTask: [],
            asyncComplete: false,
            loopOver: [],
          },
        ],
      },
      defaultCase: [],
      forkTasks: [],
      startDelay: 0,
      joinOn: [],
      optional: false,
      defaultExclusiveJoinTask: [],
      asyncComplete: false,
      loopOver: [],
    },
    {
      name: "Wait for the async message response",
      taskReferenceName: "wait_for_response",
      inputParameters: {},
      type: "WAIT",
      decisionCases: {},
      defaultCase: [],
      forkTasks: [],
      startDelay: 0,
      joinOn: [],
      optional: false,
      defaultExclusiveJoinTask: [],
      asyncComplete: false,
      loopOver: [],
    },
    {
      name: "Check Response",
      taskReferenceName: "check_response_succeeded",
      inputParameters: {
        switchCaseValue: "${wait_for_response.output.success}",
      },
      type: "DECISION",
      caseValueParam: "switchCaseValue",
      decisionCases: {
        false: [
          {
            name: "Update Records on ITGH Failure",
            taskReferenceName: "update_records_on_itg_failure",
            inputParameters: {
              response: "${wait_for_response.output}",
            },
            type: "SET_VARIABLE",
            decisionCases: {},
            defaultCase: [],
            forkTasks: [],
            startDelay: 0,
            joinOn: [],
            optional: false,
            defaultExclusiveJoinTask: [],
            asyncComplete: false,
            loopOver: [],
          },
          {
            name: "Terminate Workflow",
            taskReferenceName: "terminate_on_response_failure",
            inputParameters: {
              terminationStatus: "FAILED",
              workflowOutput:
                "Failing workflow as retries exhausted and failures are marked as permenant",
            },
            type: "TERMINATE",
            decisionCases: {},
            defaultCase: [],
            forkTasks: [],
            startDelay: 0,
            joinOn: [],
            optional: false,
            defaultExclusiveJoinTask: [],
            asyncComplete: false,
            loopOver: [],
          },
        ],
      },
      defaultCase: [],
      forkTasks: [],
      startDelay: 0,
      joinOn: [],
      optional: false,
      defaultExclusiveJoinTask: [],
      asyncComplete: false,
      loopOver: [],
    },
    {
      type: "TERMINAL",
      name: "final",
      taskReferenceName: "__final",
    },
  ],
  inputParameters: [],
  outputParameters: {},
  schemaVersion: 2,
  restartable: true,
  workflowStatusListenerEnabled: false,
  ownerEmail: "example@email.com",
  timeoutPolicy: "ALERT_ONLY",
  timeoutSeconds: 0,
  failureWorkflow: "",
  variables: {
    success: false,
  },
  inputTemplate: {},
};

export const allTaskTypes = {
  updateTime: 1646331692036,
  name: "all_task_types",
  description: "All Task Types",
  version: 1,
  tasks: [
    {
      name: "JSON JQ Transform Example",
      taskReferenceName: "json_jq_transform_example_ref",
      inputParameters: {
        body: "${get_population_data_ref.output.response.body}",
        queryExpression: "[.body.data[]] | max_by(.Population)",
      },
      type: "JSON_JQ_TRANSFORM",
      decisionCases: {},
      defaultCase: [],
      forkTasks: [],
      startDelay: 0,
      joinOn: [],
      optional: false,
      defaultExclusiveJoinTask: [],
      asyncComplete: false,
      loopOver: [],
    },
    {
      name: "inline_task_example",
      taskReferenceName: "inline_task_example",
      type: "INLINE",
      inputParameters: {
        value: "${workflow.input.value}",
        evaluatorType: "graaljs",
        expression:
          'function e() { if ($.value == 1){return {"result": true}} else { return {"result": false}}} e();',
      },
    },
    {
      name: "Kafka Task Example",
      taskReferenceName: "call_kafka",
      inputParameters: {
        kafka_request: {
          topic: "userTopic",
          value: "Message to publish",
          bootStrapServers: "localhost:9092",
          headers: {
            "x-Auth": "Auth-key",
          },
          key: {
            Key_1: "value 1",
          },
          keySerializer:
            "org.apache.kafka.common.serialization.IntegerSerializer",
        },
      },
      type: "KAFKA_PUBLISH",
    },
  ],
  inputParameters: [],
  outputParameters: {
    fileLocation: "${upload_toS3_ref.output.fileLocation}",
  },
  schemaVersion: 2,
  restartable: true,
  workflowStatusListenerEnabled: true,
  ownerEmail: "devrel@orkes.io",
  timeoutPolicy: "ALERT_ONLY",
  timeoutSeconds: 0,
  failureWorkflow: "",
  variables: {},
  inputTemplate: {},
};
