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