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