@openfn/language-common 2.0.0-rc2 → 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 ADDED
@@ -0,0 +1,1602 @@
1
+ {
2
+ "operations": [
3
+ {
4
+ "name": "execute",
5
+ "params": [
6
+ "operations"
7
+ ],
8
+ "docs": {
9
+ "description": "Execute a sequence of operations.\nMain outer API for executing expressions.",
10
+ "tags": [
11
+ {
12
+ "title": "public",
13
+ "description": null,
14
+ "type": null
15
+ },
16
+ {
17
+ "title": "example",
18
+ "description": "execute(\n create('foo'),\n delete('bar')\n )"
19
+ },
20
+ {
21
+ "title": "private",
22
+ "description": null,
23
+ "type": null
24
+ },
25
+ {
26
+ "title": "param",
27
+ "description": "Operations to be performed.",
28
+ "type": {
29
+ "type": "NameExpression",
30
+ "name": "Operations"
31
+ },
32
+ "name": "operations"
33
+ },
34
+ {
35
+ "title": "returns",
36
+ "description": null,
37
+ "type": {
38
+ "type": "NameExpression",
39
+ "name": "Promise"
40
+ }
41
+ }
42
+ ]
43
+ },
44
+ "valid": true
45
+ },
46
+ {
47
+ "name": "fn",
48
+ "params": [
49
+ "func"
50
+ ],
51
+ "docs": {
52
+ "description": "Creates a custom step (or operation) for more flexible job writing.",
53
+ "tags": [
54
+ {
55
+ "title": "public",
56
+ "description": null,
57
+ "type": null
58
+ },
59
+ {
60
+ "title": "function",
61
+ "description": null,
62
+ "name": null
63
+ },
64
+ {
65
+ "title": "example",
66
+ "description": "fn(state => {\n // do some things to state\n return state;\n});"
67
+ },
68
+ {
69
+ "title": "param",
70
+ "description": "is the function",
71
+ "type": {
72
+ "type": "NameExpression",
73
+ "name": "Function"
74
+ },
75
+ "name": "func"
76
+ },
77
+ {
78
+ "title": "returns",
79
+ "description": null,
80
+ "type": {
81
+ "type": "NameExpression",
82
+ "name": "Operation"
83
+ }
84
+ }
85
+ ]
86
+ },
87
+ "valid": true
88
+ },
89
+ {
90
+ "name": "fnIf",
91
+ "params": [
92
+ "condition",
93
+ "operation"
94
+ ],
95
+ "docs": {
96
+ "description": "A custom operation that will only execute the function if the condition returns true",
97
+ "tags": [
98
+ {
99
+ "title": "public",
100
+ "description": null,
101
+ "type": null
102
+ },
103
+ {
104
+ "title": "function",
105
+ "description": null,
106
+ "name": null
107
+ },
108
+ {
109
+ "title": "example",
110
+ "description": "fnIf((state) => state?.data?.name, get(\"https://example.com\"));"
111
+ },
112
+ {
113
+ "title": "param",
114
+ "description": "The condition that returns true",
115
+ "type": {
116
+ "type": "NameExpression",
117
+ "name": "Boolean"
118
+ },
119
+ "name": "condition"
120
+ },
121
+ {
122
+ "title": "param",
123
+ "description": "The operation needed to be executed.",
124
+ "type": {
125
+ "type": "NameExpression",
126
+ "name": "Operation"
127
+ },
128
+ "name": "operation"
129
+ },
130
+ {
131
+ "title": "returns",
132
+ "description": null,
133
+ "type": {
134
+ "type": "NameExpression",
135
+ "name": "Operation"
136
+ }
137
+ }
138
+ ]
139
+ },
140
+ "valid": true
141
+ },
142
+ {
143
+ "name": "jsonValue",
144
+ "params": [
145
+ "obj",
146
+ "path"
147
+ ],
148
+ "docs": {
149
+ "description": "Picks out a single value from a JSON object.\nIf a JSONPath returns more than one value for the reference, the first\nitem will be returned.",
150
+ "tags": [
151
+ {
152
+ "title": "public",
153
+ "description": null,
154
+ "type": null
155
+ },
156
+ {
157
+ "title": "function",
158
+ "description": null,
159
+ "name": null
160
+ },
161
+ {
162
+ "title": "example",
163
+ "description": "jsonValue({ a:1 }, 'a')"
164
+ },
165
+ {
166
+ "title": "param",
167
+ "description": "A valid JSON object.",
168
+ "type": {
169
+ "type": "NameExpression",
170
+ "name": "object"
171
+ },
172
+ "name": "obj"
173
+ },
174
+ {
175
+ "title": "param",
176
+ "description": "JSONPath referencing a point in given JSON object.",
177
+ "type": {
178
+ "type": "NameExpression",
179
+ "name": "String"
180
+ },
181
+ "name": "path"
182
+ },
183
+ {
184
+ "title": "returns",
185
+ "description": null,
186
+ "type": {
187
+ "type": "NameExpression",
188
+ "name": "Operation"
189
+ }
190
+ }
191
+ ]
192
+ },
193
+ "valid": true
194
+ },
195
+ {
196
+ "name": "sourceValue",
197
+ "params": [
198
+ "path"
199
+ ],
200
+ "docs": {
201
+ "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.",
202
+ "tags": [
203
+ {
204
+ "title": "public",
205
+ "description": null,
206
+ "type": null
207
+ },
208
+ {
209
+ "title": "function",
210
+ "description": null,
211
+ "name": null
212
+ },
213
+ {
214
+ "title": "example",
215
+ "description": "sourceValue('$.key')"
216
+ },
217
+ {
218
+ "title": "param",
219
+ "description": "JSONPath referencing a point in `state`.",
220
+ "type": {
221
+ "type": "NameExpression",
222
+ "name": "String"
223
+ },
224
+ "name": "path"
225
+ },
226
+ {
227
+ "title": "returns",
228
+ "description": null,
229
+ "type": {
230
+ "type": "NameExpression",
231
+ "name": "Operation"
232
+ }
233
+ }
234
+ ]
235
+ },
236
+ "valid": true
237
+ },
238
+ {
239
+ "name": "source",
240
+ "params": [
241
+ "path"
242
+ ],
243
+ "docs": {
244
+ "description": "Picks out a value from source data.\nWill return whatever JSONPath returns, which will always be an array.\nIf you need a single value use `sourceValue` instead.",
245
+ "tags": [
246
+ {
247
+ "title": "public",
248
+ "description": null,
249
+ "type": null
250
+ },
251
+ {
252
+ "title": "function",
253
+ "description": null,
254
+ "name": null
255
+ },
256
+ {
257
+ "title": "example",
258
+ "description": "source('$.key')"
259
+ },
260
+ {
261
+ "title": "param",
262
+ "description": "JSONPath referencing a point in `state`.",
263
+ "type": {
264
+ "type": "NameExpression",
265
+ "name": "String"
266
+ },
267
+ "name": "path"
268
+ },
269
+ {
270
+ "title": "returns",
271
+ "description": null,
272
+ "type": {
273
+ "type": "TypeApplication",
274
+ "expression": {
275
+ "type": "NameExpression",
276
+ "name": "Array"
277
+ },
278
+ "applications": [
279
+ {
280
+ "type": "UnionType",
281
+ "elements": [
282
+ {
283
+ "type": "NameExpression",
284
+ "name": "String"
285
+ },
286
+ {
287
+ "type": "NameExpression",
288
+ "name": "Object"
289
+ }
290
+ ]
291
+ }
292
+ ]
293
+ }
294
+ }
295
+ ]
296
+ },
297
+ "valid": true
298
+ },
299
+ {
300
+ "name": "dataPath",
301
+ "params": [
302
+ "path"
303
+ ],
304
+ "docs": {
305
+ "description": "Ensures a path points at the data.",
306
+ "tags": [
307
+ {
308
+ "title": "public",
309
+ "description": null,
310
+ "type": null
311
+ },
312
+ {
313
+ "title": "function",
314
+ "description": null,
315
+ "name": null
316
+ },
317
+ {
318
+ "title": "example",
319
+ "description": "dataPath('key')"
320
+ },
321
+ {
322
+ "title": "param",
323
+ "description": "JSONPath referencing a point in `data`.",
324
+ "type": {
325
+ "type": "NameExpression",
326
+ "name": "string"
327
+ },
328
+ "name": "path"
329
+ },
330
+ {
331
+ "title": "returns",
332
+ "description": null,
333
+ "type": {
334
+ "type": "NameExpression",
335
+ "name": "string"
336
+ }
337
+ }
338
+ ]
339
+ },
340
+ "valid": true
341
+ },
342
+ {
343
+ "name": "dataValue",
344
+ "params": [
345
+ "path"
346
+ ],
347
+ "docs": {
348
+ "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.",
349
+ "tags": [
350
+ {
351
+ "title": "public",
352
+ "description": null,
353
+ "type": null
354
+ },
355
+ {
356
+ "title": "function",
357
+ "description": null,
358
+ "name": null
359
+ },
360
+ {
361
+ "title": "example",
362
+ "description": "dataValue('key')"
363
+ },
364
+ {
365
+ "title": "param",
366
+ "description": "JSONPath referencing a point in `data`.",
367
+ "type": {
368
+ "type": "NameExpression",
369
+ "name": "String"
370
+ },
371
+ "name": "path"
372
+ },
373
+ {
374
+ "title": "returns",
375
+ "description": null,
376
+ "type": {
377
+ "type": "NameExpression",
378
+ "name": "Operation"
379
+ }
380
+ }
381
+ ]
382
+ },
383
+ "valid": true
384
+ },
385
+ {
386
+ "name": "referencePath",
387
+ "params": [
388
+ "path"
389
+ ],
390
+ "docs": {
391
+ "description": "Ensures a path points at references.",
392
+ "tags": [
393
+ {
394
+ "title": "public",
395
+ "description": null,
396
+ "type": null
397
+ },
398
+ {
399
+ "title": "function",
400
+ "description": null,
401
+ "name": null
402
+ },
403
+ {
404
+ "title": "example",
405
+ "description": "referencePath('key')"
406
+ },
407
+ {
408
+ "title": "param",
409
+ "description": "JSONPath referencing a point in `references`.",
410
+ "type": {
411
+ "type": "NameExpression",
412
+ "name": "string"
413
+ },
414
+ "name": "path"
415
+ },
416
+ {
417
+ "title": "returns",
418
+ "description": null,
419
+ "type": {
420
+ "type": "NameExpression",
421
+ "name": "string"
422
+ }
423
+ }
424
+ ]
425
+ },
426
+ "valid": true
427
+ },
428
+ {
429
+ "name": "lastReferenceValue",
430
+ "params": [
431
+ "path"
432
+ ],
433
+ "docs": {
434
+ "description": "Picks out the last reference value from source data.",
435
+ "tags": [
436
+ {
437
+ "title": "public",
438
+ "description": null,
439
+ "type": null
440
+ },
441
+ {
442
+ "title": "function",
443
+ "description": null,
444
+ "name": null
445
+ },
446
+ {
447
+ "title": "example",
448
+ "description": "lastReferenceValue('key')"
449
+ },
450
+ {
451
+ "title": "param",
452
+ "description": "JSONPath referencing a point in `references`.",
453
+ "type": {
454
+ "type": "NameExpression",
455
+ "name": "String"
456
+ },
457
+ "name": "path"
458
+ },
459
+ {
460
+ "title": "returns",
461
+ "description": null,
462
+ "type": {
463
+ "type": "NameExpression",
464
+ "name": "Operation"
465
+ }
466
+ }
467
+ ]
468
+ },
469
+ "valid": true
470
+ },
471
+ {
472
+ "name": "asData",
473
+ "params": [
474
+ "data",
475
+ "state"
476
+ ],
477
+ "docs": {
478
+ "description": "Simple switcher allowing other expressions to use either a JSONPath or\nobject literals as a data source.\n- JSONPath referencing a point in `state`\n- Object Literal of the data itself.\n- Function to be called with state.",
479
+ "tags": [
480
+ {
481
+ "title": "public",
482
+ "description": null,
483
+ "type": null
484
+ },
485
+ {
486
+ "title": "function",
487
+ "description": null,
488
+ "name": null
489
+ },
490
+ {
491
+ "title": "example",
492
+ "description": "asData('$.key'| key | callback)"
493
+ },
494
+ {
495
+ "title": "param",
496
+ "description": null,
497
+ "type": {
498
+ "type": "UnionType",
499
+ "elements": [
500
+ {
501
+ "type": "NameExpression",
502
+ "name": "String"
503
+ },
504
+ {
505
+ "type": "NameExpression",
506
+ "name": "object"
507
+ },
508
+ {
509
+ "type": "NameExpression",
510
+ "name": "function"
511
+ }
512
+ ]
513
+ },
514
+ "name": "data"
515
+ },
516
+ {
517
+ "title": "param",
518
+ "description": "The current state.",
519
+ "type": {
520
+ "type": "NameExpression",
521
+ "name": "object"
522
+ },
523
+ "name": "state"
524
+ },
525
+ {
526
+ "title": "returns",
527
+ "description": null,
528
+ "type": {
529
+ "type": "NameExpression",
530
+ "name": "array"
531
+ }
532
+ }
533
+ ]
534
+ },
535
+ "valid": true
536
+ },
537
+ {
538
+ "name": "each",
539
+ "params": [
540
+ "dataSource",
541
+ "operation"
542
+ ],
543
+ "docs": {
544
+ "description": "Scopes an array of data based on a JSONPath.\nUseful when the source data has `n` items you would like to map to\nan operation.\nThe operation will receive a slice of the data based of each item\nof the JSONPath provided.\n\nIt also ensures the results of an operation make their way back into\nthe state's references.",
545
+ "tags": [
546
+ {
547
+ "title": "public",
548
+ "description": null,
549
+ "type": null
550
+ },
551
+ {
552
+ "title": "function",
553
+ "description": null,
554
+ "name": null
555
+ },
556
+ {
557
+ "title": "example",
558
+ "description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
559
+ },
560
+ {
561
+ "title": "param",
562
+ "description": "JSONPath referencing a point in `state`.",
563
+ "type": {
564
+ "type": "NameExpression",
565
+ "name": "DataSource"
566
+ },
567
+ "name": "dataSource"
568
+ },
569
+ {
570
+ "title": "param",
571
+ "description": "The operation needed to be repeated.",
572
+ "type": {
573
+ "type": "NameExpression",
574
+ "name": "Operation"
575
+ },
576
+ "name": "operation"
577
+ },
578
+ {
579
+ "title": "returns",
580
+ "description": null,
581
+ "type": {
582
+ "type": "NameExpression",
583
+ "name": "Operation"
584
+ }
585
+ }
586
+ ]
587
+ },
588
+ "valid": true
589
+ },
590
+ {
591
+ "name": "combine",
592
+ "params": [
593
+ "operations"
594
+ ],
595
+ "docs": {
596
+ "description": "Combines two operations into one",
597
+ "tags": [
598
+ {
599
+ "title": "public",
600
+ "description": null,
601
+ "type": null
602
+ },
603
+ {
604
+ "title": "function",
605
+ "description": null,
606
+ "name": null
607
+ },
608
+ {
609
+ "title": "example",
610
+ "description": "combine(\n create('foo'),\n delete('bar')\n)"
611
+ },
612
+ {
613
+ "title": "param",
614
+ "description": "Operations to be performed.",
615
+ "type": {
616
+ "type": "NameExpression",
617
+ "name": "Operations"
618
+ },
619
+ "name": "operations"
620
+ },
621
+ {
622
+ "title": "returns",
623
+ "description": null,
624
+ "type": {
625
+ "type": "NameExpression",
626
+ "name": "Operation"
627
+ }
628
+ }
629
+ ]
630
+ },
631
+ "valid": true
632
+ },
633
+ {
634
+ "name": "join",
635
+ "params": [
636
+ "targetPath",
637
+ "sourcePath",
638
+ "targetKey"
639
+ ],
640
+ "docs": {
641
+ "description": "Adds data from a target object",
642
+ "tags": [
643
+ {
644
+ "title": "public",
645
+ "description": null,
646
+ "type": null
647
+ },
648
+ {
649
+ "title": "function",
650
+ "description": null,
651
+ "name": null
652
+ },
653
+ {
654
+ "title": "example",
655
+ "description": "join('$.key','$.data','newKey')"
656
+ },
657
+ {
658
+ "title": "param",
659
+ "description": "Target path",
660
+ "type": {
661
+ "type": "NameExpression",
662
+ "name": "String"
663
+ },
664
+ "name": "targetPath"
665
+ },
666
+ {
667
+ "title": "param",
668
+ "description": "Source path",
669
+ "type": {
670
+ "type": "NameExpression",
671
+ "name": "String"
672
+ },
673
+ "name": "sourcePath"
674
+ },
675
+ {
676
+ "title": "param",
677
+ "description": "Target Key",
678
+ "type": {
679
+ "type": "NameExpression",
680
+ "name": "String"
681
+ },
682
+ "name": "targetKey"
683
+ },
684
+ {
685
+ "title": "returns",
686
+ "description": null,
687
+ "type": {
688
+ "type": "NameExpression",
689
+ "name": "Operation"
690
+ }
691
+ }
692
+ ]
693
+ },
694
+ "valid": true
695
+ },
696
+ {
697
+ "name": "expandReferences",
698
+ "params": [
699
+ "value",
700
+ "skipFilter"
701
+ ],
702
+ "docs": {
703
+ "description": "Recursively resolves objects that have resolvable values (functions).",
704
+ "tags": [
705
+ {
706
+ "title": "public",
707
+ "description": null,
708
+ "type": null
709
+ },
710
+ {
711
+ "title": "function",
712
+ "description": null,
713
+ "name": null
714
+ },
715
+ {
716
+ "title": "param",
717
+ "description": "data",
718
+ "type": {
719
+ "type": "NameExpression",
720
+ "name": "object"
721
+ },
722
+ "name": "value"
723
+ },
724
+ {
725
+ "title": "param",
726
+ "description": "a function which returns true if a value should be skipped",
727
+ "type": {
728
+ "type": "OptionalType",
729
+ "expression": {
730
+ "type": "NameExpression",
731
+ "name": "Function"
732
+ }
733
+ },
734
+ "name": "skipFilter"
735
+ },
736
+ {
737
+ "title": "returns",
738
+ "description": null,
739
+ "type": {
740
+ "type": "NameExpression",
741
+ "name": "Operation"
742
+ }
743
+ }
744
+ ]
745
+ },
746
+ "valid": true
747
+ },
748
+ {
749
+ "name": "field",
750
+ "params": [
751
+ "key",
752
+ "value"
753
+ ],
754
+ "docs": {
755
+ "description": "Returns a key, value pair in an array.",
756
+ "tags": [
757
+ {
758
+ "title": "public",
759
+ "description": null,
760
+ "type": null
761
+ },
762
+ {
763
+ "title": "function",
764
+ "description": null,
765
+ "name": null
766
+ },
767
+ {
768
+ "title": "example",
769
+ "description": "field('destination_field_name__c', 'value')"
770
+ },
771
+ {
772
+ "title": "param",
773
+ "description": "Name of the field",
774
+ "type": {
775
+ "type": "NameExpression",
776
+ "name": "string"
777
+ },
778
+ "name": "key"
779
+ },
780
+ {
781
+ "title": "param",
782
+ "description": "The value itself or a sourceable operation.",
783
+ "type": {
784
+ "type": "NameExpression",
785
+ "name": "Value"
786
+ },
787
+ "name": "value"
788
+ },
789
+ {
790
+ "title": "returns",
791
+ "description": null,
792
+ "type": {
793
+ "type": "NameExpression",
794
+ "name": "Field"
795
+ }
796
+ }
797
+ ]
798
+ },
799
+ "valid": true
800
+ },
801
+ {
802
+ "name": "fields",
803
+ "params": [
804
+ "fields"
805
+ ],
806
+ "docs": {
807
+ "description": "Zips key value pairs into an object.",
808
+ "tags": [
809
+ {
810
+ "title": "public",
811
+ "description": null,
812
+ "type": null
813
+ },
814
+ {
815
+ "title": "function",
816
+ "description": null,
817
+ "name": null
818
+ },
819
+ {
820
+ "title": "example",
821
+ "description": "fields(list_of_fields)"
822
+ },
823
+ {
824
+ "title": "param",
825
+ "description": "a list of fields",
826
+ "type": {
827
+ "type": "NameExpression",
828
+ "name": "Fields"
829
+ },
830
+ "name": "fields"
831
+ },
832
+ {
833
+ "title": "returns",
834
+ "description": null,
835
+ "type": {
836
+ "type": "NameExpression",
837
+ "name": "Object"
838
+ }
839
+ }
840
+ ]
841
+ },
842
+ "valid": true
843
+ },
844
+ {
845
+ "name": "merge",
846
+ "params": [
847
+ "dataSource",
848
+ "fields"
849
+ ],
850
+ "docs": {
851
+ "description": "Merges fields into each item in an array.",
852
+ "tags": [
853
+ {
854
+ "title": "public",
855
+ "description": null,
856
+ "type": null
857
+ },
858
+ {
859
+ "title": "example",
860
+ "description": "merge(\n \"$.books[*]\",\n fields(\n field( \"publisher\", sourceValue(\"$.publisher\") )\n )\n)"
861
+ },
862
+ {
863
+ "title": "function",
864
+ "description": null,
865
+ "name": null
866
+ },
867
+ {
868
+ "title": "public",
869
+ "description": null,
870
+ "type": null
871
+ },
872
+ {
873
+ "title": "param",
874
+ "description": null,
875
+ "type": {
876
+ "type": "NameExpression",
877
+ "name": "DataSource"
878
+ },
879
+ "name": "dataSource"
880
+ },
881
+ {
882
+ "title": "param",
883
+ "description": "Group of fields to merge in.",
884
+ "type": {
885
+ "type": "NameExpression",
886
+ "name": "Object"
887
+ },
888
+ "name": "fields"
889
+ },
890
+ {
891
+ "title": "returns",
892
+ "description": null,
893
+ "type": {
894
+ "type": "NameExpression",
895
+ "name": "DataSource"
896
+ }
897
+ }
898
+ ]
899
+ },
900
+ "valid": true
901
+ },
902
+ {
903
+ "name": "group",
904
+ "params": [
905
+ "arrayOfObjects",
906
+ "keyPath",
907
+ "callback"
908
+ ],
909
+ "docs": {
910
+ "description": "Groups an array of objects by a specified key path.",
911
+ "tags": [
912
+ {
913
+ "title": "public",
914
+ "description": null,
915
+ "type": null
916
+ },
917
+ {
918
+ "title": "example",
919
+ "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 / ] }"
920
+ },
921
+ {
922
+ "title": "function",
923
+ "description": null,
924
+ "name": null
925
+ },
926
+ {
927
+ "title": "public",
928
+ "description": null,
929
+ "type": null
930
+ },
931
+ {
932
+ "title": "param",
933
+ "description": "The array of objects to be grouped.",
934
+ "type": {
935
+ "type": "TypeApplication",
936
+ "expression": {
937
+ "type": "NameExpression",
938
+ "name": "Array"
939
+ },
940
+ "applications": [
941
+ {
942
+ "type": "NameExpression",
943
+ "name": "Object"
944
+ }
945
+ ]
946
+ },
947
+ "name": "arrayOfObjects"
948
+ },
949
+ {
950
+ "title": "param",
951
+ "description": "The key path to group by.",
952
+ "type": {
953
+ "type": "NameExpression",
954
+ "name": "string"
955
+ },
956
+ "name": "keyPath"
957
+ },
958
+ {
959
+ "title": "param",
960
+ "description": "(Optional) Callback function",
961
+ "type": {
962
+ "type": "NameExpression",
963
+ "name": "function"
964
+ },
965
+ "name": "callback"
966
+ },
967
+ {
968
+ "title": "returns",
969
+ "description": null,
970
+ "type": {
971
+ "type": "NameExpression",
972
+ "name": "Operation"
973
+ }
974
+ }
975
+ ]
976
+ },
977
+ "valid": true
978
+ },
979
+ {
980
+ "name": "index",
981
+ "params": [],
982
+ "docs": {
983
+ "description": "Returns the index of the current array being iterated.\nTo be used with `each` as a data source.",
984
+ "tags": [
985
+ {
986
+ "title": "public",
987
+ "description": null,
988
+ "type": null
989
+ },
990
+ {
991
+ "title": "function",
992
+ "description": null,
993
+ "name": null
994
+ },
995
+ {
996
+ "title": "example",
997
+ "description": "index()"
998
+ },
999
+ {
1000
+ "title": "returns",
1001
+ "description": null,
1002
+ "type": {
1003
+ "type": "NameExpression",
1004
+ "name": "DataSource"
1005
+ }
1006
+ }
1007
+ ]
1008
+ },
1009
+ "valid": true
1010
+ },
1011
+ {
1012
+ "name": "arrayToString",
1013
+ "params": [
1014
+ "arr",
1015
+ "separator"
1016
+ ],
1017
+ "docs": {
1018
+ "description": "Turns an array into a string, separated by X.",
1019
+ "tags": [
1020
+ {
1021
+ "title": "public",
1022
+ "description": null,
1023
+ "type": null
1024
+ },
1025
+ {
1026
+ "title": "function",
1027
+ "description": null,
1028
+ "name": null
1029
+ },
1030
+ {
1031
+ "title": "example",
1032
+ "description": "field(\"destination_string__c\", function(state) {\n return arrayToString(dataValue(\"path_of_array\")(state), ', ')\n})"
1033
+ },
1034
+ {
1035
+ "title": "param",
1036
+ "description": "Array of toString'able primatives.",
1037
+ "type": {
1038
+ "type": "NameExpression",
1039
+ "name": "array"
1040
+ },
1041
+ "name": "arr"
1042
+ },
1043
+ {
1044
+ "title": "param",
1045
+ "description": "Separator string.",
1046
+ "type": {
1047
+ "type": "NameExpression",
1048
+ "name": "string"
1049
+ },
1050
+ "name": "separator"
1051
+ },
1052
+ {
1053
+ "title": "returns",
1054
+ "description": null,
1055
+ "type": {
1056
+ "type": "NameExpression",
1057
+ "name": "string"
1058
+ }
1059
+ }
1060
+ ]
1061
+ },
1062
+ "valid": true
1063
+ },
1064
+ {
1065
+ "name": "toArray",
1066
+ "params": [
1067
+ "arg"
1068
+ ],
1069
+ "docs": {
1070
+ "description": "Ensures primitive data types are wrapped in an array.\nDoes not affect array objects.",
1071
+ "tags": [
1072
+ {
1073
+ "title": "public",
1074
+ "description": null,
1075
+ "type": null
1076
+ },
1077
+ {
1078
+ "title": "function",
1079
+ "description": null,
1080
+ "name": null
1081
+ },
1082
+ {
1083
+ "title": "example",
1084
+ "description": "each(function(state) {\n return toArray( dataValue(\"path_of_array\")(state) )\n}, ...)"
1085
+ },
1086
+ {
1087
+ "title": "param",
1088
+ "description": "Data required to be in an array",
1089
+ "type": {
1090
+ "type": "NameExpression",
1091
+ "name": "any"
1092
+ },
1093
+ "name": "arg"
1094
+ },
1095
+ {
1096
+ "title": "returns",
1097
+ "description": null,
1098
+ "type": {
1099
+ "type": "NameExpression",
1100
+ "name": "array"
1101
+ }
1102
+ }
1103
+ ]
1104
+ },
1105
+ "valid": true
1106
+ },
1107
+ {
1108
+ "name": "composeNextState",
1109
+ "params": [
1110
+ "state",
1111
+ "response"
1112
+ ],
1113
+ "docs": {
1114
+ "description": "Prepares next state",
1115
+ "tags": [
1116
+ {
1117
+ "title": "public",
1118
+ "description": null,
1119
+ "type": null
1120
+ },
1121
+ {
1122
+ "title": "function",
1123
+ "description": null,
1124
+ "name": null
1125
+ },
1126
+ {
1127
+ "title": "example",
1128
+ "description": "composeNextState(state, response)"
1129
+ },
1130
+ {
1131
+ "title": "param",
1132
+ "description": "state",
1133
+ "type": {
1134
+ "type": "NameExpression",
1135
+ "name": "State"
1136
+ },
1137
+ "name": "state"
1138
+ },
1139
+ {
1140
+ "title": "param",
1141
+ "description": "Response to be added",
1142
+ "type": {
1143
+ "type": "NameExpression",
1144
+ "name": "Object"
1145
+ },
1146
+ "name": "response"
1147
+ },
1148
+ {
1149
+ "title": "returns",
1150
+ "description": null,
1151
+ "type": {
1152
+ "type": "NameExpression",
1153
+ "name": "State"
1154
+ }
1155
+ }
1156
+ ]
1157
+ },
1158
+ "valid": true
1159
+ },
1160
+ {
1161
+ "name": "humanProper",
1162
+ "params": [
1163
+ "str"
1164
+ ],
1165
+ "docs": {
1166
+ "description": "Substitutes underscores for spaces and proper-cases a string",
1167
+ "tags": [
1168
+ {
1169
+ "title": "public",
1170
+ "description": null,
1171
+ "type": null
1172
+ },
1173
+ {
1174
+ "title": "function",
1175
+ "description": null,
1176
+ "name": null
1177
+ },
1178
+ {
1179
+ "title": "example",
1180
+ "description": "field(\"destination_string__c\", humanProper(state.data.path_to_string))"
1181
+ },
1182
+ {
1183
+ "title": "param",
1184
+ "description": "String that needs converting",
1185
+ "type": {
1186
+ "type": "NameExpression",
1187
+ "name": "string"
1188
+ },
1189
+ "name": "str"
1190
+ },
1191
+ {
1192
+ "title": "returns",
1193
+ "description": null,
1194
+ "type": {
1195
+ "type": "NameExpression",
1196
+ "name": "string"
1197
+ }
1198
+ }
1199
+ ]
1200
+ },
1201
+ "valid": true
1202
+ },
1203
+ {
1204
+ "name": "splitKeys",
1205
+ "params": [
1206
+ "obj",
1207
+ "keys"
1208
+ ],
1209
+ "docs": {
1210
+ "description": "Splits an object into two objects based on a list of keys.\nThe first object contains the keys that are not in the list,\nand the second contains the keys that are.",
1211
+ "tags": [
1212
+ {
1213
+ "title": "public",
1214
+ "description": null,
1215
+ "type": null
1216
+ },
1217
+ {
1218
+ "title": "function",
1219
+ "description": null,
1220
+ "name": null
1221
+ },
1222
+ {
1223
+ "title": "param",
1224
+ "description": "The object to split.",
1225
+ "type": {
1226
+ "type": "NameExpression",
1227
+ "name": "Object"
1228
+ },
1229
+ "name": "obj"
1230
+ },
1231
+ {
1232
+ "title": "param",
1233
+ "description": "List of keys to split on.",
1234
+ "type": {
1235
+ "type": "TypeApplication",
1236
+ "expression": {
1237
+ "type": "NameExpression",
1238
+ "name": "Array"
1239
+ },
1240
+ "applications": [
1241
+ {
1242
+ "type": "NameExpression",
1243
+ "name": "string"
1244
+ }
1245
+ ]
1246
+ },
1247
+ "name": "keys"
1248
+ },
1249
+ {
1250
+ "title": "returns",
1251
+ "description": "Tuple of objects, first object contains keys not in list, second contains keys that are.",
1252
+ "type": {
1253
+ "type": "TypeApplication",
1254
+ "expression": {
1255
+ "type": "NameExpression",
1256
+ "name": "Array"
1257
+ },
1258
+ "applications": [
1259
+ {
1260
+ "type": "NameExpression",
1261
+ "name": "Object"
1262
+ }
1263
+ ]
1264
+ }
1265
+ }
1266
+ ]
1267
+ },
1268
+ "valid": true
1269
+ },
1270
+ {
1271
+ "name": "scrubEmojis",
1272
+ "params": [
1273
+ "text",
1274
+ "replacementChars"
1275
+ ],
1276
+ "docs": {
1277
+ "description": "Replaces emojis in a string.",
1278
+ "tags": [
1279
+ {
1280
+ "title": "public",
1281
+ "description": null,
1282
+ "type": null
1283
+ },
1284
+ {
1285
+ "title": "function",
1286
+ "description": null,
1287
+ "name": null
1288
+ },
1289
+ {
1290
+ "title": "example",
1291
+ "description": "scrubEmojis('Dove🕊️⭐ 29')"
1292
+ },
1293
+ {
1294
+ "title": "param",
1295
+ "description": "String that needs to be cleaned",
1296
+ "type": {
1297
+ "type": "NameExpression",
1298
+ "name": "string"
1299
+ },
1300
+ "name": "text"
1301
+ },
1302
+ {
1303
+ "title": "param",
1304
+ "description": "Characters that replace the emojis",
1305
+ "type": {
1306
+ "type": "NameExpression",
1307
+ "name": "string"
1308
+ },
1309
+ "name": "replacementChars"
1310
+ },
1311
+ {
1312
+ "title": "returns",
1313
+ "description": null,
1314
+ "type": {
1315
+ "type": "NameExpression",
1316
+ "name": "string"
1317
+ }
1318
+ }
1319
+ ]
1320
+ },
1321
+ "valid": true
1322
+ },
1323
+ {
1324
+ "name": "chunk",
1325
+ "params": [
1326
+ "array",
1327
+ "chunkSize"
1328
+ ],
1329
+ "docs": {
1330
+ "description": "Chunks an array into an array of arrays, each with no more than a certain size.",
1331
+ "tags": [
1332
+ {
1333
+ "title": "public",
1334
+ "description": null,
1335
+ "type": null
1336
+ },
1337
+ {
1338
+ "title": "function",
1339
+ "description": null,
1340
+ "name": null
1341
+ },
1342
+ {
1343
+ "title": "example",
1344
+ "description": "chunk([1,2,3,4,5], 2)"
1345
+ },
1346
+ {
1347
+ "title": "param",
1348
+ "description": "Array to be chunked",
1349
+ "type": {
1350
+ "type": "NameExpression",
1351
+ "name": "Object"
1352
+ },
1353
+ "name": "array"
1354
+ },
1355
+ {
1356
+ "title": "param",
1357
+ "description": "The maxiumum size of each chunks",
1358
+ "type": {
1359
+ "type": "NameExpression",
1360
+ "name": "Integer"
1361
+ },
1362
+ "name": "chunkSize"
1363
+ },
1364
+ {
1365
+ "title": "returns",
1366
+ "description": null,
1367
+ "type": {
1368
+ "type": "NameExpression",
1369
+ "name": "Object"
1370
+ }
1371
+ }
1372
+ ]
1373
+ },
1374
+ "valid": true
1375
+ },
1376
+ {
1377
+ "name": "parseCsv",
1378
+ "params": [
1379
+ "csvData",
1380
+ "parsingOptions",
1381
+ "callback"
1382
+ ],
1383
+ "docs": {
1384
+ "description": "Takes a CSV file string or stream and parsing options as input, and returns a promise that\nresolves to the parsed CSV data as an array of objects.\nOptions for `parsingOptions` include:\n- `delimiter` {string/Buffer/[string/Buffer]} - Defines the character(s) used to delineate the fields inside a record. Default: `','`\n- `quote` {string/Buffer/[string/Buffer]} - Defines the characters used to surround a field. Default: `'\"'`\n- `escape` {Buffer/string/null/boolean} - Set the escape character as one character/byte only. Default: `\"`\n- `columns` {boolean / array / function} - Generates record in the form of object literals. Default: `true`\n- `bom` {boolean} - Strips the {@link https://en.wikipedia.org/wiki/Byte_order_mark byte order mark (BOM)} from the input string or buffer. Default: `true`\n- `trim` {boolean} - Ignore whitespace characters immediately around the `delimiter`. Default: `true`\n- `ltrim` {boolean} - Ignore whitespace characters from the left side of a CSV field. Default: `true`\n- `rtrim` {boolean} - Ignore whitespace characters from the right side of a CSV field. Default: `true`\n- `chunkSize` {number} - The size of each chunk of CSV data. Default: `Infinity`\n- `skip_empty_lines` {boolean} - Ignore empty lines in the CSV file. Default: `true`",
1385
+ "tags": [
1386
+ {
1387
+ "title": "public",
1388
+ "description": null,
1389
+ "type": null
1390
+ },
1391
+ {
1392
+ "title": "function",
1393
+ "description": null,
1394
+ "name": null
1395
+ },
1396
+ {
1397
+ "title": "param",
1398
+ "description": "A CSV string or a readable stream",
1399
+ "type": {
1400
+ "type": "UnionType",
1401
+ "elements": [
1402
+ {
1403
+ "type": "NameExpression",
1404
+ "name": "String"
1405
+ },
1406
+ {
1407
+ "type": "NameExpression",
1408
+ "name": "Stream"
1409
+ }
1410
+ ]
1411
+ },
1412
+ "name": "csvData"
1413
+ },
1414
+ {
1415
+ "title": "param",
1416
+ "description": "Optional. Parsing options for converting CSV to JSON.",
1417
+ "type": {
1418
+ "type": "OptionalType",
1419
+ "expression": {
1420
+ "type": "NameExpression",
1421
+ "name": "Object"
1422
+ }
1423
+ },
1424
+ "name": "parsingOptions"
1425
+ },
1426
+ {
1427
+ "title": "param",
1428
+ "description": "(Optional) callback function. If used it will be called state and an array of rows.",
1429
+ "type": {
1430
+ "type": "OptionalType",
1431
+ "expression": {
1432
+ "type": "NameExpression",
1433
+ "name": "function"
1434
+ }
1435
+ },
1436
+ "name": "callback"
1437
+ },
1438
+ {
1439
+ "title": "returns",
1440
+ "description": "The function returns a Promise that resolves to the result of parsing a CSV `stringOrStream`.",
1441
+ "type": {
1442
+ "type": "NameExpression",
1443
+ "name": "Operation"
1444
+ }
1445
+ }
1446
+ ]
1447
+ },
1448
+ "valid": true
1449
+ },
1450
+ {
1451
+ "name": "cursor",
1452
+ "params": [
1453
+ "value",
1454
+ "options"
1455
+ ],
1456
+ "docs": {
1457
+ "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}",
1458
+ "tags": [
1459
+ {
1460
+ "title": "public",
1461
+ "description": null,
1462
+ "type": null
1463
+ },
1464
+ {
1465
+ "title": "function",
1466
+ "description": null,
1467
+ "name": null
1468
+ },
1469
+ {
1470
+ "title": "example",
1471
+ "description": "cursor($.cursor, { defaultValue: 'today' })",
1472
+ "caption": "Use a cursor from state if present, or else use the default value"
1473
+ },
1474
+ {
1475
+ "title": "example",
1476
+ "description": "cursor(22)",
1477
+ "caption": "Use a pagination cursor"
1478
+ },
1479
+ {
1480
+ "title": "param",
1481
+ "description": "the cursor value. Usually an ISO date, natural language date, or page number",
1482
+ "type": {
1483
+ "type": "NameExpression",
1484
+ "name": "any"
1485
+ },
1486
+ "name": "value"
1487
+ },
1488
+ {
1489
+ "title": "param",
1490
+ "description": "options to control the cursor.",
1491
+ "type": {
1492
+ "type": "NameExpression",
1493
+ "name": "object"
1494
+ },
1495
+ "name": "options"
1496
+ },
1497
+ {
1498
+ "title": "param",
1499
+ "description": "set the cursor key. Will persist through the whole run.",
1500
+ "type": {
1501
+ "type": "NameExpression",
1502
+ "name": "string"
1503
+ },
1504
+ "name": "options.key"
1505
+ },
1506
+ {
1507
+ "title": "param",
1508
+ "description": "the value to use if value is falsy",
1509
+ "type": {
1510
+ "type": "NameExpression",
1511
+ "name": "any"
1512
+ },
1513
+ "name": "options.defaultValue"
1514
+ },
1515
+ {
1516
+ "title": "param",
1517
+ "description": "custom formatter for the final cursor value",
1518
+ "type": {
1519
+ "type": "NameExpression",
1520
+ "name": "Function"
1521
+ },
1522
+ "name": "options.format"
1523
+ },
1524
+ {
1525
+ "title": "returns",
1526
+ "description": null,
1527
+ "type": {
1528
+ "type": "NameExpression",
1529
+ "name": "Operation"
1530
+ }
1531
+ }
1532
+ ]
1533
+ },
1534
+ "valid": false
1535
+ },
1536
+ {
1537
+ "name": "map",
1538
+ "params": [
1539
+ "path",
1540
+ "operation",
1541
+ "state"
1542
+ ],
1543
+ "docs": {
1544
+ "description": "Scopes an array of data based on a JSONPath.\nUseful when the source data has `n` items you would like to map to\nan operation.\nThe operation will receive a slice of the data based of each item\nof the JSONPath provided.",
1545
+ "tags": [
1546
+ {
1547
+ "title": "public",
1548
+ "description": null,
1549
+ "type": null
1550
+ },
1551
+ {
1552
+ "title": "function",
1553
+ "description": null,
1554
+ "name": null
1555
+ },
1556
+ {
1557
+ "title": "example",
1558
+ "description": "map(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
1559
+ },
1560
+ {
1561
+ "title": "param",
1562
+ "description": "JSONPath referencing a point in `state.data`.",
1563
+ "type": {
1564
+ "type": "NameExpression",
1565
+ "name": "string"
1566
+ },
1567
+ "name": "path"
1568
+ },
1569
+ {
1570
+ "title": "param",
1571
+ "description": "The operation needed to be repeated.",
1572
+ "type": {
1573
+ "type": "NameExpression",
1574
+ "name": "function"
1575
+ },
1576
+ "name": "operation"
1577
+ },
1578
+ {
1579
+ "title": "param",
1580
+ "description": "Runtime state.",
1581
+ "type": {
1582
+ "type": "NameExpression",
1583
+ "name": "State"
1584
+ },
1585
+ "name": "state"
1586
+ },
1587
+ {
1588
+ "title": "returns",
1589
+ "description": null,
1590
+ "type": {
1591
+ "type": "NameExpression",
1592
+ "name": "State"
1593
+ }
1594
+ }
1595
+ ]
1596
+ },
1597
+ "valid": true
1598
+ }
1599
+ ],
1600
+ "exports": [],
1601
+ "common": []
1602
+ }