zapier-platform-core 16.0.0 → 16.1.0
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": "16.
|
|
3
|
+
"version": "16.1.0",
|
|
4
4
|
"description": "The core SDK for CLI apps in the Zapier Developer Platform.",
|
|
5
5
|
"repository": "zapier/zapier-platform",
|
|
6
6
|
"homepage": "https://platform.zapier.com/",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"engineStrict": true,
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@zapier/secret-scrubber": "^1.1.
|
|
45
|
+
"@zapier/secret-scrubber": "^1.1.2",
|
|
46
46
|
"bluebird": "3.7.2",
|
|
47
47
|
"content-disposition": "0.5.4",
|
|
48
48
|
"dotenv": "16.4.6",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"node-fetch": "2.7.0",
|
|
54
54
|
"oauth-sign": "0.9.0",
|
|
55
55
|
"semver": "7.6.3",
|
|
56
|
-
"zapier-platform-schema": "16.
|
|
56
|
+
"zapier-platform-schema": "16.1.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/node-fetch": "^2.6.11",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const isInputOrOutputFields = (method) =>
|
|
4
|
+
method.endsWith('.operation.inputFields') ||
|
|
5
|
+
method.endsWith('.operation.outputFields');
|
|
6
|
+
|
|
7
|
+
const dynamicFieldsHaveKeys = {
|
|
8
|
+
name: 'dynamicFieldsHaveKeys',
|
|
9
|
+
shouldRun: isInputOrOutputFields,
|
|
10
|
+
run: (method, results) => {
|
|
11
|
+
const lastMethodPart = method.split('.').pop();
|
|
12
|
+
|
|
13
|
+
if (!Array.isArray(results)) {
|
|
14
|
+
const type = typeof results;
|
|
15
|
+
return [`${lastMethodPart} must be an array, got ${type}`];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const errors = [];
|
|
19
|
+
for (let i = 0; i < results.length; i++) {
|
|
20
|
+
const field = results[i];
|
|
21
|
+
if (!field || !field.key) {
|
|
22
|
+
errors.push(`${lastMethodPart}[${i}] is missing a key`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return errors;
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
module.exports = dynamicFieldsHaveKeys;
|
package/src/checks/index.js
CHANGED
|
@@ -7,7 +7,11 @@ module.exports = {
|
|
|
7
7
|
triggerIsObject: require('./trigger-is-object'),
|
|
8
8
|
triggerHasUniquePrimary: require('./trigger-has-unique-primary'),
|
|
9
9
|
triggerHasId: require('./trigger-has-id'),
|
|
10
|
+
|
|
10
11
|
firehoseSubscriptionIsArray: require('./firehose_is_array'),
|
|
11
12
|
firehoseSubscriptionKeyIsString: require('./firehose_is_string'),
|
|
13
|
+
|
|
12
14
|
performBufferReturnType: require('./perform-buffer-return-type'),
|
|
15
|
+
|
|
16
|
+
dynamicFieldsHaveKeys: require('./dynamic-fields-have-keys'),
|
|
13
17
|
};
|
|
@@ -73,6 +73,9 @@ const stringifyResponseContent = async (response) => {
|
|
|
73
73
|
// global.fetch = wrapFetchWithLogger(global.fetch, logger);
|
|
74
74
|
const wrapFetchWithLogger = (fetchFunc, logger) => {
|
|
75
75
|
if (fetchFunc.patchedByZapier) {
|
|
76
|
+
// Important not to reuse logger between calls, because we always destroy
|
|
77
|
+
// the logger at the end of a Lambda call.
|
|
78
|
+
fetchFunc.zapierLogger = logger;
|
|
76
79
|
return fetchFunc;
|
|
77
80
|
}
|
|
78
81
|
|
|
@@ -82,25 +85,29 @@ const wrapFetchWithLogger = (fetchFunc, logger) => {
|
|
|
82
85
|
if (requestInfo && !isZapierUserAgent(requestInfo.headers)) {
|
|
83
86
|
const responseContentType = response.headers.get('content-type');
|
|
84
87
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
:
|
|
98
|
-
|
|
88
|
+
newFetch.zapierLogger(
|
|
89
|
+
`${response.status} ${requestInfo.method} ${requestInfo.url}`,
|
|
90
|
+
{
|
|
91
|
+
log_type: 'http',
|
|
92
|
+
request_type: 'patched-devplatform-outbound',
|
|
93
|
+
request_url: requestInfo.url,
|
|
94
|
+
request_method: requestInfo.method,
|
|
95
|
+
request_headers: requestInfo.headers,
|
|
96
|
+
request_data: requestInfo.data,
|
|
97
|
+
request_via_client: false,
|
|
98
|
+
response_status_code: response.status,
|
|
99
|
+
response_headers: Object.fromEntries(response.headers.entries()),
|
|
100
|
+
response_content: shouldIncludeResponseContent(responseContentType)
|
|
101
|
+
? await stringifyResponseContent(response)
|
|
102
|
+
: '<unsupported format>',
|
|
103
|
+
},
|
|
104
|
+
);
|
|
99
105
|
}
|
|
100
106
|
return response;
|
|
101
107
|
};
|
|
102
108
|
|
|
103
109
|
newFetch.patchedByZapier = true;
|
|
110
|
+
newFetch.zapierLogger = logger;
|
|
104
111
|
return newFetch;
|
|
105
112
|
};
|
|
106
113
|
|