@mcpher/gas-fakes 1.1.4 → 1.1.5

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.
@@ -1,4 +1,4 @@
1
- import '../../main.js';
1
+ import '@mcpher/gas-fakes';
2
2
  const res1 = Sheets.Spreadsheets.create({ properties: { title: "sample" } });
3
3
  const res2 = Sheets.Spreadsheets.get(res1.spreadsheetId);
4
4
  console.log(res2);
@@ -9,9 +9,7 @@
9
9
  "version": "1.0.0",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
- "@mcpher/gas-fakes": "^1.1.2",
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.2",
273
- "resolved": "https://registry.npmjs.org/@mcpher/gas-fakes/-/gas-fakes-1.1.2.tgz",
274
- "integrity": "sha512-Wzroh7EJC+pQb+UaZMONrME2S2rYiKUX8agUI8Oh50J29+TckvA9W0ulqEIU5EionI4kJDZkase5w/h/enPqng==",
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": "^157.0.0",
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": "10.4.0",
2004
- "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-10.4.0.tgz",
2005
- "integrity": "sha512-CmIrSy1bqMQUsPmA9+hcSbAXL80cFhu40cGMUjCaLpNKVzzvi+0uAHq8GNZxkoGYIsTX4ZQ7e4aInAqWxgn4fg==",
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": "^7.0.0",
2011
- "gcp-metadata": "^7.0.0",
2012
- "google-logging-utils": "^1.0.0",
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": "8.0.0",
2243
- "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-8.0.0.tgz",
2244
- "integrity": "sha512-+CqsMbHPiSTdtSO14O51eMNlrp9N79gmeqmXeouJOhfucAedHw9noVe/n5uJk3tbKE6a+6ZCQg3RPhVhHByAIw==",
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": "^7.0.0",
2082
+ "gaxios": "^6.0.0",
2248
2083
  "jws": "^4.0.0"
2249
2084
  },
2250
2085
  "engines": {
2251
- "node": ">=18"
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": "^1.1.2",
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",
@@ -66,7 +65,7 @@
66
65
  "pub": "npm publish --access public"
67
66
  },
68
67
  "name": "@mcpher/gas-fakes",
69
- "version": "1.1.4",
68
+ "version": "1.1.5",
70
69
  "license": "MIT",
71
70
  "main": "main.js",
72
71
  "description": "A proof of concept implementation of Apps Script Environment on Node",
@@ -1,9 +1,10 @@
1
1
  import { format } from 'util';
2
2
  import { Proxies } from '../../support/proxies.js';
3
- import { Syncit } from '../../support/syncit.js';
4
3
 
5
- // --- Cloud Logging Integration ---
6
4
 
5
+ // --- Cloud Logging Integration ---
6
+ // instead of using the node client for this, which is out of date and uses conflicting version of google-auth-library
7
+ // im going to use its json api
7
8
 
8
9
  /**
9
10
  * @class
@@ -23,7 +24,7 @@ export class FakeLogger {
23
24
  this.__destination = (process.env.LOG_DESTINATION || 'CONSOLE').toUpperCase();
24
25
  this.__startedLoggingAt = new Date()
25
26
  this.__cloudLogLink = 'No cloud logging enabled - use Logger.__logDestination = "CLOUD" or "BOTH" to enable'
26
- if (['CLOUD','BOTH'].includes(this.__destination)) {
27
+ if (['CLOUD', 'BOTH'].includes(this.__destination)) {
27
28
  writeToCloudOrConsole("...Initializing cloud logging", this)
28
29
  }
29
30
  }
@@ -86,12 +87,12 @@ export class FakeLogger {
86
87
  this.__destination = destination.toUpperCase();
87
88
  }
88
89
  // we need to send a logger message to initialize and test
89
- this.log (`...setting destination to ${this.__destination}`)
90
+ this.log(`...setting destination to ${this.__destination}`)
90
91
  return this;
91
92
  }
92
93
 
93
94
  // to allow code compatibility without error on apps script, we should use the setter since it'll be undefined on Apps live Script
94
- set __logDestination (destination) {
95
+ set __logDestination(destination) {
95
96
  return this.__setLogDestination(destination);
96
97
  }
97
98
 
@@ -143,35 +144,54 @@ const writeToCloudOrConsole = (message, loggerInstance) => {
143
144
  severity: 'INFO',
144
145
  };
145
146
 
146
- // filter on user/script/priject and run times
147
- // we'll extend the end date filter to a little more than now
148
- const aLittleMore = 7 * 1000
149
- const endDate = new Date(new Date().getTime() + aLittleMore)
150
- const startDate = loggerInstance.__startedLoggingAt
151
-
152
- const base = `https://console.cloud.google.com/logs/query;`
153
-
154
- // B. Build the RAW LQL Filter String (NO "query=" prefix here)
155
- const lqlParts = [
156
- // LogName filter
157
- `logName="projects/${projectId}/logs/${logName.replace('/', '%2F')}"`,
158
- // Labels filter
159
- ...Object.keys(metadata.labels).map(k => `jsonPayload.labels.${k}="${metadata.labels[k]}"`),
160
- // Date filter (recommended for query stability)
161
- `timestamp>="${startDate.toISOString()}"`,
162
- `timestamp<="${endDate.toISOString()}"`
163
- ];
164
- const fullLQLQuery = lqlParts.join(' AND ');
165
-
166
- // C. Encode ONLY the filter content, then prepend the literal 'query='
167
- const encodedQueryParam = `query=${encodeURIComponent(fullLQLQuery)}`;
168
-
169
- // D. Create the timeRange parameter (correct casing)
170
- const timeRangeParam = `;timeRange=${startDate.getTime()}/${endDate.getTime()}`;
171
-
172
- // E. Assemble the final URL
173
- loggerInstance.__cloudLogLink = base + encodedQueryParam + `?project=${projectId}`;
174
- // fire and forget
175
- Syncit.fxLogger({ logName, metadata })
147
+ // filter on user/script/priject and run times
148
+ // we'll extend the end date filter to a little more than now
149
+ const aLittleMore = 7 * 1000
150
+ const endDate = new Date(new Date().getTime() + aLittleMore)
151
+ const startDate = loggerInstance.__startedLoggingAt
152
+
153
+ const base = `https://console.cloud.google.com/logs/query;`
154
+
155
+ // B. Build the RAW LQL Filter String (NO "query=" prefix here)
156
+ const lqlParts = [
157
+ // LogName filter
158
+ `logName="projects/${projectId}/logs/${logName.replace('/', '%2F')}"`,
159
+ // Labels filter
160
+ ...Object.keys(metadata.labels).map(k => `jsonPayload.labels.${k}="${metadata.labels[k]}"`),
161
+ // Date filter (recommended for query stability)
162
+ `timestamp>="${startDate.toISOString()}"`,
163
+ `timestamp<="${endDate.toISOString()}"`
164
+ ];
165
+ const fullLQLQuery = lqlParts.join(' AND ');
166
+
167
+ // C. Encode ONLY the filter content, then prepend the literal 'query='
168
+ const encodedQueryParam = `query=${encodeURIComponent(fullLQLQuery)}`;
169
+
170
+ // D. Create the timeRange parameter (correct casing)
171
+ const timeRangeParam = `;timeRange=${startDate.getTime()}/${endDate.getTime()}`;
172
+
173
+ // E. Assemble the final URL
174
+ loggerInstance.__cloudLogLink = base + encodedQueryParam + `?project=${projectId}`;
175
+
176
+ const apiBase = 'https://logging.googleapis.com/v2/entries:write'
177
+ const payload = JSON.stringify({
178
+ entries: [
179
+ metadata
180
+ ]
181
+ })
182
+ const token = ScriptApp.getOAuthToken()
183
+ const headers = {
184
+ Authorization: `Bearer ${token}`,
185
+ 'content-type': "application/json",
186
+ }
187
+ const response = UrlFetchApp.fetch(apiBase, {
188
+ method: 'post',
189
+ headers,
190
+ })
191
+ if (response.getResponseCode() !== 200) {
192
+ console.log ('logging failure', response.getContentText())
193
+ }
194
+
176
195
  }
196
+
177
197
  };
@@ -384,7 +384,6 @@ const fxGmail = (args) =>
384
384
  });
385
385
 
386
386
  const fxGetImagesFromXlsx = (args) => callSync("sxGetImagesFromXlsx", args);
387
- const fxLogger = ({metadata, logName}) => callSync("sxLogger", {metadata, logName});
388
387
 
389
388
  export const Syncit = {
390
389
  fxFetch,
@@ -402,6 +401,5 @@ export const Syncit = {
402
401
  fxDocs,
403
402
  fxForms,
404
403
  fxGmail,
405
- fxGetImagesFromXlsx,
406
- fxLogger
404
+ fxGetImagesFromXlsx
407
405
  };
@@ -10,4 +10,4 @@ export * from "../sxauth.js";
10
10
  export * from "../sxgmail.js";
11
11
  export * from "../sxxlsx.js";
12
12
 
13
- export * from "../sxlogger.js";
13
+
@@ -70,6 +70,23 @@ parentPort.once('message', (msg) => {
70
70
  Atomics.notify(control, 0);
71
71
  });
72
72
 
73
+ /**
74
+ * Catches any error that happens outside the main task processing loop,
75
+ * especially during worker initialization/module loading.
76
+ * @param {Error} error The uncaught error.
77
+ */
78
+ const handleUncaughtError = (error) => {
79
+ // If control is not initialized, we can't report the error.
80
+ // Just log it and exit.
81
+ if (control) {
82
+ syncError('A fatal, unhandled error occurred in the worker', error);
83
+ writeError(error);
84
+ Atomics.notify(control, 0);
85
+ }
86
+ };
87
+ process.on('uncaughtException', handleUncaughtError);
88
+ process.on('unhandledRejection', handleUncaughtError);
89
+
73
90
  // 2. Listen for tasks from the main thread.
74
91
  parentPort.on('message', async (task) => {
75
92
  // Ignore the initial setup message which has no 'method' property.
@@ -1,41 +0,0 @@
1
-
2
- //import { syncError, syncLog } from './workersync/synclogger.js';
3
- import { Logging } from '@google-cloud/logging';
4
- import { syncError, syncLog } from './workersync/synclogger.js';
5
-
6
- /**
7
- * sync a call to logger api
8
- * @param {import('./auth.js').Auth} Auth an auth object
9
- * @param {object} p pargs
10
- * @param {string} p.logName the cloud log file name
11
- * @param {string} p.metadata the entry metadata
12
- */
13
-
14
- export const sxLogger = async (Auth , { logName, metadata }) => {
15
- const keyFile = Auth.getAdcPath()
16
- const projectId = Auth.getProjectId();
17
-
18
-
19
- // Let the Logging client handle its own authentication by providing it
20
- // with the three essential pieces of information. This is the most robust
21
- // and idiomatic approach.
22
- const logging = new Logging({
23
- projectId, // The Logging client needs the projectId at the top level.
24
- });
25
- let response;
26
- let error;
27
-
28
- const cloudlog = logging.log(logName)
29
- try {
30
- response = await cloudlog.write(cloudlog.entry(metadata))
31
- } catch (err) {
32
- error = err;
33
- }
34
-
35
-
36
- if (error) {
37
- syncError(`Failed in to write to cloudlog ${logName}`, error);
38
- return { data: null, response: error.message }
39
- }
40
- return { data: response };
41
- }