{
  "operations": [
    {
      "name": "get",
      "params": [
        "path",
        "options"
      ],
      "docs": {
        "description": "Fetch resources from OpenMRS. Use this to fetch a single resource,\nor to search a list.\n\nOptions will be appended as query parameters to the request URL,\nrefer to {@link https://rest.openmrs.org/ OpenMRS Docs} for details.\n\nPagination is handled automatically by default (maximum 10k items). Set `max`\nto paginate with a higher limit, or pass `limit` to force a single request, as\nper the OpenMRS Rest API.",
        "tags": [
          {
            "title": "example",
            "description": "get(\"concept\")",
            "caption": "List all concepts (up to a maximum of 10k items, with pagination)"
          },
          {
            "title": "example",
            "description": "get(\"concept\", { query: \"brian\", max: Infinity })",
            "caption": "List all concepts (with pagination)"
          },
          {
            "title": "example",
            "description": "get(\"patient\", { query: \"brian\", max: 100 })",
            "caption": "Search up to 100 patients by name (allowing pagination) (<a href=\"https://rest.openmrs.org/#search-patients\">see OpenMRS API</a>)"
          },
          {
            "title": "example",
            "description": "get(\"patient/abc\")",
            "caption": "Fetch patient by UUID (returns an array of 1 item)"
          },
          {
            "title": "example",
            "description": "get(\"patient/abc\", { singleton: true })",
            "caption": "Fetch patient by UUID (returns an object of patient data)"
          },
          {
            "title": "example",
            "description": "get(\"patient\", { query: \"brian\", limit: 10 })",
            "caption": "Search up to 10 patients by name (in a single request without pagination) (<a href=\"https://rest.openmrs.org/#search-patients\">see OpenMRS API</a>)"
          },
          {
            "title": "example",
            "description": "get(\"patient/abc/allergy\")",
            "caption": "List allergy subresources"
          },
          {
            "title": "example",
            "description": "get(\"patient/abc/allergy/xyz\")",
            "caption": "Get allergy subresource by its UUID and parent patient UUID"
          },
          {
            "title": "example",
            "description": "get(\"patient/abc\", { language: \"fr\" })",
            "caption": "Get patient by UUID and set the language to French"
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "param",
            "description": "Path to resource (excluding `/ws/rest/v1/`)",
            "type": {
              "type": "NameExpression",
              "name": "string"
            },
            "name": "path"
          },
          {
            "title": "param",
            "description": "Query parameters and other options for the request.",
            "type": {
              "type": "OptionalType",
              "expression": {
                "type": "NameExpression",
                "name": "GetOptions"
              }
            },
            "name": "options",
            "default": "{}"
          },
          {
            "title": "state",
            "description": "data An array of result objects"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "Operation"
            }
          }
        ]
      },
      "valid": true
    },
    {
      "name": "create",
      "params": [
        "path",
        "data"
      ],
      "docs": {
        "description": "Create a resource. For a list of valid resources, see {@link https://rest.openmrs.org/ OpenMRS Docs}",
        "tags": [
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "param",
            "description": "Path to resource (excluding `/ws/rest/v1/`)",
            "type": {
              "type": "NameExpression",
              "name": "string"
            },
            "name": "path"
          },
          {
            "title": "param",
            "description": "Resource definition",
            "type": {
              "type": "NameExpression",
              "name": "object"
            },
            "name": "data"
          },
          {
            "title": "state",
            "description": "data The newly created resource, as returned by OpenMRS"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "Operation"
            }
          },
          {
            "title": "example",
            "description": "create(\"person\", {\n  names: [\n    {\n      givenName: \"Mohit\",\n      familyName: \"Kumar\",\n    },\n  ],\n  gender: \"M\",\n  birthdate: \"1997-09-02\",\n  addresses: [\n    {\n      address1: \"30, Vivekananda Layout, Munnekolal,Marathahalli\",\n      cityVillage: \"Bengaluru\",\n      country: \"India\",\n      postalCode: \"560037\",\n    },\n  ],\n});",
            "caption": "Create a person (<a href=\"https://rest.openmrs.org/#create-a-person\">see OpenMRS API</a>)"
          },
          {
            "title": "example",
            "description": "create(\"encounter\", {\n  encounterDatetime: '2023-05-25T06:08:25.000+0000',\n  patient: '1fdaa696-e759-4a7d-a066-f1ae557c151b',\n  encounterType: 'dd528487-82a5-4082-9c72-ed246bd49591',\n  location: 'ba685651-ed3b-4e63-9b35-78893060758a',\n  encounterProviders: [],\n  visit: {\n    patient: '1fdaa696-e759-4a7d-a066-f1ae557c151b',\n    visitType: '7b0f5697-27e3-40c4-8bae-f4049abfb4ed',\n    startDatetime: '2023-05-25T06:08:25.000+0000',\n    stopDatetime: '2023-05-25T06:09:25.000+0000',\n  },\n})",
            "caption": "Create an encounter (<a href=\"https://rest.openmrs.org/#create-an-encounter\">see OpenMRS API</a>)"
          },
          {
            "title": "example",
            "description": "create(\"patient\", {\n  identifiers: [\n    {\n      identifier: '4023287',\n      identifierType: '05a29f94-c0ed-11e2-94be-8c13b969e334',\n      preferred: true,\n    },\n  ],\n  person: {\n    gender: 'M',\n    age: 42,\n    birthdate: '1970-01-01T00:00:00.000+0100',\n    birthdateEstimated: false,\n    names: [\n      {\n        givenName: 'Doe',\n        familyName: 'John',\n      },\n    ],\n  },\n})",
            "caption": "Create a patient (<a href=\"https://rest.openmrs.org/#create-a-patient\">see OpenMRS API</a>)"
          },
          {
            "title": "example",
            "description": "create(\"patient/b52ec6f9-0e26-424c-a4a1-c64f9d571eb3/identifier\", { \n \"identifier\" : \"111:CLINIC1\",\n \"identifierType\" : \"a5d38e09-efcb-4d91-a526-50ce1ba5011a\",\n \"location\" : \"8d6c993e-c2cc-11de-8d13-0010c6dffd0f\",\n \"preferred\" : true\n})\n}",
            "caption": "Create a patientIdentifier subresource (<a href=\"https://rest.openmrs.org/#create-a-patientidentifier-sub-resource-with-properties\">see OpenMRS API</a>)"
          }
        ]
      },
      "valid": true
    },
    {
      "name": "update",
      "params": [
        "path",
        "data"
      ],
      "docs": {
        "description": "Update a resource. Only properties included in the data will be affected.\nFor a list of valid resources and for update rules, see the Update sections\nof the {@link https://rest.openmrs.org/ OpenMRS Docs}",
        "tags": [
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "param",
            "description": "Path to resource (excluding `/ws/rest/v1/`)",
            "type": {
              "type": "NameExpression",
              "name": "string"
            },
            "name": "path"
          },
          {
            "title": "param",
            "description": "Resource properties to update",
            "type": {
              "type": "NameExpression",
              "name": "Object"
            },
            "name": "data"
          },
          {
            "title": "state",
            "description": "data The full updated resource, as returned by OpenMRS"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "Operation"
            }
          },
          {
            "title": "example",
            "description": "update('person/3cad37ad-984d-4c65-a019-3eb120c9c373', {\n  'gender': 'M',\n  'birthdate':'1997-01-13'\n})",
            "caption": "Update a person (<a href=\"https://rest.openmrs.org/#create-a-person\">see OpenMRS API</a>)"
          }
        ]
      },
      "valid": true
    },
    {
      "name": "upsert",
      "params": [
        "path",
        "data",
        "params"
      ],
      "docs": {
        "description": "Update a resource if it already exists, or otherwise create a new one.\n\nUpsert will first make a request for the target item (using the `path` and `params`) to see if it exists, and then issue a second create or update request.\nIf the query request returns multiple items, the upsert will throw an error.\n\nParams will be appended as query parameters to the request URL,\nrefer to {@link https://rest.openmrs.org/ OpenMRS Docs} for details.",
        "tags": [
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "param",
            "description": "Path to resource (excluding `/ws/rest/v1/`)",
            "type": {
              "type": "NameExpression",
              "name": "string"
            },
            "name": "path"
          },
          {
            "title": "param",
            "description": "The resource data",
            "type": {
              "type": "NameExpression",
              "name": "Object"
            },
            "name": "data"
          },
          {
            "title": "param",
            "description": "Query parameters to append to the initial query",
            "type": {
              "type": "NameExpression",
              "name": "Object"
            },
            "name": "params"
          },
          {
            "title": "state",
            "description": "data The created/updated resource, as returned by OpenMRS"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "Operation"
            }
          },
          {
            "title": "example",
            "description": "upsert(\"patient/a5d38e09-efcb-4d91-a526-50ce1ba5011a\", {\n  identifiers: [\n    {\n      identifier: '4023287',\n      identifierType: '05a29f94-c0ed-11e2-94be-8c13b969e334',\n      preferred: true,\n    },\n  ],\n  person: {\n    gender: 'M',\n    age: 42,\n    birthdate: '1970-01-01T00:00:00.000+0100',\n    birthdateEstimated: false,\n    names: [\n      {\n        givenName: 'Doe',\n        familyName: 'John',\n      },\n    ],\n  },\n})",
            "caption": "Upsert a patient (<a href=\"https://rest.openmrs.org/#patients-overview\">see OpenMRS API</a>)"
          },
          {
            "title": "example",
            "description": "upsert(\"patient\", $.data, { q: \"Lamine Yamal\", limit: 1 })",
            "caption": "Upsert a patient using a query to identify the record"
          }
        ]
      },
      "valid": true
    },
    {
      "name": "destroy",
      "params": [
        "path",
        "options"
      ],
      "docs": {
        "description": "Delete a resource. Must include a UUID in the path.\nThrows an error if the resource does not exist.",
        "tags": [
          {
            "title": "example",
            "description": "destroy(\"patient/12346\");",
            "caption": "Void a patient"
          },
          {
            "title": "example",
            "description": "destroy(\"patient/12346\", {\n  purge: true\n});",
            "caption": "Purge a patient"
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "param",
            "description": "Path to resource (excluding `/ws/rest/v1/`)",
            "type": {
              "type": "NameExpression",
              "name": "string"
            },
            "name": "path"
          },
          {
            "title": "param",
            "description": null,
            "type": {
              "type": "OptionalType",
              "expression": {
                "type": "NameExpression",
                "name": "object"
              }
            },
            "name": "options",
            "default": "{}"
          },
          {
            "title": "param",
            "description": "The resource will be voided/retired unless true",
            "type": {
              "type": "OptionalType",
              "expression": {
                "type": "NameExpression",
                "name": "object"
              }
            },
            "name": "options.purge",
            "default": "false"
          },
          {
            "title": "state",
            "description": "data The response from OpenMRS"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "Operation"
            }
          }
        ]
      },
      "valid": false
    }
  ],
  "exports": [],
  "common": [
    {
      "name": "fn",
      "params": [
        "func"
      ],
      "docs": {
        "description": "Creates a custom step (or operation) for more flexible job writing.",
        "tags": [
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "example",
            "description": "fn(state => {\n  // do some things to state\n  return state;\n});"
          },
          {
            "title": "param",
            "description": "is the function",
            "type": {
              "type": "NameExpression",
              "name": "Function"
            },
            "name": "func"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "Operation"
            }
          }
        ]
      },
      "valid": true
    },
    {
      "name": "fnIf",
      "params": [
        "condition",
        "operation"
      ],
      "docs": {
        "description": "Execute a function only when the condition returns true",
        "tags": [
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "example",
            "description": "fnIf((state) => state?.data?.name, get(\"https://example.com\"));"
          },
          {
            "title": "param",
            "description": "The condition that returns true",
            "type": {
              "type": "NameExpression",
              "name": "Boolean"
            },
            "name": "condition"
          },
          {
            "title": "param",
            "description": "The operation needed to be executed.",
            "type": {
              "type": "NameExpression",
              "name": "Operation"
            },
            "name": "operation"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "Operation"
            }
          }
        ]
      },
      "valid": true
    },
    {
      "name": "sourceValue",
      "params": [
        "path"
      ],
      "docs": {
        "description": "Picks out a single value from source data.\nIf a JSONPath returns more than one value for the reference, the first\nitem will be returned.",
        "tags": [
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "example",
            "description": "sourceValue('$.key')"
          },
          {
            "title": "param",
            "description": "JSONPath referencing a point in `state`.",
            "type": {
              "type": "NameExpression",
              "name": "String"
            },
            "name": "path"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "Operation"
            }
          }
        ]
      },
      "valid": true
    },
    {
      "name": "dataPath",
      "params": [
        "path"
      ],
      "docs": {
        "description": "Ensures a path points at the data.",
        "tags": [
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "example",
            "description": "dataPath('key')"
          },
          {
            "title": "param",
            "description": "JSONPath referencing a point in `data`.",
            "type": {
              "type": "NameExpression",
              "name": "string"
            },
            "name": "path"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "string"
            }
          }
        ]
      },
      "valid": true
    },
    {
      "name": "dataValue",
      "params": [
        "path"
      ],
      "docs": {
        "description": "Picks out a single value from the source data object—usually `state.data`.\nIf a JSONPath returns more than one value for the reference, the first\nitem will be returned.",
        "tags": [
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "example",
            "description": "dataValue('key')"
          },
          {
            "title": "param",
            "description": "JSONPath referencing a point in `data`.",
            "type": {
              "type": "NameExpression",
              "name": "String"
            },
            "name": "path"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "Operation"
            }
          }
        ]
      },
      "valid": true
    },
    {
      "name": "lastReferenceValue",
      "params": [
        "path"
      ],
      "docs": {
        "description": "Picks out the last reference value from source data.",
        "tags": [
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "example",
            "description": "lastReferenceValue('key')"
          },
          {
            "title": "param",
            "description": "JSONPath referencing a point in `references`.",
            "type": {
              "type": "NameExpression",
              "name": "String"
            },
            "name": "path"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "Operation"
            }
          }
        ]
      },
      "valid": true
    },
    {
      "name": "each",
      "params": [
        "dataSource",
        "operation"
      ],
      "docs": {
        "description": "Iterates over an array of items and invokes an operation upon each one, where the state\nobject is _scoped_ so that state.data is the item under iteration.\nThe rest of the state object is untouched and can be referenced as usual.\nYou can pass an array directly, or use lazy state or a JSONPath string to\nreference a slice of state.",
        "tags": [
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "example",
            "description": "each(\n  $.data,\n  // Inside the callback operation, `$.data` is scoped to the item under iteration\n  insert(\"patient\", {\n    patient_name: $.data.properties.case_name,\n    patient_id: $.data.case_id,\n  })\n);",
            "caption": "Using lazy state ($) to iterate over items in state.data and pass each into an \"insert\" operation"
          },
          {
            "title": "example",
            "description": "each(\n  $.data,\n  insert(\"patient\", (state) => ({\n    patient_id: state.data.case_id,\n    ...state.data\n  }))\n);",
            "caption": "Iterate over items in state.data and pass each one into an \"insert\" operation"
          },
          {
            "title": "example",
            "description": "each(\n  \"$.data[*]\",\n  insert(\"patient\", (state) => ({\n    patient_name: state.data.properties.case_name,\n    patient_id: state.data.case_id,\n  }))\n);",
            "caption": "Using JSON path to iterate over items in state.data and pass each one into an \"insert\" operation"
          },
          {
            "title": "param",
            "description": "JSONPath referencing a point in `state`.",
            "type": {
              "type": "NameExpression",
              "name": "DataSource"
            },
            "name": "dataSource"
          },
          {
            "title": "param",
            "description": "The operation needed to be repeated.",
            "type": {
              "type": "NameExpression",
              "name": "Operation"
            },
            "name": "operation"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "Operation"
            }
          }
        ]
      },
      "valid": true
    },
    {
      "name": "combine",
      "params": [
        "operations"
      ],
      "docs": {
        "description": "Combines two operations into one",
        "tags": [
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "example",
            "description": "combine(\n  create('foo'),\n  delete('bar')\n)"
          },
          {
            "title": "param",
            "description": "Operations to be performed.",
            "type": {
              "type": "NameExpression",
              "name": "Operations"
            },
            "name": "operations"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "Operation"
            }
          }
        ]
      },
      "valid": true
    },
    {
      "name": "field",
      "params": [
        "key",
        "value"
      ],
      "docs": {
        "description": "Returns a key, value pair in an array.",
        "tags": [
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "example",
            "description": "field('destination_field_name__c', 'value')"
          },
          {
            "title": "param",
            "description": "Name of the field",
            "type": {
              "type": "NameExpression",
              "name": "string"
            },
            "name": "key"
          },
          {
            "title": "param",
            "description": "The value itself or a sourceable operation.",
            "type": {
              "type": "NameExpression",
              "name": "Value"
            },
            "name": "value"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "Field"
            }
          }
        ]
      },
      "valid": true
    },
    {
      "name": "fields",
      "params": [
        "fields"
      ],
      "docs": {
        "description": "Zips key value pairs into an object.",
        "tags": [
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "example",
            "description": "fields(list_of_fields)"
          },
          {
            "title": "param",
            "description": "a list of fields",
            "type": {
              "type": "NameExpression",
              "name": "Fields"
            },
            "name": "fields"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "Object"
            }
          }
        ]
      },
      "valid": true
    },
    {
      "name": "merge",
      "params": [
        "dataSource",
        "fields"
      ],
      "docs": {
        "description": "Merges fields into each item in an array.",
        "tags": [
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "example",
            "description": "merge(\n  \"$.books[*]\",\n  fields(\n    field( \"publisher\", sourceValue(\"$.publisher\") )\n  )\n)"
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "param",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "DataSource"
            },
            "name": "dataSource"
          },
          {
            "title": "param",
            "description": "Group of fields to merge in.",
            "type": {
              "type": "NameExpression",
              "name": "Object"
            },
            "name": "fields"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "DataSource"
            }
          }
        ]
      },
      "valid": true
    },
    {
      "name": "arrayToString",
      "params": [
        "arr",
        "separator"
      ],
      "docs": {
        "description": "Turns an array into a string, separated by X.",
        "tags": [
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "example",
            "description": "field(\"destination_string__c\", function(state) {\n  return arrayToString(dataValue(\"path_of_array\")(state), ', ')\n})"
          },
          {
            "title": "param",
            "description": "Array of toString'able primatives.",
            "type": {
              "type": "NameExpression",
              "name": "array"
            },
            "name": "arr"
          },
          {
            "title": "param",
            "description": "Separator string.",
            "type": {
              "type": "NameExpression",
              "name": "string"
            },
            "name": "separator"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "string"
            }
          }
        ]
      },
      "valid": true
    },
    {
      "name": "cursor",
      "params": [
        "value",
        "options"
      ],
      "docs": {
        "description": "Sets a cursor property on state.\nSupports natural language dates like `now`, `today`, `yesterday`, `n hours ago`, `n days ago`, and `start`,\nwhich will be converted relative to the environment (ie, the Lightning or CLI locale). Custom timezones\nare not yet supported.\nYou can provide a formatter to customise the final cursor value, which is useful for normalising\ndifferent inputs. The custom formatter runs after natural language date conversion.\nSee the usage guide at {@link https://docs.openfn.org/documentation/jobs/job-writing-guide#using-cursors}",
        "tags": [
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "example",
            "description": "cursor($.cursor, { defaultValue: 'today' })",
            "caption": "Use a cursor from state if present, or else use the default value"
          },
          {
            "title": "example",
            "description": "cursor(22)",
            "caption": "Use a pagination cursor"
          },
          {
            "title": "param",
            "description": "the cursor value. Usually an ISO date, natural language date, or page number",
            "type": {
              "type": "NameExpression",
              "name": "any"
            },
            "name": "value"
          },
          {
            "title": "param",
            "description": "options to control the cursor.",
            "type": {
              "type": "NameExpression",
              "name": "object"
            },
            "name": "options"
          },
          {
            "title": "param",
            "description": "set the cursor key. Will persist through the whole run.",
            "type": {
              "type": "NameExpression",
              "name": "string"
            },
            "name": "options.key"
          },
          {
            "title": "param",
            "description": "the value to use if value is falsy",
            "type": {
              "type": "NameExpression",
              "name": "any"
            },
            "name": "options.defaultValue"
          },
          {
            "title": "param",
            "description": "custom formatter for the final cursor value",
            "type": {
              "type": "NameExpression",
              "name": "Function"
            },
            "name": "options.format"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "Operation"
            }
          }
        ]
      },
      "valid": false
    },
    {
      "name": "log",
      "params": [
        "args"
      ],
      "docs": {
        "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.",
        "tags": [
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "example",
            "description": "log('Patient List::', $.patients);",
            "caption": "Log values from state"
          },
          {
            "title": "example",
            "description": "fn((state) => {\n  console.log(state.data);\n  return state;\n})",
            "caption": "Use console.log inside a callback or fn block"
          },
          {
            "title": "param",
            "description": "A value or message to display in the logs",
            "type": {
              "type": "NameExpression",
              "name": "any"
            },
            "name": "args"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "Operation"
            }
          }
        ]
      },
      "valid": true
    },
    {
      "name": "as",
      "params": [
        "key",
        "operation"
      ],
      "docs": {
        "description": "Run an operation and save the result to a custom key in state instead of overwriting state.data.",
        "tags": [
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "example",
            "description": "as('cceData', collections.get('cce-data-dhis2', { key: `*:*:${$.syncedAt}*` }));",
            "caption": "Fetch cce-data from collections and store them under state.cceData"
          },
          {
            "title": "param",
            "description": "The state key to assign the result of the operation to.",
            "type": {
              "type": "NameExpression",
              "name": "string"
            },
            "name": "key"
          },
          {
            "title": "param",
            "description": " An operation that returns a new state object with a `data` property",
            "type": {
              "type": "NameExpression",
              "name": "function"
            },
            "name": "operation"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "Operation"
            }
          }
        ]
      },
      "valid": true
    },
    {
      "name": "map",
      "params": {},
      "docs": {
        "description": "Iterates over a collection of items and returns a new array of mapped values,\nlike Javascript's `Array.map()` function.\n\nEach item in the source array will be passed into the callback function. The returned value\nwill be added to the new array. The callback is passed the original item, the current index\nin the source array (ie, the nth item number), and the state object.\n\nWrites a new array to `state.data` with transformed values.c array.",
        "tags": [
          {
            "title": "public",
            "description": null,
            "type": null
          },
          {
            "title": "function",
            "description": null,
            "name": null
          },
          {
            "title": "example",
            "description": "map($.items', (data, index, state) => {\n  return {\n    id: index + 1,\n    name: data.name,\n    createdAt: state.cursor,\n  };\n});",
            "caption": "Transform an array of items in state"
          },
          {
            "title": "example",
            "description": "map($.items, async (data, index, state) => {\n  const userInfo = await fetchUserInfo(data.userId);\n  return {\n    id: index + 1,\n    name: data.name,\n    extra: userInfo,\n  };\n});",
            "caption": "Map items asynchronously (e.g. fetch extra info)"
          },
          {
            "title": "param",
            "description": "An array of items or a a JSONPath string which points to an array of items.",
            "type": {
              "type": "UnionType",
              "elements": [
                {
                  "type": "NameExpression",
                  "name": "string"
                },
                {
                  "type": "NameExpression",
                  "name": "Array"
                }
              ]
            },
            "name": "path"
          },
          {
            "title": "param",
            "description": "The mapping function, invoked with `(data, index, state)` for each item in the array.",
            "type": {
              "type": "NameExpression",
              "name": "function"
            },
            "name": "callback"
          },
          {
            "title": "returns",
            "description": null,
            "type": {
              "type": "NameExpression",
              "name": "State"
            }
          }
        ]
      },
      "valid": false
    }
  ]
}