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