zapier-platform-core 15.14.1 → 15.14.2
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 +2 -2
- package/src/app-middlewares/after/checks.js +1 -1
- package/src/checks/index.js +1 -0
- package/src/checks/is-create.js +5 -1
- package/src/checks/is-trigger.js +2 -1
- package/src/checks/perform-buffer-return-type.js +65 -0
- package/src/tools/create-logger.js +2 -1
- package/types/zapier.custom.d.ts +43 -7
- package/types/zapier.generated.d.ts +48 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zapier-platform-core",
|
|
3
|
-
"version": "15.14.
|
|
3
|
+
"version": "15.14.2",
|
|
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/",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"node-fetch": "2.6.7",
|
|
54
54
|
"oauth-sign": "0.9.0",
|
|
55
55
|
"semver": "7.5.2",
|
|
56
|
-
"zapier-platform-schema": "15.14.
|
|
56
|
+
"zapier-platform-schema": "15.14.2"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/node-fetch": "^2.6.11",
|
|
@@ -32,7 +32,7 @@ const checkOutput = (output) => {
|
|
|
32
32
|
})
|
|
33
33
|
.map((check) => {
|
|
34
34
|
return check
|
|
35
|
-
.run(event.method, output.results, compiledApp)
|
|
35
|
+
.run(event.method, output.results, compiledApp, event.bundle)
|
|
36
36
|
.map((err) => ({ name: check.name, error: err }));
|
|
37
37
|
});
|
|
38
38
|
const checkResults = _.flatten(rawResults);
|
package/src/checks/index.js
CHANGED
|
@@ -9,4 +9,5 @@ module.exports = {
|
|
|
9
9
|
triggerHasId: require('./trigger-has-id'),
|
|
10
10
|
firehoseSubscriptionIsArray: require('./firehose_is_array'),
|
|
11
11
|
firehoseSubscriptionKeyIsString: require('./firehose_is_string'),
|
|
12
|
+
performBufferReturnType: require('./perform-buffer-return-type'),
|
|
12
13
|
};
|
package/src/checks/is-create.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
module.exports = (method) => {
|
|
2
|
+
// `method` will never start with "resources." in production.
|
|
3
|
+
// Seems only for testing.
|
|
2
4
|
return (
|
|
3
|
-
(method.startsWith('creates.') &&
|
|
5
|
+
(method.startsWith('creates.') &&
|
|
6
|
+
(method.endsWith('.operation.perform') ||
|
|
7
|
+
method.endsWith('.operation.performBuffer'))) ||
|
|
4
8
|
(method.startsWith('resources.') &&
|
|
5
9
|
method.endsWith('.create.operation.perform'))
|
|
6
10
|
);
|
package/src/checks/is-trigger.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
module.exports = (method) => {
|
|
2
2
|
return (
|
|
3
|
-
// `method` will never start with "resources."
|
|
3
|
+
// `method` will never start with "resources." in production.
|
|
4
|
+
// Seems only for testing.
|
|
4
5
|
(method.startsWith('triggers.') && method.endsWith('.operation.perform')) ||
|
|
5
6
|
(method.startsWith('resources.') &&
|
|
6
7
|
method.endsWith('.list.operation.perform'))
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const _ = require('lodash');
|
|
2
|
+
|
|
3
|
+
const performBufferEchoesIds = {
|
|
4
|
+
name: 'performBufferReturnType',
|
|
5
|
+
|
|
6
|
+
shouldRun: (method, bundle) => {
|
|
7
|
+
return (
|
|
8
|
+
Array.isArray(bundle.buffer) &&
|
|
9
|
+
method.endsWith('.operation.performBuffer') &&
|
|
10
|
+
method.startsWith('creates.')
|
|
11
|
+
);
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
run: (method, results, compiledApp, bundle) => {
|
|
15
|
+
if (!_.isPlainObject(results)) {
|
|
16
|
+
// create-is-object should have caught this
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const inputIds = bundle.buffer
|
|
21
|
+
.map((b) => {
|
|
22
|
+
return b && b.meta ? b.meta.id : null;
|
|
23
|
+
})
|
|
24
|
+
.filter((id) => id);
|
|
25
|
+
|
|
26
|
+
const outputIds = Object.keys(results);
|
|
27
|
+
const missingIds = inputIds.filter((id) => !outputIds.includes(id));
|
|
28
|
+
|
|
29
|
+
if (missingIds.length > 0) {
|
|
30
|
+
const LIMIT = 3;
|
|
31
|
+
let missingIdsStr = missingIds.slice(0, LIMIT).join(', ');
|
|
32
|
+
const remainingCount = missingIds.length - LIMIT;
|
|
33
|
+
if (remainingCount > 0) {
|
|
34
|
+
// Don't want to flood the user with too many IDs
|
|
35
|
+
missingIdsStr += `, and ${remainingCount} more`;
|
|
36
|
+
}
|
|
37
|
+
return [`Result object is missing these IDs as keys: ${missingIdsStr}`];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const errors = [];
|
|
41
|
+
for (const id of inputIds) {
|
|
42
|
+
const item = results[id];
|
|
43
|
+
|
|
44
|
+
if (!_.isPlainObject(item)) {
|
|
45
|
+
errors.push(`Result object member with ID '${id}' must be an object`);
|
|
46
|
+
} else if (
|
|
47
|
+
!_.isPlainObject(item.outputData) &&
|
|
48
|
+
typeof item.error !== 'string'
|
|
49
|
+
) {
|
|
50
|
+
errors.push(
|
|
51
|
+
`Result object member with ID '${id}' must have 'outputData' object or 'error' string`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (errors.length >= 4) {
|
|
56
|
+
// No need to flood the user with too many errors
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return errors;
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
module.exports = performBufferEchoesIds;
|
|
@@ -166,7 +166,8 @@ const buildSensitiveValues = (event, data) => {
|
|
|
166
166
|
const isGettingNewSecret =
|
|
167
167
|
event.method &&
|
|
168
168
|
(event.method.endsWith('refreshAccessToken') ||
|
|
169
|
-
event.method.endsWith('sessionConfig.perform')
|
|
169
|
+
event.method.endsWith('sessionConfig.perform') ||
|
|
170
|
+
event.method.endsWith('oauth1Config.getAccessToken'));
|
|
170
171
|
|
|
171
172
|
for (const prop of ['response_content', 'request_data']) {
|
|
172
173
|
if (data[prop]) {
|
package/types/zapier.custom.d.ts
CHANGED
|
@@ -135,13 +135,12 @@ type DehydrateFunc = <T>(
|
|
|
135
135
|
export interface ZObject {
|
|
136
136
|
request: {
|
|
137
137
|
// most specific overloads go first
|
|
138
|
-
(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
): Promise<
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
): Promise<RawHttpResponse>;
|
|
138
|
+
(url: string, options: HttpRequestOptions & { raw: true }): Promise<
|
|
139
|
+
RawHttpResponse
|
|
140
|
+
>;
|
|
141
|
+
(options: HttpRequestOptions & { raw: true; url: string }): Promise<
|
|
142
|
+
RawHttpResponse
|
|
143
|
+
>;
|
|
145
144
|
|
|
146
145
|
(url: string, options?: HttpRequestOptions): Promise<HttpResponse>;
|
|
147
146
|
(options: HttpRequestOptions & { url: string }): Promise<HttpResponse>;
|
|
@@ -231,3 +230,40 @@ export type AfterResponseMiddleware = (
|
|
|
231
230
|
z: ZObject,
|
|
232
231
|
bundle?: Bundle
|
|
233
232
|
) => HttpResponse | Promise<HttpResponse>;
|
|
233
|
+
|
|
234
|
+
export interface BufferedItem<InputData = { [x: string]: any }> {
|
|
235
|
+
inputData: InputData;
|
|
236
|
+
meta: {
|
|
237
|
+
id: string;
|
|
238
|
+
[x: string]: any;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export interface BufferedBundle<InputData = { [x: string]: any }> {
|
|
243
|
+
authData: { [x: string]: string };
|
|
244
|
+
buffer: BufferedItem<InputData>[];
|
|
245
|
+
groupedBy: { [x: string]: string };
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
interface PerformBufferSuccessItem {
|
|
249
|
+
outputData: { [x: string]: any };
|
|
250
|
+
error?: string;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
interface PerformBufferErrorItem {
|
|
254
|
+
outputData?: { [x: string]: any };
|
|
255
|
+
error: string;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export type PerformBufferResultItem =
|
|
259
|
+
| PerformBufferSuccessItem
|
|
260
|
+
| PerformBufferErrorItem;
|
|
261
|
+
|
|
262
|
+
export interface PerformBufferResult {
|
|
263
|
+
[id: string]: PerformBufferResultItem;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export const performBuffer: (
|
|
267
|
+
z: ZObject,
|
|
268
|
+
bundle: BufferedBundle
|
|
269
|
+
) => Promise<PerformBufferResult>;
|
|
@@ -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: 15.14.
|
|
7
|
+
* zapier-platform-schema version: 15.14.1
|
|
8
8
|
* schema-to-ts compiler version: 0.1.0
|
|
9
9
|
*/
|
|
10
10
|
|
|
@@ -1316,6 +1316,34 @@ export interface Search {
|
|
|
1316
1316
|
operation: BasicActionOperation;
|
|
1317
1317
|
}
|
|
1318
1318
|
|
|
1319
|
+
/**
|
|
1320
|
+
* Currently an **internal-only** feature. Zapier uses this
|
|
1321
|
+
* configuration for creating objects in bulk.
|
|
1322
|
+
*
|
|
1323
|
+
* [Docs: BufferConfigSchema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#BufferConfigSchema)
|
|
1324
|
+
*/
|
|
1325
|
+
export interface BufferConfig {
|
|
1326
|
+
/**
|
|
1327
|
+
* The list of keys of input fields to group bulk-create with. The
|
|
1328
|
+
* actual user data provided for the fields will be used during
|
|
1329
|
+
* execution. Note that a required input field should be referenced
|
|
1330
|
+
* to get user data always.
|
|
1331
|
+
*
|
|
1332
|
+
* @minItems 1
|
|
1333
|
+
*/
|
|
1334
|
+
groupedBy: unknown[];
|
|
1335
|
+
|
|
1336
|
+
/**
|
|
1337
|
+
* The maximum number of items to call `performBuffer` with.
|
|
1338
|
+
* **Note** that it is capped by the platform to prevent exceeding
|
|
1339
|
+
* the [AWS Lambda's request/response payload size quota of 6
|
|
1340
|
+
* MB](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html#function-configuration-deployment-and-execution).
|
|
1341
|
+
* Also, the execution is time-bound; we recommend reducing it upon
|
|
1342
|
+
* consistent timeout.
|
|
1343
|
+
*/
|
|
1344
|
+
limit: number;
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1319
1347
|
/**
|
|
1320
1348
|
* Represents the fundamental mechanics of a create.
|
|
1321
1349
|
*
|
|
@@ -1332,9 +1360,11 @@ export interface BasicCreateActionOperation {
|
|
|
1332
1360
|
|
|
1333
1361
|
/**
|
|
1334
1362
|
* How will Zapier get the data? This can be a function like `(z) =>
|
|
1335
|
-
* [{id: 123}]` or a request like `{url: 'http...'}`.
|
|
1363
|
+
* [{id: 123}]` or a request like `{url: 'http...'}`. Exactly one of
|
|
1364
|
+
* `perform` or `performBuffer` must be defined. If you choose to
|
|
1365
|
+
* define `buffer` and `performBuffer`, you must omit `perform`.
|
|
1336
1366
|
*/
|
|
1337
|
-
perform
|
|
1367
|
+
perform?: Request | Function;
|
|
1338
1368
|
|
|
1339
1369
|
/**
|
|
1340
1370
|
* Internal pointer to a function from the original source or the
|
|
@@ -1385,6 +1415,21 @@ export interface BasicCreateActionOperation {
|
|
|
1385
1415
|
* concurrency)?
|
|
1386
1416
|
*/
|
|
1387
1417
|
shouldLock?: boolean;
|
|
1418
|
+
|
|
1419
|
+
/**
|
|
1420
|
+
* Currently an **internal-only** feature. Zapier uses this
|
|
1421
|
+
* configuration for creating objects in bulk with `performBuffer`.
|
|
1422
|
+
*/
|
|
1423
|
+
buffer?: BufferConfig;
|
|
1424
|
+
|
|
1425
|
+
/**
|
|
1426
|
+
* Internal pointer to a function from the original source or the
|
|
1427
|
+
* source code itself. Encodes arity and if `arguments` is used in
|
|
1428
|
+
* the body. Note - just write normal functions and the system will
|
|
1429
|
+
* encode the pointers for you. Or, provide {source: "return 1 + 2"}
|
|
1430
|
+
* and the system will wrap in a function for you.
|
|
1431
|
+
*/
|
|
1432
|
+
performBuffer?: Function;
|
|
1388
1433
|
}
|
|
1389
1434
|
|
|
1390
1435
|
/**
|