@openfn/language-openhim 0.3.16 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ast.json CHANGED
@@ -1,5 +1,372 @@
1
1
  {
2
- "operations": [],
2
+ "operations": [
3
+ {
4
+ "name": "getTransactions",
5
+ "params": [
6
+ "options"
7
+ ],
8
+ "docs": {
9
+ "description": "Make a request to OpenHIM to get transactions",
10
+ "tags": [
11
+ {
12
+ "title": "example",
13
+ "description": "getTransactions()",
14
+ "caption": "Get all transactions"
15
+ },
16
+ {
17
+ "title": "example",
18
+ "description": "getTransactions({transactionId:\"686f56e070b851d7a21898f5\"})",
19
+ "caption": "Get a specific transaction"
20
+ },
21
+ {
22
+ "title": "example",
23
+ "description": "getTransactions({\n filterLimit: 5,\n filterPage: 0,\n filterRepresentation: 'full',\n filters: '{\"response.status\":\"200\"}',\n});",
24
+ "caption": "Get transactions with filters"
25
+ },
26
+ {
27
+ "title": "function",
28
+ "description": null,
29
+ "name": null
30
+ },
31
+ {
32
+ "title": "public",
33
+ "description": null,
34
+ "type": null
35
+ },
36
+ {
37
+ "title": "param",
38
+ "description": "Optional request options. See [OpenHIM Transactions docs](https://openhim.org/docs/api/transactions/read/#read-all-transactions)",
39
+ "type": {
40
+ "type": "NameExpression",
41
+ "name": "OpenHIMGetTransactionsOptions"
42
+ },
43
+ "name": "options"
44
+ },
45
+ {
46
+ "title": "returns",
47
+ "description": null,
48
+ "type": {
49
+ "type": "NameExpression",
50
+ "name": "Operation"
51
+ }
52
+ },
53
+ {
54
+ "title": "state",
55
+ "description": "{HttpState}"
56
+ }
57
+ ]
58
+ },
59
+ "valid": true
60
+ },
61
+ {
62
+ "name": "getClients",
63
+ "params": [
64
+ "clientId"
65
+ ],
66
+ "docs": {
67
+ "description": "Make a request to OpenHIM to get all registered client records",
68
+ "tags": [
69
+ {
70
+ "title": "example",
71
+ "description": "getClients()",
72
+ "caption": "Get all clients"
73
+ },
74
+ {
75
+ "title": "example",
76
+ "description": "getClients('6823172670b851d7a222075a');",
77
+ "caption": "Get a specific client"
78
+ },
79
+ {
80
+ "title": "function",
81
+ "description": null,
82
+ "name": null
83
+ },
84
+ {
85
+ "title": "public",
86
+ "description": null,
87
+ "type": null
88
+ },
89
+ {
90
+ "title": "param",
91
+ "description": "Optional clientID to return a specific client.",
92
+ "type": {
93
+ "type": "NameExpression",
94
+ "name": "string"
95
+ },
96
+ "name": "clientId"
97
+ },
98
+ {
99
+ "title": "returns",
100
+ "description": null,
101
+ "type": {
102
+ "type": "NameExpression",
103
+ "name": "Operation"
104
+ }
105
+ },
106
+ {
107
+ "title": "state",
108
+ "description": "{HttpState}"
109
+ }
110
+ ]
111
+ },
112
+ "valid": true
113
+ },
114
+ {
115
+ "name": "createClient",
116
+ "params": [
117
+ "body"
118
+ ],
119
+ "docs": {
120
+ "description": "Make a request to OpenHIM to create a new client record",
121
+ "tags": [
122
+ {
123
+ "title": "example",
124
+ "description": "createClient({\n roles: ['fhir'],\n clientID: 'fhir-server-7',\n name: 'FHIR Server',\n passwordAlgorithm: 'sha512',\n passwordSalt: '3e74a280c568f27241e48e938edf21bf',\n passwordHash:\n '9a5158dc87a25da9d8822d48ed831a88bb4ba7fa636ddb6d6a725f73688546052cb7f2c355758e4839f9416e6cc0e37e1e3070f597af2836d39768a5ecc050db',\n});",
125
+ "caption": "Create a client record"
126
+ },
127
+ {
128
+ "title": "function",
129
+ "description": null,
130
+ "name": null
131
+ },
132
+ {
133
+ "title": "public",
134
+ "description": null,
135
+ "type": null
136
+ },
137
+ {
138
+ "title": "param",
139
+ "description": "The client data to register.",
140
+ "type": {
141
+ "type": "NameExpression",
142
+ "name": "object"
143
+ },
144
+ "name": "body"
145
+ },
146
+ {
147
+ "title": "returns",
148
+ "description": null,
149
+ "type": {
150
+ "type": "NameExpression",
151
+ "name": "Operation"
152
+ }
153
+ },
154
+ {
155
+ "title": "state",
156
+ "description": "{HttpState}"
157
+ }
158
+ ]
159
+ },
160
+ "valid": true
161
+ },
162
+ {
163
+ "name": "getChannels",
164
+ "params": [
165
+ "channelId"
166
+ ],
167
+ "docs": {
168
+ "description": "Make a request to OpenHIM to get all channel records",
169
+ "tags": [
170
+ {
171
+ "title": "example",
172
+ "description": "getChannels()",
173
+ "caption": "Get all channels"
174
+ },
175
+ {
176
+ "title": "example",
177
+ "description": "getChannels('67dac5fd70b851d7a26d1274');",
178
+ "caption": "Get a specific channel"
179
+ },
180
+ {
181
+ "title": "function",
182
+ "description": null,
183
+ "name": null
184
+ },
185
+ {
186
+ "title": "public",
187
+ "description": null,
188
+ "type": null
189
+ },
190
+ {
191
+ "title": "param",
192
+ "description": "Optional channelId to return a specific channel.",
193
+ "type": {
194
+ "type": "NameExpression",
195
+ "name": "string"
196
+ },
197
+ "name": "channelId"
198
+ },
199
+ {
200
+ "title": "returns",
201
+ "description": null,
202
+ "type": {
203
+ "type": "NameExpression",
204
+ "name": "Operation"
205
+ }
206
+ },
207
+ {
208
+ "title": "state",
209
+ "description": "{HttpState}"
210
+ }
211
+ ]
212
+ },
213
+ "valid": true
214
+ },
215
+ {
216
+ "name": "createChannel",
217
+ "params": [
218
+ "body"
219
+ ],
220
+ "docs": {
221
+ "description": "Make a request to OpenHIM to create a new channel. See [OpenHIM Channels docs](https://openhim.org/docs/api/channels/create#create-channel)",
222
+ "tags": [
223
+ {
224
+ "title": "example",
225
+ "description": "createChannel({\n type: 'http',\n authType: 'public',\n status: 'enabled',\n routes: [\n {\n name: 'FHIR Server Testing',\n secured: false,\n host: 'localhost',\n port: '3447',\n primary: true,\n },\n ],\n requestBody: true,\n responseBody: true,\n name: 'FHIR Server Testing',\n urlPattern: '^/fhir/.*$',\n methods: [\n 'GET',\n 'POST',\n ],\n});",
226
+ "caption": "Create a channel"
227
+ },
228
+ {
229
+ "title": "function",
230
+ "description": null,
231
+ "name": null
232
+ },
233
+ {
234
+ "title": "public",
235
+ "description": null,
236
+ "type": null
237
+ },
238
+ {
239
+ "title": "param",
240
+ "description": "The channel data to create.",
241
+ "type": {
242
+ "type": "NameExpression",
243
+ "name": "object"
244
+ },
245
+ "name": "body"
246
+ },
247
+ {
248
+ "title": "returns",
249
+ "description": null,
250
+ "type": {
251
+ "type": "NameExpression",
252
+ "name": "Operation"
253
+ }
254
+ },
255
+ {
256
+ "title": "state",
257
+ "description": "{HttpState}"
258
+ }
259
+ ]
260
+ },
261
+ "valid": true
262
+ },
263
+ {
264
+ "name": "getTasks",
265
+ "params": [
266
+ "options"
267
+ ],
268
+ "docs": {
269
+ "description": "Make a request to OpenHIM to get all tasks",
270
+ "tags": [
271
+ {
272
+ "title": "example",
273
+ "description": "getTasks()",
274
+ "caption": "Get all tasks"
275
+ },
276
+ {
277
+ "title": "example",
278
+ "description": "getTasks({\n filterLimit: 10,\n filterPage: 0,\n filters: '{}',\n});",
279
+ "caption": "Get all tasks with pagination options"
280
+ },
281
+ {
282
+ "title": "example",
283
+ "description": "getTasks({\n taskId: '6870fbf470b851d7a22e9f05',\n filterLimit: 10,\n filterPage: 0,\n filters: '{}',\n});",
284
+ "caption": "Get a specific task"
285
+ },
286
+ {
287
+ "title": "function",
288
+ "description": null,
289
+ "name": null
290
+ },
291
+ {
292
+ "title": "public",
293
+ "description": null,
294
+ "type": null
295
+ },
296
+ {
297
+ "title": "param",
298
+ "description": "Required request options for each request. See [OpenHIM Tasks docs](https://openhim.org/docs/api/tasks/read/#read-all-tasks)",
299
+ "type": {
300
+ "type": "NameExpression",
301
+ "name": "OpenHIMGetTasksOptions"
302
+ },
303
+ "name": "options"
304
+ },
305
+ {
306
+ "title": "returns",
307
+ "description": null,
308
+ "type": {
309
+ "type": "NameExpression",
310
+ "name": "Operation"
311
+ }
312
+ },
313
+ {
314
+ "title": "state",
315
+ "description": "{HttpState}"
316
+ }
317
+ ]
318
+ },
319
+ "valid": true
320
+ },
321
+ {
322
+ "name": "createTask",
323
+ "params": [
324
+ "body"
325
+ ],
326
+ "docs": {
327
+ "description": "Make a request to OpenHIM to create a new task",
328
+ "tags": [
329
+ {
330
+ "title": "example",
331
+ "description": "createTask({\n tids: [\n '5bb777777bbb66cc5d4444ee',\n '5ceec0bb3ca344f9a30df633',\n '5af732d1cbf94ba88b8f0bc0',\n ],\n batchSize: 2,\n paused: true,\n});",
332
+ "caption": "Create a task record"
333
+ },
334
+ {
335
+ "title": "function",
336
+ "description": null,
337
+ "name": null
338
+ },
339
+ {
340
+ "title": "public",
341
+ "description": null,
342
+ "type": null
343
+ },
344
+ {
345
+ "title": "param",
346
+ "description": "The task data to create.",
347
+ "type": {
348
+ "type": "NameExpression",
349
+ "name": "object"
350
+ },
351
+ "name": "body"
352
+ },
353
+ {
354
+ "title": "returns",
355
+ "description": null,
356
+ "type": {
357
+ "type": "NameExpression",
358
+ "name": "Operation"
359
+ }
360
+ },
361
+ {
362
+ "title": "state",
363
+ "description": "{HttpState}"
364
+ }
365
+ ]
366
+ },
367
+ "valid": true
368
+ }
369
+ ],
3
370
  "exports": [],
4
371
  "common": [
5
372
  {
@@ -270,6 +637,70 @@
270
637
  },
271
638
  "valid": true
272
639
  },
640
+ {
641
+ "name": "each",
642
+ "params": [
643
+ "dataSource",
644
+ "operation"
645
+ ],
646
+ "docs": {
647
+ "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.",
648
+ "tags": [
649
+ {
650
+ "title": "public",
651
+ "description": null,
652
+ "type": null
653
+ },
654
+ {
655
+ "title": "function",
656
+ "description": null,
657
+ "name": null
658
+ },
659
+ {
660
+ "title": "example",
661
+ "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);",
662
+ "caption": "Using lazy state ($) to iterate over items in state.data and pass each into an \"insert\" operation"
663
+ },
664
+ {
665
+ "title": "example",
666
+ "description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n ...state.data\n }))\n);",
667
+ "caption": "Iterate over items in state.data and pass each one into an \"insert\" operation"
668
+ },
669
+ {
670
+ "title": "example",
671
+ "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);",
672
+ "caption": "Using JSON path to iterate over items in state.data and pass each one into an \"insert\" operation"
673
+ },
674
+ {
675
+ "title": "param",
676
+ "description": "JSONPath referencing a point in `state`.",
677
+ "type": {
678
+ "type": "NameExpression",
679
+ "name": "DataSource"
680
+ },
681
+ "name": "dataSource"
682
+ },
683
+ {
684
+ "title": "param",
685
+ "description": "The operation needed to be repeated.",
686
+ "type": {
687
+ "type": "NameExpression",
688
+ "name": "Operation"
689
+ },
690
+ "name": "operation"
691
+ },
692
+ {
693
+ "title": "returns",
694
+ "description": null,
695
+ "type": {
696
+ "type": "NameExpression",
697
+ "name": "Operation"
698
+ }
699
+ }
700
+ ]
701
+ },
702
+ "valid": true
703
+ },
273
704
  {
274
705
  "name": "field",
275
706
  "params": [
@@ -423,6 +854,211 @@
423
854
  ]
424
855
  },
425
856
  "valid": true
857
+ },
858
+ {
859
+ "name": "cursor",
860
+ "params": [
861
+ "value",
862
+ "options"
863
+ ],
864
+ "docs": {
865
+ "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}",
866
+ "tags": [
867
+ {
868
+ "title": "public",
869
+ "description": null,
870
+ "type": null
871
+ },
872
+ {
873
+ "title": "function",
874
+ "description": null,
875
+ "name": null
876
+ },
877
+ {
878
+ "title": "example",
879
+ "description": "cursor($.cursor, { defaultValue: 'today' })",
880
+ "caption": "Use a cursor from state if present, or else use the default value"
881
+ },
882
+ {
883
+ "title": "example",
884
+ "description": "cursor(22)",
885
+ "caption": "Use a pagination cursor"
886
+ },
887
+ {
888
+ "title": "param",
889
+ "description": "the cursor value. Usually an ISO date, natural language date, or page number",
890
+ "type": {
891
+ "type": "NameExpression",
892
+ "name": "any"
893
+ },
894
+ "name": "value"
895
+ },
896
+ {
897
+ "title": "param",
898
+ "description": "options to control the cursor.",
899
+ "type": {
900
+ "type": "NameExpression",
901
+ "name": "object"
902
+ },
903
+ "name": "options"
904
+ },
905
+ {
906
+ "title": "param",
907
+ "description": "set the cursor key. Will persist through the whole run.",
908
+ "type": {
909
+ "type": "NameExpression",
910
+ "name": "string"
911
+ },
912
+ "name": "options.key"
913
+ },
914
+ {
915
+ "title": "param",
916
+ "description": "the value to use if value is falsy",
917
+ "type": {
918
+ "type": "NameExpression",
919
+ "name": "any"
920
+ },
921
+ "name": "options.defaultValue"
922
+ },
923
+ {
924
+ "title": "param",
925
+ "description": "custom formatter for the final cursor value",
926
+ "type": {
927
+ "type": "NameExpression",
928
+ "name": "Function"
929
+ },
930
+ "name": "options.format"
931
+ },
932
+ {
933
+ "title": "returns",
934
+ "description": null,
935
+ "type": {
936
+ "type": "NameExpression",
937
+ "name": "Operation"
938
+ }
939
+ }
940
+ ]
941
+ },
942
+ "valid": false
943
+ },
944
+ {
945
+ "name": "as",
946
+ "params": [
947
+ "key",
948
+ "operation"
949
+ ],
950
+ "docs": {
951
+ "description": "Run an operation and save the result to a custom key in state instead of overwriting state.data.",
952
+ "tags": [
953
+ {
954
+ "title": "public",
955
+ "description": null,
956
+ "type": null
957
+ },
958
+ {
959
+ "title": "function",
960
+ "description": null,
961
+ "name": null
962
+ },
963
+ {
964
+ "title": "example",
965
+ "description": "as('cceData', collections.get('cce-data-dhis2', { key: `*:*:${$.syncedAt}*` }));",
966
+ "caption": "Fetch cce-data from collections and store them under state.cceData"
967
+ },
968
+ {
969
+ "title": "param",
970
+ "description": "The state key to assign the result of the operation to.",
971
+ "type": {
972
+ "type": "NameExpression",
973
+ "name": "string"
974
+ },
975
+ "name": "key"
976
+ },
977
+ {
978
+ "title": "param",
979
+ "description": " An operation that returns a new state object with a `data` property",
980
+ "type": {
981
+ "type": "NameExpression",
982
+ "name": "function"
983
+ },
984
+ "name": "operation"
985
+ },
986
+ {
987
+ "title": "returns",
988
+ "description": null,
989
+ "type": {
990
+ "type": "NameExpression",
991
+ "name": "Operation"
992
+ }
993
+ }
994
+ ]
995
+ },
996
+ "valid": true
997
+ },
998
+ {
999
+ "name": "map",
1000
+ "params": {},
1001
+ "docs": {
1002
+ "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.",
1003
+ "tags": [
1004
+ {
1005
+ "title": "public",
1006
+ "description": null,
1007
+ "type": null
1008
+ },
1009
+ {
1010
+ "title": "function",
1011
+ "description": null,
1012
+ "name": null
1013
+ },
1014
+ {
1015
+ "title": "example",
1016
+ "description": "map($.items', (data, index, state) => {\n return {\n id: index + 1,\n name: data.name,\n createdAt: state.cursor,\n };\n});",
1017
+ "caption": "Transform an array of items in state"
1018
+ },
1019
+ {
1020
+ "title": "example",
1021
+ "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});",
1022
+ "caption": "Map items asynchronously (e.g. fetch extra info)"
1023
+ },
1024
+ {
1025
+ "title": "param",
1026
+ "description": "An array of items or a a JSONPath string which points to an array of items.",
1027
+ "type": {
1028
+ "type": "UnionType",
1029
+ "elements": [
1030
+ {
1031
+ "type": "NameExpression",
1032
+ "name": "string"
1033
+ },
1034
+ {
1035
+ "type": "NameExpression",
1036
+ "name": "Array"
1037
+ }
1038
+ ]
1039
+ },
1040
+ "name": "path"
1041
+ },
1042
+ {
1043
+ "title": "param",
1044
+ "description": "The mapping function, invoked with `(data, index, state)` for each item in the array.",
1045
+ "type": {
1046
+ "type": "NameExpression",
1047
+ "name": "function"
1048
+ },
1049
+ "name": "callback"
1050
+ },
1051
+ {
1052
+ "title": "returns",
1053
+ "description": null,
1054
+ "type": {
1055
+ "type": "NameExpression",
1056
+ "name": "State"
1057
+ }
1058
+ }
1059
+ ]
1060
+ },
1061
+ "valid": false
426
1062
  }
427
1063
  ]
428
1064
  }