@openfn/language-mtn-momo 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,835 @@
1
+ {
2
+ "operations": [
3
+ {
4
+ "name": "request",
5
+ "params": [
6
+ "method",
7
+ "path",
8
+ "body",
9
+ "options"
10
+ ],
11
+ "docs": {
12
+ "description": "Make a HTTP request to the [MTN MoMo API ](https://momodeveloper.mtn.com/API-collections#api=collection&operation=bc-authorize)",
13
+ "tags": [
14
+ {
15
+ "title": "example",
16
+ "description": "request(\"GET\", \"/collection/v1_0/accountholder/MSISDN/46733123451/basicuserinfo\", {}, { headers: { \"X-Target-Environment\": \"sandbox\" } });",
17
+ "caption": "Get basic user information"
18
+ },
19
+ {
20
+ "title": "example",
21
+ "description": "request(\"POST\", \"/collection/v2_0/invoice\", \n {\n \"externalId\": \"996b82e6-d498-4c7c-87ee-7b0654350a2c\",\n \"amount\": \"100\",\n \"currency\": \"EUR\",\n \"validityDuration\": \"3600\",\n \"intendedPayer\": {\n \"partyIdType\": \"MSISDN\",\n \"partyId\": \"46733123450\"\n },\n \"payee\": {\n \"partyIdType\": \"MSISDN\",\n \"partyId\": \"46733123452\"\n }\n \"description\": \"\"\n },\n {\n \"headers\": {\n \"X-Target-Environment\": \"sandbox\",\n \"X-Reference-Id\": \"ceb46c4f-1523-405b-9d16-dd9ad45e202c\"\n }\n});",
22
+ "caption": "Create an invoice"
23
+ },
24
+ {
25
+ "title": "function",
26
+ "description": null,
27
+ "name": null
28
+ },
29
+ {
30
+ "title": "public",
31
+ "description": null,
32
+ "type": null
33
+ },
34
+ {
35
+ "title": "param",
36
+ "description": "HTTP method to use",
37
+ "type": {
38
+ "type": "NameExpression",
39
+ "name": "string"
40
+ },
41
+ "name": "method"
42
+ },
43
+ {
44
+ "title": "param",
45
+ "description": "Path to resource",
46
+ "type": {
47
+ "type": "NameExpression",
48
+ "name": "string"
49
+ },
50
+ "name": "path"
51
+ },
52
+ {
53
+ "title": "param",
54
+ "description": "Object which will be attached to the HTTP request body",
55
+ "type": {
56
+ "type": "NameExpression",
57
+ "name": "object"
58
+ },
59
+ "name": "body"
60
+ },
61
+ {
62
+ "title": "param",
63
+ "description": "Optional request options",
64
+ "type": {
65
+ "type": "NameExpression",
66
+ "name": "RequestOptions"
67
+ },
68
+ "name": "options"
69
+ },
70
+ {
71
+ "title": "returns",
72
+ "description": null,
73
+ "type": {
74
+ "type": "NameExpression",
75
+ "name": "Operation"
76
+ }
77
+ },
78
+ {
79
+ "title": "state",
80
+ "description": "{HttpState}"
81
+ }
82
+ ]
83
+ },
84
+ "valid": true
85
+ }
86
+ ],
87
+ "exports": [],
88
+ "common": [
89
+ {
90
+ "name": "fn",
91
+ "params": [
92
+ "func"
93
+ ],
94
+ "docs": {
95
+ "description": "Creates a custom step (or operation) for more flexible job writing.",
96
+ "tags": [
97
+ {
98
+ "title": "public",
99
+ "description": null,
100
+ "type": null
101
+ },
102
+ {
103
+ "title": "function",
104
+ "description": null,
105
+ "name": null
106
+ },
107
+ {
108
+ "title": "example",
109
+ "description": "fn(state => {\n // do some things to state\n return state;\n});"
110
+ },
111
+ {
112
+ "title": "param",
113
+ "description": "is the function",
114
+ "type": {
115
+ "type": "NameExpression",
116
+ "name": "Function"
117
+ },
118
+ "name": "func"
119
+ },
120
+ {
121
+ "title": "returns",
122
+ "description": null,
123
+ "type": {
124
+ "type": "NameExpression",
125
+ "name": "Operation"
126
+ }
127
+ }
128
+ ]
129
+ },
130
+ "valid": true
131
+ },
132
+ {
133
+ "name": "fnIf",
134
+ "params": [
135
+ "condition",
136
+ "operation"
137
+ ],
138
+ "docs": {
139
+ "description": "A custom operation that will only execute the function if the condition returns true",
140
+ "tags": [
141
+ {
142
+ "title": "public",
143
+ "description": null,
144
+ "type": null
145
+ },
146
+ {
147
+ "title": "function",
148
+ "description": null,
149
+ "name": null
150
+ },
151
+ {
152
+ "title": "example",
153
+ "description": "fnIf((state) => state?.data?.name, get(\"https://example.com\"));"
154
+ },
155
+ {
156
+ "title": "param",
157
+ "description": "The condition that returns true",
158
+ "type": {
159
+ "type": "NameExpression",
160
+ "name": "Boolean"
161
+ },
162
+ "name": "condition"
163
+ },
164
+ {
165
+ "title": "param",
166
+ "description": "The operation needed to be executed.",
167
+ "type": {
168
+ "type": "NameExpression",
169
+ "name": "Operation"
170
+ },
171
+ "name": "operation"
172
+ },
173
+ {
174
+ "title": "returns",
175
+ "description": null,
176
+ "type": {
177
+ "type": "NameExpression",
178
+ "name": "Operation"
179
+ }
180
+ }
181
+ ]
182
+ },
183
+ "valid": true
184
+ },
185
+ {
186
+ "name": "sourceValue",
187
+ "params": [
188
+ "path"
189
+ ],
190
+ "docs": {
191
+ "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.",
192
+ "tags": [
193
+ {
194
+ "title": "public",
195
+ "description": null,
196
+ "type": null
197
+ },
198
+ {
199
+ "title": "function",
200
+ "description": null,
201
+ "name": null
202
+ },
203
+ {
204
+ "title": "example",
205
+ "description": "sourceValue('$.key')"
206
+ },
207
+ {
208
+ "title": "param",
209
+ "description": "JSONPath referencing a point in `state`.",
210
+ "type": {
211
+ "type": "NameExpression",
212
+ "name": "String"
213
+ },
214
+ "name": "path"
215
+ },
216
+ {
217
+ "title": "returns",
218
+ "description": null,
219
+ "type": {
220
+ "type": "NameExpression",
221
+ "name": "Operation"
222
+ }
223
+ }
224
+ ]
225
+ },
226
+ "valid": true
227
+ },
228
+ {
229
+ "name": "dataPath",
230
+ "params": [
231
+ "path"
232
+ ],
233
+ "docs": {
234
+ "description": "Ensures a path points at the data.",
235
+ "tags": [
236
+ {
237
+ "title": "public",
238
+ "description": null,
239
+ "type": null
240
+ },
241
+ {
242
+ "title": "function",
243
+ "description": null,
244
+ "name": null
245
+ },
246
+ {
247
+ "title": "example",
248
+ "description": "dataPath('key')"
249
+ },
250
+ {
251
+ "title": "param",
252
+ "description": "JSONPath referencing a point in `data`.",
253
+ "type": {
254
+ "type": "NameExpression",
255
+ "name": "string"
256
+ },
257
+ "name": "path"
258
+ },
259
+ {
260
+ "title": "returns",
261
+ "description": null,
262
+ "type": {
263
+ "type": "NameExpression",
264
+ "name": "string"
265
+ }
266
+ }
267
+ ]
268
+ },
269
+ "valid": true
270
+ },
271
+ {
272
+ "name": "dataValue",
273
+ "params": [
274
+ "path"
275
+ ],
276
+ "docs": {
277
+ "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.",
278
+ "tags": [
279
+ {
280
+ "title": "public",
281
+ "description": null,
282
+ "type": null
283
+ },
284
+ {
285
+ "title": "function",
286
+ "description": null,
287
+ "name": null
288
+ },
289
+ {
290
+ "title": "example",
291
+ "description": "dataValue('key')"
292
+ },
293
+ {
294
+ "title": "param",
295
+ "description": "JSONPath referencing a point in `data`.",
296
+ "type": {
297
+ "type": "NameExpression",
298
+ "name": "String"
299
+ },
300
+ "name": "path"
301
+ },
302
+ {
303
+ "title": "returns",
304
+ "description": null,
305
+ "type": {
306
+ "type": "NameExpression",
307
+ "name": "Operation"
308
+ }
309
+ }
310
+ ]
311
+ },
312
+ "valid": true
313
+ },
314
+ {
315
+ "name": "lastReferenceValue",
316
+ "params": [
317
+ "path"
318
+ ],
319
+ "docs": {
320
+ "description": "Picks out the last reference value from source data.",
321
+ "tags": [
322
+ {
323
+ "title": "public",
324
+ "description": null,
325
+ "type": null
326
+ },
327
+ {
328
+ "title": "function",
329
+ "description": null,
330
+ "name": null
331
+ },
332
+ {
333
+ "title": "example",
334
+ "description": "lastReferenceValue('key')"
335
+ },
336
+ {
337
+ "title": "param",
338
+ "description": "JSONPath referencing a point in `references`.",
339
+ "type": {
340
+ "type": "NameExpression",
341
+ "name": "String"
342
+ },
343
+ "name": "path"
344
+ },
345
+ {
346
+ "title": "returns",
347
+ "description": null,
348
+ "type": {
349
+ "type": "NameExpression",
350
+ "name": "Operation"
351
+ }
352
+ }
353
+ ]
354
+ },
355
+ "valid": true
356
+ },
357
+ {
358
+ "name": "each",
359
+ "params": [
360
+ "dataSource",
361
+ "operation"
362
+ ],
363
+ "docs": {
364
+ "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.",
365
+ "tags": [
366
+ {
367
+ "title": "public",
368
+ "description": null,
369
+ "type": null
370
+ },
371
+ {
372
+ "title": "function",
373
+ "description": null,
374
+ "name": null
375
+ },
376
+ {
377
+ "title": "example",
378
+ "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);",
379
+ "caption": "Using lazy state ($) to iterate over items in state.data and pass each into an \"insert\" operation"
380
+ },
381
+ {
382
+ "title": "example",
383
+ "description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n ...state.data\n }))\n);",
384
+ "caption": "Iterate over items in state.data and pass each one into an \"insert\" operation"
385
+ },
386
+ {
387
+ "title": "example",
388
+ "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);",
389
+ "caption": "Using JSON path to iterate over items in state.data and pass each one into an \"insert\" operation"
390
+ },
391
+ {
392
+ "title": "param",
393
+ "description": "JSONPath referencing a point in `state`.",
394
+ "type": {
395
+ "type": "NameExpression",
396
+ "name": "DataSource"
397
+ },
398
+ "name": "dataSource"
399
+ },
400
+ {
401
+ "title": "param",
402
+ "description": "The operation needed to be repeated.",
403
+ "type": {
404
+ "type": "NameExpression",
405
+ "name": "Operation"
406
+ },
407
+ "name": "operation"
408
+ },
409
+ {
410
+ "title": "returns",
411
+ "description": null,
412
+ "type": {
413
+ "type": "NameExpression",
414
+ "name": "Operation"
415
+ }
416
+ }
417
+ ]
418
+ },
419
+ "valid": true
420
+ },
421
+ {
422
+ "name": "combine",
423
+ "params": [
424
+ "operations"
425
+ ],
426
+ "docs": {
427
+ "description": "Combines two operations into one",
428
+ "tags": [
429
+ {
430
+ "title": "public",
431
+ "description": null,
432
+ "type": null
433
+ },
434
+ {
435
+ "title": "function",
436
+ "description": null,
437
+ "name": null
438
+ },
439
+ {
440
+ "title": "example",
441
+ "description": "combine(\n create('foo'),\n delete('bar')\n)"
442
+ },
443
+ {
444
+ "title": "param",
445
+ "description": "Operations to be performed.",
446
+ "type": {
447
+ "type": "NameExpression",
448
+ "name": "Operations"
449
+ },
450
+ "name": "operations"
451
+ },
452
+ {
453
+ "title": "returns",
454
+ "description": null,
455
+ "type": {
456
+ "type": "NameExpression",
457
+ "name": "Operation"
458
+ }
459
+ }
460
+ ]
461
+ },
462
+ "valid": true
463
+ },
464
+ {
465
+ "name": "field",
466
+ "params": [
467
+ "key",
468
+ "value"
469
+ ],
470
+ "docs": {
471
+ "description": "Returns a key, value pair in an array.",
472
+ "tags": [
473
+ {
474
+ "title": "public",
475
+ "description": null,
476
+ "type": null
477
+ },
478
+ {
479
+ "title": "function",
480
+ "description": null,
481
+ "name": null
482
+ },
483
+ {
484
+ "title": "example",
485
+ "description": "field('destination_field_name__c', 'value')"
486
+ },
487
+ {
488
+ "title": "param",
489
+ "description": "Name of the field",
490
+ "type": {
491
+ "type": "NameExpression",
492
+ "name": "string"
493
+ },
494
+ "name": "key"
495
+ },
496
+ {
497
+ "title": "param",
498
+ "description": "The value itself or a sourceable operation.",
499
+ "type": {
500
+ "type": "NameExpression",
501
+ "name": "Value"
502
+ },
503
+ "name": "value"
504
+ },
505
+ {
506
+ "title": "returns",
507
+ "description": null,
508
+ "type": {
509
+ "type": "NameExpression",
510
+ "name": "Field"
511
+ }
512
+ }
513
+ ]
514
+ },
515
+ "valid": true
516
+ },
517
+ {
518
+ "name": "fields",
519
+ "params": [
520
+ "fields"
521
+ ],
522
+ "docs": {
523
+ "description": "Zips key value pairs into an object.",
524
+ "tags": [
525
+ {
526
+ "title": "public",
527
+ "description": null,
528
+ "type": null
529
+ },
530
+ {
531
+ "title": "function",
532
+ "description": null,
533
+ "name": null
534
+ },
535
+ {
536
+ "title": "example",
537
+ "description": "fields(list_of_fields)"
538
+ },
539
+ {
540
+ "title": "param",
541
+ "description": "a list of fields",
542
+ "type": {
543
+ "type": "NameExpression",
544
+ "name": "Fields"
545
+ },
546
+ "name": "fields"
547
+ },
548
+ {
549
+ "title": "returns",
550
+ "description": null,
551
+ "type": {
552
+ "type": "NameExpression",
553
+ "name": "Object"
554
+ }
555
+ }
556
+ ]
557
+ },
558
+ "valid": true
559
+ },
560
+ {
561
+ "name": "merge",
562
+ "params": [
563
+ "dataSource",
564
+ "fields"
565
+ ],
566
+ "docs": {
567
+ "description": "Merges fields into each item in an array.",
568
+ "tags": [
569
+ {
570
+ "title": "public",
571
+ "description": null,
572
+ "type": null
573
+ },
574
+ {
575
+ "title": "example",
576
+ "description": "merge(\n \"$.books[*]\",\n fields(\n field( \"publisher\", sourceValue(\"$.publisher\") )\n )\n)"
577
+ },
578
+ {
579
+ "title": "function",
580
+ "description": null,
581
+ "name": null
582
+ },
583
+ {
584
+ "title": "public",
585
+ "description": null,
586
+ "type": null
587
+ },
588
+ {
589
+ "title": "param",
590
+ "description": null,
591
+ "type": {
592
+ "type": "NameExpression",
593
+ "name": "DataSource"
594
+ },
595
+ "name": "dataSource"
596
+ },
597
+ {
598
+ "title": "param",
599
+ "description": "Group of fields to merge in.",
600
+ "type": {
601
+ "type": "NameExpression",
602
+ "name": "Object"
603
+ },
604
+ "name": "fields"
605
+ },
606
+ {
607
+ "title": "returns",
608
+ "description": null,
609
+ "type": {
610
+ "type": "NameExpression",
611
+ "name": "DataSource"
612
+ }
613
+ }
614
+ ]
615
+ },
616
+ "valid": true
617
+ },
618
+ {
619
+ "name": "group",
620
+ "params": [
621
+ "arrayOfObjects",
622
+ "keyPath",
623
+ "callback"
624
+ ],
625
+ "docs": {
626
+ "description": "Groups an array of objects by a specified key path.",
627
+ "tags": [
628
+ {
629
+ "title": "public",
630
+ "description": null,
631
+ "type": null
632
+ },
633
+ {
634
+ "title": "example",
635
+ "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 / ] }"
636
+ },
637
+ {
638
+ "title": "function",
639
+ "description": null,
640
+ "name": null
641
+ },
642
+ {
643
+ "title": "public",
644
+ "description": null,
645
+ "type": null
646
+ },
647
+ {
648
+ "title": "param",
649
+ "description": "The array of objects to be grouped.",
650
+ "type": {
651
+ "type": "TypeApplication",
652
+ "expression": {
653
+ "type": "NameExpression",
654
+ "name": "Array"
655
+ },
656
+ "applications": [
657
+ {
658
+ "type": "NameExpression",
659
+ "name": "Object"
660
+ }
661
+ ]
662
+ },
663
+ "name": "arrayOfObjects"
664
+ },
665
+ {
666
+ "title": "param",
667
+ "description": "The key path to group by.",
668
+ "type": {
669
+ "type": "NameExpression",
670
+ "name": "string"
671
+ },
672
+ "name": "keyPath"
673
+ },
674
+ {
675
+ "title": "param",
676
+ "description": "(Optional) Callback function",
677
+ "type": {
678
+ "type": "NameExpression",
679
+ "name": "function"
680
+ },
681
+ "name": "callback"
682
+ },
683
+ {
684
+ "title": "returns",
685
+ "description": null,
686
+ "type": {
687
+ "type": "NameExpression",
688
+ "name": "Operation"
689
+ }
690
+ }
691
+ ]
692
+ },
693
+ "valid": true
694
+ },
695
+ {
696
+ "name": "scrubEmojis",
697
+ "params": [
698
+ "text",
699
+ "replacementChars"
700
+ ],
701
+ "docs": {
702
+ "description": "Replaces emojis in a string.",
703
+ "tags": [
704
+ {
705
+ "title": "public",
706
+ "description": null,
707
+ "type": null
708
+ },
709
+ {
710
+ "title": "function",
711
+ "description": null,
712
+ "name": null
713
+ },
714
+ {
715
+ "title": "example",
716
+ "description": "scrubEmojis('Dove🕊️⭐ 29')"
717
+ },
718
+ {
719
+ "title": "param",
720
+ "description": "String that needs to be cleaned",
721
+ "type": {
722
+ "type": "NameExpression",
723
+ "name": "string"
724
+ },
725
+ "name": "text"
726
+ },
727
+ {
728
+ "title": "param",
729
+ "description": "Characters that replace the emojis",
730
+ "type": {
731
+ "type": "NameExpression",
732
+ "name": "string"
733
+ },
734
+ "name": "replacementChars"
735
+ },
736
+ {
737
+ "title": "returns",
738
+ "description": null,
739
+ "type": {
740
+ "type": "NameExpression",
741
+ "name": "string"
742
+ }
743
+ }
744
+ ]
745
+ },
746
+ "valid": true
747
+ },
748
+ {
749
+ "name": "cursor",
750
+ "params": [
751
+ "value",
752
+ "options"
753
+ ],
754
+ "docs": {
755
+ "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}",
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": "cursor($.cursor, { defaultValue: 'today' })",
770
+ "caption": "Use a cursor from state if present, or else use the default value"
771
+ },
772
+ {
773
+ "title": "example",
774
+ "description": "cursor(22)",
775
+ "caption": "Use a pagination cursor"
776
+ },
777
+ {
778
+ "title": "param",
779
+ "description": "the cursor value. Usually an ISO date, natural language date, or page number",
780
+ "type": {
781
+ "type": "NameExpression",
782
+ "name": "any"
783
+ },
784
+ "name": "value"
785
+ },
786
+ {
787
+ "title": "param",
788
+ "description": "options to control the cursor.",
789
+ "type": {
790
+ "type": "NameExpression",
791
+ "name": "object"
792
+ },
793
+ "name": "options"
794
+ },
795
+ {
796
+ "title": "param",
797
+ "description": "set the cursor key. Will persist through the whole run.",
798
+ "type": {
799
+ "type": "NameExpression",
800
+ "name": "string"
801
+ },
802
+ "name": "options.key"
803
+ },
804
+ {
805
+ "title": "param",
806
+ "description": "the value to use if value is falsy",
807
+ "type": {
808
+ "type": "NameExpression",
809
+ "name": "any"
810
+ },
811
+ "name": "options.defaultValue"
812
+ },
813
+ {
814
+ "title": "param",
815
+ "description": "custom formatter for the final cursor value",
816
+ "type": {
817
+ "type": "NameExpression",
818
+ "name": "Function"
819
+ },
820
+ "name": "options.format"
821
+ },
822
+ {
823
+ "title": "returns",
824
+ "description": null,
825
+ "type": {
826
+ "type": "NameExpression",
827
+ "name": "Operation"
828
+ }
829
+ }
830
+ ]
831
+ },
832
+ "valid": false
833
+ }
834
+ ]
835
+ }