@openfn/language-mogli 0.4.1 → 0.5.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 +161 -60
- package/dist/index.cjs +6 -0
- package/dist/index.js +7 -1
- package/package.json +2 -3
- package/types/Adaptor.d.ts +1 -1
- package/types/sourceHelpers.d.ts +2 -0
package/ast.json
CHANGED
|
@@ -3,27 +3,123 @@
|
|
|
3
3
|
"exports": [],
|
|
4
4
|
"common": [
|
|
5
5
|
{
|
|
6
|
-
"name": "
|
|
6
|
+
"name": "fn",
|
|
7
7
|
"params": [
|
|
8
|
-
"
|
|
8
|
+
"func"
|
|
9
9
|
],
|
|
10
10
|
"docs": {
|
|
11
|
-
"description": "
|
|
11
|
+
"description": "Creates a custom step (or operation) for more flexible job writing.",
|
|
12
12
|
"tags": [
|
|
13
13
|
{
|
|
14
14
|
"title": "public",
|
|
15
15
|
"description": null,
|
|
16
16
|
"type": null
|
|
17
17
|
},
|
|
18
|
+
{
|
|
19
|
+
"title": "function",
|
|
20
|
+
"description": null,
|
|
21
|
+
"name": null
|
|
22
|
+
},
|
|
18
23
|
{
|
|
19
24
|
"title": "example",
|
|
20
|
-
"description": "
|
|
25
|
+
"description": "fn(state => {\n // do some things to state\n return state;\n});"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"title": "param",
|
|
29
|
+
"description": "is the function",
|
|
30
|
+
"type": {
|
|
31
|
+
"type": "NameExpression",
|
|
32
|
+
"name": "Function"
|
|
33
|
+
},
|
|
34
|
+
"name": "func"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"title": "returns",
|
|
38
|
+
"description": null,
|
|
39
|
+
"type": {
|
|
40
|
+
"type": "NameExpression",
|
|
41
|
+
"name": "Operation"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"valid": true
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "fnIf",
|
|
50
|
+
"params": [
|
|
51
|
+
"condition",
|
|
52
|
+
"operation"
|
|
53
|
+
],
|
|
54
|
+
"docs": {
|
|
55
|
+
"description": "A custom operation that will only execute the function if the condition returns true",
|
|
56
|
+
"tags": [
|
|
57
|
+
{
|
|
58
|
+
"title": "public",
|
|
59
|
+
"description": null,
|
|
60
|
+
"type": null
|
|
21
61
|
},
|
|
22
62
|
{
|
|
23
63
|
"title": "function",
|
|
24
64
|
"description": null,
|
|
25
65
|
"name": null
|
|
26
66
|
},
|
|
67
|
+
{
|
|
68
|
+
"title": "example",
|
|
69
|
+
"description": "fnIf((state) => state?.data?.name, get(\"https://example.com\"));"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"title": "param",
|
|
73
|
+
"description": "The condition that returns true",
|
|
74
|
+
"type": {
|
|
75
|
+
"type": "NameExpression",
|
|
76
|
+
"name": "Boolean"
|
|
77
|
+
},
|
|
78
|
+
"name": "condition"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"title": "param",
|
|
82
|
+
"description": "The operation needed to be executed.",
|
|
83
|
+
"type": {
|
|
84
|
+
"type": "NameExpression",
|
|
85
|
+
"name": "Operation"
|
|
86
|
+
},
|
|
87
|
+
"name": "operation"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"title": "returns",
|
|
91
|
+
"description": null,
|
|
92
|
+
"type": {
|
|
93
|
+
"type": "NameExpression",
|
|
94
|
+
"name": "Operation"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
"valid": true
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"name": "sourceValue",
|
|
103
|
+
"params": [
|
|
104
|
+
"path"
|
|
105
|
+
],
|
|
106
|
+
"docs": {
|
|
107
|
+
"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.",
|
|
108
|
+
"tags": [
|
|
109
|
+
{
|
|
110
|
+
"title": "public",
|
|
111
|
+
"description": null,
|
|
112
|
+
"type": null
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"title": "function",
|
|
116
|
+
"description": null,
|
|
117
|
+
"name": null
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"title": "example",
|
|
121
|
+
"description": "sourceValue('$.key')"
|
|
122
|
+
},
|
|
27
123
|
{
|
|
28
124
|
"title": "param",
|
|
29
125
|
"description": "JSONPath referencing a point in `state`.",
|
|
@@ -58,15 +154,15 @@
|
|
|
58
154
|
"description": null,
|
|
59
155
|
"type": null
|
|
60
156
|
},
|
|
61
|
-
{
|
|
62
|
-
"title": "example",
|
|
63
|
-
"description": "source('$.key')"
|
|
64
|
-
},
|
|
65
157
|
{
|
|
66
158
|
"title": "function",
|
|
67
159
|
"description": null,
|
|
68
160
|
"name": null
|
|
69
161
|
},
|
|
162
|
+
{
|
|
163
|
+
"title": "example",
|
|
164
|
+
"description": "source('$.key')"
|
|
165
|
+
},
|
|
70
166
|
{
|
|
71
167
|
"title": "param",
|
|
72
168
|
"description": "JSONPath referencing a point in `state`.",
|
|
@@ -119,15 +215,15 @@
|
|
|
119
215
|
"description": null,
|
|
120
216
|
"type": null
|
|
121
217
|
},
|
|
122
|
-
{
|
|
123
|
-
"title": "example",
|
|
124
|
-
"description": "dataPath('key')"
|
|
125
|
-
},
|
|
126
218
|
{
|
|
127
219
|
"title": "function",
|
|
128
220
|
"description": null,
|
|
129
221
|
"name": null
|
|
130
222
|
},
|
|
223
|
+
{
|
|
224
|
+
"title": "example",
|
|
225
|
+
"description": "dataPath('key')"
|
|
226
|
+
},
|
|
131
227
|
{
|
|
132
228
|
"title": "param",
|
|
133
229
|
"description": "JSONPath referencing a point in `data`.",
|
|
@@ -162,15 +258,15 @@
|
|
|
162
258
|
"description": null,
|
|
163
259
|
"type": null
|
|
164
260
|
},
|
|
165
|
-
{
|
|
166
|
-
"title": "example",
|
|
167
|
-
"description": "dataValue('key')"
|
|
168
|
-
},
|
|
169
261
|
{
|
|
170
262
|
"title": "function",
|
|
171
263
|
"description": null,
|
|
172
264
|
"name": null
|
|
173
265
|
},
|
|
266
|
+
{
|
|
267
|
+
"title": "example",
|
|
268
|
+
"description": "dataValue('key')"
|
|
269
|
+
},
|
|
174
270
|
{
|
|
175
271
|
"title": "param",
|
|
176
272
|
"description": "JSONPath referencing a point in `data`.",
|
|
@@ -205,15 +301,15 @@
|
|
|
205
301
|
"description": null,
|
|
206
302
|
"type": null
|
|
207
303
|
},
|
|
208
|
-
{
|
|
209
|
-
"title": "example",
|
|
210
|
-
"description": "referencePath('key')"
|
|
211
|
-
},
|
|
212
304
|
{
|
|
213
305
|
"title": "function",
|
|
214
306
|
"description": null,
|
|
215
307
|
"name": null
|
|
216
308
|
},
|
|
309
|
+
{
|
|
310
|
+
"title": "example",
|
|
311
|
+
"description": "referencePath('key')"
|
|
312
|
+
},
|
|
217
313
|
{
|
|
218
314
|
"title": "param",
|
|
219
315
|
"description": "JSONPath referencing a point in `references`.",
|
|
@@ -248,15 +344,15 @@
|
|
|
248
344
|
"description": null,
|
|
249
345
|
"type": null
|
|
250
346
|
},
|
|
251
|
-
{
|
|
252
|
-
"title": "example",
|
|
253
|
-
"description": "lastReferenceValue('key')"
|
|
254
|
-
},
|
|
255
347
|
{
|
|
256
348
|
"title": "function",
|
|
257
349
|
"description": null,
|
|
258
350
|
"name": null
|
|
259
351
|
},
|
|
352
|
+
{
|
|
353
|
+
"title": "example",
|
|
354
|
+
"description": "lastReferenceValue('key')"
|
|
355
|
+
},
|
|
260
356
|
{
|
|
261
357
|
"title": "param",
|
|
262
358
|
"description": "JSONPath referencing a point in `references`.",
|
|
@@ -292,15 +388,15 @@
|
|
|
292
388
|
"description": null,
|
|
293
389
|
"type": null
|
|
294
390
|
},
|
|
295
|
-
{
|
|
296
|
-
"title": "example",
|
|
297
|
-
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
|
|
298
|
-
},
|
|
299
391
|
{
|
|
300
392
|
"title": "function",
|
|
301
393
|
"description": null,
|
|
302
394
|
"name": null
|
|
303
395
|
},
|
|
396
|
+
{
|
|
397
|
+
"title": "example",
|
|
398
|
+
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
|
|
399
|
+
},
|
|
304
400
|
{
|
|
305
401
|
"title": "param",
|
|
306
402
|
"description": "JSONPath referencing a point in `state`.",
|
|
@@ -344,15 +440,15 @@
|
|
|
344
440
|
"description": null,
|
|
345
441
|
"type": null
|
|
346
442
|
},
|
|
347
|
-
{
|
|
348
|
-
"title": "example",
|
|
349
|
-
"description": "combine(\n create('foo'),\n delete('bar')\n)"
|
|
350
|
-
},
|
|
351
443
|
{
|
|
352
444
|
"title": "function",
|
|
353
445
|
"description": null,
|
|
354
446
|
"name": null
|
|
355
447
|
},
|
|
448
|
+
{
|
|
449
|
+
"title": "example",
|
|
450
|
+
"description": "combine(\n create('foo'),\n delete('bar')\n)"
|
|
451
|
+
},
|
|
356
452
|
{
|
|
357
453
|
"title": "param",
|
|
358
454
|
"description": "Operations to be performed.",
|
|
@@ -389,15 +485,15 @@
|
|
|
389
485
|
"description": null,
|
|
390
486
|
"type": null
|
|
391
487
|
},
|
|
392
|
-
{
|
|
393
|
-
"title": "example",
|
|
394
|
-
"description": "join('$.key','$.data','newKey')"
|
|
395
|
-
},
|
|
396
488
|
{
|
|
397
489
|
"title": "function",
|
|
398
490
|
"description": null,
|
|
399
491
|
"name": null
|
|
400
492
|
},
|
|
493
|
+
{
|
|
494
|
+
"title": "example",
|
|
495
|
+
"description": "join('$.key','$.data','newKey')"
|
|
496
|
+
},
|
|
401
497
|
{
|
|
402
498
|
"title": "param",
|
|
403
499
|
"description": "Target path",
|
|
@@ -451,15 +547,15 @@
|
|
|
451
547
|
"description": null,
|
|
452
548
|
"type": null
|
|
453
549
|
},
|
|
454
|
-
{
|
|
455
|
-
"title": "example",
|
|
456
|
-
"description": "field('destination_field_name__c', 'value')"
|
|
457
|
-
},
|
|
458
550
|
{
|
|
459
551
|
"title": "function",
|
|
460
552
|
"description": null,
|
|
461
553
|
"name": null
|
|
462
554
|
},
|
|
555
|
+
{
|
|
556
|
+
"title": "example",
|
|
557
|
+
"description": "field('destination_field_name__c', 'value')"
|
|
558
|
+
},
|
|
463
559
|
{
|
|
464
560
|
"title": "param",
|
|
465
561
|
"description": "Name of the field",
|
|
@@ -503,15 +599,15 @@
|
|
|
503
599
|
"description": null,
|
|
504
600
|
"type": null
|
|
505
601
|
},
|
|
506
|
-
{
|
|
507
|
-
"title": "example",
|
|
508
|
-
"description": "fields(list_of_fields)"
|
|
509
|
-
},
|
|
510
602
|
{
|
|
511
603
|
"title": "function",
|
|
512
604
|
"description": null,
|
|
513
605
|
"name": null
|
|
514
606
|
},
|
|
607
|
+
{
|
|
608
|
+
"title": "example",
|
|
609
|
+
"description": "fields(list_of_fields)"
|
|
610
|
+
},
|
|
515
611
|
{
|
|
516
612
|
"title": "param",
|
|
517
613
|
"description": "a list of fields",
|
|
@@ -556,6 +652,11 @@
|
|
|
556
652
|
"description": null,
|
|
557
653
|
"name": null
|
|
558
654
|
},
|
|
655
|
+
{
|
|
656
|
+
"title": "public",
|
|
657
|
+
"description": null,
|
|
658
|
+
"type": null
|
|
659
|
+
},
|
|
559
660
|
{
|
|
560
661
|
"title": "param",
|
|
561
662
|
"description": null,
|
|
@@ -597,15 +698,15 @@
|
|
|
597
698
|
"description": null,
|
|
598
699
|
"type": null
|
|
599
700
|
},
|
|
600
|
-
{
|
|
601
|
-
"title": "example",
|
|
602
|
-
"description": "index()"
|
|
603
|
-
},
|
|
604
701
|
{
|
|
605
702
|
"title": "function",
|
|
606
703
|
"description": null,
|
|
607
704
|
"name": null
|
|
608
705
|
},
|
|
706
|
+
{
|
|
707
|
+
"title": "example",
|
|
708
|
+
"description": "index()"
|
|
709
|
+
},
|
|
609
710
|
{
|
|
610
711
|
"title": "returns",
|
|
611
712
|
"description": null,
|
|
@@ -632,15 +733,15 @@
|
|
|
632
733
|
"description": null,
|
|
633
734
|
"type": null
|
|
634
735
|
},
|
|
635
|
-
{
|
|
636
|
-
"title": "example",
|
|
637
|
-
"description": "field(\"destination_string__c\", function(state) {\n return arrayToString(dataValue(\"path_of_array\")(state), ', ')\n})"
|
|
638
|
-
},
|
|
639
736
|
{
|
|
640
737
|
"title": "function",
|
|
641
738
|
"description": null,
|
|
642
739
|
"name": null
|
|
643
740
|
},
|
|
741
|
+
{
|
|
742
|
+
"title": "example",
|
|
743
|
+
"description": "field(\"destination_string__c\", function(state) {\n return arrayToString(dataValue(\"path_of_array\")(state), ', ')\n})"
|
|
744
|
+
},
|
|
644
745
|
{
|
|
645
746
|
"title": "param",
|
|
646
747
|
"description": "Array of toString'able primatives.",
|
|
@@ -684,15 +785,15 @@
|
|
|
684
785
|
"description": null,
|
|
685
786
|
"type": null
|
|
686
787
|
},
|
|
687
|
-
{
|
|
688
|
-
"title": "example",
|
|
689
|
-
"description": "each(function(state) {\n return toArray( dataValue(\"path_of_array\")(state) )\n}, ...)"
|
|
690
|
-
},
|
|
691
788
|
{
|
|
692
789
|
"title": "function",
|
|
693
790
|
"description": null,
|
|
694
791
|
"name": null
|
|
695
792
|
},
|
|
793
|
+
{
|
|
794
|
+
"title": "example",
|
|
795
|
+
"description": "each(function(state) {\n return toArray( dataValue(\"path_of_array\")(state) )\n}, ...)"
|
|
796
|
+
},
|
|
696
797
|
{
|
|
697
798
|
"title": "param",
|
|
698
799
|
"description": "Data required to be in an array",
|
|
@@ -729,15 +830,15 @@
|
|
|
729
830
|
"description": null,
|
|
730
831
|
"type": null
|
|
731
832
|
},
|
|
732
|
-
{
|
|
733
|
-
"title": "example",
|
|
734
|
-
"description": "map(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
|
|
735
|
-
},
|
|
736
833
|
{
|
|
737
834
|
"title": "function",
|
|
738
835
|
"description": null,
|
|
739
836
|
"name": null
|
|
740
837
|
},
|
|
838
|
+
{
|
|
839
|
+
"title": "example",
|
|
840
|
+
"description": "map(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
|
|
841
|
+
},
|
|
741
842
|
{
|
|
742
843
|
"title": "param",
|
|
743
844
|
"description": "JSONPath referencing a point in `state.data`.",
|
package/dist/index.cjs
CHANGED
|
@@ -37,6 +37,8 @@ __export(src_exports, {
|
|
|
37
37
|
execute: () => execute,
|
|
38
38
|
field: () => import_language_common3.field,
|
|
39
39
|
fields: () => import_language_common3.fields,
|
|
40
|
+
fn: () => import_language_common3.fn,
|
|
41
|
+
fnIf: () => import_language_common3.fnIf,
|
|
40
42
|
index: () => import_language_common3.index,
|
|
41
43
|
join: () => import_language_common3.join,
|
|
42
44
|
lastReferenceValue: () => import_language_common3.lastReferenceValue,
|
|
@@ -68,6 +70,8 @@ __export(Adaptor_exports, {
|
|
|
68
70
|
execute: () => execute,
|
|
69
71
|
field: () => import_language_common3.field,
|
|
70
72
|
fields: () => import_language_common3.fields,
|
|
73
|
+
fn: () => import_language_common3.fn,
|
|
74
|
+
fnIf: () => import_language_common3.fnIf,
|
|
71
75
|
index: () => import_language_common3.index,
|
|
72
76
|
join: () => import_language_common3.join,
|
|
73
77
|
lastReferenceValue: () => import_language_common3.lastReferenceValue,
|
|
@@ -268,6 +272,8 @@ var src_default = Adaptor_exports;
|
|
|
268
272
|
execute,
|
|
269
273
|
field,
|
|
270
274
|
fields,
|
|
275
|
+
fn,
|
|
276
|
+
fnIf,
|
|
271
277
|
index,
|
|
272
278
|
join,
|
|
273
279
|
lastReferenceValue,
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,8 @@ __export(Adaptor_exports, {
|
|
|
18
18
|
execute: () => execute,
|
|
19
19
|
field: () => field2,
|
|
20
20
|
fields: () => fields,
|
|
21
|
+
fn: () => fn,
|
|
22
|
+
fnIf: () => fnIf,
|
|
21
23
|
index: () => index,
|
|
22
24
|
join: () => join,
|
|
23
25
|
lastReferenceValue: () => lastReferenceValue,
|
|
@@ -73,7 +75,9 @@ import {
|
|
|
73
75
|
beta,
|
|
74
76
|
toArray,
|
|
75
77
|
arrayToString,
|
|
76
|
-
alterState
|
|
78
|
+
alterState,
|
|
79
|
+
fn,
|
|
80
|
+
fnIf
|
|
77
81
|
} from "@openfn/language-common";
|
|
78
82
|
var { curry, mapValues, flatten } = pkg;
|
|
79
83
|
var createSMS = curry(function(params, state) {
|
|
@@ -237,6 +241,8 @@ export {
|
|
|
237
241
|
execute,
|
|
238
242
|
field2 as field,
|
|
239
243
|
fields,
|
|
244
|
+
fn,
|
|
245
|
+
fnIf,
|
|
240
246
|
index,
|
|
241
247
|
join,
|
|
242
248
|
lastReferenceValue,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/language-mogli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "A Mogli SMS Language Pack for OpenFn",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"author": "Open Function Group",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"configuration-schema.json"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@openfn/language-common": "^1.
|
|
15
|
+
"@openfn/language-common": "^1.15.1",
|
|
16
16
|
"JSONPath": "^0.10.0",
|
|
17
17
|
"jsforce": "1.5.1",
|
|
18
18
|
"lodash-fp": "^0.10.4",
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
"yargs": "^3.32.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@openfn/buildtools": "^1.0.2",
|
|
25
24
|
"@openfn/simple-ast": "0.4.1",
|
|
26
25
|
"assertion-error": "^2.0.0",
|
|
27
26
|
"chai": "^4.3.7",
|
package/types/Adaptor.d.ts
CHANGED
|
@@ -26,4 +26,4 @@ export type State = {
|
|
|
26
26
|
};
|
|
27
27
|
export type Operation = Function;
|
|
28
28
|
export { lookup, relationship } from "./sourceHelpers";
|
|
29
|
-
export { each, join, fields, field, source, sourceValue, map, combine, merge, dataPath, dataValue, referencePath, lastReferenceValue, index, beta, toArray, arrayToString, alterState } from "@openfn/language-common";
|
|
29
|
+
export { each, join, fields, field, source, sourceValue, map, combine, merge, dataPath, dataValue, referencePath, lastReferenceValue, index, beta, toArray, arrayToString, alterState, fn, fnIf } from "@openfn/language-common";
|
package/types/sourceHelpers.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* @example <caption>Example</caption>
|
|
4
4
|
* lookup("relationship_name__r", "externalID on related object", "$.path")
|
|
5
5
|
* @function
|
|
6
|
+
* @public
|
|
6
7
|
* @param {string} relationshipName - `__r` relationship field on the record.
|
|
7
8
|
* @param {string} externalID - Salesforce ExternalID field.
|
|
8
9
|
* @param {string} path - JSONPath to data source.
|
|
@@ -16,6 +17,7 @@ export function lookup(relationshipName: string, externalId: any, path: string):
|
|
|
16
17
|
* @example <caption>Fixed Value</caption>
|
|
17
18
|
* relationship("relationship_name__r", "externalID on related object", "hello world")
|
|
18
19
|
* @function
|
|
20
|
+
* @public
|
|
19
21
|
* @param {string} relationshipName - `__r` relationship field on the record.
|
|
20
22
|
* @param {string} externalID - Salesforce ExternalID field.
|
|
21
23
|
* @param {string} dataSource - resolvable source.
|