@openfn/language-ihris 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 ADDED
@@ -0,0 +1,870 @@
1
+ {
2
+ "operations": [],
3
+ "exports": [],
4
+ "common": [
5
+ {
6
+ "name": "fn",
7
+ "params": [
8
+ "func"
9
+ ],
10
+ "docs": {
11
+ "description": "Creates a custom step (or operation) for more flexible job writing.",
12
+ "tags": [
13
+ {
14
+ "title": "public",
15
+ "description": null,
16
+ "type": null
17
+ },
18
+ {
19
+ "title": "function",
20
+ "description": null,
21
+ "name": null
22
+ },
23
+ {
24
+ "title": "example",
25
+ "description": "fn(state => {\n // do some things to state\n return state;\n});"
26
+ },
27
+ {
28
+ "title": "param",
29
+ "description": "is the function",
30
+ "type": {
31
+ "type": "NameExpression",
32
+ "name": "Function"
33
+ },
34
+ "name": "func"
35
+ },
36
+ {
37
+ "title": "returns",
38
+ "description": null,
39
+ "type": {
40
+ "type": "NameExpression",
41
+ "name": "Operation"
42
+ }
43
+ }
44
+ ]
45
+ },
46
+ "valid": true
47
+ },
48
+ {
49
+ "name": "fnIf",
50
+ "params": [
51
+ "condition",
52
+ "operation"
53
+ ],
54
+ "docs": {
55
+ "description": "Execute a function only when the condition returns true",
56
+ "tags": [
57
+ {
58
+ "title": "public",
59
+ "description": null,
60
+ "type": null
61
+ },
62
+ {
63
+ "title": "function",
64
+ "description": null,
65
+ "name": null
66
+ },
67
+ {
68
+ "title": "example",
69
+ "description": "fnIf((state) => state?.data?.name, get(\"https://example.com\"));"
70
+ },
71
+ {
72
+ "title": "param",
73
+ "description": "The condition that returns true",
74
+ "type": {
75
+ "type": "NameExpression",
76
+ "name": "Boolean"
77
+ },
78
+ "name": "condition"
79
+ },
80
+ {
81
+ "title": "param",
82
+ "description": "The operation needed to be executed.",
83
+ "type": {
84
+ "type": "NameExpression",
85
+ "name": "Operation"
86
+ },
87
+ "name": "operation"
88
+ },
89
+ {
90
+ "title": "returns",
91
+ "description": null,
92
+ "type": {
93
+ "type": "NameExpression",
94
+ "name": "Operation"
95
+ }
96
+ }
97
+ ]
98
+ },
99
+ "valid": true
100
+ },
101
+ {
102
+ "name": "sourceValue",
103
+ "params": [
104
+ "path"
105
+ ],
106
+ "docs": {
107
+ "description": "Picks out a single value from source data.\nIf a JSONPath returns more than one value for the reference, the first\nitem will be returned.",
108
+ "tags": [
109
+ {
110
+ "title": "public",
111
+ "description": null,
112
+ "type": null
113
+ },
114
+ {
115
+ "title": "function",
116
+ "description": null,
117
+ "name": null
118
+ },
119
+ {
120
+ "title": "example",
121
+ "description": "sourceValue('$.key')"
122
+ },
123
+ {
124
+ "title": "param",
125
+ "description": "JSONPath referencing a point in `state`.",
126
+ "type": {
127
+ "type": "NameExpression",
128
+ "name": "String"
129
+ },
130
+ "name": "path"
131
+ },
132
+ {
133
+ "title": "returns",
134
+ "description": null,
135
+ "type": {
136
+ "type": "NameExpression",
137
+ "name": "Operation"
138
+ }
139
+ }
140
+ ]
141
+ },
142
+ "valid": true
143
+ },
144
+ {
145
+ "name": "dataPath",
146
+ "params": [
147
+ "path"
148
+ ],
149
+ "docs": {
150
+ "description": "Ensures a path points at the data.",
151
+ "tags": [
152
+ {
153
+ "title": "public",
154
+ "description": null,
155
+ "type": null
156
+ },
157
+ {
158
+ "title": "function",
159
+ "description": null,
160
+ "name": null
161
+ },
162
+ {
163
+ "title": "example",
164
+ "description": "dataPath('key')"
165
+ },
166
+ {
167
+ "title": "param",
168
+ "description": "JSONPath referencing a point in `data`.",
169
+ "type": {
170
+ "type": "NameExpression",
171
+ "name": "string"
172
+ },
173
+ "name": "path"
174
+ },
175
+ {
176
+ "title": "returns",
177
+ "description": null,
178
+ "type": {
179
+ "type": "NameExpression",
180
+ "name": "string"
181
+ }
182
+ }
183
+ ]
184
+ },
185
+ "valid": true
186
+ },
187
+ {
188
+ "name": "dataValue",
189
+ "params": [
190
+ "path"
191
+ ],
192
+ "docs": {
193
+ "description": "Picks out a single value from the source data object—usually `state.data`.\nIf a JSONPath returns more than one value for the reference, the first\nitem will be returned.",
194
+ "tags": [
195
+ {
196
+ "title": "public",
197
+ "description": null,
198
+ "type": null
199
+ },
200
+ {
201
+ "title": "function",
202
+ "description": null,
203
+ "name": null
204
+ },
205
+ {
206
+ "title": "example",
207
+ "description": "dataValue('key')"
208
+ },
209
+ {
210
+ "title": "param",
211
+ "description": "JSONPath referencing a point in `data`.",
212
+ "type": {
213
+ "type": "NameExpression",
214
+ "name": "String"
215
+ },
216
+ "name": "path"
217
+ },
218
+ {
219
+ "title": "returns",
220
+ "description": null,
221
+ "type": {
222
+ "type": "NameExpression",
223
+ "name": "Operation"
224
+ }
225
+ }
226
+ ]
227
+ },
228
+ "valid": true
229
+ },
230
+ {
231
+ "name": "lastReferenceValue",
232
+ "params": [
233
+ "path"
234
+ ],
235
+ "docs": {
236
+ "description": "Picks out the last reference value from source data.",
237
+ "tags": [
238
+ {
239
+ "title": "public",
240
+ "description": null,
241
+ "type": null
242
+ },
243
+ {
244
+ "title": "function",
245
+ "description": null,
246
+ "name": null
247
+ },
248
+ {
249
+ "title": "example",
250
+ "description": "lastReferenceValue('key')"
251
+ },
252
+ {
253
+ "title": "param",
254
+ "description": "JSONPath referencing a point in `references`.",
255
+ "type": {
256
+ "type": "NameExpression",
257
+ "name": "String"
258
+ },
259
+ "name": "path"
260
+ },
261
+ {
262
+ "title": "returns",
263
+ "description": null,
264
+ "type": {
265
+ "type": "NameExpression",
266
+ "name": "Operation"
267
+ }
268
+ }
269
+ ]
270
+ },
271
+ "valid": true
272
+ },
273
+ {
274
+ "name": "each",
275
+ "params": [
276
+ "dataSource",
277
+ "operation"
278
+ ],
279
+ "docs": {
280
+ "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.",
281
+ "tags": [
282
+ {
283
+ "title": "public",
284
+ "description": null,
285
+ "type": null
286
+ },
287
+ {
288
+ "title": "function",
289
+ "description": null,
290
+ "name": null
291
+ },
292
+ {
293
+ "title": "example",
294
+ "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);",
295
+ "caption": "Using lazy state ($) to iterate over items in state.data and pass each into an \"insert\" operation"
296
+ },
297
+ {
298
+ "title": "example",
299
+ "description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n ...state.data\n }))\n);",
300
+ "caption": "Iterate over items in state.data and pass each one into an \"insert\" operation"
301
+ },
302
+ {
303
+ "title": "example",
304
+ "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);",
305
+ "caption": "Using JSON path to iterate over items in state.data and pass each one into an \"insert\" operation"
306
+ },
307
+ {
308
+ "title": "param",
309
+ "description": "JSONPath referencing a point in `state`.",
310
+ "type": {
311
+ "type": "NameExpression",
312
+ "name": "DataSource"
313
+ },
314
+ "name": "dataSource"
315
+ },
316
+ {
317
+ "title": "param",
318
+ "description": "The operation needed to be repeated.",
319
+ "type": {
320
+ "type": "NameExpression",
321
+ "name": "Operation"
322
+ },
323
+ "name": "operation"
324
+ },
325
+ {
326
+ "title": "returns",
327
+ "description": null,
328
+ "type": {
329
+ "type": "NameExpression",
330
+ "name": "Operation"
331
+ }
332
+ }
333
+ ]
334
+ },
335
+ "valid": true
336
+ },
337
+ {
338
+ "name": "combine",
339
+ "params": [
340
+ "operations"
341
+ ],
342
+ "docs": {
343
+ "description": "Combines two operations into one",
344
+ "tags": [
345
+ {
346
+ "title": "public",
347
+ "description": null,
348
+ "type": null
349
+ },
350
+ {
351
+ "title": "function",
352
+ "description": null,
353
+ "name": null
354
+ },
355
+ {
356
+ "title": "example",
357
+ "description": "combine(\n create('foo'),\n delete('bar')\n)"
358
+ },
359
+ {
360
+ "title": "param",
361
+ "description": "Operations to be performed.",
362
+ "type": {
363
+ "type": "NameExpression",
364
+ "name": "Operations"
365
+ },
366
+ "name": "operations"
367
+ },
368
+ {
369
+ "title": "returns",
370
+ "description": null,
371
+ "type": {
372
+ "type": "NameExpression",
373
+ "name": "Operation"
374
+ }
375
+ }
376
+ ]
377
+ },
378
+ "valid": true
379
+ },
380
+ {
381
+ "name": "field",
382
+ "params": [
383
+ "key",
384
+ "value"
385
+ ],
386
+ "docs": {
387
+ "description": "Returns a key, value pair in an array.",
388
+ "tags": [
389
+ {
390
+ "title": "public",
391
+ "description": null,
392
+ "type": null
393
+ },
394
+ {
395
+ "title": "function",
396
+ "description": null,
397
+ "name": null
398
+ },
399
+ {
400
+ "title": "example",
401
+ "description": "field('destination_field_name__c', 'value')"
402
+ },
403
+ {
404
+ "title": "param",
405
+ "description": "Name of the field",
406
+ "type": {
407
+ "type": "NameExpression",
408
+ "name": "string"
409
+ },
410
+ "name": "key"
411
+ },
412
+ {
413
+ "title": "param",
414
+ "description": "The value itself or a sourceable operation.",
415
+ "type": {
416
+ "type": "NameExpression",
417
+ "name": "Value"
418
+ },
419
+ "name": "value"
420
+ },
421
+ {
422
+ "title": "returns",
423
+ "description": null,
424
+ "type": {
425
+ "type": "NameExpression",
426
+ "name": "Field"
427
+ }
428
+ }
429
+ ]
430
+ },
431
+ "valid": true
432
+ },
433
+ {
434
+ "name": "fields",
435
+ "params": [
436
+ "fields"
437
+ ],
438
+ "docs": {
439
+ "description": "Zips key value pairs into an object.",
440
+ "tags": [
441
+ {
442
+ "title": "public",
443
+ "description": null,
444
+ "type": null
445
+ },
446
+ {
447
+ "title": "function",
448
+ "description": null,
449
+ "name": null
450
+ },
451
+ {
452
+ "title": "example",
453
+ "description": "fields(list_of_fields)"
454
+ },
455
+ {
456
+ "title": "param",
457
+ "description": "a list of fields",
458
+ "type": {
459
+ "type": "NameExpression",
460
+ "name": "Fields"
461
+ },
462
+ "name": "fields"
463
+ },
464
+ {
465
+ "title": "returns",
466
+ "description": null,
467
+ "type": {
468
+ "type": "NameExpression",
469
+ "name": "Object"
470
+ }
471
+ }
472
+ ]
473
+ },
474
+ "valid": true
475
+ },
476
+ {
477
+ "name": "merge",
478
+ "params": [
479
+ "dataSource",
480
+ "fields"
481
+ ],
482
+ "docs": {
483
+ "description": "Merges fields into each item in an array.",
484
+ "tags": [
485
+ {
486
+ "title": "public",
487
+ "description": null,
488
+ "type": null
489
+ },
490
+ {
491
+ "title": "example",
492
+ "description": "merge(\n \"$.books[*]\",\n fields(\n field( \"publisher\", sourceValue(\"$.publisher\") )\n )\n)"
493
+ },
494
+ {
495
+ "title": "function",
496
+ "description": null,
497
+ "name": null
498
+ },
499
+ {
500
+ "title": "public",
501
+ "description": null,
502
+ "type": null
503
+ },
504
+ {
505
+ "title": "param",
506
+ "description": null,
507
+ "type": {
508
+ "type": "NameExpression",
509
+ "name": "DataSource"
510
+ },
511
+ "name": "dataSource"
512
+ },
513
+ {
514
+ "title": "param",
515
+ "description": "Group of fields to merge in.",
516
+ "type": {
517
+ "type": "NameExpression",
518
+ "name": "Object"
519
+ },
520
+ "name": "fields"
521
+ },
522
+ {
523
+ "title": "returns",
524
+ "description": null,
525
+ "type": {
526
+ "type": "NameExpression",
527
+ "name": "DataSource"
528
+ }
529
+ }
530
+ ]
531
+ },
532
+ "valid": true
533
+ },
534
+ {
535
+ "name": "group",
536
+ "params": [
537
+ "arrayOfObjects",
538
+ "keyPath",
539
+ "callback"
540
+ ],
541
+ "docs": {
542
+ "description": "Groups an array of objects by a specified key path.",
543
+ "tags": [
544
+ {
545
+ "title": "public",
546
+ "description": null,
547
+ "type": null
548
+ },
549
+ {
550
+ "title": "example",
551
+ "description": "const users = [\n { name: 'Alice', age: 25, city: 'New York' },\n { name: 'Bob', age: 30, city: 'San Francisco' },\n { name: 'Charlie', age: 25, city: 'New York' },\n { name: 'David', age: 30, city: 'San Francisco' }\n];\ngroup(users, 'city');\n// state is { data: { 'New York': [/Alice, Charlie/], 'San Francisco': [ /Bob, David / ] }"
552
+ },
553
+ {
554
+ "title": "function",
555
+ "description": null,
556
+ "name": null
557
+ },
558
+ {
559
+ "title": "public",
560
+ "description": null,
561
+ "type": null
562
+ },
563
+ {
564
+ "title": "param",
565
+ "description": "The array of objects to be grouped.",
566
+ "type": {
567
+ "type": "TypeApplication",
568
+ "expression": {
569
+ "type": "NameExpression",
570
+ "name": "Array"
571
+ },
572
+ "applications": [
573
+ {
574
+ "type": "NameExpression",
575
+ "name": "Object"
576
+ }
577
+ ]
578
+ },
579
+ "name": "arrayOfObjects"
580
+ },
581
+ {
582
+ "title": "param",
583
+ "description": "The key path to group by.",
584
+ "type": {
585
+ "type": "NameExpression",
586
+ "name": "string"
587
+ },
588
+ "name": "keyPath"
589
+ },
590
+ {
591
+ "title": "param",
592
+ "description": "(Optional) Callback function",
593
+ "type": {
594
+ "type": "NameExpression",
595
+ "name": "function"
596
+ },
597
+ "name": "callback"
598
+ },
599
+ {
600
+ "title": "returns",
601
+ "description": null,
602
+ "type": {
603
+ "type": "NameExpression",
604
+ "name": "Operation"
605
+ }
606
+ }
607
+ ]
608
+ },
609
+ "valid": true
610
+ },
611
+ {
612
+ "name": "scrubEmojis",
613
+ "params": [
614
+ "text",
615
+ "replacementChars"
616
+ ],
617
+ "docs": {
618
+ "description": "Replaces emojis in a string.",
619
+ "tags": [
620
+ {
621
+ "title": "public",
622
+ "description": null,
623
+ "type": null
624
+ },
625
+ {
626
+ "title": "function",
627
+ "description": null,
628
+ "name": null
629
+ },
630
+ {
631
+ "title": "example",
632
+ "description": "scrubEmojis('Dove🕊️⭐ 29')"
633
+ },
634
+ {
635
+ "title": "param",
636
+ "description": "String that needs to be cleaned",
637
+ "type": {
638
+ "type": "NameExpression",
639
+ "name": "string"
640
+ },
641
+ "name": "text"
642
+ },
643
+ {
644
+ "title": "param",
645
+ "description": "Characters that replace the emojis",
646
+ "type": {
647
+ "type": "NameExpression",
648
+ "name": "string"
649
+ },
650
+ "name": "replacementChars"
651
+ },
652
+ {
653
+ "title": "returns",
654
+ "description": null,
655
+ "type": {
656
+ "type": "NameExpression",
657
+ "name": "string"
658
+ }
659
+ }
660
+ ]
661
+ },
662
+ "valid": true
663
+ },
664
+ {
665
+ "name": "cursor",
666
+ "params": [
667
+ "value",
668
+ "options"
669
+ ],
670
+ "docs": {
671
+ "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}",
672
+ "tags": [
673
+ {
674
+ "title": "public",
675
+ "description": null,
676
+ "type": null
677
+ },
678
+ {
679
+ "title": "function",
680
+ "description": null,
681
+ "name": null
682
+ },
683
+ {
684
+ "title": "example",
685
+ "description": "cursor($.cursor, { defaultValue: 'today' })",
686
+ "caption": "Use a cursor from state if present, or else use the default value"
687
+ },
688
+ {
689
+ "title": "example",
690
+ "description": "cursor(22)",
691
+ "caption": "Use a pagination cursor"
692
+ },
693
+ {
694
+ "title": "param",
695
+ "description": "the cursor value. Usually an ISO date, natural language date, or page number",
696
+ "type": {
697
+ "type": "NameExpression",
698
+ "name": "any"
699
+ },
700
+ "name": "value"
701
+ },
702
+ {
703
+ "title": "param",
704
+ "description": "options to control the cursor.",
705
+ "type": {
706
+ "type": "NameExpression",
707
+ "name": "object"
708
+ },
709
+ "name": "options"
710
+ },
711
+ {
712
+ "title": "param",
713
+ "description": "set the cursor key. Will persist through the whole run.",
714
+ "type": {
715
+ "type": "NameExpression",
716
+ "name": "string"
717
+ },
718
+ "name": "options.key"
719
+ },
720
+ {
721
+ "title": "param",
722
+ "description": "the value to use if value is falsy",
723
+ "type": {
724
+ "type": "NameExpression",
725
+ "name": "any"
726
+ },
727
+ "name": "options.defaultValue"
728
+ },
729
+ {
730
+ "title": "param",
731
+ "description": "custom formatter for the final cursor value",
732
+ "type": {
733
+ "type": "NameExpression",
734
+ "name": "Function"
735
+ },
736
+ "name": "options.format"
737
+ },
738
+ {
739
+ "title": "returns",
740
+ "description": null,
741
+ "type": {
742
+ "type": "NameExpression",
743
+ "name": "Operation"
744
+ }
745
+ }
746
+ ]
747
+ },
748
+ "valid": false
749
+ },
750
+ {
751
+ "name": "as",
752
+ "params": [
753
+ "key",
754
+ "operation"
755
+ ],
756
+ "docs": {
757
+ "description": "Run an operation and save the result to a custom key in state instead of overwriting state.data.",
758
+ "tags": [
759
+ {
760
+ "title": "public",
761
+ "description": null,
762
+ "type": null
763
+ },
764
+ {
765
+ "title": "function",
766
+ "description": null,
767
+ "name": null
768
+ },
769
+ {
770
+ "title": "example",
771
+ "description": "as('cceData', collections.get('cce-data-dhis2', { key: `*:*:${$.syncedAt}*` }));",
772
+ "caption": "Fetch cce-data from collections and store them under state.cceData"
773
+ },
774
+ {
775
+ "title": "param",
776
+ "description": "The state key to assign the result of the operation to.",
777
+ "type": {
778
+ "type": "NameExpression",
779
+ "name": "string"
780
+ },
781
+ "name": "key"
782
+ },
783
+ {
784
+ "title": "param",
785
+ "description": " An operation that returns a new state object with a `data` property",
786
+ "type": {
787
+ "type": "NameExpression",
788
+ "name": "function"
789
+ },
790
+ "name": "operation"
791
+ },
792
+ {
793
+ "title": "returns",
794
+ "description": null,
795
+ "type": {
796
+ "type": "NameExpression",
797
+ "name": "Operation"
798
+ }
799
+ }
800
+ ]
801
+ },
802
+ "valid": true
803
+ },
804
+ {
805
+ "name": "map",
806
+ "params": {},
807
+ "docs": {
808
+ "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.",
809
+ "tags": [
810
+ {
811
+ "title": "public",
812
+ "description": null,
813
+ "type": null
814
+ },
815
+ {
816
+ "title": "function",
817
+ "description": null,
818
+ "name": null
819
+ },
820
+ {
821
+ "title": "example",
822
+ "description": "map($.items', (data, index, state) => {\n return {\n id: index + 1,\n name: data.name,\n createdAt: state.cursor,\n };\n});",
823
+ "caption": "Transform an array of items in state"
824
+ },
825
+ {
826
+ "title": "example",
827
+ "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});",
828
+ "caption": "Map items asynchronously (e.g. fetch extra info)"
829
+ },
830
+ {
831
+ "title": "param",
832
+ "description": "An array of items or a a JSONPath string which points to an array of items.",
833
+ "type": {
834
+ "type": "UnionType",
835
+ "elements": [
836
+ {
837
+ "type": "NameExpression",
838
+ "name": "string"
839
+ },
840
+ {
841
+ "type": "NameExpression",
842
+ "name": "Array"
843
+ }
844
+ ]
845
+ },
846
+ "name": "path"
847
+ },
848
+ {
849
+ "title": "param",
850
+ "description": "The mapping function, invoked with `(data, index, state)` for each item in the array.",
851
+ "type": {
852
+ "type": "NameExpression",
853
+ "name": "function"
854
+ },
855
+ "name": "callback"
856
+ },
857
+ {
858
+ "title": "returns",
859
+ "description": null,
860
+ "type": {
861
+ "type": "NameExpression",
862
+ "name": "State"
863
+ }
864
+ }
865
+ ]
866
+ },
867
+ "valid": false
868
+ }
869
+ ]
870
+ }