@mcpher/gas-fakes 2.3.2 → 2.3.4

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 CHANGED
@@ -184,6 +184,8 @@ As I mentioned earlier, to take this further, I'm going to need a lot of help to
184
184
  - [getting started](GETTING_STARTED.md) - how to handle authentication for Workspace scopes.
185
185
  - [readme](README.md)
186
186
  - [gas fakes cli](gas-fakes-cli.md)
187
+ - [github actions using adc](https://github.com/brucemcpherson/gas-fakes-actions-adc)
188
+ - [github actions using dwd and wif](https://github.com/brucemcpherson/gas-fakes-actions-dwd)
187
189
  - [ksuite as a back end](ksuite_poc.md)
188
190
  - [msgraph as a back end](msgraph.md)
189
191
  - [gas-fakes in serverless containers](https://docs.google.com/presentation/d/1JlXF9T--DD4ERHopyP3WyAMhjRCxxHblgCP5ynxaJ3k/edit?usp=sharing)
@@ -193,6 +195,7 @@ As I mentioned earlier, to take this further, I'm going to need a lot of help to
193
195
  - [running gas-fakes on google kubernetes engine](https://github.com/brucemcpherson/gas-fakes-containers)
194
196
  - [running gas-fakes on Amazon AWS lambda](https://github.com/brucemcpherson/gas-fakes-containers)
195
197
  - [running gas-fakes on Azure ACA](https://github.com/brucemcpherson/gas-fakes-containers)
198
+ - [running gas-fakes on Github actions](https://github.com/brucemcpherson/gas-fakes-containers)
196
199
  - [Yes – you can run native apps script code on Azure ACA as well!](https://ramblings.mcpher.com/yes-you-can-run-native-apps-script-code-on-azure-aca-as-well/)
197
200
  - [Yes – you can run native apps script code on AWS Lambda!](https://ramblings.mcpher.com/apps-script-on-aws-lambda/)
198
201
  - [initial idea and thoughts](https://ramblings.mcpher.com/a-proof-of-concept-implementation-of-apps-script-environment-on-node/)
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "@modelcontextprotocol/sdk": "^1.28.0",
11
11
  "@sindresorhus/is": "^7.2.0",
12
12
  "acorn": "^8.16.0",
13
- "archiver": "^7.0.1",
13
+ "adm-zip": "^0.5.16",
14
14
  "commander": "^14.0.3",
15
15
  "dotenv": "^17.3.1",
16
16
  "fast-xml-parser": "^5.5.9",
@@ -24,12 +24,8 @@
24
24
  "mime": "^4.1.0",
25
25
  "prompts": "^2.4.2",
26
26
  "sleep-synchronously": "^2.0.0",
27
- "unzipper": "^0.12.3",
28
27
  "zod": "^4.3.6"
29
28
  },
30
- "overrides": {
31
- "minimatch": "^10.0.3"
32
- },
33
29
  "type": "module",
34
30
  "scripts": {
35
31
  "pub": "npm publish --access public",
@@ -39,7 +35,7 @@
39
35
  },
40
36
  "name": "@mcpher/gas-fakes",
41
37
  "author": "bruce mcpherson",
42
- "version": "2.3.2",
38
+ "version": "2.3.4",
43
39
  "license": "MIT",
44
40
  "main": "main.js",
45
41
  "description": "An implementation of the Google Workspace Apps Script runtime: Run native App Script Code on Node and Cloud Run",
@@ -40,6 +40,86 @@ export class FakeEmbeddedChart {
40
40
  return newFakeContainerInfo(this.__apiChart.position?.overlayPosition);
41
41
  }
42
42
 
43
+ /**
44
+ * Returns the ranges that this chart uses for its source data.
45
+ * @returns {FakeSheetRange[]}
46
+ */
47
+ getRanges() {
48
+ const { nargs, matchThrow } = signatureArgs(arguments, "EmbeddedChart.getRanges");
49
+ if (nargs !== 0) matchThrow();
50
+
51
+ const ranges = [];
52
+ const spec = this.__apiChart.spec;
53
+
54
+ const extractRanges = (chartData) => {
55
+ if (chartData?.sourceRange?.sources) {
56
+ chartData.sourceRange.sources.forEach((gridRange) => {
57
+ const sheet = this.__sheet.getParent().getSheetById(gridRange.sheetId);
58
+ if (sheet) {
59
+ const numRows = (gridRange.endRowIndex !== undefined ? gridRange.endRowIndex : sheet.getMaxRows()) - gridRange.startRowIndex;
60
+ const numCols = (gridRange.endColumnIndex !== undefined ? gridRange.endColumnIndex : sheet.getMaxColumns()) - gridRange.startColumnIndex;
61
+ ranges.push(
62
+ sheet.getRange(
63
+ gridRange.startRowIndex + 1,
64
+ gridRange.startColumnIndex + 1,
65
+ numRows,
66
+ numCols
67
+ )
68
+ );
69
+ }
70
+ });
71
+ }
72
+ };
73
+
74
+ if (spec.basicChart) {
75
+ spec.basicChart.domains?.forEach((d) => extractRanges(d.domain));
76
+ spec.basicChart.series?.forEach((s) => extractRanges(s.series));
77
+ }
78
+ if (spec.pieChart) {
79
+ extractRanges(spec.pieChart.domain);
80
+ spec.pieChart.series?.forEach((s) => extractRanges(s.series));
81
+ }
82
+ if (spec.bubbleChart) {
83
+ extractRanges(spec.bubbleChart.domain);
84
+ extractRanges(spec.bubbleChart.series);
85
+ extractRanges(spec.bubbleChart.ids);
86
+ extractRanges(spec.bubbleChart.labels);
87
+ extractRanges(spec.bubbleChart.sizes);
88
+ }
89
+ if (spec.candlestickChart) {
90
+ spec.candlestickChart.data?.forEach((d) => {
91
+ extractRanges(d.highSeries?.series);
92
+ extractRanges(d.lowSeries?.series);
93
+ extractRanges(d.openSeries?.series);
94
+ extractRanges(d.closeSeries?.series);
95
+ });
96
+ }
97
+ if (spec.histogramChart) {
98
+ spec.histogramChart.series?.forEach((s) => extractRanges(s.data));
99
+ }
100
+ if (spec.orgChart) {
101
+ extractRanges(spec.orgChart.labels);
102
+ extractRanges(spec.orgChart.parentLabels);
103
+ extractRanges(spec.orgChart.tooltips);
104
+ }
105
+ if (spec.scorecardChart) {
106
+ extractRanges(spec.scorecardChart.keyValueData);
107
+ extractRanges(spec.scorecardChart.baselineValueData);
108
+ }
109
+ if (spec.treemapChart) {
110
+ extractRanges(spec.treemapChart.labels);
111
+ extractRanges(spec.treemapChart.parentLabels);
112
+ extractRanges(spec.treemapChart.sizeData);
113
+ extractRanges(spec.treemapChart.colorData);
114
+ }
115
+ if (spec.waterfallChart) {
116
+ extractRanges(spec.waterfallChart.domain?.domain);
117
+ spec.waterfallChart.series?.forEach((s) => extractRanges(s.data));
118
+ }
119
+
120
+ return ranges;
121
+ }
122
+
43
123
  /**
44
124
  * Returns the ID of this chart.
45
125
  * @returns {number}
@@ -5,19 +5,9 @@
5
5
  * note
6
6
  * - arguments and returns must be serializable ie. primitives or plain objects
7
7
  */
8
- import archiver from 'archiver';
9
- import unzipper from 'unzipper';
8
+ import AdmZip from 'adm-zip';
10
9
  import { syncWarn, syncError } from './workersync/synclogger.js';
11
10
 
12
- const streamToBuffer = (stream) => {
13
- return new Promise((resolve, reject) => {
14
- const chunks = [];
15
- stream.on('data', chunk => chunks.push(chunk));
16
- stream.on('error', err => reject(err));
17
- stream.on('end', () => resolve(Buffer.concat(chunks)));
18
- });
19
- };
20
-
21
11
  /**
22
12
  * create a zipped version of multiple files
23
13
  * @param {object} p params
@@ -25,23 +15,14 @@ const streamToBuffer = (stream) => {
25
15
  * @return {byte[]} the zipped content
26
16
  */
27
17
  export const sxZipper = async (_Auth, { blobsContent }) => {
28
-
29
- const archive = archiver.create('zip', {});
30
-
31
18
  try {
32
- // It's important to handle warnings, as they don't necessarily reject the promise.
33
- archive.on('warning', (err) => syncWarn(`Archiver warning: ${err}`));
34
-
35
- // Start collecting the buffer in parallel. This promise resolves when the stream ends.
36
- const bufferPromise = streamToBuffer(archive);
19
+ const zip = new AdmZip();
37
20
 
38
21
  blobsContent.forEach((f) => {
39
- archive.append(Buffer.from(f.bytes), { name: f.name });
22
+ zip.addFile(f.name, Buffer.from(f.bytes));
40
23
  });
41
24
 
42
- // Wait for BOTH the stream to end (which gives us the buffer) AND
43
- // for finalization to be complete. This is the most robust way.
44
- const [buffer] = await Promise.all([bufferPromise, archive.finalize()]);
25
+ const buffer = zip.toBuffer();
45
26
  return Array.from(buffer);
46
27
  } catch (err) {
47
28
  syncError('sxZipper failed', err);
@@ -56,23 +37,24 @@ export const sxZipper = async (_Auth, { blobsContent }) => {
56
37
  * @return {SerializedBlob[]} the unzipped content
57
38
  */
58
39
  export const sxUnzipper = async (_Auth, { blobContent }) => {
59
-
60
- const buffer = Buffer.from(blobContent.bytes)
61
- const unzipped = await unzipper.Open.buffer(buffer)
62
-
63
- // By wrapping the Promise.all in a try/catch, we ensure that if any
64
- // single file stream fails, the entire operation rejects cleanly.
65
40
  try {
66
- const result = await Promise.all(
67
- unzipped.files.map(async (file) => {
68
- const buffer = await streamToBuffer(file.stream());
69
- return { bytes: Array.from(buffer), name: file.path };
70
- })
71
- );
41
+ const buffer = Buffer.from(blobContent.bytes);
42
+ const zip = new AdmZip(buffer);
43
+ const zipEntries = zip.getEntries();
44
+
45
+ // Ignore directory entries (they end with a slash)
46
+ const result = zipEntries
47
+ .filter(zipEntry => !zipEntry.isDirectory)
48
+ .map(zipEntry => {
49
+ return {
50
+ bytes: Array.from(zipEntry.getData()),
51
+ name: zipEntry.entryName
52
+ };
53
+ });
72
54
 
73
55
  return result;
74
56
  } catch (err) {
75
57
  syncError('An error occurred while unzipping a file stream inside the archive.', err);
76
- throw err; // Re-throw to be caught by the main worker error handler
58
+ throw err;
77
59
  }
78
60
  }