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