@openfn/language-monnify 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,1128 @@
1
+ {
2
+ "operations": [
3
+ {
4
+ "name": "get",
5
+ "params": [
6
+ "path",
7
+ "options"
8
+ ],
9
+ "docs": {
10
+ "description": "Make a GET request",
11
+ "tags": [
12
+ {
13
+ "title": "example",
14
+ "description": "get('/api/v1/transactions/search');",
15
+ "caption": "Get all transactions"
16
+ },
17
+ {
18
+ "title": "function",
19
+ "description": null,
20
+ "name": null
21
+ },
22
+ {
23
+ "title": "public",
24
+ "description": null,
25
+ "type": null
26
+ },
27
+ {
28
+ "title": "param",
29
+ "description": "Path to resource",
30
+ "type": {
31
+ "type": "NameExpression",
32
+ "name": "string"
33
+ },
34
+ "name": "path"
35
+ },
36
+ {
37
+ "title": "param",
38
+ "description": "Optional request options",
39
+ "type": {
40
+ "type": "NameExpression",
41
+ "name": "RequestOptions"
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": "list",
63
+ "params": [
64
+ "path",
65
+ "query"
66
+ ],
67
+ "docs": {
68
+ "description": "Fetch a list of items.",
69
+ "tags": [
70
+ {
71
+ "title": "example",
72
+ "description": "list('/api/v2/disbursements/search-transactions', {\n sourceAccountNumber: 4864192954\n});",
73
+ "caption": "Get all transactions"
74
+ },
75
+ {
76
+ "title": "example",
77
+ "description": "list('/api/v2/disbursements/search-transactions', { \n sourceAccountNumber: 4864192954,\n pageNo: 0,\n pageSize: 10\n});",
78
+ "caption": "Get all transactions for a specific page and page number."
79
+ },
80
+ {
81
+ "title": "function",
82
+ "description": null,
83
+ "name": null
84
+ },
85
+ {
86
+ "title": "public",
87
+ "description": null,
88
+ "type": null
89
+ },
90
+ {
91
+ "title": "param",
92
+ "description": "Path to resource",
93
+ "type": {
94
+ "type": "NameExpression",
95
+ "name": "string"
96
+ },
97
+ "name": "path"
98
+ },
99
+ {
100
+ "title": "param",
101
+ "description": "Query options.",
102
+ "type": {
103
+ "type": "NameExpression",
104
+ "name": "ListQueryOptions"
105
+ },
106
+ "name": "query"
107
+ },
108
+ {
109
+ "title": "returns",
110
+ "description": null,
111
+ "type": {
112
+ "type": "NameExpression",
113
+ "name": "Operation"
114
+ }
115
+ },
116
+ {
117
+ "title": "state",
118
+ "description": "{HttpState}"
119
+ }
120
+ ]
121
+ },
122
+ "valid": true
123
+ },
124
+ {
125
+ "name": "post",
126
+ "params": [
127
+ "path",
128
+ "body",
129
+ "options"
130
+ ],
131
+ "docs": {
132
+ "description": "Make a POST request",
133
+ "tags": [
134
+ {
135
+ "title": "example",
136
+ "description": "post(\"/api/v1/transaction-notification/resend-failed-notifications\", {\n\"startDate\": \"2021-01-16T13:56:39.492\",\n\"endDate\": \"2021-10-16T13:56:39.492\"\n});",
137
+ "caption": "Resend all failed notifications over a time period"
138
+ },
139
+ {
140
+ "title": "function",
141
+ "description": null,
142
+ "name": null
143
+ },
144
+ {
145
+ "title": "public",
146
+ "description": null,
147
+ "type": null
148
+ },
149
+ {
150
+ "title": "param",
151
+ "description": "Path to resource",
152
+ "type": {
153
+ "type": "NameExpression",
154
+ "name": "string"
155
+ },
156
+ "name": "path"
157
+ },
158
+ {
159
+ "title": "param",
160
+ "description": "The Post request body",
161
+ "type": {
162
+ "type": "NameExpression",
163
+ "name": "object"
164
+ },
165
+ "name": "body"
166
+ },
167
+ {
168
+ "title": "param",
169
+ "description": "Optional request options",
170
+ "type": {
171
+ "type": "NameExpression",
172
+ "name": "RequestOptions"
173
+ },
174
+ "name": "options"
175
+ },
176
+ {
177
+ "title": "returns",
178
+ "description": null,
179
+ "type": {
180
+ "type": "NameExpression",
181
+ "name": "Operation"
182
+ }
183
+ },
184
+ {
185
+ "title": "state",
186
+ "description": "{HttpState}"
187
+ }
188
+ ]
189
+ },
190
+ "valid": true
191
+ },
192
+ {
193
+ "name": "request",
194
+ "params": [
195
+ "method",
196
+ "path",
197
+ "options"
198
+ ],
199
+ "docs": {
200
+ "description": "Make a generic request",
201
+ "tags": [
202
+ {
203
+ "title": "example",
204
+ "description": "request(\n 'GET', \n '/api/v2/disbursements/search-transactions', \n {\n query: {\n sourceAccountNumber: 4864192954,\n pageNo: 0,\n pageSize: 10\n }\n }\n);",
205
+ "caption": "Get disbursements from a wallet"
206
+ },
207
+ {
208
+ "title": "function",
209
+ "description": null,
210
+ "name": null
211
+ },
212
+ {
213
+ "title": "public",
214
+ "description": null,
215
+ "type": null
216
+ },
217
+ {
218
+ "title": "param",
219
+ "description": "HTTP method to use",
220
+ "type": {
221
+ "type": "NameExpression",
222
+ "name": "string"
223
+ },
224
+ "name": "method"
225
+ },
226
+ {
227
+ "title": "param",
228
+ "description": "Path to resource",
229
+ "type": {
230
+ "type": "NameExpression",
231
+ "name": "string"
232
+ },
233
+ "name": "path"
234
+ },
235
+ {
236
+ "title": "param",
237
+ "description": "Optional request options",
238
+ "type": {
239
+ "type": "NameExpression",
240
+ "name": "RequestOptions"
241
+ },
242
+ "name": "options"
243
+ },
244
+ {
245
+ "title": "returns",
246
+ "description": null,
247
+ "type": {
248
+ "type": "NameExpression",
249
+ "name": "Operation"
250
+ }
251
+ },
252
+ {
253
+ "title": "state",
254
+ "description": "{HttpState}"
255
+ }
256
+ ]
257
+ },
258
+ "valid": true
259
+ }
260
+ ],
261
+ "exports": [],
262
+ "common": [
263
+ {
264
+ "name": "fn",
265
+ "params": [
266
+ "func"
267
+ ],
268
+ "docs": {
269
+ "description": "Creates a custom step (or operation) for more flexible job writing.",
270
+ "tags": [
271
+ {
272
+ "title": "public",
273
+ "description": null,
274
+ "type": null
275
+ },
276
+ {
277
+ "title": "function",
278
+ "description": null,
279
+ "name": null
280
+ },
281
+ {
282
+ "title": "example",
283
+ "description": "fn(state => {\n // do some things to state\n return state;\n});"
284
+ },
285
+ {
286
+ "title": "param",
287
+ "description": "is the function",
288
+ "type": {
289
+ "type": "NameExpression",
290
+ "name": "Function"
291
+ },
292
+ "name": "func"
293
+ },
294
+ {
295
+ "title": "returns",
296
+ "description": null,
297
+ "type": {
298
+ "type": "NameExpression",
299
+ "name": "Operation"
300
+ }
301
+ }
302
+ ]
303
+ },
304
+ "valid": true
305
+ },
306
+ {
307
+ "name": "fnIf",
308
+ "params": [
309
+ "condition",
310
+ "operation"
311
+ ],
312
+ "docs": {
313
+ "description": "Execute a function only when the condition returns true",
314
+ "tags": [
315
+ {
316
+ "title": "public",
317
+ "description": null,
318
+ "type": null
319
+ },
320
+ {
321
+ "title": "function",
322
+ "description": null,
323
+ "name": null
324
+ },
325
+ {
326
+ "title": "example",
327
+ "description": "fnIf((state) => state?.data?.name, get(\"https://example.com\"));"
328
+ },
329
+ {
330
+ "title": "param",
331
+ "description": "The condition that returns true",
332
+ "type": {
333
+ "type": "NameExpression",
334
+ "name": "Boolean"
335
+ },
336
+ "name": "condition"
337
+ },
338
+ {
339
+ "title": "param",
340
+ "description": "The operation needed to be executed.",
341
+ "type": {
342
+ "type": "NameExpression",
343
+ "name": "Operation"
344
+ },
345
+ "name": "operation"
346
+ },
347
+ {
348
+ "title": "returns",
349
+ "description": null,
350
+ "type": {
351
+ "type": "NameExpression",
352
+ "name": "Operation"
353
+ }
354
+ }
355
+ ]
356
+ },
357
+ "valid": true
358
+ },
359
+ {
360
+ "name": "sourceValue",
361
+ "params": [
362
+ "path"
363
+ ],
364
+ "docs": {
365
+ "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.",
366
+ "tags": [
367
+ {
368
+ "title": "public",
369
+ "description": null,
370
+ "type": null
371
+ },
372
+ {
373
+ "title": "function",
374
+ "description": null,
375
+ "name": null
376
+ },
377
+ {
378
+ "title": "example",
379
+ "description": "sourceValue('$.key')"
380
+ },
381
+ {
382
+ "title": "param",
383
+ "description": "JSONPath referencing a point in `state`.",
384
+ "type": {
385
+ "type": "NameExpression",
386
+ "name": "String"
387
+ },
388
+ "name": "path"
389
+ },
390
+ {
391
+ "title": "returns",
392
+ "description": null,
393
+ "type": {
394
+ "type": "NameExpression",
395
+ "name": "Operation"
396
+ }
397
+ }
398
+ ]
399
+ },
400
+ "valid": true
401
+ },
402
+ {
403
+ "name": "dataPath",
404
+ "params": [
405
+ "path"
406
+ ],
407
+ "docs": {
408
+ "description": "Ensures a path points at the data.",
409
+ "tags": [
410
+ {
411
+ "title": "public",
412
+ "description": null,
413
+ "type": null
414
+ },
415
+ {
416
+ "title": "function",
417
+ "description": null,
418
+ "name": null
419
+ },
420
+ {
421
+ "title": "example",
422
+ "description": "dataPath('key')"
423
+ },
424
+ {
425
+ "title": "param",
426
+ "description": "JSONPath referencing a point in `data`.",
427
+ "type": {
428
+ "type": "NameExpression",
429
+ "name": "string"
430
+ },
431
+ "name": "path"
432
+ },
433
+ {
434
+ "title": "returns",
435
+ "description": null,
436
+ "type": {
437
+ "type": "NameExpression",
438
+ "name": "string"
439
+ }
440
+ }
441
+ ]
442
+ },
443
+ "valid": true
444
+ },
445
+ {
446
+ "name": "dataValue",
447
+ "params": [
448
+ "path"
449
+ ],
450
+ "docs": {
451
+ "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.",
452
+ "tags": [
453
+ {
454
+ "title": "public",
455
+ "description": null,
456
+ "type": null
457
+ },
458
+ {
459
+ "title": "function",
460
+ "description": null,
461
+ "name": null
462
+ },
463
+ {
464
+ "title": "example",
465
+ "description": "dataValue('key')"
466
+ },
467
+ {
468
+ "title": "param",
469
+ "description": "JSONPath referencing a point in `data`.",
470
+ "type": {
471
+ "type": "NameExpression",
472
+ "name": "String"
473
+ },
474
+ "name": "path"
475
+ },
476
+ {
477
+ "title": "returns",
478
+ "description": null,
479
+ "type": {
480
+ "type": "NameExpression",
481
+ "name": "Operation"
482
+ }
483
+ }
484
+ ]
485
+ },
486
+ "valid": true
487
+ },
488
+ {
489
+ "name": "lastReferenceValue",
490
+ "params": [
491
+ "path"
492
+ ],
493
+ "docs": {
494
+ "description": "Picks out the last reference value from source data.",
495
+ "tags": [
496
+ {
497
+ "title": "public",
498
+ "description": null,
499
+ "type": null
500
+ },
501
+ {
502
+ "title": "function",
503
+ "description": null,
504
+ "name": null
505
+ },
506
+ {
507
+ "title": "example",
508
+ "description": "lastReferenceValue('key')"
509
+ },
510
+ {
511
+ "title": "param",
512
+ "description": "JSONPath referencing a point in `references`.",
513
+ "type": {
514
+ "type": "NameExpression",
515
+ "name": "String"
516
+ },
517
+ "name": "path"
518
+ },
519
+ {
520
+ "title": "returns",
521
+ "description": null,
522
+ "type": {
523
+ "type": "NameExpression",
524
+ "name": "Operation"
525
+ }
526
+ }
527
+ ]
528
+ },
529
+ "valid": true
530
+ },
531
+ {
532
+ "name": "each",
533
+ "params": [
534
+ "dataSource",
535
+ "operation"
536
+ ],
537
+ "docs": {
538
+ "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.",
539
+ "tags": [
540
+ {
541
+ "title": "public",
542
+ "description": null,
543
+ "type": null
544
+ },
545
+ {
546
+ "title": "function",
547
+ "description": null,
548
+ "name": null
549
+ },
550
+ {
551
+ "title": "example",
552
+ "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);",
553
+ "caption": "Using lazy state ($) to iterate over items in state.data and pass each into an \"insert\" operation"
554
+ },
555
+ {
556
+ "title": "example",
557
+ "description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n ...state.data\n }))\n);",
558
+ "caption": "Iterate over items in state.data and pass each one into an \"insert\" operation"
559
+ },
560
+ {
561
+ "title": "example",
562
+ "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);",
563
+ "caption": "Using JSON path to iterate over items in state.data and pass each one into an \"insert\" operation"
564
+ },
565
+ {
566
+ "title": "param",
567
+ "description": "JSONPath referencing a point in `state`.",
568
+ "type": {
569
+ "type": "NameExpression",
570
+ "name": "DataSource"
571
+ },
572
+ "name": "dataSource"
573
+ },
574
+ {
575
+ "title": "param",
576
+ "description": "The operation needed to be repeated.",
577
+ "type": {
578
+ "type": "NameExpression",
579
+ "name": "Operation"
580
+ },
581
+ "name": "operation"
582
+ },
583
+ {
584
+ "title": "returns",
585
+ "description": null,
586
+ "type": {
587
+ "type": "NameExpression",
588
+ "name": "Operation"
589
+ }
590
+ }
591
+ ]
592
+ },
593
+ "valid": true
594
+ },
595
+ {
596
+ "name": "combine",
597
+ "params": [
598
+ "operations"
599
+ ],
600
+ "docs": {
601
+ "description": "Combines two operations into one",
602
+ "tags": [
603
+ {
604
+ "title": "public",
605
+ "description": null,
606
+ "type": null
607
+ },
608
+ {
609
+ "title": "function",
610
+ "description": null,
611
+ "name": null
612
+ },
613
+ {
614
+ "title": "example",
615
+ "description": "combine(\n create('foo'),\n delete('bar')\n)"
616
+ },
617
+ {
618
+ "title": "param",
619
+ "description": "Operations to be performed.",
620
+ "type": {
621
+ "type": "NameExpression",
622
+ "name": "Operations"
623
+ },
624
+ "name": "operations"
625
+ },
626
+ {
627
+ "title": "returns",
628
+ "description": null,
629
+ "type": {
630
+ "type": "NameExpression",
631
+ "name": "Operation"
632
+ }
633
+ }
634
+ ]
635
+ },
636
+ "valid": true
637
+ },
638
+ {
639
+ "name": "field",
640
+ "params": [
641
+ "key",
642
+ "value"
643
+ ],
644
+ "docs": {
645
+ "description": "Returns a key, value pair in an array.",
646
+ "tags": [
647
+ {
648
+ "title": "public",
649
+ "description": null,
650
+ "type": null
651
+ },
652
+ {
653
+ "title": "function",
654
+ "description": null,
655
+ "name": null
656
+ },
657
+ {
658
+ "title": "example",
659
+ "description": "field('destination_field_name__c', 'value')"
660
+ },
661
+ {
662
+ "title": "param",
663
+ "description": "Name of the field",
664
+ "type": {
665
+ "type": "NameExpression",
666
+ "name": "string"
667
+ },
668
+ "name": "key"
669
+ },
670
+ {
671
+ "title": "param",
672
+ "description": "The value itself or a sourceable operation.",
673
+ "type": {
674
+ "type": "NameExpression",
675
+ "name": "Value"
676
+ },
677
+ "name": "value"
678
+ },
679
+ {
680
+ "title": "returns",
681
+ "description": null,
682
+ "type": {
683
+ "type": "NameExpression",
684
+ "name": "Field"
685
+ }
686
+ }
687
+ ]
688
+ },
689
+ "valid": true
690
+ },
691
+ {
692
+ "name": "fields",
693
+ "params": [
694
+ "fields"
695
+ ],
696
+ "docs": {
697
+ "description": "Zips key value pairs into an object.",
698
+ "tags": [
699
+ {
700
+ "title": "public",
701
+ "description": null,
702
+ "type": null
703
+ },
704
+ {
705
+ "title": "function",
706
+ "description": null,
707
+ "name": null
708
+ },
709
+ {
710
+ "title": "example",
711
+ "description": "fields(list_of_fields)"
712
+ },
713
+ {
714
+ "title": "param",
715
+ "description": "a list of fields",
716
+ "type": {
717
+ "type": "NameExpression",
718
+ "name": "Fields"
719
+ },
720
+ "name": "fields"
721
+ },
722
+ {
723
+ "title": "returns",
724
+ "description": null,
725
+ "type": {
726
+ "type": "NameExpression",
727
+ "name": "Object"
728
+ }
729
+ }
730
+ ]
731
+ },
732
+ "valid": true
733
+ },
734
+ {
735
+ "name": "merge",
736
+ "params": [
737
+ "dataSource",
738
+ "fields"
739
+ ],
740
+ "docs": {
741
+ "description": "Merges fields into each item in an array.",
742
+ "tags": [
743
+ {
744
+ "title": "public",
745
+ "description": null,
746
+ "type": null
747
+ },
748
+ {
749
+ "title": "example",
750
+ "description": "merge(\n \"$.books[*]\",\n fields(\n field( \"publisher\", sourceValue(\"$.publisher\") )\n )\n)"
751
+ },
752
+ {
753
+ "title": "function",
754
+ "description": null,
755
+ "name": null
756
+ },
757
+ {
758
+ "title": "public",
759
+ "description": null,
760
+ "type": null
761
+ },
762
+ {
763
+ "title": "param",
764
+ "description": null,
765
+ "type": {
766
+ "type": "NameExpression",
767
+ "name": "DataSource"
768
+ },
769
+ "name": "dataSource"
770
+ },
771
+ {
772
+ "title": "param",
773
+ "description": "Group of fields to merge in.",
774
+ "type": {
775
+ "type": "NameExpression",
776
+ "name": "Object"
777
+ },
778
+ "name": "fields"
779
+ },
780
+ {
781
+ "title": "returns",
782
+ "description": null,
783
+ "type": {
784
+ "type": "NameExpression",
785
+ "name": "DataSource"
786
+ }
787
+ }
788
+ ]
789
+ },
790
+ "valid": true
791
+ },
792
+ {
793
+ "name": "group",
794
+ "params": [
795
+ "arrayOfObjects",
796
+ "keyPath",
797
+ "callback"
798
+ ],
799
+ "docs": {
800
+ "description": "Groups an array of objects by a specified key path.",
801
+ "tags": [
802
+ {
803
+ "title": "public",
804
+ "description": null,
805
+ "type": null
806
+ },
807
+ {
808
+ "title": "example",
809
+ "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 / ] }"
810
+ },
811
+ {
812
+ "title": "function",
813
+ "description": null,
814
+ "name": null
815
+ },
816
+ {
817
+ "title": "public",
818
+ "description": null,
819
+ "type": null
820
+ },
821
+ {
822
+ "title": "param",
823
+ "description": "The array of objects to be grouped.",
824
+ "type": {
825
+ "type": "TypeApplication",
826
+ "expression": {
827
+ "type": "NameExpression",
828
+ "name": "Array"
829
+ },
830
+ "applications": [
831
+ {
832
+ "type": "NameExpression",
833
+ "name": "Object"
834
+ }
835
+ ]
836
+ },
837
+ "name": "arrayOfObjects"
838
+ },
839
+ {
840
+ "title": "param",
841
+ "description": "The key path to group by.",
842
+ "type": {
843
+ "type": "NameExpression",
844
+ "name": "string"
845
+ },
846
+ "name": "keyPath"
847
+ },
848
+ {
849
+ "title": "param",
850
+ "description": "(Optional) Callback function",
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": "Operation"
863
+ }
864
+ }
865
+ ]
866
+ },
867
+ "valid": true
868
+ },
869
+ {
870
+ "name": "scrubEmojis",
871
+ "params": [
872
+ "text",
873
+ "replacementChars"
874
+ ],
875
+ "docs": {
876
+ "description": "Replaces emojis in a string.",
877
+ "tags": [
878
+ {
879
+ "title": "public",
880
+ "description": null,
881
+ "type": null
882
+ },
883
+ {
884
+ "title": "function",
885
+ "description": null,
886
+ "name": null
887
+ },
888
+ {
889
+ "title": "example",
890
+ "description": "scrubEmojis('Dove🕊️⭐ 29')"
891
+ },
892
+ {
893
+ "title": "param",
894
+ "description": "String that needs to be cleaned",
895
+ "type": {
896
+ "type": "NameExpression",
897
+ "name": "string"
898
+ },
899
+ "name": "text"
900
+ },
901
+ {
902
+ "title": "param",
903
+ "description": "Characters that replace the emojis",
904
+ "type": {
905
+ "type": "NameExpression",
906
+ "name": "string"
907
+ },
908
+ "name": "replacementChars"
909
+ },
910
+ {
911
+ "title": "returns",
912
+ "description": null,
913
+ "type": {
914
+ "type": "NameExpression",
915
+ "name": "string"
916
+ }
917
+ }
918
+ ]
919
+ },
920
+ "valid": true
921
+ },
922
+ {
923
+ "name": "cursor",
924
+ "params": [
925
+ "value",
926
+ "options"
927
+ ],
928
+ "docs": {
929
+ "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}",
930
+ "tags": [
931
+ {
932
+ "title": "public",
933
+ "description": null,
934
+ "type": null
935
+ },
936
+ {
937
+ "title": "function",
938
+ "description": null,
939
+ "name": null
940
+ },
941
+ {
942
+ "title": "example",
943
+ "description": "cursor($.cursor, { defaultValue: 'today' })",
944
+ "caption": "Use a cursor from state if present, or else use the default value"
945
+ },
946
+ {
947
+ "title": "example",
948
+ "description": "cursor(22)",
949
+ "caption": "Use a pagination cursor"
950
+ },
951
+ {
952
+ "title": "param",
953
+ "description": "the cursor value. Usually an ISO date, natural language date, or page number",
954
+ "type": {
955
+ "type": "NameExpression",
956
+ "name": "any"
957
+ },
958
+ "name": "value"
959
+ },
960
+ {
961
+ "title": "param",
962
+ "description": "options to control the cursor.",
963
+ "type": {
964
+ "type": "NameExpression",
965
+ "name": "object"
966
+ },
967
+ "name": "options"
968
+ },
969
+ {
970
+ "title": "param",
971
+ "description": "set the cursor key. Will persist through the whole run.",
972
+ "type": {
973
+ "type": "NameExpression",
974
+ "name": "string"
975
+ },
976
+ "name": "options.key"
977
+ },
978
+ {
979
+ "title": "param",
980
+ "description": "the value to use if value is falsy",
981
+ "type": {
982
+ "type": "NameExpression",
983
+ "name": "any"
984
+ },
985
+ "name": "options.defaultValue"
986
+ },
987
+ {
988
+ "title": "param",
989
+ "description": "custom formatter for the final cursor value",
990
+ "type": {
991
+ "type": "NameExpression",
992
+ "name": "Function"
993
+ },
994
+ "name": "options.format"
995
+ },
996
+ {
997
+ "title": "returns",
998
+ "description": null,
999
+ "type": {
1000
+ "type": "NameExpression",
1001
+ "name": "Operation"
1002
+ }
1003
+ }
1004
+ ]
1005
+ },
1006
+ "valid": false
1007
+ },
1008
+ {
1009
+ "name": "as",
1010
+ "params": [
1011
+ "key",
1012
+ "operation"
1013
+ ],
1014
+ "docs": {
1015
+ "description": "Run an operation and save the result to a custom key in state instead of overwriting state.data.",
1016
+ "tags": [
1017
+ {
1018
+ "title": "public",
1019
+ "description": null,
1020
+ "type": null
1021
+ },
1022
+ {
1023
+ "title": "function",
1024
+ "description": null,
1025
+ "name": null
1026
+ },
1027
+ {
1028
+ "title": "example",
1029
+ "description": "as('cceData', collections.get('cce-data-dhis2', { key: `*:*:${$.syncedAt}*` }));",
1030
+ "caption": "Fetch cce-data from collections and store them under state.cceData"
1031
+ },
1032
+ {
1033
+ "title": "param",
1034
+ "description": "The state key to assign the result of the operation to.",
1035
+ "type": {
1036
+ "type": "NameExpression",
1037
+ "name": "string"
1038
+ },
1039
+ "name": "key"
1040
+ },
1041
+ {
1042
+ "title": "param",
1043
+ "description": " An operation that returns a new state object with a `data` property",
1044
+ "type": {
1045
+ "type": "NameExpression",
1046
+ "name": "function"
1047
+ },
1048
+ "name": "operation"
1049
+ },
1050
+ {
1051
+ "title": "returns",
1052
+ "description": null,
1053
+ "type": {
1054
+ "type": "NameExpression",
1055
+ "name": "Operation"
1056
+ }
1057
+ }
1058
+ ]
1059
+ },
1060
+ "valid": true
1061
+ },
1062
+ {
1063
+ "name": "map",
1064
+ "params": {},
1065
+ "docs": {
1066
+ "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.",
1067
+ "tags": [
1068
+ {
1069
+ "title": "public",
1070
+ "description": null,
1071
+ "type": null
1072
+ },
1073
+ {
1074
+ "title": "function",
1075
+ "description": null,
1076
+ "name": null
1077
+ },
1078
+ {
1079
+ "title": "example",
1080
+ "description": "map($.items', (data, index, state) => {\n return {\n id: index + 1,\n name: data.name,\n createdAt: state.cursor,\n };\n});",
1081
+ "caption": "Transform an array of items in state"
1082
+ },
1083
+ {
1084
+ "title": "example",
1085
+ "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});",
1086
+ "caption": "Map items asynchronously (e.g. fetch extra info)"
1087
+ },
1088
+ {
1089
+ "title": "param",
1090
+ "description": "An array of items or a a JSONPath string which points to an array of items.",
1091
+ "type": {
1092
+ "type": "UnionType",
1093
+ "elements": [
1094
+ {
1095
+ "type": "NameExpression",
1096
+ "name": "string"
1097
+ },
1098
+ {
1099
+ "type": "NameExpression",
1100
+ "name": "Array"
1101
+ }
1102
+ ]
1103
+ },
1104
+ "name": "path"
1105
+ },
1106
+ {
1107
+ "title": "param",
1108
+ "description": "The mapping function, invoked with `(data, index, state)` for each item in the array.",
1109
+ "type": {
1110
+ "type": "NameExpression",
1111
+ "name": "function"
1112
+ },
1113
+ "name": "callback"
1114
+ },
1115
+ {
1116
+ "title": "returns",
1117
+ "description": null,
1118
+ "type": {
1119
+ "type": "NameExpression",
1120
+ "name": "State"
1121
+ }
1122
+ }
1123
+ ]
1124
+ },
1125
+ "valid": false
1126
+ }
1127
+ ]
1128
+ }