# id: It represents the id of the process
# string, required
# allows letters, numbers and underscores only (should start with a letter)
key: processExample1

# type: Should be "process" for processes
# required, string
type: process

startsFromExistingData: true

# name: Describes the name of the process
# string, required
name: Start Recruitment

# icon: font-awesome icon
# string, optional
icon: person

# mainTable: Describes the table that will affect this process
# string, required
mainTable: Recruiters

summary:
  title: Process for {{fullName}}

# permissions: Defines the permissions for this process. Probably it should be moved to its own schema.
# object, optional
permissions:

  # each permission name must correspond to a valid role
  # it might reference to a role in the same app (e.g. "recruitment"), or a role in another app
  # (e.g. "anotherApp.anotherRole") or a role defined in the commons folder (e.g. "commons.interviewer")

  # valid values are:
  # - a boolean
  # - an object with the following optional properties:
  #   - start. It is a boolean indicating if the user can start a case of this process.
  #   - pause. Indicates if the user can pause cases. It can be:
  #     - a boolean
  #     - an object with the following optional properties
  #       - own
  #       - assigned
  #       - any
  #   - archive. Indicates if the user can archive cases. Structure is similar to pause option.

  interviewer:
    start: true # can start a process
    pause:
      own: true # can pause only own cases
    archive: false # cannot archive any case

  recruiter:
    start: true # can start cases
    pause: true # can pause any case
    # (cannot archive cases)

# field groups allows to easily repeat fields that are common to multiple forms
# optional, object
fieldGroups:

  # they should have a key, which should follow the rules of an identifier
  # the content should match the definition of a form
  summary:

    # we can mark the whole group as readOnly
    readOnly: true

    # then we define the rows
    rows:
      - [fullName, identificationNumber]
      - education

  summaryWithScores:
    readOnly: true
    rows:
      # we can include another group as part of this group
      - _group: summary

# Defines the forms used by this process
# object, optional
forms:

  # The form has an id, which should follow the identification pattern
  fillOutInvitationInformation:

    # name: Determines the name of the form, string, optional. It should follow the guidelines of a name.
    # string, required
    name: Start application

    title: fillOutInvitationInformation for {{tableField.firstName}} {{city.group}} - {{city}}

    # rows: Determines the rows to be displayed in the form
    # each element can be an string, an array or an object (use the form schema to validate)
    rows:
      - identificationNumber
      - fullName
      - identificationDocumentType
      - - identificationDocumentType:
            label: Otro label
      - tableField:
          filter:
            combinator: and
            not: false
            rules:
              - field: firstName
                operator: isNotNull
          columns:
            - firstName
            - lastName:
                label: Last Name
      - tableField.anotherTableField:
          columns:
            - first

  fillOutScores:
    name: Fill out scores

    # title: Determines the title to show to the user when loooking at the task
    # It's different to the name that it accepts variables
    title: Fill out scores for {{identificationDocumentType}} {{identificationNumber}} - {{salary}}

    rows:
      # a row element can be a group
      - _group: summary
      # or a _title
      - _title: Scores
      # or a _statement
      - _statement: Please enter the candidate scores
      - identificationDocumentType: {}
      # or the fields
      - identificationNumber
      - fullName
      - salary
      - upload
      - [signature, city]
      - - tableField:
            label: first label
            filter:
              combinator: and
              not: false
              rules:
                - field: firstName
                  operator: isNotNull
            columns:
              - relationshipField:
                  label: change label
              - firstName
              - lastName:
                  label: Last Name

  manualApproval1:
    name: Manual Approval 1
    rows:
      - _group: summaryWithScores
      - education

    # a form can have outcomes. This is optional
    # object, optional
    outcomes:
      # an action has a key (that should follow the identifier pattern)
      # it can be a string (that should follow the name pattern)
      approve: Approve

      # or it can be an object, with the following attributes:
      reject:
        # title: It should be a name, required
        title: Reject

        # form: It determines the form to show when they choose this option.
        # object, optional
        # it should validate against the form schema.
        form:
          rows:
            - identificationDocumentType

  manualApproval2:
    name: Manual Approval 2
    rows:
      - education
    outcomes:
      reject: Reject

serviceTasks:
  calculateScore:
    name: Calculate score
    type: httpRequest
    retries: 3
    method: POST
    url: http://example.com/myEndpoint/{{tableField.lastName}}
    query:
      a: any text
      b: "{{upload}}"
      d: "{{_secrets.mySecret}}"
      e: "{{_vars.initiator.id}}"
      f: A mix of anything {{_vars.initiator.email}} {{_secrets.abc}}
    headers:
      Authorization: Bearer {{_secrets.myToken}} {{identificationNumber}}
    body:
      myKey: myValue
      anotherKey: "{{_secrets.mySecret}}"
      fieldKey: "{{salary}}"
    mapping:
      _vars.response: "{{body}}"
      tableField.lastName: "{{body.data.score}}"
      salary: "{{body.data.field}}"
      _vars.statusCode: "{{statusCode}}"
      _vars.expireDate: "{{headers}}"
  test:
    name: Calculate score
    type: httpRequest
    retries: 3
    method: POST
    url: http://example.com/myEndpoint/{{education}}
    query:
      a: any text
      b: "{{city.user}}"
      d: "{{_secrets.mySecret}}"
      e: "{{_vars.initiator.id}}"
      f: A mix of anything {{_vars.initiator.email}} {{_secrets.abc}}
    headers:
      Authorization: Bearer {{_secrets.myToken}} {{tableField}}
    body: Bearer token {{_vars.myVar}} {{_secrets.secretTres}}
