@openfn/language-common 1.15.0 → 1.15.1
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 +107 -97
- package/dist/index.js +4 -1
- package/package.json +1 -1
- package/types/Adaptor.d.ts +28 -24
- package/types/http.deprecated.d.ts +9 -9
package/ast.json
CHANGED
|
@@ -56,15 +56,15 @@
|
|
|
56
56
|
"description": null,
|
|
57
57
|
"type": null
|
|
58
58
|
},
|
|
59
|
-
{
|
|
60
|
-
"title": "example",
|
|
61
|
-
"description": "fn(state => {\n // do some things to state\n return state;\n});"
|
|
62
|
-
},
|
|
63
59
|
{
|
|
64
60
|
"title": "function",
|
|
65
61
|
"description": null,
|
|
66
62
|
"name": null
|
|
67
63
|
},
|
|
64
|
+
{
|
|
65
|
+
"title": "example",
|
|
66
|
+
"description": "fn(state => {\n // do some things to state\n return state;\n});"
|
|
67
|
+
},
|
|
68
68
|
{
|
|
69
69
|
"title": "param",
|
|
70
70
|
"description": "is the function",
|
|
@@ -100,15 +100,15 @@
|
|
|
100
100
|
"description": null,
|
|
101
101
|
"type": null
|
|
102
102
|
},
|
|
103
|
-
{
|
|
104
|
-
"title": "example",
|
|
105
|
-
"description": "fnIf((state) => state?.data?.name, get(\"https://example.com\"));"
|
|
106
|
-
},
|
|
107
103
|
{
|
|
108
104
|
"title": "function",
|
|
109
105
|
"description": null,
|
|
110
106
|
"name": null
|
|
111
107
|
},
|
|
108
|
+
{
|
|
109
|
+
"title": "example",
|
|
110
|
+
"description": "fnIf((state) => state?.data?.name, get(\"https://example.com\"));"
|
|
111
|
+
},
|
|
112
112
|
{
|
|
113
113
|
"title": "param",
|
|
114
114
|
"description": "The condition that returns true",
|
|
@@ -153,15 +153,15 @@
|
|
|
153
153
|
"description": null,
|
|
154
154
|
"type": null
|
|
155
155
|
},
|
|
156
|
-
{
|
|
157
|
-
"title": "example",
|
|
158
|
-
"description": "jsonValue({ a:1 }, 'a')"
|
|
159
|
-
},
|
|
160
156
|
{
|
|
161
157
|
"title": "function",
|
|
162
158
|
"description": null,
|
|
163
159
|
"name": null
|
|
164
160
|
},
|
|
161
|
+
{
|
|
162
|
+
"title": "example",
|
|
163
|
+
"description": "jsonValue({ a:1 }, 'a')"
|
|
164
|
+
},
|
|
165
165
|
{
|
|
166
166
|
"title": "param",
|
|
167
167
|
"description": "A valid JSON object.",
|
|
@@ -205,15 +205,15 @@
|
|
|
205
205
|
"description": null,
|
|
206
206
|
"type": null
|
|
207
207
|
},
|
|
208
|
-
{
|
|
209
|
-
"title": "example",
|
|
210
|
-
"description": "sourceValue('$.key')"
|
|
211
|
-
},
|
|
212
208
|
{
|
|
213
209
|
"title": "function",
|
|
214
210
|
"description": null,
|
|
215
211
|
"name": null
|
|
216
212
|
},
|
|
213
|
+
{
|
|
214
|
+
"title": "example",
|
|
215
|
+
"description": "sourceValue('$.key')"
|
|
216
|
+
},
|
|
217
217
|
{
|
|
218
218
|
"title": "param",
|
|
219
219
|
"description": "JSONPath referencing a point in `state`.",
|
|
@@ -248,15 +248,15 @@
|
|
|
248
248
|
"description": null,
|
|
249
249
|
"type": null
|
|
250
250
|
},
|
|
251
|
-
{
|
|
252
|
-
"title": "example",
|
|
253
|
-
"description": "source('$.key')"
|
|
254
|
-
},
|
|
255
251
|
{
|
|
256
252
|
"title": "function",
|
|
257
253
|
"description": null,
|
|
258
254
|
"name": null
|
|
259
255
|
},
|
|
256
|
+
{
|
|
257
|
+
"title": "example",
|
|
258
|
+
"description": "source('$.key')"
|
|
259
|
+
},
|
|
260
260
|
{
|
|
261
261
|
"title": "param",
|
|
262
262
|
"description": "JSONPath referencing a point in `state`.",
|
|
@@ -309,15 +309,15 @@
|
|
|
309
309
|
"description": null,
|
|
310
310
|
"type": null
|
|
311
311
|
},
|
|
312
|
-
{
|
|
313
|
-
"title": "example",
|
|
314
|
-
"description": "dataPath('key')"
|
|
315
|
-
},
|
|
316
312
|
{
|
|
317
313
|
"title": "function",
|
|
318
314
|
"description": null,
|
|
319
315
|
"name": null
|
|
320
316
|
},
|
|
317
|
+
{
|
|
318
|
+
"title": "example",
|
|
319
|
+
"description": "dataPath('key')"
|
|
320
|
+
},
|
|
321
321
|
{
|
|
322
322
|
"title": "param",
|
|
323
323
|
"description": "JSONPath referencing a point in `data`.",
|
|
@@ -352,15 +352,15 @@
|
|
|
352
352
|
"description": null,
|
|
353
353
|
"type": null
|
|
354
354
|
},
|
|
355
|
-
{
|
|
356
|
-
"title": "example",
|
|
357
|
-
"description": "dataValue('key')"
|
|
358
|
-
},
|
|
359
355
|
{
|
|
360
356
|
"title": "function",
|
|
361
357
|
"description": null,
|
|
362
358
|
"name": null
|
|
363
359
|
},
|
|
360
|
+
{
|
|
361
|
+
"title": "example",
|
|
362
|
+
"description": "dataValue('key')"
|
|
363
|
+
},
|
|
364
364
|
{
|
|
365
365
|
"title": "param",
|
|
366
366
|
"description": "JSONPath referencing a point in `data`.",
|
|
@@ -395,15 +395,15 @@
|
|
|
395
395
|
"description": null,
|
|
396
396
|
"type": null
|
|
397
397
|
},
|
|
398
|
-
{
|
|
399
|
-
"title": "example",
|
|
400
|
-
"description": "referencePath('key')"
|
|
401
|
-
},
|
|
402
398
|
{
|
|
403
399
|
"title": "function",
|
|
404
400
|
"description": null,
|
|
405
401
|
"name": null
|
|
406
402
|
},
|
|
403
|
+
{
|
|
404
|
+
"title": "example",
|
|
405
|
+
"description": "referencePath('key')"
|
|
406
|
+
},
|
|
407
407
|
{
|
|
408
408
|
"title": "param",
|
|
409
409
|
"description": "JSONPath referencing a point in `references`.",
|
|
@@ -438,15 +438,15 @@
|
|
|
438
438
|
"description": null,
|
|
439
439
|
"type": null
|
|
440
440
|
},
|
|
441
|
-
{
|
|
442
|
-
"title": "example",
|
|
443
|
-
"description": "lastReferenceValue('key')"
|
|
444
|
-
},
|
|
445
441
|
{
|
|
446
442
|
"title": "function",
|
|
447
443
|
"description": null,
|
|
448
444
|
"name": null
|
|
449
445
|
},
|
|
446
|
+
{
|
|
447
|
+
"title": "example",
|
|
448
|
+
"description": "lastReferenceValue('key')"
|
|
449
|
+
},
|
|
450
450
|
{
|
|
451
451
|
"title": "param",
|
|
452
452
|
"description": "JSONPath referencing a point in `references`.",
|
|
@@ -482,15 +482,15 @@
|
|
|
482
482
|
"description": null,
|
|
483
483
|
"type": null
|
|
484
484
|
},
|
|
485
|
-
{
|
|
486
|
-
"title": "example",
|
|
487
|
-
"description": "asData('$.key'| key | callback)"
|
|
488
|
-
},
|
|
489
485
|
{
|
|
490
486
|
"title": "function",
|
|
491
487
|
"description": null,
|
|
492
488
|
"name": null
|
|
493
489
|
},
|
|
490
|
+
{
|
|
491
|
+
"title": "example",
|
|
492
|
+
"description": "asData('$.key'| key | callback)"
|
|
493
|
+
},
|
|
494
494
|
{
|
|
495
495
|
"title": "param",
|
|
496
496
|
"description": null,
|
|
@@ -548,15 +548,15 @@
|
|
|
548
548
|
"description": null,
|
|
549
549
|
"type": null
|
|
550
550
|
},
|
|
551
|
-
{
|
|
552
|
-
"title": "example",
|
|
553
|
-
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
|
|
554
|
-
},
|
|
555
551
|
{
|
|
556
552
|
"title": "function",
|
|
557
553
|
"description": null,
|
|
558
554
|
"name": null
|
|
559
555
|
},
|
|
556
|
+
{
|
|
557
|
+
"title": "example",
|
|
558
|
+
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
|
|
559
|
+
},
|
|
560
560
|
{
|
|
561
561
|
"title": "param",
|
|
562
562
|
"description": "JSONPath referencing a point in `state`.",
|
|
@@ -600,15 +600,15 @@
|
|
|
600
600
|
"description": null,
|
|
601
601
|
"type": null
|
|
602
602
|
},
|
|
603
|
-
{
|
|
604
|
-
"title": "example",
|
|
605
|
-
"description": "combine(\n create('foo'),\n delete('bar')\n)"
|
|
606
|
-
},
|
|
607
603
|
{
|
|
608
604
|
"title": "function",
|
|
609
605
|
"description": null,
|
|
610
606
|
"name": null
|
|
611
607
|
},
|
|
608
|
+
{
|
|
609
|
+
"title": "example",
|
|
610
|
+
"description": "combine(\n create('foo'),\n delete('bar')\n)"
|
|
611
|
+
},
|
|
612
612
|
{
|
|
613
613
|
"title": "param",
|
|
614
614
|
"description": "Operations to be performed.",
|
|
@@ -645,15 +645,15 @@
|
|
|
645
645
|
"description": null,
|
|
646
646
|
"type": null
|
|
647
647
|
},
|
|
648
|
-
{
|
|
649
|
-
"title": "example",
|
|
650
|
-
"description": "join('$.key','$.data','newKey')"
|
|
651
|
-
},
|
|
652
648
|
{
|
|
653
649
|
"title": "function",
|
|
654
650
|
"description": null,
|
|
655
651
|
"name": null
|
|
656
652
|
},
|
|
653
|
+
{
|
|
654
|
+
"title": "example",
|
|
655
|
+
"description": "join('$.key','$.data','newKey')"
|
|
656
|
+
},
|
|
657
657
|
{
|
|
658
658
|
"title": "param",
|
|
659
659
|
"description": "Target path",
|
|
@@ -759,15 +759,15 @@
|
|
|
759
759
|
"description": null,
|
|
760
760
|
"type": null
|
|
761
761
|
},
|
|
762
|
-
{
|
|
763
|
-
"title": "example",
|
|
764
|
-
"description": "field('destination_field_name__c', 'value')"
|
|
765
|
-
},
|
|
766
762
|
{
|
|
767
763
|
"title": "function",
|
|
768
764
|
"description": null,
|
|
769
765
|
"name": null
|
|
770
766
|
},
|
|
767
|
+
{
|
|
768
|
+
"title": "example",
|
|
769
|
+
"description": "field('destination_field_name__c', 'value')"
|
|
770
|
+
},
|
|
771
771
|
{
|
|
772
772
|
"title": "param",
|
|
773
773
|
"description": "Name of the field",
|
|
@@ -811,15 +811,15 @@
|
|
|
811
811
|
"description": null,
|
|
812
812
|
"type": null
|
|
813
813
|
},
|
|
814
|
-
{
|
|
815
|
-
"title": "example",
|
|
816
|
-
"description": "fields(list_of_fields)"
|
|
817
|
-
},
|
|
818
814
|
{
|
|
819
815
|
"title": "function",
|
|
820
816
|
"description": null,
|
|
821
817
|
"name": null
|
|
822
818
|
},
|
|
819
|
+
{
|
|
820
|
+
"title": "example",
|
|
821
|
+
"description": "fields(list_of_fields)"
|
|
822
|
+
},
|
|
823
823
|
{
|
|
824
824
|
"title": "param",
|
|
825
825
|
"description": "a list of fields",
|
|
@@ -864,6 +864,11 @@
|
|
|
864
864
|
"description": null,
|
|
865
865
|
"name": null
|
|
866
866
|
},
|
|
867
|
+
{
|
|
868
|
+
"title": "public",
|
|
869
|
+
"description": null,
|
|
870
|
+
"type": null
|
|
871
|
+
},
|
|
867
872
|
{
|
|
868
873
|
"title": "param",
|
|
869
874
|
"description": null,
|
|
@@ -918,6 +923,11 @@
|
|
|
918
923
|
"description": null,
|
|
919
924
|
"name": null
|
|
920
925
|
},
|
|
926
|
+
{
|
|
927
|
+
"title": "public",
|
|
928
|
+
"description": null,
|
|
929
|
+
"type": null
|
|
930
|
+
},
|
|
921
931
|
{
|
|
922
932
|
"title": "param",
|
|
923
933
|
"description": "The array of objects to be grouped.",
|
|
@@ -977,15 +987,15 @@
|
|
|
977
987
|
"description": null,
|
|
978
988
|
"type": null
|
|
979
989
|
},
|
|
980
|
-
{
|
|
981
|
-
"title": "example",
|
|
982
|
-
"description": "index()"
|
|
983
|
-
},
|
|
984
990
|
{
|
|
985
991
|
"title": "function",
|
|
986
992
|
"description": null,
|
|
987
993
|
"name": null
|
|
988
994
|
},
|
|
995
|
+
{
|
|
996
|
+
"title": "example",
|
|
997
|
+
"description": "index()"
|
|
998
|
+
},
|
|
989
999
|
{
|
|
990
1000
|
"title": "returns",
|
|
991
1001
|
"description": null,
|
|
@@ -1012,15 +1022,15 @@
|
|
|
1012
1022
|
"description": null,
|
|
1013
1023
|
"type": null
|
|
1014
1024
|
},
|
|
1015
|
-
{
|
|
1016
|
-
"title": "example",
|
|
1017
|
-
"description": "field(\"destination_string__c\", function(state) {\n return arrayToString(dataValue(\"path_of_array\")(state), ', ')\n})"
|
|
1018
|
-
},
|
|
1019
1025
|
{
|
|
1020
1026
|
"title": "function",
|
|
1021
1027
|
"description": null,
|
|
1022
1028
|
"name": null
|
|
1023
1029
|
},
|
|
1030
|
+
{
|
|
1031
|
+
"title": "example",
|
|
1032
|
+
"description": "field(\"destination_string__c\", function(state) {\n return arrayToString(dataValue(\"path_of_array\")(state), ', ')\n})"
|
|
1033
|
+
},
|
|
1024
1034
|
{
|
|
1025
1035
|
"title": "param",
|
|
1026
1036
|
"description": "Array of toString'able primatives.",
|
|
@@ -1064,15 +1074,15 @@
|
|
|
1064
1074
|
"description": null,
|
|
1065
1075
|
"type": null
|
|
1066
1076
|
},
|
|
1067
|
-
{
|
|
1068
|
-
"title": "example",
|
|
1069
|
-
"description": "each(function(state) {\n return toArray( dataValue(\"path_of_array\")(state) )\n}, ...)"
|
|
1070
|
-
},
|
|
1071
1077
|
{
|
|
1072
1078
|
"title": "function",
|
|
1073
1079
|
"description": null,
|
|
1074
1080
|
"name": null
|
|
1075
1081
|
},
|
|
1082
|
+
{
|
|
1083
|
+
"title": "example",
|
|
1084
|
+
"description": "each(function(state) {\n return toArray( dataValue(\"path_of_array\")(state) )\n}, ...)"
|
|
1085
|
+
},
|
|
1076
1086
|
{
|
|
1077
1087
|
"title": "param",
|
|
1078
1088
|
"description": "Data required to be in an array",
|
|
@@ -1108,15 +1118,15 @@
|
|
|
1108
1118
|
"description": null,
|
|
1109
1119
|
"type": null
|
|
1110
1120
|
},
|
|
1111
|
-
{
|
|
1112
|
-
"title": "example",
|
|
1113
|
-
"description": "composeNextState(state, response)"
|
|
1114
|
-
},
|
|
1115
1121
|
{
|
|
1116
1122
|
"title": "function",
|
|
1117
1123
|
"description": null,
|
|
1118
1124
|
"name": null
|
|
1119
1125
|
},
|
|
1126
|
+
{
|
|
1127
|
+
"title": "example",
|
|
1128
|
+
"description": "composeNextState(state, response)"
|
|
1129
|
+
},
|
|
1120
1130
|
{
|
|
1121
1131
|
"title": "param",
|
|
1122
1132
|
"description": "state",
|
|
@@ -1160,15 +1170,15 @@
|
|
|
1160
1170
|
"description": null,
|
|
1161
1171
|
"type": null
|
|
1162
1172
|
},
|
|
1163
|
-
{
|
|
1164
|
-
"title": "example",
|
|
1165
|
-
"description": "field(\"destination_string__c\", humanProper(state.data.path_to_string))"
|
|
1166
|
-
},
|
|
1167
1173
|
{
|
|
1168
1174
|
"title": "function",
|
|
1169
1175
|
"description": null,
|
|
1170
1176
|
"name": null
|
|
1171
1177
|
},
|
|
1178
|
+
{
|
|
1179
|
+
"title": "example",
|
|
1180
|
+
"description": "field(\"destination_string__c\", humanProper(state.data.path_to_string))"
|
|
1181
|
+
},
|
|
1172
1182
|
{
|
|
1173
1183
|
"title": "param",
|
|
1174
1184
|
"description": "String that needs converting",
|
|
@@ -1271,15 +1281,15 @@
|
|
|
1271
1281
|
"description": null,
|
|
1272
1282
|
"type": null
|
|
1273
1283
|
},
|
|
1274
|
-
{
|
|
1275
|
-
"title": "example",
|
|
1276
|
-
"description": "scrubEmojis('Dove🕊️⭐ 29')"
|
|
1277
|
-
},
|
|
1278
1284
|
{
|
|
1279
1285
|
"title": "function",
|
|
1280
1286
|
"description": null,
|
|
1281
1287
|
"name": null
|
|
1282
1288
|
},
|
|
1289
|
+
{
|
|
1290
|
+
"title": "example",
|
|
1291
|
+
"description": "scrubEmojis('Dove🕊️⭐ 29')"
|
|
1292
|
+
},
|
|
1283
1293
|
{
|
|
1284
1294
|
"title": "param",
|
|
1285
1295
|
"description": "String that needs to be cleaned",
|
|
@@ -1324,15 +1334,15 @@
|
|
|
1324
1334
|
"description": null,
|
|
1325
1335
|
"type": null
|
|
1326
1336
|
},
|
|
1327
|
-
{
|
|
1328
|
-
"title": "example",
|
|
1329
|
-
"description": "chunk([1,2,3,4,5], 2)"
|
|
1330
|
-
},
|
|
1331
1337
|
{
|
|
1332
1338
|
"title": "function",
|
|
1333
1339
|
"description": null,
|
|
1334
1340
|
"name": null
|
|
1335
1341
|
},
|
|
1342
|
+
{
|
|
1343
|
+
"title": "example",
|
|
1344
|
+
"description": "chunk([1,2,3,4,5], 2)"
|
|
1345
|
+
},
|
|
1336
1346
|
{
|
|
1337
1347
|
"title": "param",
|
|
1338
1348
|
"description": "Array to be chunked",
|
|
@@ -1451,6 +1461,11 @@
|
|
|
1451
1461
|
"description": null,
|
|
1452
1462
|
"type": null
|
|
1453
1463
|
},
|
|
1464
|
+
{
|
|
1465
|
+
"title": "function",
|
|
1466
|
+
"description": null,
|
|
1467
|
+
"name": null
|
|
1468
|
+
},
|
|
1454
1469
|
{
|
|
1455
1470
|
"title": "example",
|
|
1456
1471
|
"description": "cursor($.cursor, { defaultValue: 'today' })",
|
|
@@ -1461,11 +1476,6 @@
|
|
|
1461
1476
|
"description": "cursor(22)",
|
|
1462
1477
|
"caption": "Use a pagination cursor"
|
|
1463
1478
|
},
|
|
1464
|
-
{
|
|
1465
|
-
"title": "function",
|
|
1466
|
-
"description": null,
|
|
1467
|
-
"name": null
|
|
1468
|
-
},
|
|
1469
1479
|
{
|
|
1470
1480
|
"title": "param",
|
|
1471
1481
|
"description": "the cursor value. Usually an ISO date, natural language date, or page number",
|
|
@@ -1538,15 +1548,15 @@
|
|
|
1538
1548
|
"description": null,
|
|
1539
1549
|
"type": null
|
|
1540
1550
|
},
|
|
1541
|
-
{
|
|
1542
|
-
"title": "example",
|
|
1543
|
-
"description": "map(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
|
|
1544
|
-
},
|
|
1545
1551
|
{
|
|
1546
1552
|
"title": "function",
|
|
1547
1553
|
"description": null,
|
|
1548
1554
|
"name": null
|
|
1549
1555
|
},
|
|
1556
|
+
{
|
|
1557
|
+
"title": "example",
|
|
1558
|
+
"description": "map(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
|
|
1559
|
+
},
|
|
1550
1560
|
{
|
|
1551
1561
|
"title": "param",
|
|
1552
1562
|
"description": "JSONPath referencing a point in `state.data`.",
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
package/types/Adaptor.d.ts
CHANGED
|
@@ -22,12 +22,12 @@ export function alterState(func: Function): Operation;
|
|
|
22
22
|
/**
|
|
23
23
|
* Creates a custom step (or operation) for more flexible job writing.
|
|
24
24
|
* @public
|
|
25
|
+
* @function
|
|
25
26
|
* @example
|
|
26
27
|
* fn(state => {
|
|
27
28
|
* // do some things to state
|
|
28
29
|
* return state;
|
|
29
30
|
* });
|
|
30
|
-
* @function
|
|
31
31
|
* @param {Function} func is the function
|
|
32
32
|
* @returns {Operation}
|
|
33
33
|
*/
|
|
@@ -35,9 +35,9 @@ export function fn(func: Function): Operation;
|
|
|
35
35
|
/**
|
|
36
36
|
* A custom operation that will only execute the function if the condition returns true
|
|
37
37
|
* @public
|
|
38
|
+
* @function
|
|
38
39
|
* @example
|
|
39
40
|
* fnIf((state) => state?.data?.name, get("https://example.com"));
|
|
40
|
-
* @function
|
|
41
41
|
* @param {Boolean} condition - The condition that returns true
|
|
42
42
|
* @param {Operation} operation - The operation needed to be executed.
|
|
43
43
|
* @returns {Operation}
|
|
@@ -48,9 +48,9 @@ export function fnIf(condition: boolean, operation: Operation): Operation;
|
|
|
48
48
|
* If a JSONPath returns more than one value for the reference, the first
|
|
49
49
|
* item will be returned.
|
|
50
50
|
* @public
|
|
51
|
+
* @function
|
|
51
52
|
* @example
|
|
52
53
|
* jsonValue({ a:1 }, 'a')
|
|
53
|
-
* @function
|
|
54
54
|
* @param {object} obj - A valid JSON object.
|
|
55
55
|
* @param {String} path - JSONPath referencing a point in given JSON object.
|
|
56
56
|
* @returns {Operation}
|
|
@@ -61,9 +61,9 @@ export function jsonValue(obj: object, path: string): Operation;
|
|
|
61
61
|
* If a JSONPath returns more than one value for the reference, the first
|
|
62
62
|
* item will be returned.
|
|
63
63
|
* @public
|
|
64
|
+
* @function
|
|
64
65
|
* @example
|
|
65
66
|
* sourceValue('$.key')
|
|
66
|
-
* @function
|
|
67
67
|
* @param {String} path - JSONPath referencing a point in `state`.
|
|
68
68
|
* @returns {Operation}
|
|
69
69
|
*/
|
|
@@ -73,9 +73,9 @@ export function sourceValue(path: string): Operation;
|
|
|
73
73
|
* Will return whatever JSONPath returns, which will always be an array.
|
|
74
74
|
* If you need a single value use `sourceValue` instead.
|
|
75
75
|
* @public
|
|
76
|
+
* @function
|
|
76
77
|
* @example
|
|
77
78
|
* source('$.key')
|
|
78
|
-
* @function
|
|
79
79
|
* @param {String} path - JSONPath referencing a point in `state`.
|
|
80
80
|
* @returns {Array.<String|Object>}
|
|
81
81
|
*/
|
|
@@ -83,9 +83,9 @@ export function source(path: string): Array<string | any>;
|
|
|
83
83
|
/**
|
|
84
84
|
* Ensures a path points at the data.
|
|
85
85
|
* @public
|
|
86
|
+
* @function
|
|
86
87
|
* @example
|
|
87
88
|
* dataPath('key')
|
|
88
|
-
* @function
|
|
89
89
|
* @param {string} path - JSONPath referencing a point in `data`.
|
|
90
90
|
* @returns {string}
|
|
91
91
|
*/
|
|
@@ -95,9 +95,9 @@ export function dataPath(path: string): string;
|
|
|
95
95
|
* If a JSONPath returns more than one value for the reference, the first
|
|
96
96
|
* item will be returned.
|
|
97
97
|
* @public
|
|
98
|
+
* @function
|
|
98
99
|
* @example
|
|
99
100
|
* dataValue('key')
|
|
100
|
-
* @function
|
|
101
101
|
* @param {String} path - JSONPath referencing a point in `data`.
|
|
102
102
|
* @returns {Operation}
|
|
103
103
|
*/
|
|
@@ -105,9 +105,9 @@ export function dataValue(path: string): Operation;
|
|
|
105
105
|
/**
|
|
106
106
|
* Ensures a path points at references.
|
|
107
107
|
* @public
|
|
108
|
+
* @function
|
|
108
109
|
* @example
|
|
109
110
|
* referencePath('key')
|
|
110
|
-
* @function
|
|
111
111
|
* @param {string} path - JSONPath referencing a point in `references`.
|
|
112
112
|
* @returns {string}
|
|
113
113
|
*/
|
|
@@ -115,9 +115,9 @@ export function referencePath(path: string): string;
|
|
|
115
115
|
/**
|
|
116
116
|
* Picks out the last reference value from source data.
|
|
117
117
|
* @public
|
|
118
|
+
* @function
|
|
118
119
|
* @example
|
|
119
120
|
* lastReferenceValue('key')
|
|
120
|
-
* @function
|
|
121
121
|
* @param {String} path - JSONPath referencing a point in `references`.
|
|
122
122
|
* @returns {Operation}
|
|
123
123
|
*/
|
|
@@ -129,9 +129,9 @@ export function lastReferenceValue(path: string): Operation;
|
|
|
129
129
|
* - Object Literal of the data itself.
|
|
130
130
|
* - Function to be called with state.
|
|
131
131
|
* @public
|
|
132
|
+
* @function
|
|
132
133
|
* @example
|
|
133
134
|
* asData('$.key'| key | callback)
|
|
134
|
-
* @function
|
|
135
135
|
* @param {String|object|function} data
|
|
136
136
|
* @param {object} state - The current state.
|
|
137
137
|
* @returns {array}
|
|
@@ -147,13 +147,13 @@ export function asData(data: string | object | Function, state: object): any[];
|
|
|
147
147
|
* It also ensures the results of an operation make their way back into
|
|
148
148
|
* the state's references.
|
|
149
149
|
* @public
|
|
150
|
+
* @function
|
|
150
151
|
* @example
|
|
151
152
|
* each("$.[*]",
|
|
152
153
|
* create("SObject",
|
|
153
154
|
* field("FirstName", sourceValue("$.firstName"))
|
|
154
155
|
* )
|
|
155
156
|
* )
|
|
156
|
-
* @function
|
|
157
157
|
* @param {DataSource} dataSource - JSONPath referencing a point in `state`.
|
|
158
158
|
* @param {Operation} operation - The operation needed to be repeated.
|
|
159
159
|
* @returns {Operation}
|
|
@@ -162,12 +162,12 @@ export function each(dataSource: DataSource, operation: Operation): Operation;
|
|
|
162
162
|
/**
|
|
163
163
|
* Combines two operations into one
|
|
164
164
|
* @public
|
|
165
|
+
* @function
|
|
165
166
|
* @example
|
|
166
167
|
* combine(
|
|
167
168
|
* create('foo'),
|
|
168
169
|
* delete('bar')
|
|
169
170
|
* )
|
|
170
|
-
* @function
|
|
171
171
|
* @param {Operations} operations - Operations to be performed.
|
|
172
172
|
* @returns {Operation}
|
|
173
173
|
*/
|
|
@@ -175,9 +175,9 @@ export function combine(...operations: Operations): Operation;
|
|
|
175
175
|
/**
|
|
176
176
|
* Adds data from a target object
|
|
177
177
|
* @public
|
|
178
|
+
* @function
|
|
178
179
|
* @example
|
|
179
180
|
* join('$.key','$.data','newKey')
|
|
180
|
-
* @function
|
|
181
181
|
* @param {String} targetPath - Target path
|
|
182
182
|
* @param {String} sourcePath - Source path
|
|
183
183
|
* @param {String} targetKey - Target Key
|
|
@@ -196,9 +196,9 @@ export function expandReferences(value: object, skipFilter?: Function): Operatio
|
|
|
196
196
|
/**
|
|
197
197
|
* Returns a key, value pair in an array.
|
|
198
198
|
* @public
|
|
199
|
+
* @function
|
|
199
200
|
* @example
|
|
200
201
|
* field('destination_field_name__c', 'value')
|
|
201
|
-
* @function
|
|
202
202
|
* @param {string} key - Name of the field
|
|
203
203
|
* @param {Value} value - The value itself or a sourceable operation.
|
|
204
204
|
* @returns {Field}
|
|
@@ -207,9 +207,9 @@ export function field(key: string, value: Value): Field;
|
|
|
207
207
|
/**
|
|
208
208
|
* Zips key value pairs into an object.
|
|
209
209
|
* @public
|
|
210
|
+
* @function
|
|
210
211
|
* @example
|
|
211
212
|
* fields(list_of_fields)
|
|
212
|
-
* @function
|
|
213
213
|
* @param {Fields} fields - a list of fields
|
|
214
214
|
* @returns {Object}
|
|
215
215
|
*/
|
|
@@ -225,6 +225,7 @@ export function fields(...fields: Fields): any;
|
|
|
225
225
|
* )
|
|
226
226
|
* )
|
|
227
227
|
* @function
|
|
228
|
+
* @public
|
|
228
229
|
* @param {DataSource} dataSource
|
|
229
230
|
* @param {Object} fields - Group of fields to merge in.
|
|
230
231
|
* @returns {DataSource}
|
|
@@ -243,6 +244,7 @@ export function merge(dataSource: DataSource, fields: any): DataSource;
|
|
|
243
244
|
* group(users, 'city');
|
|
244
245
|
* // state is { data: { 'New York': [/Alice, Charlie/], 'San Francisco': [ /Bob, David / ] }
|
|
245
246
|
* @function
|
|
247
|
+
* @public
|
|
246
248
|
* @param {Object[]} arrayOfObjects - The array of objects to be grouped.
|
|
247
249
|
* @param {string} keyPath - The key path to group by.
|
|
248
250
|
* @param {function} callback - (Optional) Callback function
|
|
@@ -253,20 +255,20 @@ export function group(arrayOfObjects: any[], keyPath: string, callback?: Functio
|
|
|
253
255
|
* Returns the index of the current array being iterated.
|
|
254
256
|
* To be used with `each` as a data source.
|
|
255
257
|
* @public
|
|
258
|
+
* @function
|
|
256
259
|
* @example
|
|
257
260
|
* index()
|
|
258
|
-
* @function
|
|
259
261
|
* @returns {DataSource}
|
|
260
262
|
*/
|
|
261
263
|
export function index(): DataSource;
|
|
262
264
|
/**
|
|
263
265
|
* Turns an array into a string, separated by X.
|
|
264
266
|
* @public
|
|
267
|
+
* @function
|
|
265
268
|
* @example
|
|
266
269
|
* field("destination_string__c", function(state) {
|
|
267
270
|
* return arrayToString(dataValue("path_of_array")(state), ', ')
|
|
268
271
|
* })
|
|
269
|
-
* @function
|
|
270
272
|
* @param {array} arr - Array of toString'able primatives.
|
|
271
273
|
* @param {string} separator - Separator string.
|
|
272
274
|
* @returns {string}
|
|
@@ -276,11 +278,11 @@ export function arrayToString(arr: any[], separator: string): string;
|
|
|
276
278
|
* Ensures primitive data types are wrapped in an array.
|
|
277
279
|
* Does not affect array objects.
|
|
278
280
|
* @public
|
|
281
|
+
* @function
|
|
279
282
|
* @example
|
|
280
283
|
* each(function(state) {
|
|
281
284
|
* return toArray( dataValue("path_of_array")(state) )
|
|
282
285
|
* }, ...)
|
|
283
|
-
* @function
|
|
284
286
|
* @param {any} arg - Data required to be in an array
|
|
285
287
|
* @returns {array}
|
|
286
288
|
*/
|
|
@@ -288,9 +290,9 @@ export function toArray(arg: any): any[];
|
|
|
288
290
|
/**
|
|
289
291
|
* Prepares next state
|
|
290
292
|
* @public
|
|
293
|
+
* @function
|
|
291
294
|
* @example
|
|
292
295
|
* composeNextState(state, response)
|
|
293
|
-
* @function
|
|
294
296
|
* @param {State} state - state
|
|
295
297
|
* @param {Object} response - Response to be added
|
|
296
298
|
* @returns {State}
|
|
@@ -299,9 +301,9 @@ export function composeNextState(state: State, response: any): State;
|
|
|
299
301
|
/**
|
|
300
302
|
* Substitutes underscores for spaces and proper-cases a string
|
|
301
303
|
* @public
|
|
304
|
+
* @function
|
|
302
305
|
* @example
|
|
303
306
|
* field("destination_string__c", humanProper(state.data.path_to_string))
|
|
304
|
-
* @function
|
|
305
307
|
* @param {string} str - String that needs converting
|
|
306
308
|
* @returns {string}
|
|
307
309
|
*/
|
|
@@ -320,9 +322,9 @@ export function splitKeys(obj: any, keys: string[]): any[];
|
|
|
320
322
|
/**
|
|
321
323
|
* Replaces emojis in a string.
|
|
322
324
|
* @public
|
|
325
|
+
* @function
|
|
323
326
|
* @example
|
|
324
327
|
* scrubEmojis('Dove🕊️⭐ 29')
|
|
325
|
-
* @function
|
|
326
328
|
* @param {string} text - String that needs to be cleaned
|
|
327
329
|
* @param {string} replacementChars - Characters that replace the emojis
|
|
328
330
|
* @returns {string}
|
|
@@ -331,9 +333,9 @@ export function scrubEmojis(text: string, replacementChars: string): string;
|
|
|
331
333
|
/**
|
|
332
334
|
* Chunks an array into an array of arrays, each with no more than a certain size.
|
|
333
335
|
* @public
|
|
336
|
+
* @function
|
|
334
337
|
* @example
|
|
335
338
|
* chunk([1,2,3,4,5], 2)
|
|
336
|
-
* @function
|
|
337
339
|
* @param {Object} array - Array to be chunked
|
|
338
340
|
* @param {Integer} chunkSize - The maxiumum size of each chunks
|
|
339
341
|
* @returns {Object}
|
|
@@ -366,6 +368,8 @@ export function parseCsv(csvData: string | Stream, parsingOptions?: any, callbac
|
|
|
366
368
|
* Schema can be passed directly, loaded as a JSON path from state, or loaded from a URL
|
|
367
369
|
* Data can be passed directly or loaded as a JSON path from state.
|
|
368
370
|
* By default, schema is loaded from `state.schema` and data from `state.data`.
|
|
371
|
+
* @pubic
|
|
372
|
+
* @function
|
|
369
373
|
* @param {string|object} schema - The schema, path or URL to validate against
|
|
370
374
|
* @param {string|object} data - The data or path to validate
|
|
371
375
|
* @example <caption>Validate `state.data` with `state.schema`</caption>
|
|
@@ -386,11 +390,11 @@ export function validate(schema?: string | object, data?: string | object): Oper
|
|
|
386
390
|
* different inputs. The custom formatter runs after natural language date conversion.
|
|
387
391
|
* See the usage guide at {@link https://docs.openfn.org/documentation/jobs/job-writing-guide#using-cursors}
|
|
388
392
|
* @public
|
|
393
|
+
* @function
|
|
389
394
|
* @example <caption>Use a cursor from state if present, or else use the default value</caption>
|
|
390
395
|
* cursor($.cursor, { defaultValue: 'today' })
|
|
391
396
|
* @example <caption>Use a pagination cursor</caption>
|
|
392
397
|
* cursor(22)
|
|
393
|
-
* @function
|
|
394
398
|
* @param {any} value - the cursor value. Usually an ISO date, natural language date, or page number
|
|
395
399
|
* @param {object} options - options to control the cursor.
|
|
396
400
|
* @param {string} options.key - set the cursor key. Will persist through the whole run.
|
|
@@ -413,13 +417,13 @@ export * as dateFns from "./dateFns";
|
|
|
413
417
|
* The operation will receive a slice of the data based of each item
|
|
414
418
|
* of the JSONPath provided.
|
|
415
419
|
* @public
|
|
420
|
+
* @function
|
|
416
421
|
* @example
|
|
417
422
|
* map("$.[*]",
|
|
418
423
|
* create("SObject",
|
|
419
424
|
* field("FirstName", sourceValue("$.firstName"))
|
|
420
425
|
* )
|
|
421
426
|
* )
|
|
422
|
-
* @function
|
|
423
427
|
* @param {string} path - JSONPath referencing a point in `state.data`.
|
|
424
428
|
* @param {function} operation - The operation needed to be repeated.
|
|
425
429
|
* @param {State} state - Runtime state.
|
|
@@ -14,7 +14,7 @@ export function expandRequestReferences(params: any): Operation;
|
|
|
14
14
|
* @param {object} requestParams - Supports the exact parameters as Axios. See {@link https://github.com/axios/axios#axios-api here}
|
|
15
15
|
* @returns {Operation} - Function which takes state and returns a Promise
|
|
16
16
|
* @example <caption>Get an item with a specified id from state</caption>
|
|
17
|
-
* get({
|
|
17
|
+
* http.get({
|
|
18
18
|
* url: state => `https://www.example.com/api/items/${state.id},
|
|
19
19
|
* headers: {"content-type": "application/json"}
|
|
20
20
|
* });
|
|
@@ -26,13 +26,13 @@ export function get(requestParams: object): Operation;
|
|
|
26
26
|
* @function
|
|
27
27
|
* @param {object} requestParams - Supports the exact parameters as Axios. See {@link https://github.com/axios/axios#axios-api here}
|
|
28
28
|
* @example <caption>Sending a payload with data that comes from state</caption>
|
|
29
|
-
* post({
|
|
29
|
+
* http.post({
|
|
30
30
|
* url: "https://example.com",
|
|
31
31
|
* data: (state) => state.data
|
|
32
32
|
* });
|
|
33
33
|
* @example <caption> Capturing the response for later use in state </caption>
|
|
34
|
-
*
|
|
35
|
-
* return post({
|
|
34
|
+
* fn((state) => {
|
|
35
|
+
* return http.post({
|
|
36
36
|
* url: "https://example.com",
|
|
37
37
|
* data: (state) => state.data
|
|
38
38
|
* })(state).then(({response}) => {
|
|
@@ -48,7 +48,7 @@ export function post(requestParams: object): Operation;
|
|
|
48
48
|
* @function
|
|
49
49
|
* @param {object} requestParams - Supports the exact parameters as Axios. See {@link https://github.com/axios/axios#axios-api here}
|
|
50
50
|
* @example <caption>Gets the headers that would be returned if the HEAD request's URL was instead requested with the HTTP GET method</caption>
|
|
51
|
-
* head({
|
|
51
|
+
* http.head({
|
|
52
52
|
* url: 'https://www.example.com/api/items',
|
|
53
53
|
* });
|
|
54
54
|
* @returns {Operation} - Function which takes state and returns a Promise
|
|
@@ -60,7 +60,7 @@ export function head(requestParams: object): Operation;
|
|
|
60
60
|
* @function
|
|
61
61
|
* @param {object} requestParams - Supports the exact parameters as Axios. See {@link https://github.com/axios/axios#axios-api here}
|
|
62
62
|
* @example <caption>Creates a new resource or replaces a representation of the target resource with the request payload, with data from state.</caption>
|
|
63
|
-
* put({
|
|
63
|
+
* http.put({
|
|
64
64
|
* url: state => `https://www.example.com/api/items/${state.id}`,
|
|
65
65
|
* data: state => state.data
|
|
66
66
|
* });
|
|
@@ -73,7 +73,7 @@ export function put(requestParams: object): Operation;
|
|
|
73
73
|
* @function
|
|
74
74
|
* @param {object} requestParams - Supports the exact parameters as Axios. See {@link https://github.com/axios/axios#axios-api here}
|
|
75
75
|
* @example <caption>Applies partial modifications to a resource, with data from state.</caption>
|
|
76
|
-
* patch({
|
|
76
|
+
* http.patch({
|
|
77
77
|
* url: state => `https://www.example.com/api/items/${state.id}`,
|
|
78
78
|
* data: state => state.data
|
|
79
79
|
* });
|
|
@@ -86,7 +86,7 @@ export function patch(requestParams: object): Operation;
|
|
|
86
86
|
* @function
|
|
87
87
|
* @param {object} requestParams - Supports the exact parameters as Axios. See {@link https://github.com/axios/axios#axios-api here}
|
|
88
88
|
* @example <caption>Requests permitted communication options for a given URL or server, with data from state.</caption>
|
|
89
|
-
* options({
|
|
89
|
+
* http.options({
|
|
90
90
|
* url: 'https://www.example.com/api/items',
|
|
91
91
|
* });
|
|
92
92
|
* @returns {Operation} - Function which takes state and returns a Promise
|
|
@@ -99,7 +99,7 @@ import axios from "axios";
|
|
|
99
99
|
* @function
|
|
100
100
|
* @param {object} requestParams - Supports the exact parameters as Axios. See {@link https://github.com/axios/axios#axios-api here}
|
|
101
101
|
* @example <caption>Deleting a record with data that comes from state</caption>
|
|
102
|
-
* delete({
|
|
102
|
+
* http.delete({
|
|
103
103
|
* url: state => `https://www.example.com/api/items/${state.id}`,
|
|
104
104
|
* })(state);
|
|
105
105
|
* @returns {Operation} - Function which takes state and returns a Promise
|