zapier-platform-cli 12.2.1 → 14.0.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/README-source.md +113 -48
- package/README.md +201 -74
- package/oclif.manifest.json +1 -1
- package/package.json +29 -26
- package/scaffold/create.template.js +2 -2
- package/scaffold/resource.template.js +2 -2
- package/scaffold/search.template.js +2 -2
- package/scaffold/trigger.template.js +2 -2
- package/src/constants.js +4 -1
- package/src/generators/templates/README.template.md +1 -1
- package/src/generators/templates/callback/README.md +1 -1
- package/src/generators/templates/files/README.md +1 -1
- package/src/oclif/ZapierBaseCommand.js +44 -2
- package/src/oclif/commands/convert.js +27 -64
- package/src/oclif/commands/link.js +1 -1
- package/src/oclif/commands/promote.js +4 -1
- package/src/oclif/commands/register.js +274 -22
- package/src/oclif/hooks/getAppRegistrationFieldChoices.js +45 -0
- package/src/utils/api.js +7 -0
- package/src/utils/build.js +4 -0
- package/src/utils/check-missing-app-info.js +26 -0
- package/src/version-store.js +1 -1
package/README-source.md
CHANGED
|
@@ -14,17 +14,17 @@ Zapier is a platform for creating integrations and workflows. This CLI is your g
|
|
|
14
14
|
|
|
15
15
|
You may find docs duplicate or outdated across the Zapier site. The most up-to-date contents are always available on GitHub:
|
|
16
16
|
|
|
17
|
-
- [Latest CLI Docs](https://github.com/zapier/zapier-platform/blob/
|
|
18
|
-
- [Latest CLI Reference](https://github.com/zapier/zapier-platform/blob/
|
|
19
|
-
- [Latest Schema Docs](https://github.com/zapier/zapier-platform/blob/
|
|
17
|
+
- [Latest CLI Docs](https://github.com/zapier/zapier-platform/blob/main/packages/cli/README.md)
|
|
18
|
+
- [Latest CLI Reference](https://github.com/zapier/zapier-platform/blob/main/packages/cli/docs/cli.md)
|
|
19
|
+
- [Latest Schema Docs](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md)
|
|
20
20
|
|
|
21
|
-
Our code is updated frequently. To see a full list of changes, look no further than [the CHANGELOG](https://github.com/zapier/zapier-platform/blob/
|
|
21
|
+
Our code is updated frequently. To see a full list of changes, look no further than [the CHANGELOG](https://github.com/zapier/zapier-platform/blob/main/CHANGELOG.md).
|
|
22
22
|
|
|
23
23
|
This doc describes the latest CLI version (**PACKAGE_VERSION**), as of this writing. If you're using an older version of the CLI, you may want to check out these historical releases:
|
|
24
24
|
|
|
25
|
-
- CLI Docs: [
|
|
26
|
-
- CLI Reference: [
|
|
27
|
-
- Schema Docs: [
|
|
25
|
+
- CLI Docs: [11.3.3](https://github.com/zapier/zapier-platform/blob/zapier-platform-cli@11.3.3/packages/cli/README.md), [10.2.0](https://github.com/zapier/zapier-platform/blob/zapier-platform-cli@10.2.0/packages/cli/README.md), [9.7.3](https://github.com/zapier/zapier-platform/blob/zapier-platform-cli@9.7.3/packages/cli/README.md)
|
|
26
|
+
- CLI Reference: [11.3.3](https://github.com/zapier/zapier-platform/blob/zapier-platform-cli@11.3.3/packages/cli/docs/cli.md), [10.2.0](https://github.com/zapier/zapier-platform/blob/zapier-platform-cli@10.2.0/packages/cli/docs/cli.md), [9.7.3](https://github.com/zapier/zapier-platform/blob/zapier-platform-cli@9.7.3/packages/cli/docs/cli.md)
|
|
27
|
+
- Schema Docs: [11.3.3](https://github.com/zapier/zapier-platform/blob/zapier-platform-schema@11.3.3/packages/schema/docs/build/schema.md), [10.2.0](https://github.com/zapier/zapier-platform/blob/zapier-platform-schema@10.2.0/packages/schema/docs/build/schema.md), [9.7.3](https://github.com/zapier/zapier-platform/blob/zapier-platform-schema@9.7.3/packages/schema/docs/build/schema.md)
|
|
28
28
|
|
|
29
29
|
## Table of Contents
|
|
30
30
|
|
|
@@ -41,7 +41,7 @@ This doc describes the latest CLI version (**PACKAGE_VERSION**), as of this writ
|
|
|
41
41
|
> Note: this document uses "app" while modern Zapier nomenclature refers instead to "integrations". In both cases, the phrase refers to your code that connects your API with Zapier.
|
|
42
42
|
|
|
43
43
|
A CLI App is an implementation of your app's API. You build a Node.js application
|
|
44
|
-
that exports a single object ([JSON Schema](https://github.com/zapier/zapier-platform/blob/
|
|
44
|
+
that exports a single object ([JSON Schema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#appschema)) and upload it to Zapier.
|
|
45
45
|
Zapier introspects that definition to find out what your app is capable of and
|
|
46
46
|
what options to present end users in the Zap Editor.
|
|
47
47
|
|
|
@@ -76,7 +76,7 @@ You can develop using any version of Node you'd like, but your eventual code mus
|
|
|
76
76
|
|
|
77
77
|
To ensure stability for our users, we strongly encourage you run tests on `LAMBDA_VERSION` sometime before your code reaches users. This can be done multiple ways.
|
|
78
78
|
|
|
79
|
-
Firstly, by using a CI tool (like [Travis CI](https://travis-ci.org/) or [Circle CI](https://circleci.com/), which are free for open source projects). We provide a sample [.travis.yml](https://github.com/zapier/zapier-platform/blob/
|
|
79
|
+
Firstly, by using a CI tool (like [Travis CI](https://travis-ci.org/) or [Circle CI](https://circleci.com/), which are free for open source projects). We provide a sample [.travis.yml](https://github.com/zapier/zapier-platform/blob/main/example-apps/trigger/.travis.yml) file in our template apps to get you started.
|
|
80
80
|
|
|
81
81
|
Alternatively, you can change your local node version with tools such as [nvm](https://github.com/nvm-sh/nvm#installation-and-update). Then you can either swap to that version with `nvm use LAMBDA_VERSION`, or do `nvm exec LAMBDA_VERSION zapier test` so you can run tests without having to switch versions while developing.
|
|
82
82
|
|
|
@@ -107,7 +107,7 @@ cd example-app
|
|
|
107
107
|
npm install
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
> Note: When you run `zapier init`, you'll be presented with a list of templates to start with. Pick the one that matches a feature you'll need (such as "dynamic-dropdown" for an integration with [dynamic dropdown fields](#dynamic-dropdowns)), or select "minimal" for an integration with only the essentials. [View more example apps here](https://github.com/zapier/zapier-platform/tree/
|
|
110
|
+
> Note: When you run `zapier init`, you'll be presented with a list of templates to start with. Pick the one that matches a feature you'll need (such as "dynamic-dropdown" for an integration with [dynamic dropdown fields](#dynamic-dropdowns)), or select "minimal" for an integration with only the essentials. [View more example apps here](https://github.com/zapier/zapier-platform/tree/main/example-apps).
|
|
111
111
|
|
|
112
112
|
You should now have a working local app. You can run several local commands to try it out.
|
|
113
113
|
|
|
@@ -310,7 +310,7 @@ When a user authenticates to your application through Zapier, a "connection" is
|
|
|
310
310
|
|
|
311
311
|
Useful if your app requires two pieces of information to authenticate: `username` and `password`, which only the end user can provide. By default, Zapier will do the standard Basic authentication base64 header encoding for you (via an automatically registered middleware).
|
|
312
312
|
|
|
313
|
-
> To create a new integration with basic authentication, run `zapier init [your app name] --template basic-auth`. You can also review an example of that code [here](https://github.com/zapier/zapier-platform/tree/
|
|
313
|
+
> To create a new integration with basic authentication, run `zapier init [your app name] --template basic-auth`. You can also review an example of that code [here](https://github.com/zapier/zapier-platform/tree/main/example-apps/basic-auth).
|
|
314
314
|
|
|
315
315
|
If your app uses Basic auth with an encoded API key rather than a username and password, like `Authorization: Basic APIKEYHERE:x`, consider the [Custom](#custom) authentication method instead.
|
|
316
316
|
|
|
@@ -324,7 +324,7 @@ If your app uses Basic auth with an encoded API key rather than a username and p
|
|
|
324
324
|
|
|
325
325
|
The setup and user experience of Digest Auth is identical to Basic Auth. Users provide Zapier their username and password, and Zapier handles all the nonce and quality of protection details automatically.
|
|
326
326
|
|
|
327
|
-
> To create a new integration with digest authentication, run `zapier init [your app name] --template digest-auth`. You can also review an example of that code [here](https://github.com/zapier/zapier-platform/tree/
|
|
327
|
+
> To create a new integration with digest authentication, run `zapier init [your app name] --template digest-auth`. You can also review an example of that code [here](https://github.com/zapier/zapier-platform/tree/main/example-apps/digest-auth).
|
|
328
328
|
|
|
329
329
|
> Limitation: Currently, MD5-sess and SHA are not implemented. Only the MD5 algorithm is supported. In addition, server nonces are not reused. That means for every `z.request` call, Zapier will send an additional request beforehand to get the server nonce.
|
|
330
330
|
|
|
@@ -336,7 +336,7 @@ The setup and user experience of Digest Auth is identical to Basic Auth. Users p
|
|
|
336
336
|
|
|
337
337
|
Custom auth is most commonly used for apps that authenticate with API keys, although it also provides flexibility for any unusual authentication setup. You'll likely provide some custom `beforeRequest` middleware or a `requestTemplate` (see [Making HTTP Requests](#making-http-requests)) to pass in data returned from the authentication process, most commonly by adding/computing needed headers.
|
|
338
338
|
|
|
339
|
-
> To create a new integration with custom authentication, run `zapier init [your app name] --template custom-auth`. You can also review an example of that code [here](https://github.com/zapier/zapier-platform/tree/
|
|
339
|
+
> To create a new integration with custom authentication, run `zapier init [your app name] --template custom-auth`. You can also review an example of that code [here](https://github.com/zapier/zapier-platform/tree/main/example-apps/custom-auth).
|
|
340
340
|
|
|
341
341
|
```js
|
|
342
342
|
[insert-file:./snippets/custom-auth.js]
|
|
@@ -346,7 +346,7 @@ Custom auth is most commonly used for apps that authenticate with API keys, alth
|
|
|
346
346
|
|
|
347
347
|
Session auth gives you the ability to exchange some user-provided data for some authentication data; for example, username and password for a session key. It can be used to implement almost any authentication method that uses that pattern - for example, alternative OAuth flows.
|
|
348
348
|
|
|
349
|
-
> To create a new integration with session authentication, run `zapier init [your app name] --template session-auth`. You can also review an example of that code [here](https://github.com/zapier/zapier-platform/tree/
|
|
349
|
+
> To create a new integration with session authentication, run `zapier init [your app name] --template session-auth`. You can also review an example of that code [here](https://github.com/zapier/zapier-platform/tree/main/example-apps/session-auth).
|
|
350
350
|
|
|
351
351
|
```js
|
|
352
352
|
[insert-file:./snippets/session-auth.js]
|
|
@@ -360,7 +360,7 @@ For Session auth, the function that fetches the additional authentication data n
|
|
|
360
360
|
|
|
361
361
|
Zapier's OAuth1 implementation matches [Twitter](https://developer.twitter.com/en/docs/tutorials/authenticating-with-twitter-api-for-enterprise/authentication-method-overview#oauth1.0a) and [Trello](https://developer.atlassian.com/cloud/trello/guides/rest-api/authorization/#using-basic-oauth) implementations of the 3-legged OAuth flow.
|
|
362
362
|
|
|
363
|
-
> To create a new integration with OAuth1, run `zapier init [your app name] --template oauth1-trello`. You can also check out [oauth1-trello](https://github.com/zapier/zapier-platform/tree/
|
|
363
|
+
> To create a new integration with OAuth1, run `zapier init [your app name] --template oauth1-trello`. You can also check out [oauth1-trello](https://github.com/zapier/zapier-platform/tree/main/example-apps/oauth1-trello), [oauth1-tumblr](https://github.com/zapier/zapier-platform/tree/main/example-apps/oauth1-tumblr), and [oauth1-twitter](https://github.com/zapier/zapier-platform/tree/main/example-apps/oauth1-twitter) for working example apps with OAuth1.
|
|
364
364
|
|
|
365
365
|
The flow works like this:
|
|
366
366
|
|
|
@@ -401,7 +401,7 @@ Also, `authentication.oauth1Config.getAccessToken` has access to the additional
|
|
|
401
401
|
|
|
402
402
|
Zapier's OAuth2 implementation is based on the `authorization_code` flow, similar to [GitHub](https://developer.github.com/v3/oauth/) and [Facebook](https://developers.facebook.com/docs/authentication/server-side/).
|
|
403
403
|
|
|
404
|
-
> To create a new integration with OAuth2, run `zapier init [your app name] --template oauth2`. You can also check out [our working example app](https://github.com/zapier/zapier-platform/tree/
|
|
404
|
+
> To create a new integration with OAuth2, run `zapier init [your app name] --template oauth2`. You can also check out [our working example app](https://github.com/zapier/zapier-platform/tree/main/example-apps/oauth2).
|
|
405
405
|
|
|
406
406
|
If your app's OAuth2 flow uses a different grant type, such as `client_credentials`, try using [Session auth](#session) instead.
|
|
407
407
|
|
|
@@ -443,6 +443,35 @@ Also, `authentication.oauth2Config.getAccessToken` has access to the additional
|
|
|
443
443
|
|
|
444
444
|
If you define `fields` to collect additional details from the user, please note that `client_id` and `client_secret` are reserved keys and cannot be used as keys for input form fields.
|
|
445
445
|
|
|
446
|
+
|
|
447
|
+
### OAuth2 with PKCE
|
|
448
|
+
|
|
449
|
+
*Added in v14.0.0.*
|
|
450
|
+
|
|
451
|
+
Zapier's OAuth2 implementation also supports [PKCE](https://oauth.net/2/pkce/). This implementation is an extension of the OAuth2 `authorization_code` flow described above.
|
|
452
|
+
|
|
453
|
+
To use PKCE in your OAuth2 flow, you'll need to set the following variables:
|
|
454
|
+
1. `enablePkce: true`
|
|
455
|
+
2. `getAccessToken.body` to include `code_verifier: "{{bundle.inputData.code_verifier}}"`
|
|
456
|
+
|
|
457
|
+
The OAuth2 PKCE flow uses the same flow as OAuth2 but adds a few extra parameters:
|
|
458
|
+
|
|
459
|
+
1. Zapier computes a `code_verifier` and `code_challenge` internally and stores the `code_verifier` in the Zapier bundle.
|
|
460
|
+
2. Zapier sends the user to the authorization URL defined by your app, passing along the computed `code_challenge`.
|
|
461
|
+
3. Once authorized, your website sends the user to the `redirect_uri` Zapier provided.
|
|
462
|
+
4. Zapier makes a call to your API to exchange the `code` and the computed `code_verifier` for an `access_token`.
|
|
463
|
+
5. Zapier stores the `access_token` and uses it to make calls on behalf of the user.
|
|
464
|
+
|
|
465
|
+
Your auth definition would look something like this:
|
|
466
|
+
|
|
467
|
+
```js
|
|
468
|
+
[insert-file:./snippets/oauth2-pkce.js]
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
The computed `code_verifier` uses this standard: [RFC 7636 Code Verifier](https://www.rfc-editor.org/rfc/rfc7636#section-4.1)
|
|
472
|
+
|
|
473
|
+
The computed `code_challenge` uses this standard: [RFC 7636 Code Challenge](https://www.rfc-editor.org/rfc/rfc7636#section-4.2)
|
|
474
|
+
|
|
446
475
|
### Connection Label
|
|
447
476
|
|
|
448
477
|
When a user connects to your app via Zapier and a connection is created to hold the related data in `bundle.authData`, the connection is automatically labeled with the app name. You also have the option of setting a connection label (`connectionLabel`), which can be extremely helpful to identify information like which user is connected or what instance of your app they are connected to. That way, users don't get confused if they have multiple connections to your app.
|
|
@@ -480,10 +509,10 @@ This will generate the resource file and add the necessary statements to the `in
|
|
|
480
509
|
A resource has a few basic properties. The first is the `key`, which allows Zapier to identify the resource on our backend.
|
|
481
510
|
The second is the `noun`, the user-friendly name of the resource that is presented to users throughout the Zapier UI.
|
|
482
511
|
|
|
483
|
-
> Check out [this working example app](https://github.com/zapier/zapier-platform/tree/
|
|
512
|
+
> Check out [this working example app](https://github.com/zapier/zapier-platform/tree/main/example-apps/resource) to see resources in action.
|
|
484
513
|
|
|
485
514
|
After those, there is a set of optional properties that tell Zapier what methods can be performed on the resource.
|
|
486
|
-
The complete list of available methods can be found in the [Resource Schema Docs](https://github.com/zapier/zapier-platform/blob/
|
|
515
|
+
The complete list of available methods can be found in the [Resource Schema Docs](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#resourceschema).
|
|
487
516
|
For now, let's focus on two:
|
|
488
517
|
|
|
489
518
|
* `list` - Tells Zapier how to fetch a set of this resource. This becomes a Trigger in the Zapier Editor.
|
|
@@ -495,7 +524,7 @@ Here is a complete example of what the list method might look like
|
|
|
495
524
|
[insert-file:./snippets/recipe-list.js]
|
|
496
525
|
```
|
|
497
526
|
|
|
498
|
-
The method is made up of two properties, a `display` and an `operation`. The `display` property ([schema](https://github.com/zapier/zapier-platform/blob/
|
|
527
|
+
The method is made up of two properties, a `display` and an `operation`. The `display` property ([schema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#basicdisplayschema)) holds the info needed to present the method as an available Trigger in the Zapier Editor. The `operation` ([schema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#resourceschema)) provides the implementation to make the API call.
|
|
499
528
|
|
|
500
529
|
Adding a create method looks very similar.
|
|
501
530
|
|
|
@@ -521,24 +550,60 @@ The definition for each of these follows the same structure. Here is an example
|
|
|
521
550
|
[insert-file:./snippets/trigger.js]
|
|
522
551
|
```
|
|
523
552
|
|
|
524
|
-
You can find more details on the definition for each by looking at the [Trigger Schema](https://github.com/zapier/zapier-platform/blob/
|
|
525
|
-
[Search Schema](https://github.com/zapier/zapier-platform/blob/
|
|
553
|
+
You can find more details on the definition for each by looking at the [Trigger Schema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#triggerschema),
|
|
554
|
+
[Search Schema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#searchschema), and [Create Schema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#createschema).
|
|
526
555
|
|
|
527
|
-
> To create a new integration with a premade trigger, search, or create, run `zapier init [your app name]` and select from the list that appears. You can also check out our working example apps [here](https://github.com/zapier/zapier-platform/tree/
|
|
556
|
+
> To create a new integration with a premade trigger, search, or create, run `zapier init [your app name]` and select from the list that appears. You can also check out our working example apps [here](https://github.com/zapier/zapier-platform/tree/main/example-apps).
|
|
528
557
|
|
|
529
558
|
> To add a trigger, search, or create to an existing integration, run `zapier scaffold [trigger|search|create] [noun]` to create the necessary files to your project. For example, `zapier scaffold trigger post` will create a new trigger called "New Post".
|
|
530
559
|
### Return Types
|
|
531
560
|
|
|
532
|
-
Each of the 3 types of function
|
|
561
|
+
Each of the 3 types of function should return a certain data type for use by the platform. There are automated checks to let you know when you're trying to pass the wrong type back. For reference, each expects:
|
|
533
562
|
|
|
534
563
|
| Method | Return Type | Notes |
|
|
535
564
|
|---------|-------------|----------------------------------------------------------------------------------------------------------------------|
|
|
536
|
-
| Trigger | Array | 0 or more objects; passed to the [deduper](https://zapier.com/
|
|
565
|
+
| Trigger | Array | 0 or more objects; passed to the [deduper](https://platform.zapier.com/docs/dedupe/) if polling |
|
|
537
566
|
| Search | Array | 0 or more objects. Only the first object will be returned, so if len > 1, put the best match first |
|
|
538
|
-
|
|
|
567
|
+
| Create | Object | Return values are evaluated by [`isPlainObject`](https://lodash.com/docs#isPlainObject) |
|
|
539
568
|
|
|
540
569
|
When a trigger function returns an empty array, the Zap will not trigger. For REST Hook triggers, this can be used to filter data if the available subscription options are not specific enough for the Zap's needs.
|
|
541
570
|
|
|
571
|
+
#### Returning Line Items (Array of Objects)
|
|
572
|
+
|
|
573
|
+
In some cases, you may want to include multiple items in the data you return for Searches or Creates. To do that, return the set of items as an array of objects under a descriptive key. This may be as part of another object (like items in an invoice) or as multiple top-level items.
|
|
574
|
+
|
|
575
|
+
For example, a Create Order action returning an order with multiple items might look like this:
|
|
576
|
+
|
|
577
|
+
```
|
|
578
|
+
order = {
|
|
579
|
+
name: 'Zap Zaplar',
|
|
580
|
+
total_cost: 25.96,
|
|
581
|
+
items: [
|
|
582
|
+
{ name: 'Zapier T-Shirt', unit_price: 11.99, quantity: 3, line_amount: 35.97, category: 'shirts' },
|
|
583
|
+
{ name: 'Orange Widget', unit_price: 7.99, quantity: 10, line_amount: 79.90, category: 'widgets' },
|
|
584
|
+
{ name:'Stuff', unit_price: 2.99, quantity: 7, line_amount: 20.93, category: 'stuff' },
|
|
585
|
+
{ name: 'Allbird Shoes', unit_price: 2.99, quantity: 7, line_amount: 20.93, category: 'shoes' },
|
|
586
|
+
],
|
|
587
|
+
zip: 01002
|
|
588
|
+
}
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
While a Find Users search could return multiple items under an object key within an array, like this:
|
|
592
|
+
|
|
593
|
+
```
|
|
594
|
+
result = [{
|
|
595
|
+
users: [
|
|
596
|
+
{ name: 'Zap Zaplar', age: 12, city: 'Columbia', region: 'Missouri' },
|
|
597
|
+
{ name: 'Orange Crush', age: 28, city: 'West Ocean City', region: 'Maryland' },
|
|
598
|
+
{ name: 'Lego Brick', age: 91, city: 'Billund', region: 'Denmark' },
|
|
599
|
+
],
|
|
600
|
+
}];
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
A standard search would return just the inner array of users, and only the first user would be provided as a final result. Returning line items instead means that the "first result" return is the object containing all the user details within it.
|
|
604
|
+
|
|
605
|
+
Using the standard approach is recommended, because not all Zapier integrations support line items directly, so users may need to take additional actions to reformat this data for use in their Zaps. More detail on that at [Use line items in Zaps](https://zapier.com/help/create/basics/use-line-items-in-zaps). However, there are use cases where returning multiple results is helpful enough to outweigh that additional effort.
|
|
606
|
+
|
|
542
607
|
### Fallback Sample
|
|
543
608
|
In cases where Zapier needs to show an example record to the user, but we are unable to get a live example from the API, Zapier will fallback to this hard-coded sample. This should reflect the data structure of the Trigger's perform method, and have dummy values that we can show to any user.
|
|
544
609
|
|
|
@@ -578,7 +643,7 @@ Notably, fields come in different types, which may look and act differently in t
|
|
|
578
643
|
| `password` | Displays entered characters as hidden, accepts text input. Does not accept input from previous steps. |
|
|
579
644
|
| `copy` | Does not allow users enter data. Shows the value of the Markdown-formatted Help Text for the field as a rich text note in the Zap editor. Good for important notices to users. |
|
|
580
645
|
|
|
581
|
-
You can find more details on the different field schema options at [our Field Schema](https://github.com/zapier/zapier-platform/blob/
|
|
646
|
+
You can find more details on the different field schema options at [our Field Schema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#fieldschema).
|
|
582
647
|
|
|
583
648
|
### Custom/Dynamic Fields
|
|
584
649
|
|
|
@@ -697,7 +762,7 @@ You can see examples of computed fields in the [OAuth2](#oauth2) or [Session Aut
|
|
|
697
762
|
|
|
698
763
|
### Nested & Children (Line Item) Fields
|
|
699
764
|
|
|
700
|
-
When your action needs to accept an array of items, you can include an input field with the `children` attribute. The `children` attribute accepts a list of [fields](https://github.com/zapier/zapier-platform/blob/
|
|
765
|
+
When your action needs to accept an array of items, you can include an input field with the `children` attribute. The `children` attribute accepts a list of [fields](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#fieldschema) that can be input for each item in this array.
|
|
701
766
|
|
|
702
767
|
```js
|
|
703
768
|
[insert-file:./snippets/input-fields-children.js]
|
|
@@ -712,7 +777,7 @@ Output Fields are optional, but can be used to:
|
|
|
712
777
|
- Define friendly labels for the returned fields. By default, we will *humanize* for example `my_key` as *My Key*.
|
|
713
778
|
- Make sure that custom fields that may not be found in every live sample and - since they're custom to the connected account - cannot be defined in the static sample, can still be mapped.
|
|
714
779
|
|
|
715
|
-
The [schema](https://github.com/zapier/zapier-platform/blob/
|
|
780
|
+
The [schema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#fieldschema) for `outputFields` is shared with `inputFields` but only the `key` and `required` properties are relevant.
|
|
716
781
|
|
|
717
782
|
Custom/Dynamic Output Fields are defined in the same way as [Custom/Dynamic Input Fields](#customdynamic-fields).
|
|
718
783
|
|
|
@@ -985,7 +1050,7 @@ module.exports = {
|
|
|
985
1050
|
};
|
|
986
1051
|
```
|
|
987
1052
|
|
|
988
|
-
Read more in the [REST hook example](https://github.com/zapier/zapier-platform/blob/
|
|
1053
|
+
Read more in the [REST hook example](https://github.com/zapier/zapier-platform/blob/main/example-apps/rest-hooks/triggers/recipe.js).
|
|
989
1054
|
|
|
990
1055
|
### `bundle.subscribeData`
|
|
991
1056
|
|
|
@@ -993,7 +1058,7 @@ Read more in the [REST hook example](https://github.com/zapier/zapier-platform/b
|
|
|
993
1058
|
|
|
994
1059
|
This is an object that contains the data you returned from the `performSubscribe` function. It should contain whatever information you need send a `DELETE` request to your server to stop sending webhooks to Zapier.
|
|
995
1060
|
|
|
996
|
-
Read more in the [REST hook example](https://github.com/zapier/zapier-platform/blob/
|
|
1061
|
+
Read more in the [REST hook example](https://github.com/zapier/zapier-platform/blob/main/example-apps/rest-hooks/triggers/recipe.js).
|
|
997
1062
|
|
|
998
1063
|
## Environment
|
|
999
1064
|
|
|
@@ -1156,7 +1221,7 @@ Here is the full request lifecycle when you call `z.request({...})`:
|
|
|
1156
1221
|
|
|
1157
1222
|
The resulting response object is returned from `z.request()`.
|
|
1158
1223
|
|
|
1159
|
-
> Example App: check out https://github.com/zapier/zapier-platform/tree/
|
|
1224
|
+
> Example App: check out https://github.com/zapier/zapier-platform/tree/main/example-apps/middleware for a working example app using HTTP middleware.
|
|
1160
1225
|
|
|
1161
1226
|
#### Error Response Handling
|
|
1162
1227
|
|
|
@@ -1391,7 +1456,7 @@ See a full example with dehydration/hydration wired in correctly:
|
|
|
1391
1456
|
[insert-file:./snippets/stash-file.js]
|
|
1392
1457
|
```
|
|
1393
1458
|
|
|
1394
|
-
> To create a new integration for handling files, run `zapier init [your app name] --template files`. You can also check out our working example app [here](https://github.com/zapier/zapier-platform/tree/
|
|
1459
|
+
> To create a new integration for handling files, run `zapier init [your app name] --template files`. You can also check out our working example app [here](https://github.com/zapier/zapier-platform/tree/main/example-apps/files).
|
|
1395
1460
|
|
|
1396
1461
|
|
|
1397
1462
|
## Logging
|
|
@@ -1543,15 +1608,12 @@ Example: `throw new z.errors.RefreshAuthError();`
|
|
|
1543
1608
|
### Handling Throttled Requests
|
|
1544
1609
|
|
|
1545
1610
|
Since v11.2.0, there are two types of errors that can cause Zapier to throttle an operation and retry at a later time.
|
|
1546
|
-
This is useful if the API you're interfacing with
|
|
1611
|
+
This is useful if the API you're interfacing with reports it is receiving too many requests, often indicated by
|
|
1547
1612
|
receiving a response status code of 429.
|
|
1548
1613
|
|
|
1549
1614
|
If a response receives a status code of 429 and is not caught, Zapier will re-attempt the operation after a delay.
|
|
1550
|
-
The delay can be customized by the server response containing a
|
|
1551
|
-
[Retry-After](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) header
|
|
1552
|
-
|
|
1553
|
-
Another way to request Zapier retry an operation is to throw a `ThrottledError`, which may also optionally specify a
|
|
1554
|
-
delay in seconds:
|
|
1615
|
+
The delay can be customized by the server response containing a specific
|
|
1616
|
+
[Retry-After](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) header in your error response or with a specified time delay in seconds using a `ThrottledError`:
|
|
1555
1617
|
|
|
1556
1618
|
```js
|
|
1557
1619
|
const yourAfterResponse = (resp) => {
|
|
@@ -1561,6 +1623,9 @@ const yourAfterResponse = (resp) => {
|
|
|
1561
1623
|
return resp;
|
|
1562
1624
|
};
|
|
1563
1625
|
```
|
|
1626
|
+
Instead of a user’s Zap erroring and halting, the request will be repeatedly retried at the specified time.
|
|
1627
|
+
|
|
1628
|
+
For throttled requests that occur during processing of a webhook trigger's perform, before results are produced; there is a max retry delay of 300 seconds and a default delay of 60 seconds if none is specified. For webhook processing only, if a request during the retry attempt is also throttled, it will not be re-attempted again.
|
|
1564
1629
|
|
|
1565
1630
|
## Testing
|
|
1566
1631
|
|
|
@@ -1828,17 +1893,17 @@ zapier push
|
|
|
1828
1893
|
|
|
1829
1894
|
There are a lot of details left out - check out the full example app for a working setup.
|
|
1830
1895
|
|
|
1831
|
-
> To create a new integration with Babel, run `zapier init [your app name] --template babel`. You can also check out our working example app [here](https://github.com/zapier/zapier-platform/tree/
|
|
1896
|
+
> To create a new integration with Babel, run `zapier init [your app name] --template babel`. You can also check out our working example app [here](https://github.com/zapier/zapier-platform/tree/main/example-apps/babel).
|
|
1832
1897
|
|
|
1833
1898
|
## FAQs
|
|
1834
1899
|
|
|
1835
1900
|
### Why doesn't Zapier support newer versions of Node.js?
|
|
1836
1901
|
|
|
1837
|
-
We run your code on AWS Lambda, which only supports a few [versions](https://docs.aws.amazon.com/lambda/latest/dg/programming-model.html) of Node
|
|
1902
|
+
We run your code on AWS Lambda, which only supports a few [versions](https://docs.aws.amazon.com/lambda/latest/dg/programming-model.html) of Node. Sometimes that doesn't include the latest version. Additionally, with thousands of apps running on the Zapier platform, we have to be sure upgrading to the latest Node version will not have a negative impact.
|
|
1838
1903
|
|
|
1839
1904
|
### How do I manually set the Node.js version to run my app with?
|
|
1840
1905
|
|
|
1841
|
-
Update your `zapier-platform-core` dependency in `package.json`. Each major version ties to a specific version of Node.js. You can find the mapping [here](https://github.com/zapier/zapier-platform/blob/
|
|
1906
|
+
Update your `zapier-platform-core` dependency in `package.json`. Each major version ties to a specific version of Node.js. You can find the mapping [here](https://github.com/zapier/zapier-platform/blob/main/packages/cli/src/version-store.js). We only support the version(s) supported by [AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/programming-model.html).
|
|
1842
1907
|
|
|
1843
1908
|
**IMPORTANT CAVEAT**: AWS periodically deprecates Node versions as they reach EOL. They announce this[on their blog](https://aws.amazon.com/blogs/developer/node-js-6-is-approaching-end-of-life-upgrade-your-aws-lambda-functions-to-the-node-js-10-lts/). Similar info and dates are available on [github](https://github.com/nodejs/Release). Well before this date, we'll have a version of `core` that targets the newer Node version.
|
|
1844
1909
|
|
|
@@ -1933,7 +1998,7 @@ If your API uses cursor-based paging instead of an offset, you can use `z.cursor
|
|
|
1933
1998
|
|
|
1934
1999
|
Cursors are stored per-zap and last about an hour. Per the above, make sure to only include the cursor if `bundle.meta.page !== 0`, so you don't accidentally reuse a cursor from a previous poll.
|
|
1935
2000
|
|
|
1936
|
-
Lastly, you need to set `canPaginate` to `true` in your polling definition (per the [schema](https://github.com/zapier/zapier-platform/blob/
|
|
2001
|
+
Lastly, you need to set `canPaginate` to `true` in your polling definition (per the [schema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#basicpollingoperationschema)) for the `z.cursor` methods to work as expected.
|
|
1937
2002
|
|
|
1938
2003
|
<a id="dedup"></a>
|
|
1939
2004
|
### How does deduplication work?
|
|
@@ -1967,7 +2032,7 @@ InvalidParameterValueException An error occurred (InvalidParameterValueException
|
|
|
1967
2032
|
|
|
1968
2033
|
... then you need to update your `zapier-platform-core` dependency to a non-deprecated version that uses a newer version of Node.js. Complete the following instructions as soon as possible:
|
|
1969
2034
|
|
|
1970
|
-
1. Edit `package.json` to depend on a later major version of `zapier-platform-core`. There's a list of all breaking changes (marked with a :exclamation:) in the [changelog](https://github.com/zapier/zapier-platform/blob/
|
|
2035
|
+
1. Edit `package.json` to depend on a later major version of `zapier-platform-core`. There's a list of all breaking changes (marked with a :exclamation:) in the [changelog](https://github.com/zapier/zapier-platform/blob/main/CHANGELOG.md).
|
|
1971
2036
|
2. Increment the `version` property in `package.json`
|
|
1972
2037
|
3. Ensure you're using version `LAMBDA_VERSION` (or greater) of node locally (`node -v`). Use [nvm](https://github.com/nvm-sh/nvm) to use a different one if need be.
|
|
1973
2038
|
4. Run `rm -rf node_modules && npm i` to get a fresh copy of everything
|
|
@@ -2020,9 +2085,9 @@ Follow those instructions to enable completion for `zapier` commands and flags!
|
|
|
2020
2085
|
|
|
2021
2086
|
The Zapier Platform consists of 3 npm packages that are released simultaneously.
|
|
2022
2087
|
|
|
2023
|
-
- [`zapier-platform-cli`](https://github.com/zapier/zapier-platform/tree/
|
|
2024
|
-
- [`zapier-platform-core`](https://github.com/zapier/zapier-platform/tree/
|
|
2025
|
-
- [`zapier-platform-schema`](https://github.com/zapier/zapier-platform/tree/
|
|
2088
|
+
- [`zapier-platform-cli`](https://github.com/zapier/zapier-platform/tree/main/packages/cli) is the code that powers the `zapier` command. You use it most commonly with the `test`, `scaffold`, and `push` commands. It's installed with `npm install -g zapier-platform-cli` and does not correspond to a particular app.
|
|
2089
|
+
- [`zapier-platform-core`](https://github.com/zapier/zapier-platform/tree/main/packages/core) is what allows your app to interact with Zapier. It holds the `z` object and app tester code. Your app depends on a specific version of `zapier-platform-core` in the `package.json` file. It's installed via `npm install` along with the rest of your app's dependencies.
|
|
2090
|
+
- [`zapier-platform-schema`](https://github.com/zapier/zapier-platform/tree/main/packages/schema) enforces app structure behind the scenes. It's a dependency of `core`, so it will be installed automatically.
|
|
2026
2091
|
|
|
2027
2092
|
To learn more about the structure of the code (especially if you're interested in contributing), check out the `ARCHITECTURE.md` file(s).
|
|
2028
2093
|
|
|
@@ -2030,7 +2095,7 @@ To learn more about the structure of the code (especially if you're interested i
|
|
|
2030
2095
|
|
|
2031
2096
|
The Zapier platform and its tools are under active development. While you don't need to install every release, we release new versions because they are better than the last. We do our best to adhere to [Semantic Versioning](https://semver.org/) wherein we won't break your code unless there's a `major` release. Otherwise, we're just fixing bugs (`patch`) and adding features (`minor`).
|
|
2032
2097
|
|
|
2033
|
-
Broadly speaking, all releases will continue to work indefinitely. While you never *have* to upgrade your app's `zapier-platform-core` dependency, we recommend keeping an eye on the [changelog](https://github.com/zapier/zapier-platform/blob/
|
|
2098
|
+
Broadly speaking, all releases will continue to work indefinitely. While you never *have* to upgrade your app's `zapier-platform-core` dependency, we recommend keeping an eye on the [changelog](https://github.com/zapier/zapier-platform/blob/main/CHANGELOG.md) to see what new features and bug fixes are available.
|
|
2034
2099
|
|
|
2035
2100
|
For more info about which Node versions are supported, see [the faq](#how-do-i-manually-set-the-nodejs-version-to-run-my-app-with).
|
|
2036
2101
|
|
|
@@ -2051,4 +2116,4 @@ You can get help by either emailing `partners@zapier.com` or by [joining our dev
|
|
|
2051
2116
|
|
|
2052
2117
|
## Developing on the CLI
|
|
2053
2118
|
|
|
2054
|
-
See [CONTRIBUTING.md](https://github.com/zapier/zapier-platform/blob/
|
|
2119
|
+
See [CONTRIBUTING.md](https://github.com/zapier/zapier-platform/blob/main/CONTRIBUTING.md).
|