From 4ea2965e593bb3812b1817ef4a1e31dfd121d84e Mon Sep 17 00:00:00 2001 From: Emmanuel Evance Date: Fri, 6 Sep 2024 16:29:47 +0300 Subject: [PATCH 1/2] add cursor and dateFns --- packages/openmrs/ast.json | 86 +++++++++++++++++++++++++++++++++ packages/openmrs/src/Adaptor.js | 2 + 2 files changed, 88 insertions(+) diff --git a/packages/openmrs/ast.json b/packages/openmrs/ast.json index a208d4d7b..c95119320 100644 --- a/packages/openmrs/ast.json +++ b/packages/openmrs/ast.json @@ -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 } ] } \ No newline at end of file diff --git a/packages/openmrs/src/Adaptor.js b/packages/openmrs/src/Adaptor.js index 2c43d7e91..cb21b5d39 100644 --- a/packages/openmrs/src/Adaptor.js +++ b/packages/openmrs/src/Adaptor.js @@ -498,6 +498,8 @@ export { fnIf, field, fields, + cursor, + dateFns, sourceValue, merge, dataPath, From c8dbd21a97e114a3a3a6c48accce39264587c59a Mon Sep 17 00:00:00 2001 From: Emmanuel Evance Date: Mon, 9 Sep 2024 09:08:22 +0300 Subject: [PATCH 2/2] add changeset --- .changeset/light-forks-arrive.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/light-forks-arrive.md diff --git a/.changeset/light-forks-arrive.md b/.changeset/light-forks-arrive.md new file mode 100644 index 000000000..dd8dc3499 --- /dev/null +++ b/.changeset/light-forks-arrive.md @@ -0,0 +1,5 @@ +--- +'@openfn/language-openmrs': minor +--- + +Add cursor and dateFns helper functions