zapier-platform-core 9.7.0 → 9.7.3
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zapier-platform-core",
|
|
3
|
-
"version": "9.7.
|
|
3
|
+
"version": "9.7.3",
|
|
4
4
|
"description": "The core SDK for CLI apps in the Zapier Developer Platform.",
|
|
5
5
|
"repository": "zapier/zapier-platform-core",
|
|
6
6
|
"homepage": "https://zapier.com/",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"form-data": "4.0.0",
|
|
45
45
|
"lodash": "4.17.15",
|
|
46
46
|
"mime-types": "2.1.34",
|
|
47
|
-
"node-fetch": "2.6.
|
|
47
|
+
"node-fetch": "2.6.7",
|
|
48
48
|
"oauth-sign": "0.9.0",
|
|
49
49
|
"semver": "5.6.0",
|
|
50
|
-
"zapier-platform-schema": "9.7.
|
|
50
|
+
"zapier-platform-schema": "9.7.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"adm-zip": "0.4.13",
|
|
@@ -8,13 +8,30 @@ const hasQueryParams = ({ params = {} }) => Object.keys(params).length;
|
|
|
8
8
|
// Take params off of req.params and append to url - "?a=1&b=2"".
|
|
9
9
|
// This middleware should run *after* custom middlewares, because
|
|
10
10
|
// custom middlewares might add params.
|
|
11
|
-
const addQueryParams = req => {
|
|
11
|
+
const addQueryParams = (req) => {
|
|
12
12
|
if (hasQueryParams(req)) {
|
|
13
13
|
const splitter = req.url.includes('?') ? '&' : '?';
|
|
14
14
|
|
|
15
15
|
normalizeEmptyParamFields(req);
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
let stringifiedParams = querystring.stringify(req.params);
|
|
18
|
+
|
|
19
|
+
// it goes against spec, but for compatibility, some APIs want certain
|
|
20
|
+
// characters (mostly $) unencoded
|
|
21
|
+
if (req.skipEncodingChars) {
|
|
22
|
+
for (let i = 0; i < req.skipEncodingChars.length; i++) {
|
|
23
|
+
const char = req.skipEncodingChars.charAt(i);
|
|
24
|
+
const valToReplace = querystring.escape(char);
|
|
25
|
+
if (valToReplace === char) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
// no replaceAll in JS yet, coming in a node version soon!
|
|
29
|
+
stringifiedParams = stringifiedParams.replace(
|
|
30
|
+
new RegExp(valToReplace, 'g'),
|
|
31
|
+
char
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
18
35
|
|
|
19
36
|
if (stringifiedParams) {
|
|
20
37
|
req.url += `${splitter}${stringifiedParams}`;
|
|
@@ -6,6 +6,10 @@ const createHttpPatch = (event) => {
|
|
|
6
6
|
const httpPatch = (object, logger) => {
|
|
7
7
|
const originalRequest = object.request;
|
|
8
8
|
|
|
9
|
+
// Important not to reuse logger between calls, because we always destroy
|
|
10
|
+
// the logger at the end of a Lambda call.
|
|
11
|
+
object.zapierLogger = logger;
|
|
12
|
+
|
|
9
13
|
// Avoids multiple patching and memory leaks (mostly when running tests locally)
|
|
10
14
|
if (object.patchedByZapier) {
|
|
11
15
|
return;
|
|
@@ -65,7 +69,7 @@ const createHttpPatch = (event) => {
|
|
|
65
69
|
response_content: responseBody,
|
|
66
70
|
};
|
|
67
71
|
|
|
68
|
-
|
|
72
|
+
object.zapierLogger(
|
|
69
73
|
`${logData.response_status_code} ${logData.request_method} ${logData.request_url}`,
|
|
70
74
|
logData
|
|
71
75
|
);
|
|
@@ -172,6 +172,7 @@ class LogStream extends Transform {
|
|
|
172
172
|
class LogStreamFactory {
|
|
173
173
|
constructor() {
|
|
174
174
|
this._logStream = null;
|
|
175
|
+
this.ended = false;
|
|
175
176
|
}
|
|
176
177
|
|
|
177
178
|
getOrCreate(url, token) {
|
|
@@ -190,6 +191,10 @@ class LogStreamFactory {
|
|
|
190
191
|
}
|
|
191
192
|
|
|
192
193
|
async end() {
|
|
194
|
+
// Mark the factory as ended. This suggests that any logStream.write() that
|
|
195
|
+
// follows should end() right away.
|
|
196
|
+
this.ended = true;
|
|
197
|
+
|
|
193
198
|
if (this._logStream) {
|
|
194
199
|
this._logStream.end();
|
|
195
200
|
const response = await this._logStream.request;
|
|
@@ -245,6 +250,14 @@ const sendLog = async (logStreamFactory, options, event, message, data) => {
|
|
|
245
250
|
// no line breaks, and after an object it ends with a line break.
|
|
246
251
|
JSON.stringify({ message: safeMessage, data: safeData }) + '\n'
|
|
247
252
|
);
|
|
253
|
+
|
|
254
|
+
if (logStreamFactory.ended) {
|
|
255
|
+
// Lambda handler calls logger.end() at the end. But what if there's a
|
|
256
|
+
// (bad) callback that is still running after the Lambda handler returns?
|
|
257
|
+
// We need to make sure the bad callback ends the logger as well.
|
|
258
|
+
// Otherwise, it will hang!
|
|
259
|
+
logStreamFactory.end();
|
|
260
|
+
}
|
|
248
261
|
}
|
|
249
262
|
};
|
|
250
263
|
|