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.0.0",
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.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.0.0"
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;
@@ -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
- logger(`${response.status} ${requestInfo.method} ${requestInfo.url}`, {
86
- log_type: 'http',
87
- request_type: 'patched-devplatform-outbound',
88
- request_url: requestInfo.url,
89
- request_method: requestInfo.method,
90
- request_headers: requestInfo.headers,
91
- request_data: requestInfo.data,
92
- request_via_client: false,
93
- response_status_code: response.status,
94
- response_headers: Object.fromEntries(response.headers.entries()),
95
- response_content: shouldIncludeResponseContent(responseContentType)
96
- ? await stringifyResponseContent(response)
97
- : '<unsupported format>',
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
 
@@ -4,7 +4,7 @@
4
4
  * files, and/or the schema-to-ts tool and run its CLI to regenerate
5
5
  * these typings.
6
6
  *
7
- * zapier-platform-schema version: 16.0.0
7
+ * zapier-platform-schema version: 16.1.0
8
8
  * schema-to-ts compiler version: 0.1.0
9
9
  */
10
10