Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openmrs add cursor and dateFns #743

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading