@openfn/language-openhim 0.3.16 → 1.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,415 @@
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": "registerClient",
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": "registerClient({\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": "updateClient",
164
+ "params": [
165
+ "body"
166
+ ],
167
+ "docs": {
168
+ "description": "Make a request to OpenHIM to update a client record",
169
+ "tags": [
170
+ {
171
+ "title": "example",
172
+ "description": "updateClient({\n _id:'6870c19870b851d7a22b8d27',\n roles: ['fhir', 'testing'],\n clientID: 'fhir-server-7',\n name: 'FHIR Server Testing',\n passwordAlgorithm: 'sha512',\n passwordSalt: '3e74a280c568f27241e48e938edf21bf',\n passwordHash:\n '9a5158dc87a25da9d8822d48ed831a88bb4ba7fa636ddb6d6a725f73688546052cb7f2c355758e4839f9416e6cc0e37e1e3070f597af2836d39768a5ecc050db',\n});",
173
+ "caption": "Update a client record"
174
+ },
175
+ {
176
+ "title": "function",
177
+ "description": null,
178
+ "name": null
179
+ },
180
+ {
181
+ "title": "public",
182
+ "description": null,
183
+ "type": null
184
+ },
185
+ {
186
+ "title": "param",
187
+ "description": "The client data to update.",
188
+ "type": {
189
+ "type": "NameExpression",
190
+ "name": "object"
191
+ },
192
+ "name": "body"
193
+ },
194
+ {
195
+ "title": "returns",
196
+ "description": null,
197
+ "type": {
198
+ "type": "NameExpression",
199
+ "name": "Operation"
200
+ }
201
+ },
202
+ {
203
+ "title": "state",
204
+ "description": "{HttpState}"
205
+ }
206
+ ]
207
+ },
208
+ "valid": true
209
+ },
210
+ {
211
+ "name": "getChannels",
212
+ "params": [
213
+ "channelId"
214
+ ],
215
+ "docs": {
216
+ "description": "Make a request to OpenHIM to get all channel records",
217
+ "tags": [
218
+ {
219
+ "title": "example",
220
+ "description": "getChannels()",
221
+ "caption": "Get all channels"
222
+ },
223
+ {
224
+ "title": "example",
225
+ "description": "getChannels('67dac5fd70b851d7a26d1274');",
226
+ "caption": "Get a specific 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": "Optional channelId to return a specific channel.",
241
+ "type": {
242
+ "type": "NameExpression",
243
+ "name": "string"
244
+ },
245
+ "name": "channelId"
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": "createChannel",
265
+ "params": [
266
+ "body"
267
+ ],
268
+ "docs": {
269
+ "description": "Make a request to OpenHIM to create a new channel. See [OpenHIM Channels docs](https://openhim.org/docs/api/channels/create#create-channel)",
270
+ "tags": [
271
+ {
272
+ "title": "example",
273
+ "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});",
274
+ "caption": "Create a channel"
275
+ },
276
+ {
277
+ "title": "function",
278
+ "description": null,
279
+ "name": null
280
+ },
281
+ {
282
+ "title": "public",
283
+ "description": null,
284
+ "type": null
285
+ },
286
+ {
287
+ "title": "param",
288
+ "description": "The channel data to create.",
289
+ "type": {
290
+ "type": "NameExpression",
291
+ "name": "object"
292
+ },
293
+ "name": "body"
294
+ },
295
+ {
296
+ "title": "returns",
297
+ "description": null,
298
+ "type": {
299
+ "type": "NameExpression",
300
+ "name": "Operation"
301
+ }
302
+ },
303
+ {
304
+ "title": "state",
305
+ "description": "{HttpState}"
306
+ }
307
+ ]
308
+ },
309
+ "valid": true
310
+ },
311
+ {
312
+ "name": "getTasks",
313
+ "params": [
314
+ "options"
315
+ ],
316
+ "docs": {
317
+ "description": "Make a request to OpenHIM to get all tasks",
318
+ "tags": [
319
+ {
320
+ "title": "example",
321
+ "description": "getTasks({\n filterLimit: 10,\n filterPage: 0,\n filters: '{}',\n});",
322
+ "caption": "Get all tasks"
323
+ },
324
+ {
325
+ "title": "example",
326
+ "description": "getTasks({\n taskId: '6870fbf470b851d7a22e9f05',\n filterLimit: 10,\n filterPage: 0,\n filters: '{}',\n});",
327
+ "caption": "Get a specific task"
328
+ },
329
+ {
330
+ "title": "function",
331
+ "description": null,
332
+ "name": null
333
+ },
334
+ {
335
+ "title": "public",
336
+ "description": null,
337
+ "type": null
338
+ },
339
+ {
340
+ "title": "param",
341
+ "description": "Required request options for each request. See [OpenHIM Tasks docs](https://openhim.org/docs/api/tasks/read/#read-all-tasks)",
342
+ "type": {
343
+ "type": "NameExpression",
344
+ "name": "OpenHIMGetTasksOptions"
345
+ },
346
+ "name": "options"
347
+ },
348
+ {
349
+ "title": "returns",
350
+ "description": null,
351
+ "type": {
352
+ "type": "NameExpression",
353
+ "name": "Operation"
354
+ }
355
+ },
356
+ {
357
+ "title": "state",
358
+ "description": "{HttpState}"
359
+ }
360
+ ]
361
+ },
362
+ "valid": true
363
+ },
364
+ {
365
+ "name": "createTask",
366
+ "params": [
367
+ "body"
368
+ ],
369
+ "docs": {
370
+ "description": "Make a request to OpenHIM to create a new task",
371
+ "tags": [
372
+ {
373
+ "title": "example",
374
+ "description": "createTask({\n tids: [\n '5bb777777bbb66cc5d4444ee',\n '5ceec0bb3ca344f9a30df633',\n '5af732d1cbf94ba88b8f0bc0',\n ],\n batchSize: 2,\n paused: true,\n});",
375
+ "caption": "Create a task record"
376
+ },
377
+ {
378
+ "title": "function",
379
+ "description": null,
380
+ "name": null
381
+ },
382
+ {
383
+ "title": "public",
384
+ "description": null,
385
+ "type": null
386
+ },
387
+ {
388
+ "title": "param",
389
+ "description": "The task data to create.",
390
+ "type": {
391
+ "type": "NameExpression",
392
+ "name": "object"
393
+ },
394
+ "name": "body"
395
+ },
396
+ {
397
+ "title": "returns",
398
+ "description": null,
399
+ "type": {
400
+ "type": "NameExpression",
401
+ "name": "Operation"
402
+ }
403
+ },
404
+ {
405
+ "title": "state",
406
+ "description": "{HttpState}"
407
+ }
408
+ ]
409
+ },
410
+ "valid": true
411
+ }
412
+ ],
3
413
  "exports": [],
4
414
  "common": [
5
415
  {
@@ -270,6 +680,70 @@
270
680
  },
271
681
  "valid": true
272
682
  },
683
+ {
684
+ "name": "each",
685
+ "params": [
686
+ "dataSource",
687
+ "operation"
688
+ ],
689
+ "docs": {
690
+ "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.",
691
+ "tags": [
692
+ {
693
+ "title": "public",
694
+ "description": null,
695
+ "type": null
696
+ },
697
+ {
698
+ "title": "function",
699
+ "description": null,
700
+ "name": null
701
+ },
702
+ {
703
+ "title": "example",
704
+ "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);",
705
+ "caption": "Using lazy state ($) to iterate over items in state.data and pass each into an \"insert\" operation"
706
+ },
707
+ {
708
+ "title": "example",
709
+ "description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n ...state.data\n }))\n);",
710
+ "caption": "Iterate over items in state.data and pass each one into an \"insert\" operation"
711
+ },
712
+ {
713
+ "title": "example",
714
+ "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);",
715
+ "caption": "Using JSON path to iterate over items in state.data and pass each one into an \"insert\" operation"
716
+ },
717
+ {
718
+ "title": "param",
719
+ "description": "JSONPath referencing a point in `state`.",
720
+ "type": {
721
+ "type": "NameExpression",
722
+ "name": "DataSource"
723
+ },
724
+ "name": "dataSource"
725
+ },
726
+ {
727
+ "title": "param",
728
+ "description": "The operation needed to be repeated.",
729
+ "type": {
730
+ "type": "NameExpression",
731
+ "name": "Operation"
732
+ },
733
+ "name": "operation"
734
+ },
735
+ {
736
+ "title": "returns",
737
+ "description": null,
738
+ "type": {
739
+ "type": "NameExpression",
740
+ "name": "Operation"
741
+ }
742
+ }
743
+ ]
744
+ },
745
+ "valid": true
746
+ },
273
747
  {
274
748
  "name": "field",
275
749
  "params": [
@@ -423,6 +897,211 @@
423
897
  ]
424
898
  },
425
899
  "valid": true
900
+ },
901
+ {
902
+ "name": "cursor",
903
+ "params": [
904
+ "value",
905
+ "options"
906
+ ],
907
+ "docs": {
908
+ "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}",
909
+ "tags": [
910
+ {
911
+ "title": "public",
912
+ "description": null,
913
+ "type": null
914
+ },
915
+ {
916
+ "title": "function",
917
+ "description": null,
918
+ "name": null
919
+ },
920
+ {
921
+ "title": "example",
922
+ "description": "cursor($.cursor, { defaultValue: 'today' })",
923
+ "caption": "Use a cursor from state if present, or else use the default value"
924
+ },
925
+ {
926
+ "title": "example",
927
+ "description": "cursor(22)",
928
+ "caption": "Use a pagination cursor"
929
+ },
930
+ {
931
+ "title": "param",
932
+ "description": "the cursor value. Usually an ISO date, natural language date, or page number",
933
+ "type": {
934
+ "type": "NameExpression",
935
+ "name": "any"
936
+ },
937
+ "name": "value"
938
+ },
939
+ {
940
+ "title": "param",
941
+ "description": "options to control the cursor.",
942
+ "type": {
943
+ "type": "NameExpression",
944
+ "name": "object"
945
+ },
946
+ "name": "options"
947
+ },
948
+ {
949
+ "title": "param",
950
+ "description": "set the cursor key. Will persist through the whole run.",
951
+ "type": {
952
+ "type": "NameExpression",
953
+ "name": "string"
954
+ },
955
+ "name": "options.key"
956
+ },
957
+ {
958
+ "title": "param",
959
+ "description": "the value to use if value is falsy",
960
+ "type": {
961
+ "type": "NameExpression",
962
+ "name": "any"
963
+ },
964
+ "name": "options.defaultValue"
965
+ },
966
+ {
967
+ "title": "param",
968
+ "description": "custom formatter for the final cursor value",
969
+ "type": {
970
+ "type": "NameExpression",
971
+ "name": "Function"
972
+ },
973
+ "name": "options.format"
974
+ },
975
+ {
976
+ "title": "returns",
977
+ "description": null,
978
+ "type": {
979
+ "type": "NameExpression",
980
+ "name": "Operation"
981
+ }
982
+ }
983
+ ]
984
+ },
985
+ "valid": false
986
+ },
987
+ {
988
+ "name": "as",
989
+ "params": [
990
+ "key",
991
+ "operation"
992
+ ],
993
+ "docs": {
994
+ "description": "Run an operation and save the result to a custom key in state instead of overwriting state.data.",
995
+ "tags": [
996
+ {
997
+ "title": "public",
998
+ "description": null,
999
+ "type": null
1000
+ },
1001
+ {
1002
+ "title": "function",
1003
+ "description": null,
1004
+ "name": null
1005
+ },
1006
+ {
1007
+ "title": "example",
1008
+ "description": "as('cceData', collections.get('cce-data-dhis2', { key: `*:*:${$.syncedAt}*` }));",
1009
+ "caption": "Fetch cce-data from collections and store them under state.cceData"
1010
+ },
1011
+ {
1012
+ "title": "param",
1013
+ "description": "The state key to assign the result of the operation to.",
1014
+ "type": {
1015
+ "type": "NameExpression",
1016
+ "name": "string"
1017
+ },
1018
+ "name": "key"
1019
+ },
1020
+ {
1021
+ "title": "param",
1022
+ "description": " An operation that returns a new state object with a `data` property",
1023
+ "type": {
1024
+ "type": "NameExpression",
1025
+ "name": "function"
1026
+ },
1027
+ "name": "operation"
1028
+ },
1029
+ {
1030
+ "title": "returns",
1031
+ "description": null,
1032
+ "type": {
1033
+ "type": "NameExpression",
1034
+ "name": "Operation"
1035
+ }
1036
+ }
1037
+ ]
1038
+ },
1039
+ "valid": true
1040
+ },
1041
+ {
1042
+ "name": "map",
1043
+ "params": {},
1044
+ "docs": {
1045
+ "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.",
1046
+ "tags": [
1047
+ {
1048
+ "title": "public",
1049
+ "description": null,
1050
+ "type": null
1051
+ },
1052
+ {
1053
+ "title": "function",
1054
+ "description": null,
1055
+ "name": null
1056
+ },
1057
+ {
1058
+ "title": "example",
1059
+ "description": "map($.items', (data, index, state) => {\n return {\n id: index + 1,\n name: data.name,\n createdAt: state.cursor,\n };\n});",
1060
+ "caption": "Transform an array of items in state"
1061
+ },
1062
+ {
1063
+ "title": "example",
1064
+ "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});",
1065
+ "caption": "Map items asynchronously (e.g. fetch extra info)"
1066
+ },
1067
+ {
1068
+ "title": "param",
1069
+ "description": "An array of items or a a JSONPath string which points to an array of items.",
1070
+ "type": {
1071
+ "type": "UnionType",
1072
+ "elements": [
1073
+ {
1074
+ "type": "NameExpression",
1075
+ "name": "string"
1076
+ },
1077
+ {
1078
+ "type": "NameExpression",
1079
+ "name": "Array"
1080
+ }
1081
+ ]
1082
+ },
1083
+ "name": "path"
1084
+ },
1085
+ {
1086
+ "title": "param",
1087
+ "description": "The mapping function, invoked with `(data, index, state)` for each item in the array.",
1088
+ "type": {
1089
+ "type": "NameExpression",
1090
+ "name": "function"
1091
+ },
1092
+ "name": "callback"
1093
+ },
1094
+ {
1095
+ "title": "returns",
1096
+ "description": null,
1097
+ "type": {
1098
+ "type": "NameExpression",
1099
+ "name": "State"
1100
+ }
1101
+ }
1102
+ ]
1103
+ },
1104
+ "valid": false
426
1105
  }
427
1106
  ]
428
1107
  }