zapier-platform-core 17.2.0 → 17.3.1
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.
|
@@ -5,9 +5,14 @@ let _appRaw;
|
|
|
5
5
|
try {
|
|
6
6
|
_appRaw = await import('{REPLACE_ME_PACKAGE_NAME}');
|
|
7
7
|
} catch (err) {
|
|
8
|
-
if (
|
|
9
|
-
err.
|
|
10
|
-
|
|
8
|
+
if (
|
|
9
|
+
err.code === 'ERR_MODULE_NOT_FOUND' &&
|
|
10
|
+
err.message?.includes('{REPLACE_ME_PACKAGE_NAME}')
|
|
11
|
+
) {
|
|
12
|
+
err.message =
|
|
13
|
+
'It seems you are using ESM because your package.json has `"type": "module"`. ' +
|
|
14
|
+
'For ESM to work, make sure you specify a valid entry point using `exports` (instead of `main`) in package.json.\n\n' +
|
|
15
|
+
err.message;
|
|
11
16
|
}
|
|
12
17
|
throw err;
|
|
13
18
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zapier-platform-core",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.3.1",
|
|
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/",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@zapier/secret-scrubber": "^1.1.2",
|
|
56
56
|
"content-disposition": "0.5.4",
|
|
57
57
|
"dotenv": "16.5.0",
|
|
58
|
-
"fernet": "^0.
|
|
58
|
+
"fernet": "^0.3.3",
|
|
59
59
|
"form-data": "4.0.1",
|
|
60
60
|
"lodash": "4.17.21",
|
|
61
61
|
"mime-types": "2.1.35",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"node-fetch": "2.7.0",
|
|
64
64
|
"oauth-sign": "0.9.0",
|
|
65
65
|
"semver": "7.7.1",
|
|
66
|
-
"zapier-platform-schema": "17.
|
|
66
|
+
"zapier-platform-schema": "17.3.1"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/node-fetch": "^2.6.11",
|
|
@@ -56,11 +56,16 @@ const isZapierUserAgent = (headers) =>
|
|
|
56
56
|
_.get(headers, 'user-agent', []).indexOf('Zapier') !== -1;
|
|
57
57
|
|
|
58
58
|
const shouldIncludeResponseContent = (contentType) => {
|
|
59
|
+
if (!contentType) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
59
63
|
for (const ctype of ALLOWED_HTTP_DATA_CONTENT_TYPES) {
|
|
60
64
|
if (contentType.includes(ctype)) {
|
|
61
65
|
return true;
|
|
62
66
|
}
|
|
63
67
|
}
|
|
68
|
+
|
|
64
69
|
return false;
|
|
65
70
|
};
|
|
66
71
|
|
package/src/tools/http.js
CHANGED
|
@@ -9,7 +9,8 @@ const HTML_TYPE = 'text/html';
|
|
|
9
9
|
const TEXT_TYPE = 'text/plain';
|
|
10
10
|
const TEXT_TYPE_UTF8 = 'text/plain; charset=utf-8';
|
|
11
11
|
const YAML_TYPE = 'application/yaml';
|
|
12
|
-
const
|
|
12
|
+
const XML_TEXT_TYPE = 'text/xml';
|
|
13
|
+
const XML_APPLICATION_TYPE = 'application/xml';
|
|
13
14
|
const JSONAPI_TYPE = 'application/vnd.api+json';
|
|
14
15
|
|
|
15
16
|
const ALLOWED_HTTP_DATA_CONTENT_TYPES = new Set([
|
|
@@ -20,7 +21,8 @@ const ALLOWED_HTTP_DATA_CONTENT_TYPES = new Set([
|
|
|
20
21
|
TEXT_TYPE,
|
|
21
22
|
TEXT_TYPE_UTF8,
|
|
22
23
|
YAML_TYPE,
|
|
23
|
-
|
|
24
|
+
XML_TEXT_TYPE,
|
|
25
|
+
XML_APPLICATION_TYPE,
|
|
24
26
|
JSONAPI_TYPE,
|
|
25
27
|
]);
|
|
26
28
|
|
|
@@ -122,7 +124,8 @@ module.exports = {
|
|
|
122
124
|
HTML_TYPE,
|
|
123
125
|
TEXT_TYPE,
|
|
124
126
|
YAML_TYPE,
|
|
125
|
-
|
|
127
|
+
XML_TEXT_TYPE,
|
|
128
|
+
XML_APPLICATION_TYPE,
|
|
126
129
|
JSONAPI_TYPE,
|
|
127
130
|
ALLOWED_HTTP_DATA_CONTENT_TYPES,
|
|
128
131
|
getContentType,
|
package/types/custom.d.ts
CHANGED
|
@@ -18,10 +18,15 @@ export const createAppTester: (
|
|
|
18
18
|
options?: { customStoreKey?: string },
|
|
19
19
|
) => <T, B extends Bundle>(
|
|
20
20
|
func: (z: ZObject, bundle: B) => T | Promise<T>,
|
|
21
|
-
bundle?:
|
|
21
|
+
bundle?: DeepPartial<B>, // partial so we don't have to make a full bundle in tests
|
|
22
22
|
clearZcacheBeforeUse?: boolean,
|
|
23
23
|
) => Promise<T>; // appTester always returns a promise
|
|
24
24
|
|
|
25
|
+
/** Recursively make all properties of an object optional. */
|
|
26
|
+
type DeepPartial<T> = T extends object
|
|
27
|
+
? { [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P] }
|
|
28
|
+
: T;
|
|
29
|
+
|
|
25
30
|
type HttpMethod =
|
|
26
31
|
| 'GET'
|
|
27
32
|
| 'POST'
|
package/types/functions.d.ts
CHANGED
|
@@ -2,9 +2,16 @@ import type { Bundle, ZObject } from './custom';
|
|
|
2
2
|
|
|
3
3
|
type DefaultInputData = Record<string, unknown>;
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Wraps a `perform` function that is used to poll for data from an API.
|
|
7
|
+
* By default must return an array of objects with an `id` field, but
|
|
8
|
+
* when one or more output fields have `primary:true` set on them, this
|
|
9
|
+
* can be overridden by setting the second type parameter to a type with
|
|
10
|
+
* those keys.
|
|
11
|
+
*/
|
|
5
12
|
export type PollingTriggerPerform<
|
|
6
13
|
$InputData extends DefaultInputData = DefaultInputData,
|
|
7
|
-
$Return extends {
|
|
14
|
+
$Return extends {} = { id: string },
|
|
8
15
|
> = (z: ZObject, bundle: Bundle<$InputData>) => $Return[] | Promise<$Return[]>;
|
|
9
16
|
|
|
10
17
|
/**
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { expectAssignable } from 'tsd';
|
|
2
|
+
import type { PollingTriggerPerform } from './functions';
|
|
3
|
+
|
|
4
|
+
const simplePerform = (async (z, bundle) => {
|
|
5
|
+
return [{ id: '1', name: 'test' }];
|
|
6
|
+
}) satisfies PollingTriggerPerform;
|
|
7
|
+
|
|
8
|
+
expectAssignable<PollingTriggerPerform<{}, { id: string; name: string }>>(
|
|
9
|
+
simplePerform,
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const primaryKeyOverridePerform = (async (z, bundle) => {
|
|
13
|
+
return [{ itemId: 123, name: 'test' }];
|
|
14
|
+
}) satisfies PollingTriggerPerform<{}, { itemId: number; name: string }>;
|
|
15
|
+
|
|
16
|
+
expectAssignable<PollingTriggerPerform<{}, { itemId: number; name: string }>>(
|
|
17
|
+
primaryKeyOverridePerform,
|
|
18
|
+
);
|
|
@@ -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: 17.1
|
|
7
|
+
* zapier-platform-schema version: 17.3.1
|
|
8
8
|
* schema-to-ts compiler version: 0.1.0
|
|
9
9
|
*/
|
|
10
10
|
import type {
|
|
@@ -906,6 +906,12 @@ export interface BasicPollingOperation<
|
|
|
906
906
|
/** What should the form a user sees and configures look like? */
|
|
907
907
|
inputFields?: $InputFields;
|
|
908
908
|
|
|
909
|
+
/**
|
|
910
|
+
* Defines groups for organizing input fields in the UI. Each group
|
|
911
|
+
* can have a key, label, and emphasis styling.
|
|
912
|
+
*/
|
|
913
|
+
inputFieldGroups?: InputFieldGroups;
|
|
914
|
+
|
|
909
915
|
/**
|
|
910
916
|
* What fields of data will this return? Will use resource
|
|
911
917
|
* outputFields if missing, will also use sample if available.
|
|
@@ -995,6 +1001,12 @@ export interface BasicHookOperation<
|
|
|
995
1001
|
/** What should the form a user sees and configures look like? */
|
|
996
1002
|
inputFields?: $InputFields;
|
|
997
1003
|
|
|
1004
|
+
/**
|
|
1005
|
+
* Defines groups for organizing input fields in the UI. Each group
|
|
1006
|
+
* can have a key, label, and emphasis styling.
|
|
1007
|
+
*/
|
|
1008
|
+
inputFieldGroups?: InputFieldGroups;
|
|
1009
|
+
|
|
998
1010
|
/**
|
|
999
1011
|
* What fields of data will this return? Will use resource
|
|
1000
1012
|
* outputFields if missing, will also use sample if available.
|
|
@@ -1049,6 +1061,12 @@ export interface BasicHookToPollOperation<
|
|
|
1049
1061
|
/** What should the form a user sees and configures look like? */
|
|
1050
1062
|
inputFields?: $InputFields;
|
|
1051
1063
|
|
|
1064
|
+
/**
|
|
1065
|
+
* Defines groups for organizing input fields in the UI. Each group
|
|
1066
|
+
* can have a key, label, and emphasis styling.
|
|
1067
|
+
*/
|
|
1068
|
+
inputFieldGroups?: InputFieldGroups;
|
|
1069
|
+
|
|
1052
1070
|
/**
|
|
1053
1071
|
* What fields of data will this return? Will use resource
|
|
1054
1072
|
* outputFields if missing, will also use sample if available.
|
|
@@ -1103,6 +1121,12 @@ export interface BasicActionOperation {
|
|
|
1103
1121
|
/** What should the form a user sees and configures look like? */
|
|
1104
1122
|
inputFields?: InputFields;
|
|
1105
1123
|
|
|
1124
|
+
/**
|
|
1125
|
+
* Defines groups for organizing input fields in the UI. Each group
|
|
1126
|
+
* can have a key, label, and emphasis styling.
|
|
1127
|
+
*/
|
|
1128
|
+
inputFieldGroups?: InputFieldGroups;
|
|
1129
|
+
|
|
1106
1130
|
/**
|
|
1107
1131
|
* What fields of data will this return? Will use resource
|
|
1108
1132
|
* outputFields if missing, will also use sample if available.
|
|
@@ -1164,6 +1188,12 @@ export interface BasicSearchOperation<
|
|
|
1164
1188
|
/** What should the form a user sees and configures look like? */
|
|
1165
1189
|
inputFields?: $InputFields;
|
|
1166
1190
|
|
|
1191
|
+
/**
|
|
1192
|
+
* Defines groups for organizing input fields in the UI. Each group
|
|
1193
|
+
* can have a key, label, and emphasis styling.
|
|
1194
|
+
*/
|
|
1195
|
+
inputFieldGroups?: InputFieldGroups;
|
|
1196
|
+
|
|
1167
1197
|
/**
|
|
1168
1198
|
* What fields of data will this return? Will use resource
|
|
1169
1199
|
* outputFields if missing, will also use sample if available.
|
|
@@ -1227,6 +1257,12 @@ export interface BasicCreateOperation<
|
|
|
1227
1257
|
/** What should the form a user sees and configures look like? */
|
|
1228
1258
|
inputFields?: $InputFields;
|
|
1229
1259
|
|
|
1260
|
+
/**
|
|
1261
|
+
* Defines groups for organizing input fields in the UI. Each group
|
|
1262
|
+
* can have a key, label, and emphasis styling.
|
|
1263
|
+
*/
|
|
1264
|
+
inputFieldGroups?: InputFieldGroups;
|
|
1265
|
+
|
|
1230
1266
|
/**
|
|
1231
1267
|
* What fields of data will this return? Will use resource
|
|
1232
1268
|
* outputFields if missing, will also use sample if available.
|
|
@@ -1305,6 +1341,12 @@ export interface BasicOperation {
|
|
|
1305
1341
|
/** What should the form a user sees and configures look like? */
|
|
1306
1342
|
inputFields?: InputFields;
|
|
1307
1343
|
|
|
1344
|
+
/**
|
|
1345
|
+
* Defines groups for organizing input fields in the UI. Each group
|
|
1346
|
+
* can have a key, label, and emphasis styling.
|
|
1347
|
+
*/
|
|
1348
|
+
inputFieldGroups?: InputFieldGroups;
|
|
1349
|
+
|
|
1308
1350
|
/**
|
|
1309
1351
|
* What fields of data will this return? Will use resource
|
|
1310
1352
|
* outputFields if missing, will also use sample if available.
|
|
@@ -1412,6 +1454,13 @@ export interface PlainOutputField {
|
|
|
1412
1454
|
steadyState?: boolean;
|
|
1413
1455
|
}
|
|
1414
1456
|
|
|
1457
|
+
/** An array or collection of input field groups. */
|
|
1458
|
+
export type InputFieldGroups = {
|
|
1459
|
+
key: Key;
|
|
1460
|
+
label: string;
|
|
1461
|
+
emphasize: boolean;
|
|
1462
|
+
}[];
|
|
1463
|
+
|
|
1415
1464
|
/**
|
|
1416
1465
|
* Zapier uses this configuration to ensure this action is performed
|
|
1417
1466
|
* one at a time per scope (avoid concurrency).
|
|
@@ -1613,6 +1662,12 @@ export interface PlainInputField {
|
|
|
1613
1662
|
* Supports simple key-values only (no sub-objects or arrays).
|
|
1614
1663
|
*/
|
|
1615
1664
|
meta?: FieldMeta;
|
|
1665
|
+
|
|
1666
|
+
/**
|
|
1667
|
+
* References a group key from the operation's inputFieldGroups to
|
|
1668
|
+
* organize this field with others.
|
|
1669
|
+
*/
|
|
1670
|
+
group?: Key;
|
|
1616
1671
|
}
|
|
1617
1672
|
|
|
1618
1673
|
/**
|