@mcpher/gas-fakes 2.3.15 → 2.3.16

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/gf_agent/SKILL.md CHANGED
@@ -344,6 +344,7 @@ ScriptApp.__behavior.sandboxService.GmailApp.cleanup = false;
344
344
  ## Best Practices for `gf_agent`
345
345
  - **Session Isolation**: When a user provides a list of files or emails, always initialize the sandbox with those specific whitelists at the top of the script.
346
346
  - **Explicit Whitelisting**: Use `behavior.addIdWhitelist` for file access. DO NOT assume `sandboxService.SpreadsheetApp` has an `addFileWhitelist` method (it is handled globally by the behavior ID whitelist).
347
+ - **Cross-Platform Portability**: The `ScriptApp.__behavior` object is a `gas-fakes` exclusive feature. If the generated script is intended to be copied and run in Live Apps Script later, you MUST wrap all sandbox-related boilerplate in an `if (ScriptApp.isFake)` block to prevent `TypeError` crashes in the cloud.
347
348
  - **Safe Execution**: In the Orchestrator Phase, identify if the task requires external access and include the necessary sandbox boilerplate in the generated script.
348
349
 
349
350
 
package/gf_agent/index.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  This index lists all Google Apps Script services and classes supported by `gf_agent` via `gas-fakes`.
4
4
 
5
+ - [Gmail](skills/gmail.md)
6
+ - [Spreadsheet](skills/spreadsheet.md)
5
7
  - [base](skills/base.md)
6
8
  - [cache](skills/cache.md)
7
9
  - [calendar](skills/calendar.md)
@@ -9,13 +11,11 @@ This index lists all Google Apps Script services and classes supported by `gf_ag
9
11
  - [document](skills/document.md)
10
12
  - [drive](skills/drive.md)
11
13
  - [forms](skills/forms.md)
12
- - [gmail](skills/gmail.md)
13
14
  - [jdbc](skills/jdbc.md)
14
15
  - [lock](skills/lock.md)
15
16
  - [properties](skills/properties.md)
16
17
  - [script](skills/script.md)
17
18
  - [slides](skills/slides.md)
18
- - [spreadsheet](skills/spreadsheet.md)
19
19
  - [urlfetch](skills/urlfetch.md)
20
20
  - [utilities](skills/utilities.md)
21
21
  - [xml](skills/xml.md)
@@ -58,4 +58,5 @@ ScriptApp.__behavior.sandboxService.GmailApp.cleanup = false;
58
58
  ## Best Practices for `gf_agent`
59
59
  - **Session Isolation**: When a user provides a list of files or emails, always initialize the sandbox with those specific whitelists at the top of the script.
60
60
  - **Explicit Whitelisting**: Use `behavior.addIdWhitelist` for file access. DO NOT assume `sandboxService.SpreadsheetApp` has an `addFileWhitelist` method (it is handled globally by the behavior ID whitelist).
61
+ - **Cross-Platform Portability**: The `ScriptApp.__behavior` object is a `gas-fakes` exclusive feature. If the generated script is intended to be copied and run in Live Apps Script later, you MUST wrap all sandbox-related boilerplate in an `if (ScriptApp.isFake)` block to prevent `TypeError` crashes in the cloud.
61
62
  - **Safe Execution**: In the Orchestrator Phase, identify if the task requires external access and include the necessary sandbox boilerplate in the generated script.
@@ -18,6 +18,8 @@ Supported Methods:
18
18
  - `copy()`
19
19
  - `getChild(Integer)`
20
20
  - `getChildIndex(Element)`
21
+ - `getImages()`
22
+ - `getListItems()`
21
23
  - `getMarginBottom()`
22
24
  - `getMarginLeft()`
23
25
  - `getMarginRight()`
@@ -25,7 +27,9 @@ Supported Methods:
25
27
  - `getNumChildren()`
26
28
  - `getPageHeight()`
27
29
  - `getPageWidth()`
30
+ - `getParagraphs()`
28
31
  - `getParent()`
32
+ - `getTables()`
29
33
  - `getText()`
30
34
  - `getType()`
31
35
  - `insertImage(Integer,BlobSource)`
@@ -101,8 +105,12 @@ Supported Methods:
101
105
  - `copy()`
102
106
  - `getChild(Integer)`
103
107
  - `getChildIndex(Element)`
108
+ - `getImages()`
109
+ - `getListItems()`
104
110
  - `getNumChildren()`
111
+ - `getParagraphs()`
105
112
  - `getParent()`
113
+ - `getTables()`
106
114
  - `getType()`
107
115
  - `copy()`
108
116
  - `getFootnoteContents()`
@@ -115,6 +123,7 @@ Supported Methods:
115
123
  - `getChild(Integer)`
116
124
  - `getChildIndex(Element)`
117
125
  - `getNumChildren()`
126
+ - `getParagraphs()`
118
127
  - `getParent()`
119
128
  - `getText()`
120
129
  - `getType()`
@@ -122,8 +131,12 @@ Supported Methods:
122
131
  - `copy()`
123
132
  - `getChild(Integer)`
124
133
  - `getChildIndex(Element)`
134
+ - `getImages()`
135
+ - `getListItems()`
125
136
  - `getNumChildren()`
137
+ - `getParagraphs()`
126
138
  - `getParent()`
139
+ - `getTables()`
127
140
  - `getType()`
128
141
  - `copy()`
129
142
  - `getParent()`
@@ -402,8 +415,12 @@ Supported Methods:
402
415
  - `copy()`
403
416
  - `getChild(Integer)`
404
417
  - `getChildIndex(Element)`
418
+ - `getImages()`
419
+ - `getListItems()`
405
420
  - `getNumChildren()`
421
+ - `getParagraphs()`
406
422
  - `getParent()`
423
+ - `getTables()`
407
424
  - `getType()`
408
425
  - `copy()`
409
426
  - `getFootnoteContents()`
@@ -416,6 +433,7 @@ Supported Methods:
416
433
  - `getChild(Integer)`
417
434
  - `getChildIndex(Element)`
418
435
  - `getNumChildren()`
436
+ - `getParagraphs()`
419
437
  - `getParent()`
420
438
  - `getText()`
421
439
  - `getType()`
@@ -423,8 +441,12 @@ Supported Methods:
423
441
  - `copy()`
424
442
  - `getChild(Integer)`
425
443
  - `getChildIndex(Element)`
444
+ - `getImages()`
445
+ - `getListItems()`
426
446
  - `getNumChildren()`
447
+ - `getParagraphs()`
427
448
  - `getParent()`
449
+ - `getTables()`
428
450
  - `getType()`
429
451
  - `copy()`
430
452
  - `getParent()`
@@ -700,8 +722,12 @@ Supported Methods:
700
722
  - `copy()`
701
723
  - `getChild(Integer)`
702
724
  - `getChildIndex(Element)`
725
+ - `getImages()`
726
+ - `getListItems()`
703
727
  - `getNumChildren()`
728
+ - `getParagraphs()`
704
729
  - `getParent()`
730
+ - `getTables()`
705
731
  - `getType()`
706
732
  - `copy()`
707
733
  - `getFootnoteContents()`
@@ -714,6 +740,7 @@ Supported Methods:
714
740
  - `getChild(Integer)`
715
741
  - `getChildIndex(Element)`
716
742
  - `getNumChildren()`
743
+ - `getParagraphs()`
717
744
  - `getParent()`
718
745
  - `getText()`
719
746
  - `getType()`
@@ -721,8 +748,12 @@ Supported Methods:
721
748
  - `copy()`
722
749
  - `getChild(Integer)`
723
750
  - `getChildIndex(Element)`
751
+ - `getImages()`
752
+ - `getListItems()`
724
753
  - `getNumChildren()`
754
+ - `getParagraphs()`
725
755
  - `getParent()`
756
+ - `getTables()`
726
757
  - `getType()`
727
758
  - `copy()`
728
759
  - `getParent()`
@@ -986,8 +1017,12 @@ Supported Methods:
986
1017
  - `copy()`
987
1018
  - `getChild(Integer)`
988
1019
  - `getChildIndex(Element)`
1020
+ - `getImages()`
1021
+ - `getListItems()`
989
1022
  - `getNumChildren()`
1023
+ - `getParagraphs()`
990
1024
  - `getParent()`
1025
+ - `getTables()`
991
1026
  - `getType()`
992
1027
  - `copy()`
993
1028
  - `getFootnoteContents()`
@@ -1000,6 +1035,7 @@ Supported Methods:
1000
1035
  - `getChild(Integer)`
1001
1036
  - `getChildIndex(Element)`
1002
1037
  - `getNumChildren()`
1038
+ - `getParagraphs()`
1003
1039
  - `getParent()`
1004
1040
  - `getText()`
1005
1041
  - `getType()`
@@ -1007,8 +1043,12 @@ Supported Methods:
1007
1043
  - `copy()`
1008
1044
  - `getChild(Integer)`
1009
1045
  - `getChildIndex(Element)`
1046
+ - `getImages()`
1047
+ - `getListItems()`
1010
1048
  - `getNumChildren()`
1049
+ - `getParagraphs()`
1011
1050
  - `getParent()`
1051
+ - `getTables()`
1012
1052
  - `getType()`
1013
1053
  - `copy()`
1014
1054
  - `getParent()`
@@ -1272,8 +1312,12 @@ Supported Methods:
1272
1312
  - `copy()`
1273
1313
  - `getChild(Integer)`
1274
1314
  - `getChildIndex(Element)`
1315
+ - `getImages()`
1316
+ - `getListItems()`
1275
1317
  - `getNumChildren()`
1318
+ - `getParagraphs()`
1276
1319
  - `getParent()`
1320
+ - `getTables()`
1277
1321
  - `getType()`
1278
1322
  - `copy()`
1279
1323
  - `getFootnoteContents()`
@@ -1286,6 +1330,7 @@ Supported Methods:
1286
1330
  - `getChild(Integer)`
1287
1331
  - `getChildIndex(Element)`
1288
1332
  - `getNumChildren()`
1333
+ - `getParagraphs()`
1289
1334
  - `getParent()`
1290
1335
  - `getText()`
1291
1336
  - `getType()`
@@ -1293,8 +1338,12 @@ Supported Methods:
1293
1338
  - `copy()`
1294
1339
  - `getChild(Integer)`
1295
1340
  - `getChildIndex(Element)`
1341
+ - `getImages()`
1342
+ - `getListItems()`
1296
1343
  - `getNumChildren()`
1344
+ - `getParagraphs()`
1297
1345
  - `getParent()`
1346
+ - `getTables()`
1298
1347
  - `getType()`
1299
1348
  - `copy()`
1300
1349
  - `getParent()`
@@ -1532,8 +1581,12 @@ Supported Methods:
1532
1581
  - `copy()`
1533
1582
  - `getChild(Integer)`
1534
1583
  - `getChildIndex(Element)`
1584
+ - `getImages()`
1585
+ - `getListItems()`
1535
1586
  - `getNumChildren()`
1587
+ - `getParagraphs()`
1536
1588
  - `getParent()`
1589
+ - `getTables()`
1537
1590
  - `getType()`
1538
1591
  - `copy()`
1539
1592
  - `getFootnoteContents()`
@@ -1546,6 +1599,7 @@ Supported Methods:
1546
1599
  - `getChild(Integer)`
1547
1600
  - `getChildIndex(Element)`
1548
1601
  - `getNumChildren()`
1602
+ - `getParagraphs()`
1549
1603
  - `getParent()`
1550
1604
  - `getText()`
1551
1605
  - `getType()`
@@ -1553,8 +1607,12 @@ Supported Methods:
1553
1607
  - `copy()`
1554
1608
  - `getChild(Integer)`
1555
1609
  - `getChildIndex(Element)`
1610
+ - `getImages()`
1611
+ - `getListItems()`
1556
1612
  - `getNumChildren()`
1613
+ - `getParagraphs()`
1557
1614
  - `getParent()`
1615
+ - `getTables()`
1558
1616
  - `getType()`
1559
1617
  - `copy()`
1560
1618
  - `getParent()`
@@ -1787,8 +1845,12 @@ Supported Methods:
1787
1845
  - `copy()`
1788
1846
  - `getChild(Integer)`
1789
1847
  - `getChildIndex(Element)`
1848
+ - `getImages()`
1849
+ - `getListItems()`
1790
1850
  - `getNumChildren()`
1851
+ - `getParagraphs()`
1791
1852
  - `getParent()`
1853
+ - `getTables()`
1792
1854
  - `getType()`
1793
1855
  - `copy()`
1794
1856
  - `getFootnoteContents()`
@@ -1801,6 +1863,7 @@ Supported Methods:
1801
1863
  - `getChild(Integer)`
1802
1864
  - `getChildIndex(Element)`
1803
1865
  - `getNumChildren()`
1866
+ - `getParagraphs()`
1804
1867
  - `getParent()`
1805
1868
  - `getText()`
1806
1869
  - `getType()`
@@ -1808,8 +1871,12 @@ Supported Methods:
1808
1871
  - `copy()`
1809
1872
  - `getChild(Integer)`
1810
1873
  - `getChildIndex(Element)`
1874
+ - `getImages()`
1875
+ - `getListItems()`
1811
1876
  - `getNumChildren()`
1877
+ - `getParagraphs()`
1812
1878
  - `getParent()`
1879
+ - `getTables()`
1813
1880
  - `getType()`
1814
1881
  - `copy()`
1815
1882
  - `getParent()`
@@ -2039,8 +2106,12 @@ Supported Methods:
2039
2106
  - `copy()`
2040
2107
  - `getChild(Integer)`
2041
2108
  - `getChildIndex(Element)`
2109
+ - `getImages()`
2110
+ - `getListItems()`
2042
2111
  - `getNumChildren()`
2112
+ - `getParagraphs()`
2043
2113
  - `getParent()`
2114
+ - `getTables()`
2044
2115
  - `getType()`
2045
2116
  - `copy()`
2046
2117
  - `getFootnoteContents()`
@@ -2053,6 +2124,7 @@ Supported Methods:
2053
2124
  - `getChild(Integer)`
2054
2125
  - `getChildIndex(Element)`
2055
2126
  - `getNumChildren()`
2127
+ - `getParagraphs()`
2056
2128
  - `getParent()`
2057
2129
  - `getText()`
2058
2130
  - `getType()`
@@ -2060,8 +2132,12 @@ Supported Methods:
2060
2132
  - `copy()`
2061
2133
  - `getChild(Integer)`
2062
2134
  - `getChildIndex(Element)`
2135
+ - `getImages()`
2136
+ - `getListItems()`
2063
2137
  - `getNumChildren()`
2138
+ - `getParagraphs()`
2064
2139
  - `getParent()`
2140
+ - `getTables()`
2065
2141
  - `getType()`
2066
2142
  - `copy()`
2067
2143
  - `getParent()`
@@ -2291,8 +2367,12 @@ Supported Methods:
2291
2367
  - `copy()`
2292
2368
  - `getChild(Integer)`
2293
2369
  - `getChildIndex(Element)`
2370
+ - `getImages()`
2371
+ - `getListItems()`
2294
2372
  - `getNumChildren()`
2373
+ - `getParagraphs()`
2295
2374
  - `getParent()`
2375
+ - `getTables()`
2296
2376
  - `getType()`
2297
2377
  - `copy()`
2298
2378
  - `getFootnoteContents()`
@@ -2305,6 +2385,7 @@ Supported Methods:
2305
2385
  - `getChild(Integer)`
2306
2386
  - `getChildIndex(Element)`
2307
2387
  - `getNumChildren()`
2388
+ - `getParagraphs()`
2308
2389
  - `getParent()`
2309
2390
  - `getText()`
2310
2391
  - `getType()`
@@ -2312,8 +2393,12 @@ Supported Methods:
2312
2393
  - `copy()`
2313
2394
  - `getChild(Integer)`
2314
2395
  - `getChildIndex(Element)`
2396
+ - `getImages()`
2397
+ - `getListItems()`
2315
2398
  - `getNumChildren()`
2399
+ - `getParagraphs()`
2316
2400
  - `getParent()`
2401
+ - `getTables()`
2317
2402
  - `getType()`
2318
2403
  - `copy()`
2319
2404
  - `getParent()`
@@ -2543,8 +2628,12 @@ Supported Methods:
2543
2628
  - `copy()`
2544
2629
  - `getChild(Integer)`
2545
2630
  - `getChildIndex(Element)`
2631
+ - `getImages()`
2632
+ - `getListItems()`
2546
2633
  - `getNumChildren()`
2634
+ - `getParagraphs()`
2547
2635
  - `getParent()`
2636
+ - `getTables()`
2548
2637
  - `getType()`
2549
2638
  - `copy()`
2550
2639
  - `getFootnoteContents()`
@@ -2557,6 +2646,7 @@ Supported Methods:
2557
2646
  - `getChild(Integer)`
2558
2647
  - `getChildIndex(Element)`
2559
2648
  - `getNumChildren()`
2649
+ - `getParagraphs()`
2560
2650
  - `getParent()`
2561
2651
  - `getText()`
2562
2652
  - `getType()`
@@ -2564,8 +2654,12 @@ Supported Methods:
2564
2654
  - `copy()`
2565
2655
  - `getChild(Integer)`
2566
2656
  - `getChildIndex(Element)`
2657
+ - `getImages()`
2658
+ - `getListItems()`
2567
2659
  - `getNumChildren()`
2660
+ - `getParagraphs()`
2568
2661
  - `getParent()`
2662
+ - `getTables()`
2569
2663
  - `getType()`
2570
2664
  - `copy()`
2571
2665
  - `getParent()`
@@ -2795,8 +2889,12 @@ Supported Methods:
2795
2889
  - `copy()`
2796
2890
  - `getChild(Integer)`
2797
2891
  - `getChildIndex(Element)`
2892
+ - `getImages()`
2893
+ - `getListItems()`
2798
2894
  - `getNumChildren()`
2895
+ - `getParagraphs()`
2799
2896
  - `getParent()`
2897
+ - `getTables()`
2800
2898
  - `getType()`
2801
2899
  - `copy()`
2802
2900
  - `getFootnoteContents()`
@@ -2809,6 +2907,7 @@ Supported Methods:
2809
2907
  - `getChild(Integer)`
2810
2908
  - `getChildIndex(Element)`
2811
2909
  - `getNumChildren()`
2910
+ - `getParagraphs()`
2812
2911
  - `getParent()`
2813
2912
  - `getText()`
2814
2913
  - `getType()`
@@ -2816,8 +2915,12 @@ Supported Methods:
2816
2915
  - `copy()`
2817
2916
  - `getChild(Integer)`
2818
2917
  - `getChildIndex(Element)`
2918
+ - `getImages()`
2919
+ - `getListItems()`
2819
2920
  - `getNumChildren()`
2921
+ - `getParagraphs()`
2820
2922
  - `getParent()`
2923
+ - `getTables()`
2821
2924
  - `getType()`
2822
2925
  - `copy()`
2823
2926
  - `getParent()`
@@ -3047,8 +3150,12 @@ Supported Methods:
3047
3150
  - `copy()`
3048
3151
  - `getChild(Integer)`
3049
3152
  - `getChildIndex(Element)`
3153
+ - `getImages()`
3154
+ - `getListItems()`
3050
3155
  - `getNumChildren()`
3156
+ - `getParagraphs()`
3051
3157
  - `getParent()`
3158
+ - `getTables()`
3052
3159
  - `getType()`
3053
3160
  - `copy()`
3054
3161
  - `getFootnoteContents()`
@@ -3061,6 +3168,7 @@ Supported Methods:
3061
3168
  - `getChild(Integer)`
3062
3169
  - `getChildIndex(Element)`
3063
3170
  - `getNumChildren()`
3171
+ - `getParagraphs()`
3064
3172
  - `getParent()`
3065
3173
  - `getText()`
3066
3174
  - `getType()`
@@ -3068,8 +3176,12 @@ Supported Methods:
3068
3176
  - `copy()`
3069
3177
  - `getChild(Integer)`
3070
3178
  - `getChildIndex(Element)`
3179
+ - `getImages()`
3180
+ - `getListItems()`
3071
3181
  - `getNumChildren()`
3182
+ - `getParagraphs()`
3072
3183
  - `getParent()`
3184
+ - `getTables()`
3073
3185
  - `getType()`
3074
3186
  - `copy()`
3075
3187
  - `getParent()`
@@ -3307,6 +3419,7 @@ Supported Methods:
3307
3419
  - `getChild(Integer)`
3308
3420
  - `getChildIndex(Element)`
3309
3421
  - `getNumChildren()`
3422
+ - `getParagraphs()`
3310
3423
  - `getParent()`
3311
3424
  - `getText()`
3312
3425
  - `getType()`
@@ -3314,8 +3427,12 @@ Supported Methods:
3314
3427
  - `copy()`
3315
3428
  - `getChild(Integer)`
3316
3429
  - `getChildIndex(Element)`
3430
+ - `getImages()`
3431
+ - `getListItems()`
3317
3432
  - `getNumChildren()`
3433
+ - `getParagraphs()`
3318
3434
  - `getParent()`
3435
+ - `getTables()`
3319
3436
  - `getType()`
3320
3437
  - `copy()`
3321
3438
  - `getParent()`
@@ -3549,6 +3666,7 @@ Supported Methods:
3549
3666
  - `getChild(Integer)`
3550
3667
  - `getChildIndex(Element)`
3551
3668
  - `getNumChildren()`
3669
+ - `getParagraphs()`
3552
3670
  - `getParent()`
3553
3671
  - `getText()`
3554
3672
  - `getType()`
@@ -3556,8 +3674,12 @@ Supported Methods:
3556
3674
  - `copy()`
3557
3675
  - `getChild(Integer)`
3558
3676
  - `getChildIndex(Element)`
3677
+ - `getImages()`
3678
+ - `getListItems()`
3559
3679
  - `getNumChildren()`
3680
+ - `getParagraphs()`
3560
3681
  - `getParent()`
3682
+ - `getTables()`
3561
3683
  - `getType()`
3562
3684
  - `copy()`
3563
3685
  - `getParent()`
@@ -3787,8 +3909,12 @@ Supported Methods:
3787
3909
  - `copy()`
3788
3910
  - `getChild(Integer)`
3789
3911
  - `getChildIndex(Element)`
3912
+ - `getImages()`
3913
+ - `getListItems()`
3790
3914
  - `getNumChildren()`
3915
+ - `getParagraphs()`
3791
3916
  - `getParent()`
3917
+ - `getTables()`
3792
3918
  - `getType()`
3793
3919
  - `copy()`
3794
3920
  - `getParent()`
@@ -1,4 +1,4 @@
1
- # Service: gmail
1
+ # Service: Gmail
2
2
 
3
3
  ## Class: GmailApp
4
4
 
@@ -1,4 +1,4 @@
1
- # Service: spreadsheet
1
+ # Service: Spreadsheet
2
2
 
3
3
  ## Class: Banding
4
4
 
package/package.json CHANGED
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "name": "@mcpher/gas-fakes",
42
42
  "author": "bruce mcpherson",
43
- "version": "2.3.15",
43
+ "version": "2.3.16",
44
44
  "license": "MIT",
45
45
  "main": "main.js",
46
46
  "description": "An implementation of the Google Workspace Apps Script runtime: Run native App Script Code on Node and Cloud Run",
@@ -95,6 +95,94 @@ export class FakeContainerElement extends FakeElement {
95
95
  return this.appendFootnote(text);
96
96
  }
97
97
 
98
+ /**
99
+ * Retrieves all the InlineImages contained in the section.
100
+ * @returns {GoogleAppsScript.Document.InlineImage[]} The section images.
101
+ */
102
+ getImages() {
103
+ ScriptApp.__behavior.checkMethod(this.toString(), 'getImages');
104
+ const elements = [];
105
+ const numChildren = this.getNumChildren();
106
+ for (let i = 0; i < numChildren; i++) {
107
+ const child = this.getChild(i);
108
+ const type = child.getType().toString();
109
+ if (type === 'INLINE_IMAGE') {
110
+ elements.push(child);
111
+ } else if (child.getNumChildren) {
112
+ // Recurse into containers
113
+ elements.push(...child.getImages());
114
+ } else if (type === 'PARAGRAPH') {
115
+ // Paragraphs can contain inline images
116
+ const numParaChildren = child.getNumChildren();
117
+ for (let j = 0; j < numParaChildren; j++) {
118
+ const pChild = child.getChild(j);
119
+ if (pChild.getType().toString() === 'INLINE_IMAGE') {
120
+ elements.push(pChild);
121
+ }
122
+ }
123
+ }
124
+ }
125
+ return elements;
126
+ }
127
+
128
+ /**
129
+ * Retrieves all the ListItems contained in the section.
130
+ * @returns {GoogleAppsScript.Document.ListItem[]} The section list items.
131
+ */
132
+ getListItems() {
133
+ ScriptApp.__behavior.checkMethod(this.toString(), 'getListItems');
134
+ const elements = [];
135
+ const numChildren = this.getNumChildren();
136
+ for (let i = 0; i < numChildren; i++) {
137
+ const child = this.getChild(i);
138
+ if (child.getType().toString() === 'LIST_ITEM') {
139
+ elements.push(child);
140
+ } else if (child.getNumChildren) {
141
+ elements.push(...child.getListItems());
142
+ }
143
+ }
144
+ return elements;
145
+ }
146
+
147
+ /**
148
+ * Retrieves all the Paragraphs contained in the section (including ListItems).
149
+ * @returns {GoogleAppsScript.Document.Paragraph[]} The section paragraphs.
150
+ */
151
+ getParagraphs() {
152
+ ScriptApp.__behavior.checkMethod(this.toString(), 'getParagraphs');
153
+ const elements = [];
154
+ const numChildren = this.getNumChildren();
155
+ for (let i = 0; i < numChildren; i++) {
156
+ const child = this.getChild(i);
157
+ const type = child.getType().toString();
158
+ if (type === 'PARAGRAPH' || type === 'LIST_ITEM') {
159
+ elements.push(child);
160
+ } else if (child.getNumChildren) {
161
+ elements.push(...child.getParagraphs());
162
+ }
163
+ }
164
+ return elements;
165
+ }
166
+
167
+ /**
168
+ * Retrieves all the Tables contained in the section.
169
+ * @returns {GoogleAppsScript.Document.Table[]} The section tables.
170
+ */
171
+ getTables() {
172
+ ScriptApp.__behavior.checkMethod(this.toString(), 'getTables');
173
+ const elements = [];
174
+ const numChildren = this.getNumChildren();
175
+ for (let i = 0; i < numChildren; i++) {
176
+ const child = this.getChild(i);
177
+ if (child.getType().toString() === 'TABLE') {
178
+ elements.push(child);
179
+ } else if (child.getNumChildren) {
180
+ elements.push(...child.getTables());
181
+ }
182
+ }
183
+ return elements;
184
+ }
185
+
98
186
  /**
99
187
  * Retrieves the child element at the specified index.
100
188
  * @param {number} childIndex The zero-based index of the child element to retrieve.
@@ -81,9 +81,9 @@ export class FakeColorScheme {
81
81
  * @param {FakeColor} color
82
82
  * @returns {FakeColorScheme} self
83
83
  */
84
- setConcreteColor(themeColorType, color) {
84
+ setConcreteColor(themeColorType, ...colorArgs) {
85
85
  const { nargs, matchThrow } = signatureArgs(arguments, "ColorScheme.setConcreteColor");
86
- if (nargs !== 2) matchThrow();
86
+ if (nargs < 2 || nargs > 4) matchThrow();
87
87
 
88
88
  const master = this.__masterPage;
89
89
  if (!master) throw new Error('Could not find master page for color scheme');
@@ -96,15 +96,34 @@ export class FakeColorScheme {
96
96
  const currentResource = this.__resource;
97
97
  const colors = [...(currentResource.colors || [])];
98
98
 
99
- // Convert the new Color to API format
100
99
  const apiColor = {};
101
- if (color.getColorType().toString() === 'RGB') {
102
- const rgb = color.asRgbColor();
103
- apiColor.red = rgb.getRed() / 255;
104
- apiColor.green = rgb.getGreen() / 255;
105
- apiColor.blue = rgb.getBlue() / 255;
106
- } else if (color.getColorType().toString() === 'THEME') {
107
- apiColor.themeColor = color.asThemeColor().getThemeColorType().toString();
100
+ if (colorArgs.length === 3) {
101
+ // (ThemeColorType, r, g, b)
102
+ apiColor.red = colorArgs[0] / 255;
103
+ apiColor.green = colorArgs[1] / 255;
104
+ apiColor.blue = colorArgs[2] / 255;
105
+ } else if (typeof colorArgs[0] === 'string') {
106
+ // (ThemeColorType, hexString)
107
+ const hex = colorArgs[0];
108
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
109
+ if (result) {
110
+ apiColor.red = parseInt(result[1], 16) / 255;
111
+ apiColor.green = parseInt(result[2], 16) / 255;
112
+ apiColor.blue = parseInt(result[3], 16) / 255;
113
+ } else {
114
+ throw new Error("Invalid hex color string");
115
+ }
116
+ } else {
117
+ // (ThemeColorType, Color)
118
+ const color = colorArgs[0];
119
+ if (color.getColorType().toString() === 'RGB') {
120
+ const rgb = color.asRgbColor();
121
+ apiColor.red = rgb.getRed() / 255;
122
+ apiColor.green = rgb.getGreen() / 255;
123
+ apiColor.blue = rgb.getBlue() / 255;
124
+ } else if (color.getColorType().toString() === 'THEME') {
125
+ apiColor.themeColor = color.asThemeColor().getThemeColorType().toString();
126
+ }
108
127
  }
109
128
 
110
129
  // Find and update or add the color pair
@@ -52,14 +52,6 @@ export class FakePresentation {
52
52
  return `https://docs.google.com/presentation/d/${this.getId()}/edit`;
53
53
  }
54
54
 
55
- /**
56
- * Gets the color scheme of the presentation.
57
- * @returns {FakeColorScheme} The color scheme.
58
- */
59
- getColorScheme() {
60
- return newFakeColorScheme(this);
61
- }
62
-
63
55
  /**
64
56
  * Gets the masters in the presentation.
65
57
  * @returns {FakeMaster[]} The masters.
@@ -91,7 +91,6 @@ export class FakeSpreadsheetApp {
91
91
  "setActiveRange",
92
92
  "setActiveRangeList",
93
93
  "getUi",
94
- "open",
95
94
 
96
95
  "ChartAggregationType",
97
96
  "ChartTransformationType",
@@ -106,6 +105,21 @@ export class FakeSpreadsheetApp {
106
105
  toString() {
107
106
  return "SpreadsheetApp";
108
107
  }
108
+
109
+ /**
110
+ * Opens the spreadsheet that corresponds to the given File object.
111
+ * @param {File} file A Drive file object representing a spreadsheet.
112
+ * @returns {FakeSpreadsheet} the spreadsheet
113
+ */
114
+ open(file) {
115
+ const { nargs, matchThrow } = signatureArgs(arguments, "SpreadsheetApp.open");
116
+ if (nargs !== 1) matchThrow();
117
+ if (!file || typeof file.getId !== 'function') {
118
+ throw new Error('Invalid file object');
119
+ }
120
+ return this.openById(file.getId());
121
+ }
122
+
109
123
  getActiveSpreadsheet() {
110
124
  if (this.__activeSpreadsheet) return this.__activeSpreadsheet;
111
125
  // because this is a faked container bound app, we need to get the documentId from the config file
@@ -50,11 +50,24 @@ export const sxJdbcConnect = async (Auth, { url, user, password }) => {
50
50
  ssl: disableSsl ? false : { rejectUnauthorized: false }
51
51
  };
52
52
 
53
- if (user !== null && typeof user !== 'undefined' && password !== null && typeof password !== 'undefined') {
53
+ let finalUser = user;
54
+ let finalPassword = password;
55
+
56
+ if ((user === null || typeof user === 'undefined') && (password === null || typeof password === 'undefined')) {
57
+ try {
58
+ const parsedUrl = new URL(pgConnectionString);
59
+ if (parsedUrl.username) finalUser = decodeURIComponent(parsedUrl.username);
60
+ if (parsedUrl.password) finalPassword = decodeURIComponent(parsedUrl.password);
61
+ } catch (e) {
62
+ // ignore parsing errors
63
+ }
64
+ }
65
+
66
+ if (finalUser !== null && typeof finalUser !== 'undefined' && finalPassword !== null && typeof finalPassword !== 'undefined') {
54
67
  client = new pg.Client({
55
68
  ...clientConfig,
56
- user: String(user),
57
- password: String(password)
69
+ user: String(finalUser),
70
+ password: String(finalPassword)
58
71
  });
59
72
  } else {
60
73
  client = new pg.Client(clientConfig);
@@ -363,11 +363,11 @@ const normalizeColorStringToHex = (color) => {
363
363
  if (!is.string(color)) return null;
364
364
  const lowerColor = color.toLowerCase().replace(/\s/g, '');
365
365
  if (colorNameToHex[lowerColor]) {
366
- return colorNameToHex[lowerColor];
366
+ return colorNameToHex[lowerColor].toUpperCase();
367
367
  }
368
368
  // Check if it's a valid hex string
369
369
  if (/^#[0-9a-f]{6}$/i.test(lowerColor)) {
370
- return lowerColor;
370
+ return lowerColor.toUpperCase();
371
371
  }
372
372
  return null; // Invalid color string
373
373
  };