@mcpher/gas-fakes 1.2.32 → 2.0.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.
Files changed (49) hide show
  1. package/.gcloudignore +24 -0
  2. package/README.md +5 -5
  3. package/appsscript.json +101 -0
  4. package/exgcp.sh +4 -4
  5. package/package.json +5 -6
  6. package/src/cli/app.js +9 -1
  7. package/src/cli/lib-manager.js +0 -1
  8. package/src/cli/setup.js +330 -228
  9. package/src/services/advcalendar/clapis.js +4 -2
  10. package/src/services/advdocs/docapis.js +4 -3
  11. package/src/services/advdrive/drapis.js +8 -5
  12. package/src/services/advforms/formsapis.js +4 -3
  13. package/src/services/advgmail/gmailapis.js +4 -3
  14. package/src/services/advsheets/shapis.js +5 -10
  15. package/src/services/advslides/slapis.js +4 -3
  16. package/src/services/driveapp/fakedriveapp.js +10 -2
  17. package/src/services/logger/fakelogger.js +6 -3
  18. package/src/services/scriptapp/app.js +16 -11
  19. package/src/services/scriptapp/behavior.js +132 -107
  20. package/src/services/session/fakesession.js +24 -9
  21. package/src/services/slidesapp/fakepresentation.js +19 -8
  22. package/src/services/slidesapp/fakeslide.js +45 -20
  23. package/src/services/spreadsheetapp/fakesheet.js +9 -7
  24. package/src/services/stores/fakestores.js +20 -18
  25. package/src/services/stores/gasflex.js +13 -14
  26. package/src/services/urlfetchapp/app.js +3 -3
  27. package/src/support/auth.js +227 -55
  28. package/src/support/slogger.js +42 -0
  29. package/src/support/sxauth.js +42 -39
  30. package/src/support/sxcalendar.js +9 -43
  31. package/src/support/sxdocs.js +6 -42
  32. package/src/support/sxdrive.js +19 -76
  33. package/src/support/sxfetch.js +36 -30
  34. package/src/support/sxforms.js +9 -40
  35. package/src/support/sxgmail.js +9 -37
  36. package/src/support/sxretry.js +79 -0
  37. package/src/support/sxsheets.js +6 -37
  38. package/src/support/sxslides.js +5 -36
  39. package/src/support/sxtoken.js +15 -0
  40. package/src/support/syncit.js +27 -10
  41. package/src/support/workersync/sxfunctions.js +2 -0
  42. package/src/support/workersync/synclogger.js +22 -5
  43. package/src/support/workersync/worker.js +8 -11
  44. package/README.RU.md +0 -373
  45. package/env.setup.template +0 -16
  46. package/run.js +0 -35
  47. package/setup.js +0 -689
  48. package/src/Code.js +0 -3
  49. package/src/appsscript.json +0 -5
package/.gcloudignore ADDED
@@ -0,0 +1,24 @@
1
+ **/node_modules
2
+ **/private
3
+ testongas
4
+ **/.gas-fakes/store
5
+ **/.env*
6
+ ghissues
7
+ **/.gemini
8
+ .DS_Store
9
+ articles
10
+ # **/gasfakes.json
11
+ gprompts
12
+ **/gas-dist
13
+ **/bundle
14
+ .agent
15
+ _includes
16
+ doccreation
17
+ gasmess
18
+ src-gas
19
+ versionnotes
20
+ progress
21
+ **/*.md
22
+ **/*.sh
23
+ **/*.png
24
+ **/.git
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # <img src="./logo.png" alt="gas-fakes logo" width="50" align="top"> A proof of concept implementation of Apps Script Environment on Node
2
2
 
3
- I use clasp/vscode to develop Google Apps Script (GAS) applications, but when using GAS native services, there's way too much back and forwards to the GAS IDE going while testing. I set myself the ambition of implementing a fake version of the GAS runtime environment on Node so I could at least do some testing and debugging of Apps Scripts locally on Node.
3
+ I use clasp/antigravity to develop Google Apps Script (GAS) applications, but when using GAS native services, there's way too much back and forwards to the GAS IDE going while testing. I set myself the ambition of implementing a fake version of the GAS runtime environment on Node so I could at least do some testing and debugging of Apps Scripts locally on Node.
4
4
 
5
5
  This is a proof of concept so I've implemented a growing subset of number of services and methods. There are a rigorous set of tests for all emulated classes and methods to make sure the same code produces the same result on both Node and Apps Script. Please report any inconsistencies in the issues of this repo.
6
6
 
@@ -114,7 +114,8 @@ It contains a cloud logging query that will display any logging done in this ses
114
114
 
115
115
  #### A note on .env location
116
116
 
117
- Optionally you can set the initial Logging environment in your .env file. By default it assumes you want to log to the console only.
117
+ You will have used the gas-fakes init command to create a .env file, containing the LOG_DESTINATION setting. You can change any of the settings in the .env file manually if you want to.
118
+
118
119
  If you want to set an initial LOG_DESTINATION using that .env file, you have to let gas-fakes know where to find it. Let's assume it's in the same folder as your main script.
119
120
  ```env
120
121
  node --env-file=.env yourapp.js
@@ -155,16 +156,16 @@ As I mentioned earlier, to take this further, I'm going to need a lot of help to
155
156
 
156
157
  - [getting started](GETTING_STARTED.md) - how to handle authentication for restricted scopes.
157
158
  - [readme](README.md)
159
+ - [gas fakes cli](gas-fakes-cli.md)
160
+ - [running gas-fakes on google cloud run](cloud-run.md)
158
161
  - [initial idea and thoughts](https://ramblings.mcpher.com/a-proof-of-concept-implementation-of-apps-script-environment-on-node/)
159
162
  - [Inside the volatile world of a Google Document](https://ramblings.mcpher.com/inside-the-volatile-world-of-a-google-document/)
160
163
  - [Apps Script Services on Node – using apps script libraries](https://ramblings.mcpher.com/apps-script-services-on-node-using-apps-script-libraries/)
161
164
  - [Apps Script environment on Node – more services](https://ramblings.mcpher.com/apps-script-environment-on-node-more-services/)
162
165
  - [Turning async into synch on Node using workers](https://ramblings.mcpher.com/turning-async-into-synch-on-node-using-workers/)
163
166
  - [All about Apps Script Enums and how to fake them](https://ramblings.mcpher.com/all-about-apps-script-enums-and-how-to-fake-them/)
164
- - [Russian version](README.RU.md) ([credit Alex Ivanov](https://github.com/oshliaer)) - needs updating
165
167
  - [colaborators](collaborators.md) - additional information for collaborators
166
168
  - [oddities](oddities.md) - a collection of oddities uncovered during this project
167
- - [gemini](gemini-observations.md) - some reflections and experiences on using gemini to help code large projects
168
169
  - [named colors](named-colors.md)
169
170
  - [sandbox](sandbox.md)
170
171
  - [using apps script libraries with gas-fakes](libraries.md)
@@ -173,7 +174,6 @@ As I mentioned earlier, to take this further, I'm going to need a lot of help to
173
174
  - [named range identity](named-range-identity.md)
174
175
  - [adc and restricted scopes](https://ramblings.mcpher.com/how-to-allow-access-to-sensitive-scopes-with-application-default-credentials/)
175
176
  - [push test pull](pull-test-push.md)
176
- - [gas fakes cli](gas-fakes-cli.md)
177
177
  - [sharing cache and properties between gas-fakes and live apps script](https://ramblings.mcpher.com/sharing-cache-and-properties-between-gas-fakes-and-live-apps-script/)
178
178
  - [gas-fakes-cli now has built in mcp server and gemini extension](https://ramblings.mcpher.com/gas-fakes-cli-now-has-built-in-mcp-server-and-gemini-extension/)
179
179
  - [gas-fakes CLI: Run apps script code directly from your terminal](https://ramblings.mcpher.com/gas-fakes-cli-run-apps-script-code-directly-from-your-terminal/)
@@ -0,0 +1,101 @@
1
+ {
2
+ "timeZone": "Europe/London",
3
+ "exceptionLogging": "STACKDRIVER",
4
+ "runtimeVersion": "V8",
5
+ "oauthScopes": [
6
+ "https://www.googleapis.com/auth/cloud-platform",
7
+ "https://www.googleapis.com/auth/drive",
8
+ "https://www.googleapis.com/auth/script.external_request",
9
+ "https://www.googleapis.com/auth/spreadsheets",
10
+ "https://www.googleapis.com/auth/userinfo.email",
11
+ "https://www.googleapis.com/auth/documents",
12
+ "https://www.googleapis.com/auth/presentations",
13
+ "https://www.googleapis.com/auth/forms",
14
+ "https://mail.google.com/",
15
+ "openid",
16
+ "https://www.googleapis.com/auth/calendar"
17
+ ],
18
+ "dependencies": {
19
+ "libraries": [
20
+ {
21
+ "userSymbol": "bmPreFiddler",
22
+ "version": "34",
23
+ "libraryId": "13JUFGY18RHfjjuKmIRRfvmGlCYrEkEtN6uUm-iLUcxOUFRJD-WBX-tkR",
24
+ "developmentMode": false
25
+ },
26
+ {
27
+ "userSymbol": "bmUnitTester",
28
+ "version": "20",
29
+ "libraryId": "1zOlHMOpO89vqLPe5XpC-wzA9r5yaBkWt_qFjKqFNsIZtNJ-iUjBYDt-x"
30
+ },
31
+ {
32
+ "userSymbol": "bmIs",
33
+ "version": "1",
34
+ "libraryId": "1tFa7Gc68142wiiZaNmj0zA-ELDHh0q31eDXodeeCf1LxRR1LeSr3opAd"
35
+ },
36
+ {
37
+ "userSymbol": "bmFiddler",
38
+ "version": "30",
39
+ "libraryId": "13EWG4-lPrEf34itxQhAQ7b9JEbmCBfO8uE4Mhr99CHi3Pw65oxXtq-rU",
40
+ "developmentMode": false
41
+ },
42
+ {
43
+ "userSymbol": "bmGasFlexCache",
44
+ "libraryId": "1R_r9n4EGctvA8lWBZVeuT66mgaKBRV5IxfIsD_And-ra2H16iNXVWva0",
45
+ "version": "10"
46
+ }
47
+ ],
48
+ "enabledAdvancedServices": [
49
+ {
50
+ "userSymbol": "Sheets",
51
+ "version": "v4",
52
+ "serviceId": "sheets"
53
+ },
54
+ {
55
+ "userSymbol": "Docs",
56
+ "version": "v1",
57
+ "serviceId": "docs"
58
+ },
59
+ {
60
+ "userSymbol": "Slides",
61
+ "version": "v1",
62
+ "serviceId": "slides"
63
+ },
64
+ {
65
+ "userSymbol": "Gmail",
66
+ "version": "v1",
67
+ "serviceId": "gmail"
68
+ },
69
+ {
70
+ "userSymbol": "Chat",
71
+ "version": "v1",
72
+ "serviceId": "chat"
73
+ },
74
+ {
75
+ "userSymbol": "People",
76
+ "version": "v1",
77
+ "serviceId": "peopleapi"
78
+ },
79
+ {
80
+ "userSymbol": "Tasks",
81
+ "version": "v1",
82
+ "serviceId": "tasks"
83
+ },
84
+ {
85
+ "userSymbol": "Calendar",
86
+ "version": "v3",
87
+ "serviceId": "calendar"
88
+ },
89
+ {
90
+ "userSymbol": "WorkspaceEvents",
91
+ "version": "v1",
92
+ "serviceId": "workspaceevents"
93
+ },
94
+ {
95
+ "userSymbol": "Drive",
96
+ "version": "v3",
97
+ "serviceId": "drive"
98
+ }
99
+ ]
100
+ }
101
+ }
package/exgcp.sh CHANGED
@@ -17,13 +17,13 @@ if [ ! -f "$ENV_FILE" ]; then
17
17
  fi
18
18
 
19
19
  # Read the GCP_PROJECT_ID, remove quotes, and handle potential carriage returns
20
- GCP_PROJECT_ID_VALUE=$(grep -E '^GCP_PROJECT_ID=' "$ENV_FILE" | cut -d '=' -f2 | tr -d '"\r')
20
+ GOOGLE_CLOUD_PROJECT_VALUE=$(grep -E '^GOOGLE_CLOUD_PROJECT=' "$ENV_FILE" | cut -d '=' -f2 | tr -d '"\r')
21
21
  GEMINI_API_KEY_VALUE=$(grep -E '^GEMINI_API_KEY=' "$ENV_FILE" | cut -d '=' -f2 | tr -d '"\r')
22
22
  GEMINI_MODEL_VALUE=$(grep -E '^GEMINI_MODEL=' "$ENV_FILE" | cut -d '=' -f2 | tr -d '"\r')
23
23
  OMDB_API_KEY_VALUE=$(grep -E '^OMDB_API_KEY=' "$ENV_FILE" | cut -d '=' -f2 | tr -d '"\r')
24
24
  # Check if a value was extracted
25
- if [ -z "$GCP_PROJECT_ID_VALUE" ]; then
26
- echo "Error: GCP_PROJECT_ID not found or is empty in $ENV_FILE."
25
+ if [ -z "$GOOGLE_CLOUD_PROJECT_VALUE" ]; then
26
+ echo "Error: GOOGLE_CLOUD_PROJECT not found or is empty in $ENV_FILE."
27
27
  return 1
28
28
  fi
29
29
 
@@ -49,6 +49,6 @@ else
49
49
  fi
50
50
 
51
51
  # Export the variable for the current session
52
- export GOOGLE_CLOUD_PROJECT="$GCP_PROJECT_ID_VALUE"
52
+ export GOOGLE_CLOUD_PROJECT="$GOOGLE_CLOUD_PROJECT_VALUE"
53
53
 
54
54
  echo "exported: GOOGLE_CLOUD_PROJECT=$GOOGLE_CLOUD_PROJECT"
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  },
5
5
  "dependencies": {
6
6
  "@mcpher/fake-gasenum": "^1.0.6",
7
- "@mcpher/gas-flex-cache": "^1.1.3",
7
+ "@mcpher/gas-flex-cache": "^1.1.4",
8
8
  "@modelcontextprotocol/sdk": "^1.20.2",
9
9
  "@sindresorhus/is": "^7.0.1",
10
10
  "acorn": "^8.15.0",
@@ -13,7 +13,7 @@
13
13
  "dotenv": "^17.2.3",
14
14
  "fast-xml-parser": "^5.3.0",
15
15
  "get-stream": "^9.0.1",
16
- "googleapis": "^161.0.0",
16
+ "googleapis": "^170.1.0",
17
17
  "got": "^14.4.7",
18
18
  "into-stream": "^8.0.1",
19
19
  "keyv": "^5.5.0",
@@ -21,7 +21,6 @@
21
21
  "mime": "^4.0.7",
22
22
  "prompts": "^2.4.2",
23
23
  "sleep-synchronously": "^2.0.0",
24
- "tape": "^5.9.0",
25
24
  "unzipper": "^0.12.3",
26
25
  "zod": "^3.25.76"
27
26
  },
@@ -34,13 +33,13 @@
34
33
  },
35
34
  "name": "@mcpher/gas-fakes",
36
35
  "author": "bruce mcpherson",
37
- "version": "1.2.32",
36
+ "version": "2.0.1",
38
37
  "license": "MIT",
39
38
  "main": "main.js",
40
- "description": "A proof of concept implementation of Apps Script Environment on Node",
39
+ "description": "An implementation of the Google Workspace Apps Script runtime: Run native App Script Code on Node and Cloud Run",
41
40
  "repository": "github:brucemcpherson/gas-fakes",
42
41
  "homepage": "https://ramblings.mcpher.com/a-proof-of-concept-implementation-of-apps-script-environment-on-node/",
43
42
  "bin": {
44
43
  "gas-fakes": "gas-fakes.js"
45
44
  }
46
- }
45
+ }
package/src/cli/app.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Command } from "commander";
1
+ import { Command, Option } from "commander";
2
2
  import dotenv from "dotenv";
3
3
  import path from "path";
4
4
  import { VERSION, buildSandboxConfig } from "./utils.js";
@@ -127,6 +127,14 @@ export async function main() {
127
127
  .command("init")
128
128
  .description("Initializes the configuration (.env).")
129
129
  .option("-e, --env <path>", "Path to a custom .env file.")
130
+ .addOption(
131
+ new Option(
132
+ "--at,--auth-type <string>",
133
+ "Use Domain Wide Delegation (dwd) or Application Default Credentials (adc) for authentication (default)."
134
+ )
135
+ .choices(["dwd", "adc"])
136
+ .default("dwd")
137
+ )
130
138
  .action(initializeConfiguration);
131
139
 
132
140
  program
@@ -8,7 +8,6 @@ async function getAccessToken(pattern) {
8
8
  // Authorization pattern 1
9
9
  const auth = await Auth.setAuth(
10
10
  ["https://www.googleapis.com/auth/drive.readonly"],
11
- null,
12
11
  true
13
12
  );
14
13
  auth.cachedCredential = null;