@mcpher/gas-fakes 2.3.9 → 2.3.10

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/package.json CHANGED
@@ -5,6 +5,7 @@
5
5
  "dependencies": {
6
6
  "@azure/identity": "^4.13.1",
7
7
  "@mcpher/fake-gasenum": "^1.0.6",
8
+ "@mcpher/gas-fakes": "^2.3.9",
8
9
  "@mcpher/gas-flex-cache": "^1.1.5",
9
10
  "@microsoft/microsoft-graph-client": "^3.0.7",
10
11
  "@modelcontextprotocol/sdk": "^1.28.0",
@@ -34,11 +35,12 @@
34
35
  "pub": "npm publish --access public",
35
36
  "includes": "node ./doccreation/include-docs.js",
36
37
  "progress": "cd ./doccreation && bash pipeline.sh",
37
- "docs": "npm run includes && npm run progress"
38
+ "docs": "npm run includes && npm run progress && npm run gf_agent",
39
+ "gf_agent": "node ./gf_agent/scripts/builder.js"
38
40
  },
39
41
  "name": "@mcpher/gas-fakes",
40
42
  "author": "bruce mcpherson",
41
- "version": "2.3.9",
43
+ "version": "2.3.10",
42
44
  "license": "MIT",
43
45
  "main": "main.js",
44
46
  "description": "An implementation of the Google Workspace Apps Script runtime: Run native App Script Code on Node and Cloud Run",
@@ -93,6 +93,46 @@ class FakeGmailMessage {
93
93
  return this.__getHeader('To');
94
94
  }
95
95
 
96
+ /**
97
+ * Helper to extract body by mime type
98
+ * @param {Object} payload The message payload
99
+ * @param {string} mimeType The mime type to search for
100
+ * @returns {string} The decoded content
101
+ */
102
+ __extractBodyData(payload, mimeType) {
103
+ if (!payload) return '';
104
+ if (payload.mimeType === mimeType && payload.body && payload.body.data) {
105
+ return Buffer.from(payload.body.data, 'base64url').toString('utf8');
106
+ }
107
+ if (payload.parts && payload.parts.length > 0) {
108
+ for (const part of payload.parts) {
109
+ const data = this.__extractBodyData(part, mimeType);
110
+ if (data) return data;
111
+ }
112
+ }
113
+ return '';
114
+ }
115
+
116
+ /**
117
+ * Gets the HTML content of the body of this message.
118
+ * @returns {string} The body content.
119
+ */
120
+ getBody() {
121
+ ScriptApp.__behavior.checkMethod('GmailMessage', 'getBody');
122
+ const htmlData = this.__extractBodyData(this.__messageResource.payload, 'text/html');
123
+ if (htmlData) return htmlData;
124
+ return this.__extractBodyData(this.__messageResource.payload, 'text/plain');
125
+ }
126
+
127
+ /**
128
+ * Gets the plain-text content of the body of this message.
129
+ * @returns {string} The plain-text body content.
130
+ */
131
+ getPlainBody() {
132
+ ScriptApp.__behavior.checkMethod('GmailMessage', 'getPlainBody');
133
+ return this.__extractBodyData(this.__messageResource.payload, 'text/plain');
134
+ }
135
+
96
136
  toString() {
97
137
  return this.__fakeObjectType;
98
138
  }