@mcpher/gas-fakes 1.0.19 → 1.0.20

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.
Files changed (51) hide show
  1. package/README.md +17 -23
  2. package/gasmess/bruce/pbx.js +53 -2
  3. package/gprompts/gas-inventory.json +80 -0
  4. package/gprompts/gas-inventory.mjs +80 -0
  5. package/gprompts/inventory-list.json +1 -0
  6. package/gprompts/model.json +34 -0
  7. package/gprompts/package-lock.json +869 -0
  8. package/gprompts/package.json +17 -0
  9. package/gprompts/temp_fetch.mjs +9 -0
  10. package/gprompts/update-progress.js +142 -0
  11. package/package.json +4 -2
  12. package/setup.sh +147 -0
  13. package/src/index.js +7 -1
  14. package/src/services/advgmail/app.js +31 -0
  15. package/src/services/advgmail/fakeadvgmail.js +39 -0
  16. package/src/services/advgmail/fakeadvgmaillabels.js +119 -0
  17. package/src/services/advgmail/fakeadvgmailusers.js +23 -0
  18. package/src/services/advgmail/gmailapis.js +15 -0
  19. package/src/services/documentapp/appenderhelpers.js +21 -23
  20. package/src/services/documentapp/elementhelpers.js +0 -1
  21. package/src/services/documentapp/elementoptions.js +22 -32
  22. package/src/services/documentapp/fakeelement.js +20 -3
  23. package/src/services/documentapp/fakelistitem.js +177 -28
  24. package/src/services/documentapp/fakeparagraph.js +194 -7
  25. package/src/services/documentapp/faketable.js +16 -0
  26. package/src/services/documentapp/faketablerow.js +15 -0
  27. package/src/services/documentapp/nrhelpers.js +1 -0
  28. package/src/services/documentapp/shadowdocument.js +10 -0
  29. package/src/services/enums/gmailenums.js +8 -0
  30. package/src/services/gmailapp/app.js +44 -0
  31. package/src/services/gmailapp/fakegmailapp.js +35 -0
  32. package/src/services/gmailapp/fakegmaillabel.js +44 -0
  33. package/src/services/slidesapp/app.js +3 -3
  34. package/src/services/spreadsheetapp/fakeprotection.js +6 -7
  35. package/src/support/gmailcacher.js +7 -0
  36. package/src/support/helpers.js +2 -2
  37. package/src/support/proxies.js +4 -1
  38. package/src/support/sxgmail.js +55 -0
  39. package/src/support/syncit.js +3 -0
  40. package/src/support/utils.js +46 -15
  41. package/src/support/workersync/sxfunctions.js +5 -10
  42. package/togas.bash +18 -5
  43. package/ghissues/image-size-inconsistency-issue.sh +0 -46
  44. package/ghissues/issue-formapp-create-title-inconsistency.sh +0 -51
  45. package/ghissues/issue-positioned-image.sh +0 -25
  46. package/ghissues/post-issue.sh +0 -53
  47. package/ghissues/protection-editors-issue.sh +0 -33
  48. package/ghissues/review-sandbox-listing-issue.sh +0 -45
  49. package/ghissues/sandbox-issue.sh +0 -31
  50. package/ghissues/setup-under-construction.sh +0 -107
  51. /package/{regenerate-progress-reports.sh → gprompts/regenerate-progress-reports.sh} +0 -0
package/README.md CHANGED
@@ -33,12 +33,24 @@ In order to duplicate the OAuth management handled by GAS, we'll use Application
33
33
 
34
34
  #### Application default credentials
35
35
 
36
- At the very least you need to add the gcp project id you'll be using for testing, plus the id of some file you have access to - this'll be used to check that you have set up ADC properly.
36
+ In order to avoid a bunch of Node specific code and credentials, yet still handle OAuth, I figured that we could simply rely on ADC. This is a problem I already wrote about here [Application Default Credentials with Google Cloud and Workspace APIs](https://ramblings.mcpher.com/application-default-credentials-with-google-cloud-and-workspace-apis/)
37
+
38
+ At the very least you need to add the gcp project id and optionally the id of some file you have access to - this'll be used to check that you have set up ADC properly.
39
+
40
+ #### Option 1 - automated setup
41
+
42
+ In the shells folder run
43
+ ```sh
44
+ bash setup.sh
45
+ ```
46
+ This will prompt you for project id and a file id to test with. It will also ask it you want to set up all the parameters needed for testing. If you answer yes, this will set up other things from the .env-template you can ignore unless you're planning to run the test suite. More information on that is in [collaborators info](collaborators.md)
47
+
48
+ Running set up will enhance your .env file and auth you in ADC with the required scopes
37
49
 
38
- There are other things in the .env-template you can ignore unless you're planning to run the test suite. More information on that is in [collaborators info](collaborators.md)
50
+ #### Option 2 - manual setup
39
51
 
52
+ You can setup the .env file your self using the .env.template as a guide.
40
53
 
41
- These should be in your .env file to enable ADC authentication. The purpose of the DRIVE_TEST_FILE_ID is so that the script can check you've enabled ADC correctly by pinging a file you have access to. The GCP_PROJECT_ID is required as it will be used by gas-fakes to access the workspace apis on your behalf.
42
54
  ```
43
55
  # must set these
44
56
  GCP_PROJECT_ID="add your gcp project id here"
@@ -55,25 +67,6 @@ EXTRA_SCOPES=",https://www.googleapis.com/auth/drive,https://www.googleapis.com/
55
67
 
56
68
  - goto ./shells and execute sp.sh
57
69
 
58
- ### OAuth
59
-
60
- There's 2 pieces to this solution.
61
-
62
- #### Application default credentials (ADC)
63
-
64
- In order to avoid a bunch of Node specific code and credentials, yet still handle OAuth, I figured that we could simply rely on ADC. This is a problem I already wrote about here [Application Default Credentials with Google Cloud and Workspace APIs](https://ramblings.mcpher.com/application-default-credentials-with-google-cloud-and-workspace-apis/)
65
-
66
- This section in your env file controls which scopes you plan to use.
67
-
68
- ```
69
- we'll use the default config for application default credentials
70
- AC=default
71
- # these are the scopes set by default - take some of these out if you want to minimize access
72
- DEFAULT_SCOPES="https://www.googleapis.com/auth/userinfo.email,openid,https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/sqlservice.login"
73
- EXTRA_SCOPES=",https://www.googleapis.com/auth/drive,https://www.googleapis.com/auth/spreadsheets"
74
-
75
- .....etc
76
- ```
77
70
 
78
71
  #### Manifest file
79
72
 
@@ -144,4 +137,5 @@ As I mentioned earlier, to take this further, I'm going to need a lot of help to
144
137
  - [setup env](setup-env.md) - ([credit Eric Shapiro] - additional info on contents of .env file
145
138
  - [this file](README.md)
146
139
  - [named colors](named-colors.md)
147
- - [sandbox](sandbox.md)
140
+ - [sandbox](sandbox.md)
141
+ - [named range identity](named-range-identity.md)
@@ -5,6 +5,58 @@ import { report, scl } from './dreport.js';
5
5
 
6
6
 
7
7
  const suffix = "-bruce"
8
+ const tli = () => {
9
+ let doc = DocumentApp.create("abc")
10
+ const id = doc.getId()
11
+ moveToTempFolder(id, suffix)
12
+ let body = doc.getBody();
13
+ let li = body.appendListItem("Initial list item text.");
14
+
15
+ doc = scl(doc)
16
+ let d = Docs.Documents.get(id)
17
+ console.log('after append item', doc.getBody().getNumChildren())
18
+ console.log(JSON.stringify(d.body.content))
19
+
20
+ body = doc.getBody()
21
+ li = body.getChild(1)
22
+ li.clear();
23
+
24
+ doc = scl(doc)
25
+ d = Docs.Documents.get(id)
26
+ console.log('after clear', doc.getBody().getNumChildren())
27
+ console.log(JSON.stringify(d.body.content))
28
+
29
+ body = doc.getBody()
30
+ li = body.getChild(1)
31
+ li.setText("New text after clear.");
32
+ doc = scl(doc)
33
+ d = Docs.Documents.get(id)
34
+ console.log('after new text', doc.getBody().getNumChildren())
35
+ console.log(JSON.stringify(d.body.content))
36
+
37
+ body = doc.getBody()
38
+ li = body.getChild(1)
39
+ li.setText("Image test: "); // setText returns void, so we can't chain.
40
+
41
+ doc = scl(doc)
42
+ d = Docs.Documents.get(id)
43
+ console.log('after image text', doc.getBody().getNumChildren())
44
+ console.log(JSON.stringify(d.body.content))
45
+
46
+
47
+ const imageUrl = 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png';
48
+ const imageBlob = UrlFetchApp.fetch(imageUrl).getBlob();
49
+ body = doc.getBody()
50
+ li = body.getChild(1)
51
+ li.appendInlineImage(imageBlob.copyBlob());
52
+
53
+ console.log('after inlinr image', doc.getBody().getNumChildren())
54
+ console.log(JSON.stringify(d.body.content))
55
+
56
+ deleteTempFile(id)
57
+
58
+ }
59
+ tli()
8
60
 
9
61
  const tx2 = () => {
10
62
  let doc = DocumentApp.create("abc")
@@ -34,7 +86,6 @@ const tx2 = () => {
34
86
  deleteTempFile(id)
35
87
  }
36
88
 
37
- tx2()
38
89
  const tx1 = () => {
39
90
  let doc = DocumentApp.create("abc")
40
91
  const id = doc.getId()
@@ -53,7 +104,7 @@ const tx1 = () => {
53
104
 
54
105
  deleteTempFile(id)
55
106
  }
56
- tx1()
107
+
57
108
  const tabsa = () => {
58
109
 
59
110
  let doc = DocumentApp.create("abc")
@@ -0,0 +1,80 @@
1
+ {
2
+ "Base Service": {
3
+ "name": "Base Service",
4
+ "link": "https://developers.google.com/apps-script/reference/base",
5
+ "classes": {
6
+ "Classes": {
7
+ "methods": {},
8
+ "properties": {}
9
+ },
10
+ "Blob": {
11
+ "methods": {},
12
+ "properties": {}
13
+ },
14
+ "BlobSource": {
15
+ "methods": {},
16
+ "properties": {}
17
+ },
18
+ "Browser": {
19
+ "methods": {},
20
+ "properties": {}
21
+ },
22
+ "Button": {
23
+ "methods": {},
24
+ "properties": {}
25
+ },
26
+ "ButtonSet": {
27
+ "methods": {},
28
+ "properties": {}
29
+ },
30
+ "ColorType": {
31
+ "methods": {},
32
+ "properties": {}
33
+ },
34
+ "Logger": {
35
+ "methods": {},
36
+ "properties": {}
37
+ },
38
+ "Menu": {
39
+ "methods": {},
40
+ "properties": {}
41
+ },
42
+ "MimeType": {
43
+ "methods": {},
44
+ "properties": {}
45
+ },
46
+ "Month": {
47
+ "methods": {},
48
+ "properties": {}
49
+ },
50
+ "PromptResponse": {
51
+ "methods": {},
52
+ "properties": {}
53
+ },
54
+ "RgbColor": {
55
+ "methods": {},
56
+ "properties": {}
57
+ },
58
+ "Session": {
59
+ "methods": {},
60
+ "properties": {}
61
+ },
62
+ "Ui": {
63
+ "methods": {},
64
+ "properties": {}
65
+ },
66
+ "User": {
67
+ "methods": {},
68
+ "properties": {}
69
+ },
70
+ "Weekday": {
71
+ "methods": {},
72
+ "properties": {}
73
+ },
74
+ "console": {
75
+ "methods": {},
76
+ "properties": {}
77
+ }
78
+ }
79
+ }
80
+ }
@@ -0,0 +1,80 @@
1
+ import got from 'got';
2
+ import * as cheerio from 'cheerio';
3
+ import fs from 'fs/promises';
4
+ import { URL } from 'url';
5
+
6
+ const baseUrl = "https://developers.google.com/apps-script/reference/"
7
+ const items = JSON.parse(await fs.readFile('/home/bruce/gas-fakes/gprompts/inventory-list.json', 'utf-8'));
8
+ const outputFile = '/home/bruce/gas-fakes/gprompts/gas-inventory.json';
9
+
10
+ const visited = new Set();
11
+ const queue = items.map (f=>baseUrl+f);
12
+
13
+ async function scrape() {
14
+ const inventory = {};
15
+
16
+ while (queue.length > 0) {
17
+ const url = queue.shift();
18
+ if (visited.has(url)) {
19
+ continue;
20
+ }
21
+ visited.add(url);
22
+
23
+ console.log(`Scraping ${url}`);
24
+ const response = await got(url);
25
+ const $ = cheerio.load(response.body);
26
+
27
+ const serviceName = $('h1').text().split('\n').map(f=>f.replace(/^\s+/,'').trim()).filter (f=>f)[0];
28
+ console.log ('...starting service name',serviceName)
29
+ inventory[serviceName] = {
30
+ name: serviceName,
31
+ link: url,
32
+ classes: {},
33
+ };
34
+
35
+ $('a').each((i, el) => {
36
+ const href = $(el).attr('href');
37
+ if (href && href.startsWith(url)) {
38
+ const absoluteUrl = new URL(href, url).href;
39
+ if (!visited.has(absoluteUrl)) {
40
+ queue.push(absoluteUrl);
41
+ }
42
+ }
43
+ });
44
+
45
+ // Extract classes and methods
46
+ $('h2').each((i, el) => {
47
+ const className = $(el).text().trim();
48
+ if (className) {
49
+ console.log ('...found class',className,'for service',serviceName)
50
+ inventory[serviceName].classes[className] = {
51
+ methods: {},
52
+ properties: {},
53
+ };
54
+
55
+ // Find the table of methods for the current class
56
+ const methodsTable = $(el).nextAll('table').first();
57
+ methodsTable.find('tbody tr').each((j, row) => {
58
+ const methodName = $(row).find('td').eq(1).text().trim();
59
+ const methodLink = $(row).find('td').eq(1).find('a').attr('href');
60
+ const returnType = $(row).find('td').eq(0).text().trim();
61
+
62
+ if (methodName) {
63
+ inventory[serviceName].classes[className].methods[methodName] = {
64
+ link: methodLink ? new URL(methodLink, url).href : '',
65
+ returns: {
66
+ type: returnType,
67
+ link: '' // to be extracted later
68
+ }
69
+ };
70
+ }
71
+ });
72
+ }
73
+ });
74
+ }
75
+
76
+ await fs.writeFile(outputFile, JSON.stringify(inventory, null, 2));
77
+ console.log(`Inventory saved to ${outputFile}`);
78
+ }
79
+
80
+ scrape().catch(console.error);
@@ -0,0 +1 @@
1
+ ["base"]
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "Document Service",
3
+ "link": "https://developers.google.com/apps-script/reference/document",
4
+ "classes": {
5
+ "DocumentApp": {
6
+ "methods": {
7
+ "create": {
8
+ "link": "https://developers.google.com/apps-script/reference/document/document-app#create(String)",
9
+ "returns": {
10
+ "type": "Document",
11
+ "link": "https://developers.google.com/apps-script/reference/document/document"
12
+ }
13
+ },
14
+ "properties": {
15
+ "Attribute": {
16
+ "type": "Attribute",
17
+ "link": "https://developers.google.com/apps-script/reference/document/attribute"
18
+ }
19
+ }
20
+ },
21
+ "Bookmark": {
22
+ "methods": {
23
+ "getId": {
24
+ "link": "https://developers.google.com/apps-script/reference/document/bookmark#getId()",
25
+ "returns": {
26
+ "type": "String",
27
+ "link": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String"
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }