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