Skip to content

Commit

Permalink
Merge pull request #743 from OpenFn/openmrs-cursor
Browse files Browse the repository at this point in the history
`openmrs` add cursor and dateFns
  • Loading branch information
josephjclark authored Sep 11, 2024
2 parents 152deb0 + c8dbd21 commit 3f16170
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/light-forks-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openfn/language-openmrs': minor
---

Add cursor and dateFns helper functions
86 changes: 86 additions & 0 deletions packages/openmrs/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,92 @@
]
},
"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
}
]
}
2 changes: 2 additions & 0 deletions packages/openmrs/src/Adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ export {
fnIf,
field,
fields,
cursor,
dateFns,
sourceValue,
merge,
dataPath,
Expand Down

0 comments on commit 3f16170

Please sign in to comment.