@mcpher/gas-fakes 1.1.4 → 1.1.6
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/README.md +16 -89
- package/env.setup.template +16 -0
- package/gasmess/bruce/d.js +1 -1
- package/gasmess/bruce/package-lock.json +16 -213
- package/gasmess/bruce/package.json +4 -3
- package/gasmess/bruce/testlogging.js +7 -1
- package/package.json +2 -3
- package/src/services/advdocs/docapis.js +1 -1
- package/src/services/advdrive/drapis.js +1 -1
- package/src/services/advforms/formsapis.js +1 -1
- package/src/services/advgmail/fakeadvgmaildrafts.js +31 -0
- package/src/services/advgmail/fakeadvgmailusers.js +5 -0
- package/src/services/advgmail/gmailapis.js +1 -1
- package/src/services/advsheets/shapis.js +1 -1
- package/src/services/advslides/slapis.js +1 -1
- package/src/services/gmailapp/fakegmailapp.js +26 -0
- package/src/services/gmailapp/fakegmaildraft.js +30 -0
- package/src/services/logger/fakelogger.js +55 -35
- package/src/support/auth.js +20 -25
- package/src/support/sxauth.js +7 -32
- package/src/support/sxdrive.js +2 -0
- package/src/support/syncit.js +1 -5
- package/src/support/workersync/sxfunctions.js +1 -1
- package/src/support/workersync/synchronizer.js +52 -16
- package/src/support/workersync/worker.js +39 -13
- package/src/support/sxlogger.js +0 -41
package/README.md
CHANGED
|
@@ -1,110 +1,37 @@
|
|
|
1
|
-
# A proof of concept implementation of Apps Script Environment on Node
|
|
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
|
|
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.
|
|
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
|
|
|
7
7
|
|
|
8
8
|
## Getting started as a package user
|
|
9
9
|
|
|
10
|
-
You can get the package from npm
|
|
11
|
-
|
|
10
|
+
You can get the package from npm:
|
|
12
11
|
```sh
|
|
13
12
|
npm i @mcpher/gas-fakes
|
|
14
13
|
```
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
For a complete guide on how to set up your local environment for authentication and development, please see the consolidated guide: [Getting Started with `gas-fakes`](gas-fakes/GETTING_STARTED.md)
|
|
16
|
+
|
|
17
|
+
Collaborators should fork the repo and use the local versions of these files - see collaborators info.
|
|
17
18
|
|
|
18
19
|
### Use exactly the same code as in Apps Script
|
|
19
20
|
|
|
20
21
|
Just as on Apps Script, everything is executed synchronously so you don't need to bother with handling Promises/async/await. Just write normal Apps Script code. Usually you would have an associated App Script project if that's your eventual target, but it's not essential that you do. You can get started right away on Node.
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
### Cloud project
|
|
24
|
-
|
|
25
|
-
You don't have access to GAS maintained cloud projects from Node, so you'll need to create a GCP project to use locally (or you can use it on Apps Script too if you prefer) that has the workspace APIs enabled (Drive, Docs, Sheets etc).
|
|
26
|
-
|
|
27
|
-
### .env and shell script helpers
|
|
28
|
-
|
|
29
|
-
In order to duplicate the OAuth management handled by GAS, we'll use Application Default Credentials. I've provided a handy shell that will take care of all this for you.
|
|
30
|
-
|
|
31
|
-
- Get this [folder](https://github.com/brucemcpherson/gas-fakes/tree/main/shells) into the ./shells folder of your project.
|
|
32
|
-
- Get this [env template](https://github.com/brucemcpherson/gas-fakes/blob/main/shells/.env.template) and copy it/add it to your .env file in your project
|
|
33
|
-
|
|
34
|
-
#### Application default credentials
|
|
35
|
-
|
|
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
|
-
#### Your .env file
|
|
41
|
-
|
|
42
|
-
You can setup the .env file your self using the .env.template as a guide.
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
# must set these
|
|
46
|
-
GCP_PROJECT_ID="add your gcp project id here"
|
|
47
|
-
|
|
48
|
-
# optional reference if you want to run a test after setting up
|
|
49
|
-
DRIVE_TEST_FILE_ID="add the id of some test file you have access to here"
|
|
50
|
-
|
|
51
|
-
# we'll use the default config for application default credentials
|
|
52
|
-
# probably dont need to change these
|
|
53
|
-
AC=default
|
|
54
|
-
# these are the scopes set by default - take some of these out if you want to minimize access
|
|
55
|
-
DEFAULT_SCOPES="https://www.googleapis.com/auth/userinfo.email,openid,https://www.googleapis.com/auth/cloud-platform"
|
|
56
|
-
EXTRA_SCOPES=",https://www.googleapis.com/auth/drive,https://www.googleapis.com/auth/spreadsheets"
|
|
57
|
-
|
|
58
|
-
# optional logging destination
|
|
59
|
-
# can be CONSOLE (default), CLOUD, BOTH, NONE
|
|
60
|
-
LOG_DESTINATION="BOTH"
|
|
61
|
-
|
|
62
|
-
```
|
|
63
|
-
#### Applying the .env
|
|
64
|
-
|
|
65
|
-
You can run
|
|
66
|
-
```bash
|
|
67
|
-
cd shells
|
|
68
|
-
bash setaccounts.sh
|
|
69
|
-
```
|
|
70
|
-
Which will set up and test the initial application default login with the selected scopes.
|
|
71
|
-
|
|
72
|
-
#### enabling workspace services
|
|
73
|
-
|
|
74
|
-
You can run this shell to enable all the required cloud services
|
|
75
|
-
```bash
|
|
76
|
-
cd shells
|
|
77
|
-
bash enable.sh
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
#### Restricted scopes
|
|
81
|
-
|
|
82
|
-
Recent changes in the OAuth security model have made it more difficult for Application Default credentials to work with all the scopes we'll need to fully emulate Live Apps Script locally. However there is a way to work around this by creating an oauth client for internal use in the cloud console, and injecting its credentials into those used by the application default creadentials process. You should now follow the guidance in [restricted scopes](restricted_scopes.md) to enhance your login process to be able access all the supported services in gas-fakes
|
|
83
|
-
|
|
84
|
-
#### Manifest file
|
|
85
|
-
|
|
86
|
-
If you have an associated apps script project, you'll probably be using clasp to sync with the apps script IDE, and you'll have an appsscript.json available in your project folder
|
|
87
|
-
|
|
88
|
-
**gas-fakes** reads the manifest file to see which scopes you need in your project, uses the Google Auth library to attempt to authorizes them and has `ScriptApp.getOauthToken()` return a sufficiently specced token, just as the GAS environment does. Just make sure you have an `appsscript.json` in the same folder as your main script.
|
|
89
|
-
|
|
90
|
-
Now you can execute this and it will set up your ADC to be able to run any services that require the scopes you add.
|
|
91
|
-
|
|
92
|
-
##### note
|
|
93
|
-
|
|
94
|
-
Although you may be tempted to add `https://www.googleapis.com/auth/script.external_request`, it's not necessary for the ADC and in fact will generate an error. You will of course need it in your Apps script manifest. Same goes for "https://www.googleapis.com/auth/documents" and "https://www.googleapis.com/auth/documents"
|
|
95
|
-
|
|
96
23
|
### Settings
|
|
97
24
|
|
|
98
|
-
|
|
25
|
+
The optional `gasfakes.json` file holds various location and behavior parameters for your local Node environment. It is not required on GAS, as you can't change anything over there. If you don't provide this file, `gas-fakes` will create one for you with sensible defaults.
|
|
99
26
|
|
|
100
|
-
```
|
|
27
|
+
```json
|
|
101
28
|
{
|
|
102
29
|
"manifest": "./appsscript.json",
|
|
103
30
|
"clasp": "./.clasp.json",
|
|
104
31
|
"documentId": null,
|
|
105
32
|
"cache": "/tmp/gas-fakes/cache",
|
|
106
33
|
"properties": "/tmp/gas-fakes/properties",
|
|
107
|
-
"scriptId": "
|
|
34
|
+
"scriptId": "a-unique-id-for-your-local-project"
|
|
108
35
|
}
|
|
109
36
|
```
|
|
110
37
|
|
|
@@ -182,7 +109,7 @@ If you want to set an initial LOG_DESTINATION using that .env file, you have to
|
|
|
182
109
|
```env
|
|
183
110
|
node --env-file=.env yourapp.js
|
|
184
111
|
```
|
|
185
|
-
Some developers prefer to use
|
|
112
|
+
Some developers prefer to use dotenv to set the path of the .env file
|
|
186
113
|
```javascript
|
|
187
114
|
import dotenv from 'dotenv'
|
|
188
115
|
dotenv.config({ path: '/custom/path/to/.env' })
|
|
@@ -213,11 +140,12 @@ For inspiration on pushing modified files to the IDE, see the togas.sh bash scri
|
|
|
213
140
|
|
|
214
141
|
As I mentioned earlier, to take this further, I'm going to need a lot of help to extend the methods and services supported - so if you feel this would be useful to you, and would like to collaborate, please ping me on bruce@mcpher.com and we'll talk.
|
|
215
142
|
|
|
216
|
-
##
|
|
217
|
-
|
|
143
|
+
## <img src="./logo.png" alt="gas-fakes logo" width="50" align="top"> Further Reading
|
|
218
144
|
|
|
145
|
+
- [getting started](GETTING_STARTED.md) - how to handle authentication for restricted scopes.
|
|
146
|
+
- [readme](README.md)
|
|
219
147
|
- [initial idea and thoughts](https://ramblings.mcpher.com/a-proof-of-concept-implementation-of-apps-script-environment-on-node/)
|
|
220
|
-
- [Inside the volatile world of a Google Document](https://ramblings.mcpher.com/inside-the-volatile-world-of-a-google-document/
|
|
148
|
+
- [Inside the volatile world of a Google Document](https://ramblings.mcpher.com/inside-the-volatile-world-of-a-google-document/)
|
|
221
149
|
- [Apps Script Services on Node – using apps script libraries](https://ramblings.mcpher.com/apps-script-services-on-node-using-apps-script-libraries/)
|
|
222
150
|
- [Apps Script environment on Node – more services](https://ramblings.mcpher.com/apps-script-environment-on-node-more-services/)
|
|
223
151
|
- [Turning async into synch on Node using workers](https://ramblings.mcpher.com/turning-async-into-synch-on-node-using-workers/)
|
|
@@ -226,8 +154,7 @@ As I mentioned earlier, to take this further, I'm going to need a lot of help to
|
|
|
226
154
|
- [colaborators](collaborators.md) - additional information for collaborators
|
|
227
155
|
- [oddities](oddities.md) - a collection of oddities uncovered during this project
|
|
228
156
|
- [gemini](gemini.md) - some reflections and experiences on using gemini to help code large projects
|
|
229
|
-
- [named colors](named-colors.md) - colors supported by Apps Script
|
|
230
|
-
- [this file](README.md)
|
|
231
157
|
- [named colors](named-colors.md)
|
|
232
158
|
- [sandbox](sandbox.md)
|
|
233
|
-
- [named range identity](named-range-identity.md)
|
|
159
|
+
- [named range identity](named-range-identity.md)
|
|
160
|
+
- [adc and restricted scopes](https://ramblings.mcpher.com/how-to-allow-access-to-sensitive-scopes-with-application-default-credentials/)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# for testing authentication
|
|
2
|
+
GCP_PROJECT_ID="add your gcp project id here"
|
|
3
|
+
|
|
4
|
+
# this is optional
|
|
5
|
+
DRIVE_TEST_FILE_ID="add the id of some test file you have access to here"
|
|
6
|
+
|
|
7
|
+
# we'll use the default config for application default credentials
|
|
8
|
+
AC=default
|
|
9
|
+
# these are the scopes set by default - take some of these out if you want to minimize access
|
|
10
|
+
DEFAULT_SCOPES="https://www.googleapis.com/auth/userinfo.email,openid,https://www.googleapis.com/auth/cloud-platform"
|
|
11
|
+
EXTRA_SCOPES=",https://www.googleapis.com/auth/drive,https://www.googleapis.com/auth/spreadsheets,https://www.googleapis.com/auth/gmail.labels"
|
|
12
|
+
|
|
13
|
+
# if you need access to sensitive or restricted scopes you'll need to provide a credentials file
|
|
14
|
+
# this is a path relative to the project root, or an absolute path
|
|
15
|
+
CLIENT_CREDENTIAL_FILE="private/gasfakes-oa.json"
|
|
16
|
+
LOG_DESTINATION="CONSOLE"
|
package/gasmess/bruce/d.js
CHANGED
|
@@ -9,9 +9,7 @@
|
|
|
9
9
|
"version": "1.0.0",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@mcpher/gas-fakes": "
|
|
13
|
-
"google-auth-library": ">=9.0.0",
|
|
14
|
-
"googleapis": ">=157.0.0"
|
|
12
|
+
"@mcpher/gas-fakes": "file:../../mcpher-gas-fakes-1.1.4.tgz"
|
|
15
13
|
}
|
|
16
14
|
},
|
|
17
15
|
"node_modules/@fast-csv/format": {
|
|
@@ -63,36 +61,6 @@
|
|
|
63
61
|
"node": ">=14.0.0"
|
|
64
62
|
}
|
|
65
63
|
},
|
|
66
|
-
"node_modules/@google-cloud/common/node_modules/google-auth-library": {
|
|
67
|
-
"version": "9.15.1",
|
|
68
|
-
"resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-9.15.1.tgz",
|
|
69
|
-
"integrity": "sha512-Jb6Z0+nvECVz+2lzSMt9u98UsoakXxA2HGHMCxh+so3n90XgYWkq5dur19JAJV7ONiJY22yBTyJB1TSkvPq9Ng==",
|
|
70
|
-
"license": "Apache-2.0",
|
|
71
|
-
"dependencies": {
|
|
72
|
-
"base64-js": "^1.3.0",
|
|
73
|
-
"ecdsa-sig-formatter": "^1.0.11",
|
|
74
|
-
"gaxios": "^6.1.1",
|
|
75
|
-
"gcp-metadata": "^6.1.0",
|
|
76
|
-
"gtoken": "^7.0.0",
|
|
77
|
-
"jws": "^4.0.0"
|
|
78
|
-
},
|
|
79
|
-
"engines": {
|
|
80
|
-
"node": ">=14"
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
"node_modules/@google-cloud/common/node_modules/gtoken": {
|
|
84
|
-
"version": "7.1.0",
|
|
85
|
-
"resolved": "https://registry.npmjs.org/gtoken/-/gtoken-7.1.0.tgz",
|
|
86
|
-
"integrity": "sha512-pCcEwRi+TKpMlxAQObHDQ56KawURgyAf6jtIY046fJ5tIv3zDe/LEIubckAO8fj6JnAxLdmWkUfNyulQ2iKdEw==",
|
|
87
|
-
"license": "MIT",
|
|
88
|
-
"dependencies": {
|
|
89
|
-
"gaxios": "^6.0.0",
|
|
90
|
-
"jws": "^4.0.0"
|
|
91
|
-
},
|
|
92
|
-
"engines": {
|
|
93
|
-
"node": ">=14.0.0"
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
64
|
"node_modules/@google-cloud/logging": {
|
|
97
65
|
"version": "11.2.1",
|
|
98
66
|
"resolved": "https://registry.npmjs.org/@google-cloud/logging/-/logging-11.2.1.tgz",
|
|
@@ -120,36 +88,6 @@
|
|
|
120
88
|
"node": ">=14.0.0"
|
|
121
89
|
}
|
|
122
90
|
},
|
|
123
|
-
"node_modules/@google-cloud/logging/node_modules/google-auth-library": {
|
|
124
|
-
"version": "9.15.1",
|
|
125
|
-
"resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-9.15.1.tgz",
|
|
126
|
-
"integrity": "sha512-Jb6Z0+nvECVz+2lzSMt9u98UsoakXxA2HGHMCxh+so3n90XgYWkq5dur19JAJV7ONiJY22yBTyJB1TSkvPq9Ng==",
|
|
127
|
-
"license": "Apache-2.0",
|
|
128
|
-
"dependencies": {
|
|
129
|
-
"base64-js": "^1.3.0",
|
|
130
|
-
"ecdsa-sig-formatter": "^1.0.11",
|
|
131
|
-
"gaxios": "^6.1.1",
|
|
132
|
-
"gcp-metadata": "^6.1.0",
|
|
133
|
-
"gtoken": "^7.0.0",
|
|
134
|
-
"jws": "^4.0.0"
|
|
135
|
-
},
|
|
136
|
-
"engines": {
|
|
137
|
-
"node": ">=14"
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
"node_modules/@google-cloud/logging/node_modules/gtoken": {
|
|
141
|
-
"version": "7.1.0",
|
|
142
|
-
"resolved": "https://registry.npmjs.org/gtoken/-/gtoken-7.1.0.tgz",
|
|
143
|
-
"integrity": "sha512-pCcEwRi+TKpMlxAQObHDQ56KawURgyAf6jtIY046fJ5tIv3zDe/LEIubckAO8fj6JnAxLdmWkUfNyulQ2iKdEw==",
|
|
144
|
-
"license": "MIT",
|
|
145
|
-
"dependencies": {
|
|
146
|
-
"gaxios": "^6.0.0",
|
|
147
|
-
"jws": "^4.0.0"
|
|
148
|
-
},
|
|
149
|
-
"engines": {
|
|
150
|
-
"node": ">=14.0.0"
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
91
|
"node_modules/@google-cloud/paginator": {
|
|
154
92
|
"version": "5.0.2",
|
|
155
93
|
"resolved": "https://registry.npmjs.org/@google-cloud/paginator/-/paginator-5.0.2.tgz",
|
|
@@ -269,9 +207,9 @@
|
|
|
269
207
|
"integrity": "sha512-ExCSyt7a7wPIsaz/IZdjMElD3bQW3lNaoXhtmVwt2ozzwbEdWe5f7yueN1MtBR+bDfpWqK4v6dS0QxkmlB/Xnw=="
|
|
270
208
|
},
|
|
271
209
|
"node_modules/@mcpher/gas-fakes": {
|
|
272
|
-
"version": "1.1.
|
|
273
|
-
"resolved": "
|
|
274
|
-
"integrity": "sha512-
|
|
210
|
+
"version": "1.1.4",
|
|
211
|
+
"resolved": "file:../../mcpher-gas-fakes-1.1.4.tgz",
|
|
212
|
+
"integrity": "sha512-6K4xBup1O0AoqR/OCRfbncYbtubSXpz8mjGV/jcQyxlWJzerpodqgQleq2jCDHpFfW7cUF0B18ImPJHNoVpYmg==",
|
|
275
213
|
"license": "MIT",
|
|
276
214
|
"dependencies": {
|
|
277
215
|
"@google-cloud/logging": "^11.2.1",
|
|
@@ -281,7 +219,7 @@
|
|
|
281
219
|
"exceljs": "^4.4.0",
|
|
282
220
|
"fast-json-stable-stringify": "^2.1.0",
|
|
283
221
|
"get-stream": "^9.0.1",
|
|
284
|
-
"googleapis": "^
|
|
222
|
+
"googleapis": "^161.0.0",
|
|
285
223
|
"got": "^14.4.7",
|
|
286
224
|
"into-stream": "^8.0.1",
|
|
287
225
|
"is": "^3.3.2",
|
|
@@ -297,23 +235,6 @@
|
|
|
297
235
|
},
|
|
298
236
|
"engines": {
|
|
299
237
|
"node": ">=20.11.0"
|
|
300
|
-
},
|
|
301
|
-
"peerDependencies": {
|
|
302
|
-
"google-auth-library": ">=9.0.0",
|
|
303
|
-
"googleapis": ">=157.0.0"
|
|
304
|
-
}
|
|
305
|
-
},
|
|
306
|
-
"node_modules/@mcpher/gas-fakes/node_modules/googleapis": {
|
|
307
|
-
"version": "157.0.0",
|
|
308
|
-
"resolved": "https://registry.npmjs.org/googleapis/-/googleapis-157.0.0.tgz",
|
|
309
|
-
"integrity": "sha512-0q6V93amJANRu1BRkeG6eftrAxweM7ZLbgRshmRg2zLSPpPLaRiDFCckHpEOFspXGglfw8l+hZql7NgWPwAwfQ==",
|
|
310
|
-
"license": "Apache-2.0",
|
|
311
|
-
"dependencies": {
|
|
312
|
-
"google-auth-library": "^10.2.0",
|
|
313
|
-
"googleapis-common": "^8.0.0"
|
|
314
|
-
},
|
|
315
|
-
"engines": {
|
|
316
|
-
"node": ">=18"
|
|
317
238
|
}
|
|
318
239
|
},
|
|
319
240
|
"node_modules/@opentelemetry/api": {
|
|
@@ -2000,78 +1921,22 @@
|
|
|
2000
1921
|
}
|
|
2001
1922
|
},
|
|
2002
1923
|
"node_modules/google-auth-library": {
|
|
2003
|
-
"version": "
|
|
2004
|
-
"resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-
|
|
2005
|
-
"integrity": "sha512-
|
|
1924
|
+
"version": "9.15.1",
|
|
1925
|
+
"resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-9.15.1.tgz",
|
|
1926
|
+
"integrity": "sha512-Jb6Z0+nvECVz+2lzSMt9u98UsoakXxA2HGHMCxh+so3n90XgYWkq5dur19JAJV7ONiJY22yBTyJB1TSkvPq9Ng==",
|
|
2006
1927
|
"license": "Apache-2.0",
|
|
2007
1928
|
"dependencies": {
|
|
2008
1929
|
"base64-js": "^1.3.0",
|
|
2009
1930
|
"ecdsa-sig-formatter": "^1.0.11",
|
|
2010
|
-
"gaxios": "^
|
|
2011
|
-
"gcp-metadata": "^
|
|
2012
|
-
"
|
|
2013
|
-
"gtoken": "^8.0.0",
|
|
1931
|
+
"gaxios": "^6.1.1",
|
|
1932
|
+
"gcp-metadata": "^6.1.0",
|
|
1933
|
+
"gtoken": "^7.0.0",
|
|
2014
1934
|
"jws": "^4.0.0"
|
|
2015
1935
|
},
|
|
2016
|
-
"engines": {
|
|
2017
|
-
"node": ">=18"
|
|
2018
|
-
}
|
|
2019
|
-
},
|
|
2020
|
-
"node_modules/google-auth-library/node_modules/gaxios": {
|
|
2021
|
-
"version": "7.1.2",
|
|
2022
|
-
"resolved": "https://registry.npmjs.org/gaxios/-/gaxios-7.1.2.tgz",
|
|
2023
|
-
"integrity": "sha512-/Szrn8nr+2TsQT1Gp8iIe/BEytJmbyfrbFh419DfGQSkEgNEhbPi7JRJuughjkTzPWgU9gBQf5AVu3DbHt0OXA==",
|
|
2024
|
-
"license": "Apache-2.0",
|
|
2025
|
-
"dependencies": {
|
|
2026
|
-
"extend": "^3.0.2",
|
|
2027
|
-
"https-proxy-agent": "^7.0.1",
|
|
2028
|
-
"node-fetch": "^3.3.2"
|
|
2029
|
-
},
|
|
2030
|
-
"engines": {
|
|
2031
|
-
"node": ">=18"
|
|
2032
|
-
}
|
|
2033
|
-
},
|
|
2034
|
-
"node_modules/google-auth-library/node_modules/gcp-metadata": {
|
|
2035
|
-
"version": "7.0.1",
|
|
2036
|
-
"resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-7.0.1.tgz",
|
|
2037
|
-
"integrity": "sha512-UcO3kefx6dCcZkgcTGgVOTFb7b1LlQ02hY1omMjjrrBzkajRMCFgYOjs7J71WqnuG1k2b+9ppGL7FsOfhZMQKQ==",
|
|
2038
|
-
"license": "Apache-2.0",
|
|
2039
|
-
"dependencies": {
|
|
2040
|
-
"gaxios": "^7.0.0",
|
|
2041
|
-
"google-logging-utils": "^1.0.0",
|
|
2042
|
-
"json-bigint": "^1.0.0"
|
|
2043
|
-
},
|
|
2044
|
-
"engines": {
|
|
2045
|
-
"node": ">=18"
|
|
2046
|
-
}
|
|
2047
|
-
},
|
|
2048
|
-
"node_modules/google-auth-library/node_modules/google-logging-utils": {
|
|
2049
|
-
"version": "1.1.1",
|
|
2050
|
-
"resolved": "https://registry.npmjs.org/google-logging-utils/-/google-logging-utils-1.1.1.tgz",
|
|
2051
|
-
"integrity": "sha512-rcX58I7nqpu4mbKztFeOAObbomBbHU2oIb/d3tJfF3dizGSApqtSwYJigGCooHdnMyQBIw8BrWyK96w3YXgr6A==",
|
|
2052
|
-
"license": "Apache-2.0",
|
|
2053
1936
|
"engines": {
|
|
2054
1937
|
"node": ">=14"
|
|
2055
1938
|
}
|
|
2056
1939
|
},
|
|
2057
|
-
"node_modules/google-auth-library/node_modules/node-fetch": {
|
|
2058
|
-
"version": "3.3.2",
|
|
2059
|
-
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz",
|
|
2060
|
-
"integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
|
|
2061
|
-
"license": "MIT",
|
|
2062
|
-
"dependencies": {
|
|
2063
|
-
"data-uri-to-buffer": "^4.0.0",
|
|
2064
|
-
"fetch-blob": "^3.1.4",
|
|
2065
|
-
"formdata-polyfill": "^4.0.10"
|
|
2066
|
-
},
|
|
2067
|
-
"engines": {
|
|
2068
|
-
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
2069
|
-
},
|
|
2070
|
-
"funding": {
|
|
2071
|
-
"type": "opencollective",
|
|
2072
|
-
"url": "https://opencollective.com/node-fetch"
|
|
2073
|
-
}
|
|
2074
|
-
},
|
|
2075
1940
|
"node_modules/google-gax": {
|
|
2076
1941
|
"version": "4.6.1",
|
|
2077
1942
|
"resolved": "https://registry.npmjs.org/google-gax/-/google-gax-4.6.1.tgz",
|
|
@@ -2095,36 +1960,6 @@
|
|
|
2095
1960
|
"node": ">=14"
|
|
2096
1961
|
}
|
|
2097
1962
|
},
|
|
2098
|
-
"node_modules/google-gax/node_modules/google-auth-library": {
|
|
2099
|
-
"version": "9.15.1",
|
|
2100
|
-
"resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-9.15.1.tgz",
|
|
2101
|
-
"integrity": "sha512-Jb6Z0+nvECVz+2lzSMt9u98UsoakXxA2HGHMCxh+so3n90XgYWkq5dur19JAJV7ONiJY22yBTyJB1TSkvPq9Ng==",
|
|
2102
|
-
"license": "Apache-2.0",
|
|
2103
|
-
"dependencies": {
|
|
2104
|
-
"base64-js": "^1.3.0",
|
|
2105
|
-
"ecdsa-sig-formatter": "^1.0.11",
|
|
2106
|
-
"gaxios": "^6.1.1",
|
|
2107
|
-
"gcp-metadata": "^6.1.0",
|
|
2108
|
-
"gtoken": "^7.0.0",
|
|
2109
|
-
"jws": "^4.0.0"
|
|
2110
|
-
},
|
|
2111
|
-
"engines": {
|
|
2112
|
-
"node": ">=14"
|
|
2113
|
-
}
|
|
2114
|
-
},
|
|
2115
|
-
"node_modules/google-gax/node_modules/gtoken": {
|
|
2116
|
-
"version": "7.1.0",
|
|
2117
|
-
"resolved": "https://registry.npmjs.org/gtoken/-/gtoken-7.1.0.tgz",
|
|
2118
|
-
"integrity": "sha512-pCcEwRi+TKpMlxAQObHDQ56KawURgyAf6jtIY046fJ5tIv3zDe/LEIubckAO8fj6JnAxLdmWkUfNyulQ2iKdEw==",
|
|
2119
|
-
"license": "MIT",
|
|
2120
|
-
"dependencies": {
|
|
2121
|
-
"gaxios": "^6.0.0",
|
|
2122
|
-
"jws": "^4.0.0"
|
|
2123
|
-
},
|
|
2124
|
-
"engines": {
|
|
2125
|
-
"node": ">=14.0.0"
|
|
2126
|
-
}
|
|
2127
|
-
},
|
|
2128
1963
|
"node_modules/google-logging-utils": {
|
|
2129
1964
|
"version": "0.0.2",
|
|
2130
1965
|
"resolved": "https://registry.npmjs.org/google-logging-utils/-/google-logging-utils-0.0.2.tgz",
|
|
@@ -2239,48 +2074,16 @@
|
|
|
2239
2074
|
"license": "ISC"
|
|
2240
2075
|
},
|
|
2241
2076
|
"node_modules/gtoken": {
|
|
2242
|
-
"version": "
|
|
2243
|
-
"resolved": "https://registry.npmjs.org/gtoken/-/gtoken-
|
|
2244
|
-
"integrity": "sha512
|
|
2077
|
+
"version": "7.1.0",
|
|
2078
|
+
"resolved": "https://registry.npmjs.org/gtoken/-/gtoken-7.1.0.tgz",
|
|
2079
|
+
"integrity": "sha512-pCcEwRi+TKpMlxAQObHDQ56KawURgyAf6jtIY046fJ5tIv3zDe/LEIubckAO8fj6JnAxLdmWkUfNyulQ2iKdEw==",
|
|
2245
2080
|
"license": "MIT",
|
|
2246
2081
|
"dependencies": {
|
|
2247
|
-
"gaxios": "^
|
|
2082
|
+
"gaxios": "^6.0.0",
|
|
2248
2083
|
"jws": "^4.0.0"
|
|
2249
2084
|
},
|
|
2250
2085
|
"engines": {
|
|
2251
|
-
"node": ">=
|
|
2252
|
-
}
|
|
2253
|
-
},
|
|
2254
|
-
"node_modules/gtoken/node_modules/gaxios": {
|
|
2255
|
-
"version": "7.1.2",
|
|
2256
|
-
"resolved": "https://registry.npmjs.org/gaxios/-/gaxios-7.1.2.tgz",
|
|
2257
|
-
"integrity": "sha512-/Szrn8nr+2TsQT1Gp8iIe/BEytJmbyfrbFh419DfGQSkEgNEhbPi7JRJuughjkTzPWgU9gBQf5AVu3DbHt0OXA==",
|
|
2258
|
-
"license": "Apache-2.0",
|
|
2259
|
-
"dependencies": {
|
|
2260
|
-
"extend": "^3.0.2",
|
|
2261
|
-
"https-proxy-agent": "^7.0.1",
|
|
2262
|
-
"node-fetch": "^3.3.2"
|
|
2263
|
-
},
|
|
2264
|
-
"engines": {
|
|
2265
|
-
"node": ">=18"
|
|
2266
|
-
}
|
|
2267
|
-
},
|
|
2268
|
-
"node_modules/gtoken/node_modules/node-fetch": {
|
|
2269
|
-
"version": "3.3.2",
|
|
2270
|
-
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz",
|
|
2271
|
-
"integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
|
|
2272
|
-
"license": "MIT",
|
|
2273
|
-
"dependencies": {
|
|
2274
|
-
"data-uri-to-buffer": "^4.0.0",
|
|
2275
|
-
"fetch-blob": "^3.1.4",
|
|
2276
|
-
"formdata-polyfill": "^4.0.10"
|
|
2277
|
-
},
|
|
2278
|
-
"engines": {
|
|
2279
|
-
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
2280
|
-
},
|
|
2281
|
-
"funding": {
|
|
2282
|
-
"type": "opencollective",
|
|
2283
|
-
"url": "https://opencollective.com/node-fetch"
|
|
2086
|
+
"node": ">=14.0.0"
|
|
2284
2087
|
}
|
|
2285
2088
|
},
|
|
2286
2089
|
"node_modules/has-flag": {
|
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
"author": "",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"type": "module",
|
|
12
|
+
"overrides": {
|
|
13
|
+
"google-auth-library": "9.15.1"
|
|
14
|
+
},
|
|
12
15
|
"dependencies": {
|
|
13
|
-
"@mcpher/gas-fakes": "
|
|
14
|
-
"google-auth-library": ">=9.0.0",
|
|
15
|
-
"googleapis": ">=157.0.0"
|
|
16
|
+
"@mcpher/gas-fakes": "file:../../"
|
|
16
17
|
}
|
|
17
18
|
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import '../../main.js';
|
|
2
|
+
//import './node_modules/@mcpher/gas-fakes/main.js'
|
|
3
|
+
|
|
4
|
+
// we can pretest npm with npm pack, then
|
|
5
|
+
// npm install ../../mcpher-gas-fakes-1.1.4.tgz
|
|
6
|
+
//import '@mcpher/gas-fakes'
|
|
2
7
|
console.log(process.env.LOG_DESTINATION)
|
|
3
8
|
Logger.__logDestination="BOTH"
|
|
4
9
|
console.log(Logger.__destination)
|
|
5
10
|
console.log (Logger.__cloudLogLink)
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
const file = DriveApp.getFileById("1iOqRbA6zbV3ry73iEf4y9cygtDchJvAh")
|
|
13
|
+
console.log (file.getName())
|
package/package.json
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
"node": ">=20.11.0"
|
|
4
4
|
},
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@google-cloud/logging": "^11.2.1",
|
|
7
6
|
"@mcpher/fake-gasenum": "^1.0.2",
|
|
8
7
|
"@sindresorhus/is": "^7.0.1",
|
|
9
8
|
"archiver": "^7.0.1",
|
|
@@ -60,13 +59,13 @@
|
|
|
60
59
|
"testdocsfootnotes": "node ./test/testdocsfootnotes.js execute",
|
|
61
60
|
"testdocsimages": "node ./test/testdocsimages.js execute",
|
|
62
61
|
"testdocsstyles": "node ./test/testdocsstyles.js execute",
|
|
63
|
-
"testsandbox": "node ./test/testsandbox.js execute",
|
|
62
|
+
"testsandbox": "node --trace-warnings ./test/testsandbox.js execute",
|
|
64
63
|
"testgmail": "node ./test/testgmail.js execute",
|
|
65
64
|
"testlogger": "node ./test/testlogger.js execute",
|
|
66
65
|
"pub": "npm publish --access public"
|
|
67
66
|
},
|
|
68
67
|
"name": "@mcpher/gas-fakes",
|
|
69
|
-
"version": "1.1.
|
|
68
|
+
"version": "1.1.6",
|
|
70
69
|
"license": "MIT",
|
|
71
70
|
"main": "main.js",
|
|
72
71
|
"description": "A proof of concept implementation of Apps Script Environment on Node",
|
|
@@ -5,7 +5,7 @@ import { syncLog} from '../../support/workersync/synclogger.js'
|
|
|
5
5
|
let __client = null;
|
|
6
6
|
|
|
7
7
|
export const getDocsApiClient = () => {
|
|
8
|
-
const auth = Auth.
|
|
8
|
+
const auth = Auth.getAuthClient()
|
|
9
9
|
if (!__client) {
|
|
10
10
|
syncLog('Creating new Docs API client');
|
|
11
11
|
__client = google.docs({ version: 'v1', auth });
|
|
@@ -5,7 +5,7 @@ import { syncLog} from '../../support/workersync/synclogger.js'
|
|
|
5
5
|
let __client = null;
|
|
6
6
|
syncLog('...importing Drive API');
|
|
7
7
|
export const getDriveApiClient = () => {
|
|
8
|
-
const auth = Auth.
|
|
8
|
+
const auth = Auth.getAuthClient()
|
|
9
9
|
if (!__client) {
|
|
10
10
|
syncLog('Creating new Drive API client');
|
|
11
11
|
__client = google.drive({ version: 'v3', auth });
|
|
@@ -5,7 +5,7 @@ import { syncLog} from '../../support/workersync/synclogger.js'
|
|
|
5
5
|
let __client = null;
|
|
6
6
|
|
|
7
7
|
export const getFormsApiClient = () => {
|
|
8
|
-
const auth = Auth.
|
|
8
|
+
const auth = Auth.getAuthClient()
|
|
9
9
|
if (!__client) {
|
|
10
10
|
syncLog('Creating new Forms API client');
|
|
11
11
|
__client = google.forms({ version: 'v1', auth });
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FakeAdvResource } from '../common/fakeadvresource.js';
|
|
2
|
+
import { Proxies } from '../../support/proxies.js';
|
|
3
|
+
import { gError, normalizeSerialization } from '../../support/helpers.js';
|
|
4
|
+
import { Syncit } from '../../support/syncit.js';
|
|
5
|
+
|
|
6
|
+
export const newFakeAdvGmailDrafts = (...args) => Proxies.guard(new FakeAdvGmailDrafts(...args));
|
|
7
|
+
|
|
8
|
+
class FakeAdvGmailDrafts extends FakeAdvResource {
|
|
9
|
+
constructor(mainService) {
|
|
10
|
+
super(mainService, 'users', Syncit.fxGmail);
|
|
11
|
+
this.gmail = mainService;
|
|
12
|
+
this.__fakeObjectType = 'Gmail.Users.Drafts';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new draft with the DRAFT label.
|
|
17
|
+
* @param {object} resource - The draft resource to create.
|
|
18
|
+
* @param {string} userId - The user's email address. The special value me can be used to indicate the authenticated user.
|
|
19
|
+
* @returns {object} The created draft resource.
|
|
20
|
+
*/
|
|
21
|
+
create(resource, userId) {
|
|
22
|
+
const { data, response } = this._call(
|
|
23
|
+
'create',
|
|
24
|
+
{ userId, requestBody: normalizeSerialization(resource) },
|
|
25
|
+
null,
|
|
26
|
+
'drafts'
|
|
27
|
+
);
|
|
28
|
+
gError(response, 'gmail', 'users.drafts.create');
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -2,6 +2,7 @@ import { FakeAdvResource } from '../common/fakeadvresource.js';
|
|
|
2
2
|
import { Syncit } from '../../support/syncit.js';
|
|
3
3
|
import { signatureArgs, ssError, gError } from '../../support/helpers.js';
|
|
4
4
|
import { newFakeAdvGmailLabels } from './fakeadvgmaillabels.js';
|
|
5
|
+
import { newFakeAdvGmailDrafts } from './fakeadvgmaildrafts.js';
|
|
5
6
|
|
|
6
7
|
import { Proxies } from '../../support/proxies.js';
|
|
7
8
|
import { Utils } from '../../support/utils.js';
|
|
@@ -20,4 +21,8 @@ class FakeAdvGmailUsers extends FakeAdvResource {
|
|
|
20
21
|
return newFakeAdvGmailLabels(this.gmail);
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
get Drafts() {
|
|
25
|
+
return newFakeAdvGmailDrafts(this.gmail);
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
}
|
|
@@ -5,7 +5,7 @@ import { syncLog} from '../../support/workersync/synclogger.js'
|
|
|
5
5
|
let __client = null;
|
|
6
6
|
|
|
7
7
|
export const getGmailApiClient = () => {
|
|
8
|
-
const auth = Auth.
|
|
8
|
+
const auth = Auth.getAuthClient()
|
|
9
9
|
if (!__client) {
|
|
10
10
|
syncLog('Creating new Gmail API client');
|
|
11
11
|
__client = google.gmail({ version: 'v1', auth });
|
|
@@ -5,7 +5,7 @@ let currentAuth = null;
|
|
|
5
5
|
let __client = null;
|
|
6
6
|
syncLog('...importing Sheets API');
|
|
7
7
|
export const getSheetsApiClient = () => {
|
|
8
|
-
const auth = Auth.
|
|
8
|
+
const auth = Auth.getAuthClient()
|
|
9
9
|
|
|
10
10
|
if (__client && currentAuth !== auth) {
|
|
11
11
|
syncLog('Auth has changed - creating new Sheets API client');
|
|
@@ -6,7 +6,7 @@ import { syncLog} from '../../support/workersync/synclogger.js'
|
|
|
6
6
|
let __client = null;
|
|
7
7
|
syncLog('...importing Slides API');
|
|
8
8
|
export const getSlidesApiClient = () => {
|
|
9
|
-
const auth = Auth.
|
|
9
|
+
const auth = Auth.getAuthClient()
|
|
10
10
|
if (!__client) {
|
|
11
11
|
syncLog('Creating new Slides API client');
|
|
12
12
|
__client = google.slides({ version: 'v1', auth });
|