Code Monkey home page Code Monkey logo

zapier-platform's Introduction

Zapier Platform

CI

This is the main monorepo for all public code that powers the Zapier Platform Experience.

Contents

It consists of a few main packages:

Docs

zapier-platform's People

Contributors

armchairlinguist avatar bcooksey avatar bryanhelmig avatar casshill avatar codebycaleb avatar cyberwitch avatar dependabot[bot] avatar eliangcs avatar etcaton avatar fokkezb avatar gregilo avatar kaznovac avatar kola-er avatar kreddlear avatar maguay avatar marinahand avatar michellechu77 avatar ngryman avatar reganstarr avatar rnegron avatar robertscl avatar robwa10 avatar standielpls avatar stevelikesmusic avatar stevemolitor avatar szchenghuang avatar tayhalla avatar ter0 avatar xavdid avatar zanelyon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zapier-platform's Issues

When you pass on a file (URL) using form-data it doesn't use the Content-Disposition filename

This issue submission follows a conversation with Fokke.

Your "creates/upload.js" shows use of Form-Data and request to upload a file presented to a create by a trigger. However, I have seen Form-Data is not receiving the filename from the Content-Disposition line. I have had to set filename manually (providing a placeholder) using the Alternate Submission Methods and submitted PR #7 relating to this.

Form-Data says that it "can recognize and fetch all the required information from common types of streams (fs.readStream, http.response and mikeal's request)". This suggests that the filename is not getting to request and/or Form-Data correctly. (Perhaps the issue is in stashing and/or dehydration - though I admit I am not super familiar with the impact of those.) Fokke and I have both observed Form-Data using the value from path in this method

Thank you for your attention to this.

Dynamic Samples Support

I have built a trigger in my zapier cli that makes request to different urls based on the value of a dropdown. Now I want to apply dynamic samples for this trigger based on the value of this dropdown. Can I do that? I tried this, but did not work -

{
  key: 'searchInvoice',
  noun: 'Filter Invoices',
  display: {
    label: 'Filter Invoices',
    description: 'Triggers when a new Invoice is added that meets the specific conditions'
  },
  operation: {
    inputFields: [
      { key: 'invoiceType', type: 'string', required: true, choices: { 'drafts': 'Drafts', 'booked': 'Booked', 'paid': 'Paid', 'unpaid': 'Unpaid', 'overdue': 'Overdue', 'not-due': 'Not-Due', 'sent': 'Sent' }, label: 'Invoice Type', helpText: 'The Invoice Type.' }
    ],
    sample: {getDynamicSample}, // this did not work!!
    perform: filterInvoices,
    outputFields: [getDynamicOutputFields]
  }
}

// actual function
const getDynamicSample = (z, bundle) => {
// does not even get called
console.log(bundle.inputData);

};

Current Behavior

returns the name of the function as key and value as function (uglified). The function does not even get called.

Desired Behavior

The function gets called and loads different sampes based on value of input field dropdown.

zapier push --without-style does not work

The CLI command "zapier push --without-style", as described at https://zapier.github.io/zapier-platform-schema/build/schema.html#basichookoperationschema does not work. It works well with zapier validate, but it still cannot push any data without style even for a private app.

There response I get is:
zapier push --without-style

Errors running command zapier push --without-style:

!!! Unexpected keyword argument --without-style

For more information, run zapier help push.

Child field ‘required’ settings are globally scoped, but maybe should be parent-scoped

I'm getting:

Error: missing the required address field locality

with inputFields like:

{
  key: 'address',
  label: 'Address',
  children: [
    {
      key: 'street-address',
      label:'Street Address',
      type: 'string',
      placeholder: '123 Main St.'
    },
    {
      key: 'locality',
      label: 'Locality',
      helpText: 'For most addresses, this is the city name.',
      type: 'string',
      required: true,
      placeholder: 'Anytown'
    },
    
  ]
}

My intention is to have address be optional as a whole (e.g. {} would be valid input) but if address is set, then address.locality must be set (e.g. {address: {locality: 'Anytown'}} would be valid, while {address: {}} would be invalid).

Zapier fails to build when the module depends on a relative file

In my app I need to use local package, so I specify it in package.json:

  "dependencies": {
    "fibery-schema": "file:../fibery-schema",
    "lodash": "4.17.4",
    "zapier-platform-core": "5.1.0"
  },

zapier-cli when building copies project to a temp folder and installs dependencies there and of course can not find this package:

$ zapier build
Building project.

  Copying project to temp directory ⠃ done!
  Installing project dependencies ⠆

Error! npm ERR! code ENOLOCAL
npm ERR! Could not install from "../fibery-schema" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/itsu/.npm/_logs/2018-04-23T14_46_40_886Z-debug.log

In logs:

56 verbose stack Error: ENOENT: no such file or directory, open '/private/var/folders/bf/9_3xh2310kl_p8_wxwpfpb180000gn/T/fibery-schema/package.json'
57 verbose cwd /private/var/folders/bf/9_3xh2310kl_p8_wxwpfpb180000gn/T/zapier-2ec52d0b

Zapier information:

$ zapier -v
zapier-platform-cli/5.2.0
zapier-platform-core/5.1.0
node/v9.11.1

While I can use absolute path I can not commit it as it will not work for other developers of our app.

inputData provides children field data multiple times

What would you like to change?

The bundle.inputData provided by an action's perform function is sending the same data (nested at different levels) in multiple fields when children fields are used.

Example

expected:

"inputData": {
		"favourite": [{
			"food": "the description of the first line item"
		}, {
			"food": "This second item is fab"
		}],
		"address": [{
			"number": 10.5,
			"street": "First Item"
		}, {
			"number": 5.0,
			"street": "Second Item"
		}],
		"table_id": "repeated",
		"dataset_id": "casstest_dataset1",
		"project_id": "cass-test-232905"
	}

actual:

(note the extra street, number and food fields)

"inputData": {
		"street": "First Item,Second Item",
		"favourite": [{
			"food": "the description of the first line item"
		}, {
			"food": "This second item is fab"
		}],
		"address": [{
			"number": 10.5,
			"street": "First Item"
		}, {
			"number": 5.0,
			"street": "Second Item"
		}],
		"food": "the description of the first line item,This second item is fab",
		"table_id": "repeated",
		"dataset_id": "casstest_dataset1",
		"project_id": "cass-test-232905",
		"number": "10.5,5"
	}

Your Environment

  • CLI Version (zapier -v):
zapier-platform-cli/8.0.1
zapier-platform-core/8.0.1
node/v8.10.0

"Invalid cursor" error when using resources instead of triggers

What would you like to change?

When calling z.cursor.get or z.cursor.set in a trigger, the appTester does not raise an error.

However, copying the same code to a resource's list.operation.perform and running a test against that resource will raise an error:

Invalid cursor operation. `z.cursor` can only be used in `perform` methods of polling triggers and when `canPaginate` is `true`.

Investigation seems to point to https://github.com/zapier/zapier-platform-core/blob/48ddbd4a355723bd04143ef64da9319c1d4e1ebf/src/tools/create-app-tester.js#L9-L21 being the area that needs adjusted (it checks for triggers but not resources).

Your Environment

  • CLI Version (zapier -v):
zapier-platform-cli/8.1.0
zapier-platform-core/8.1.0
node/v10.5.0
  • App id: 20367

convert command fails when code ends with comment

Bug Description

In visual builder, if the custom code ends with a single-line comment // ..., zapier convert will fail with this traceback:

  zapier:convert     at t (/.../zapier-platform-cli/node_modules/prettier/parser-babylon.js:1:264)
  zapier:convert     at Object.parse (/.../zapier-platform-cli/node_modules/prettier/parser-babylon.js:1:214621)
  zapier:convert     at Object.parse$2 [as parse] (/.../zapier-platform-cli/node_modules/prettier/index.js:10629:19)
  zapier:convert     at coreFormat (/.../zapier-platform-cli/node_modules/prettier/index.js:13888:23)
  zapier:convert     at format (/.../zapier-platform-cli/node_modules/prettier/index.js:14146:73)
  zapier:convert     at formatWithCursor (/.../zapier-platform-cli/node_modules/prettier/index.js:14162:12)
  zapier:convert     at /.../zapier-platform-cli/node_modules/prettier/index.js:42756:15
  zapier:convert     at Object.format (/.../zapier-platform-cli/node_modules/prettier/index.js:42775:12)
  zapier:convert     at prettifyJs (/.../zapier-platform-cli/packages/cli/src/utils/convert.js:44:12)
  zapier:convert     at renderStep (/.../zapier-platform-cli/packages/cli/src/utils/convert.js:196:10) +2s
 ›   Error: Unexpected token

Reproduction Steps

  1. Create an integration in visual builder
  2. Create a trigger or an action
  3. Switch to code mode for that trigger/action
  4. Edit the code so that it ends with a single-line comment, such as:
return {
  'message': 'ok'
};
// this line would break `zapier convert`
  1. Run zapier convert APP_ID ./myapp --version 1.0.0 --debug

Version Info

$ zapier -v
zapier-platform-cli/9.0.0 darwin-x64 node-v10.16.3

Integration vs app?

In the web UI, it looks like apps have been renamed to integrations—is that correct? If so, it seems like zapier-platform has not been updated with this new name, which is causing me some confusion.

CHANGELOG.md incorrect format error is misleading

If you don't have a trailing newline at the end of your CHANGELOG.md file then the CLI will fail with:

Warning! Changelog not found. Please create a `CHANGELOG.md` file in a format similar to https://gist.github.com/xavdid/b9ede3565f1188ce339292acc29612b2, with user-facing descriptions

I'm okay with it wanting it in the exact format but the error message made it seem like the file was in the wrong directory / didn't exist.

UPDATE:
This also is the case if you don't have an empty line between the version number and the bullet points.

What would you like to change?

Improve error messaging about validating the file structure or more forgiving validation.

Your Environment

  • zapier-platform-cli/7.0.0
  • zapier-platform-core/7.0.0
  • node/v8.10.0
  • OSX High Sierra 10.13.3

Add field key to trigger params when using dynamic dropdowns.

Current Behavior

Currently, triggers on dynamic dropdowns do no know what field called them. So if you have input fields generated dynamically, and you want to have the same trigger be used for all of them, you have no way of knowing what field called what trigger.

for example I have 2 fields on an object called "owner" and "company"
the Api call would be the same, but i need to pass in the field that called it.
so I can make 2 triggers ownerlist.id.name and companylist.id.name

However, our list of input fields is generated dynamically. Ie, a user may have a custom input field "pets" but we don't have a trigger made for it, because we don't know if it will exist at runtime.

Desired Behavior

I believe this request might be a duplicate of #22 but I am asking for a slightly different use-case. While custom bundle properties might be the more idea solution, I think simply passing in some argument into the trigger that tells you where it came from (input field key) we could then re-use the same logic for multiple fields without needing to make a trigger for every single one.

if our triggers knew what the field was that called them, we could support tons of additional functionality

const getRelatedData = (z, bundle, fieldKey) => {
}

Dynamic fields do not properly support "default" property

Bug Description

Multiple reports have come in where developers want to use the default property for a field that is generated dynamically, but the property is not respected (i.e. when a value is not provided for a task, the default value is not used).

Reproduction Steps

  1. Create a Trigger or Action that uses a dynamic field with a default value (e.g. () => {key: "test", default: "foo"}
  2. Create a Zap using that Trigger or Action
  3. Test the Zap without providing a value for the field

prefill option for FieldSchema

I know that I can use a default value option, but users can not easily change this default value. He needs to fill it again.

It there any other way how to do it?

It would be great to have a prefill option.

For hooks, provide access to bundle.subscribeData in perform function

What would you like to change?

The bundle.subscribeData object is available in the performUnsubscribe function defined on hook operations. It makes it easy to keep a reference on the hook to be deleted.

It might also be useful to have it accessible in the perform function. In my particular use case, my platform generates a unique token when the webhook is registered, that allows clients to validate the origin of requests. It would be stored in bundle.subscribeData. I would like to be able to do something like this in my perform function:

const getMyThing = (z, bundle) => {
    const {instance, token} = bundle.cleanedRequest;
    if (token !== bundle.subscribeData.token) {
        throw new Error(`Validation token '${token}' is not the expected value.`);
    }
    return [instance];
}

Your Environment

  • CLI Version (zapier -v): zapier-platform-cli/5.1.0, zapier-platform-core/5.1.0, node/v6.10.3
  • Operating System and version: MacOS 10.13.4

validate provides incorrect explanation link

Bug Description

When validating a CLI project, if there is a warning/error/etc, it provides some information that includes a link to the schema for the issue. The link is incorrect and leads to a 404.

Reproduction Steps

 zapier validate

Validating project locally.
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ = 1 =                                                                                                        │
│     Property │ App.creates.work_item_comment.operation.inputFields[0].                                       │
│     Message  │ additionalProperty "helptext" exists in instance when not allowed                             │
│     Links    │ https://github.com/zapier/zapier-platform-schema/blob/v8.4.2/docs/build/schema.md#fieldschema │
└──────────────┴───────────────────────────────────────────────────────────────────────────────────────────────┘

Version Info

  • Version info: zapier-platform-cli/8.4.2
    zapier-platform-core/8.4.2
    node/v10.13.0
  • Operating System: Windows 10
  • App id: 21129

Where is the latest changelog?

subscribeData information is missing in performUnsubscribe

Using the Platform UI, there is no way to modify a temporary subscribeData when using the emulated tests.

Here is the parsed response.content from the performSubscribe hook:

{
  "hook": [
    {
      "hookId": "2f9075ca-50f3-4aee-8152-6005719d70f0",
      "created_at": "2019-07-18T21:59:17.219Z",
      "companyId": "125b2f08-0b9d-418d-a013-28633f8b7c89",
      "updated_at": "2019-07-19T02:55:28.582Z",
      "targetUrl": "https://hooks.zapier.com/fake-subscription-url"
    }
  ],
  "success": true
}

I would expect to be able to access this data inside of performUnsubscribe in order to pass the hookId to my DELETE call. But It's not there! I cannot get reference values from using either the code editor OR the form editor.

and here is the output from performUnsubscribe:

{
  "authData": {
    "success": true,
    "userId": ":censored:36:b824e6a29a:",
    "defaultCompanyId": ":censored:36:f99b159ffe:",
    "result": true,
    "password": ":censored:6:b0026d6dfb:",
    "email": ":censored:20:3324b63c56:"
  },
  "subscribeData": {},
  "meta": {
    "isTestingAuth": false,
    "isLoadingSample": false,
    "limit": -1,
    "isPopulatingDedupe": false,
    "isFillingDynamicDropdown": false,
    "page": 0,
    "zap": {}
  },
  "targetUrl": "https://hooks.zapier.com/fake-subscription-url",
  "inputDataRaw": {},
  "inputData": {}
}

Another related issue is that through the documentation it mentions that there is some place to go to RAW mode in the documentation. I don't see that option anywhere on the current UI.

Screen Shot 2019-07-18 at 8 04 38 PM

URL Encoding inconsistent in z.request

Current Behaviour

If you create a request using z.request, URL params are encoded differently depending on if you specify them in the url field vs the params field.

Expected Behaviour

If you create a request using z.request, I would expect that query params are encoded the same way if you pass them in via the url param as if you pass them in via the params param. If this is a "feature", I'd expect documentation to exist explaining this (it's possible this exists and I'm just missing it ^.^)

Example

const response = await z.request({
    url: `foobar.com/some/path/query`,
    params: {
      q: 'SELECT+ID+FROM',
    }
  });

results in a query param of SELECT%2BID%2BFROM

whereas

const response = await z.request({
    url: `foobar.com/some/path/query?q=SELECT+ID+FROM`,
  });

results in a query param of SELECT%20ID%20FROM (notice the plus has been encoded as a space rather than as a plus in this case).

Expose the Zap/App that triggered an Action

Hi guys and thank you for an awesome platform!

We're having an action that creates some messages in our databases and we'd like to know the origin of them. We're storing triggers' corresponding zap id via performSubscribe then find their steps via https://api.zapier.com/v1/zaps, but actions don't seem to support performSubscribe and don't include zap id in their perform request's metadata.

Can you show us a way to get the Zap/App that triggered an Action? If this feature is missing, can we request or help implement it? Thank you.

Legacy scripting runner does not support Actions that return nothing

Bug Description

It seems that apps built with the old Web Builder platform didn't have a hard requirement that Actions returned objects. With apps being migrated, I've spotted a couple that have been throwing errors because their Visual Builder counterparts are not returning objects.

Reproduction Steps

  1. Create an Action in a Web Builder app with post_write scripting that returns nothing
  2. Have the app migrated to the Visual Builder Platform
  3. Test out the Action

Node 12 support

Current Behavior

AWS Lambda version is pinned to Node 8

Desired Behavior

AWS supports latest stable Node version (version 12). This comes with latest Javascript features minimizing the need to transpile when using newer JavaScript features.

Add command to change multiple env variables at once

Add command to change multiple env variables at once

As a developer I would like to have a cli command that let me change env variables easily. This will help to move around different environments.

At the moment I need to do zapier env <version> <variable> <value> and I have multiple variables that depends on the develop, stage or production environment.

So a command like zapier bulk <version> <file_name> should be awesome, changing my environment in one easy step, improving the develop process.

As a fact, my team has two zapier apps, one for production and other for development, all with isolated variables for security purpose.

How to include event name in performSubscribe hook

My understanding is that when a subscription is created via rest hooks it should include a name for the particular event that the user is interested in e.g. user_registered. The server is then able to trigger rest hooks at the appropriate times. I haven't been able to find any documentation for the performSubscribe hook showing how to include this event name, is it available on the bundle somehow?

All z.requests fail with empty error in catch in v8.1.0

All http requests made with z.request fail. Even making a simple request to a website fails. In the catch block, the error is just an empty object.

Example:

const requestExample = (z, bundle) => {
    return z.request('https://www.google.com')
        .then(response => {
            return 'successful';
        })
        .catch(error => {
            return JSON.stringify(error);
        });
};

Downgrading to v8.0.1 resolves the issue.

Support helpText for fields with children

Setting inputFields like:

{
  key: 'person',
  label: 'Person',
  helpText: 'This field contains user information.  If any of these fields are set, you must also set …',
  children: [
    {key: 'name', label: 'Name'}
  ]
}

raises zapier validate errors like:

│     Property │ App.creates.person.inputFields[0]                                                                │
│     Message  │ must not contain children and helpText, as they're mutually exclusive.                           │
│     Links    │ https://github.com/zapier/zapier-platform-schema/blob/v5.1.0/docs/build/schema.md#fieldschema    │

It would be nice if this was possible. I expect implementing this would also require UX changes to display the parent helpText and is more than just lifting this restriction, but hopefully it makes sense as a long-term feature request. In the short term, it's probably worth updating the docs here and here to mention the limitation.

Pass parameters to the hidden trigger

In my Platform CLI integration I have 2 public triggers which use same dynamic dropdown element and same hidden trigger behind it.
Now I want to be able to customize the request my hidden trigger produces.

So let say the hidden trigger (behind the dynamic dropdown) produces object list, but for 1st public trigger I want to show only object with type=1, and in 2nd public trigger with type=3.

So I want to see my perform function in the hidden trigger like this:

const getFrogList = (z, bundle) => {
  const requestOptions = {
    url: `${process.env.BASE_URL}/api/frogs/getall`,
    params: {type: bundle._MY_CUSTOM_TYPE_FIELD}
  };

  return z.request(requestOptions)
  .then((response) => z.JSON.parse(response.content));
};

And in my public trigger:

inputFields: [
{
  key: "frog",
  type: "string",
  helpText: "Please define which kind of frog you want to use",
  label: "Frog",
  dynamic: "getFrogList.id.name",
  altersDynamicFields: true,
  required: true,
  _MY_CUSTOM_TYPE_FIELD: 1
 } 
]

Scaffold commands shouldn't overwrite existing files

What would you like to change?

Currently Scaffold commands will rewrite the contents of the file created by the scaffold command if it already exists. As such work can be lost by accidentally running the scaffold command on an existing resource/trigger/action.

We should error out of the scaffold command and warn the user that the file already exists. Or provide them an option to force an overwrite.

Unable to create dependent input field from dynamic field.

I wanted to create a form where below 4 fields of the form is dependent on the option that user choose in the middle of the form.

I have read the Zapier document and also used their script but unable to succeed. i think something i am missing to implement.

pls guide

delete

I use technology in order to hate it more properly.
		-- Nam June Paik

cli-app > bundle size

Hi Zapier Team,

the zapier-platoform has a hard limit of 6MB for cli-apps. This is nice to keep the upload process fast and the app in a maintainable size - 👍 nice engineered! We just hit that hard limit with our app and I investigated where all the space goes.

Screenshot 2019-11-13 at 11 06 22

It turns out that the node_modules folder is already 5MB and the biggest packages are zapier-platform-core and zapier-platform-schema

Is there any chance that we could tackle this issue. I have some ideas on how to avoid a big node_modules e.g:

  • Reduce size of zapier-platform-core and zapier-platform-schema by remove lodash
  • Remove zapier-platform-core as required dependency for every app (could be a dev-dep in my opinion?)
  • Set the max bundle limit to 7 or 8 MB.

What do you think about this? Is this an issue for other partners as well?

Best Stefan

Pagination during testing triggers

Hello everybody,

I use REST hook trigger in my Zapier application and I think that it would be useful to actually load more examples using the button "Get More Examples" when users of my Zapier application test the trigger on the step "Pick A Sample To Set Up Your Zap". If user previously pulled out some set of the samples sorted by their creation date, they will wait for nothing for 3 minutes (since Zapier makes an attempt to find new entities for the 3 minutes) because the request initialized by this Zapier UI button "Get More Examples" doesn't use the pagination.

During these 3 minutes Zapier consequently requests my server in order to find if there are any new entities. This chain of requests will be stopped only if there are some new entities in the server response during this 3 minutes.

But I think when user clicks "Get More Examples" it's logical to load older entities using the bundle.meta.page attribute since all the entities are sorted by the creation date in the descending order. Zapier can try to check if there are any new entities and if there are no new entities, try to load some older entities.

Let's say I have 7 clients:

[
	{"id":1, "name": "Client #1", "created_at": "2013-01-10 10:10:10"},
	{"id":2, "name": "Client #2", "created_at": "2014-01-10 10:10:10"},
	{"id":3, "name": "Client #3", "created_at": "2015-01-10 10:10:10"},
	{"id":4, "name": "Client #4", "created_at": "2016-01-10 10:10:10"},
	{"id":5, "name": "Client #5", "created_at": "2017-01-10 10:10:10"},
	{"id":6, "name": "Client #6", "created_at": "2018-01-10 10:10:10"},
	{"id":7, "name": "Client #7", "created_at": "2019-01-10 10:10:10"}
]

Using the bundle.meta.limit parameter the operation.performList of my trigger returns three the most recent clients:

[
	{"id":7, "name": "Client #7", "created_at": "2019-01-10 10:10:10"},
	{"id":6, "name": "Client #6", "created_at": "2018-01-10 10:10:10"},
	{"id":5, "name": "Client #5", "created_at": "2017-01-10 10:10:10"}
]

When users click the "Get More Examples" button, Zapier can send two requests: one to check the most recent entities (bundle.meta.page is 0 or unset) and the second to load the clients from the other "page" consequently increasing the bundle.meta.page parameter each time when users hit this button. Second request can be sent only if there are new entities found by the first request.

If there are no new clients, users will see the 3 old clients, thanks to the bundle.meta.page=2

[
	{"id":4, "name": "Client #4", "created_at": "2016-01-10 10:10:10"},
	{"id":3, "name": "Client #3", "created_at": "2015-01-10 10:10:10"},
	{"id":2, "name": "Client #2", "created_at": "2014-01-10 10:10:10"}
]

If users click "Get More Examples" one more time, the bundle.meta.page will be set to 3, so the following response will be returned:

[
	{"id":7, "name": "Client #7", "created_at": "2019-01-10 10:10:10"}
]

If there are new clients, then Zapier can show them and don't search for the other clients. In that case Zapier UI can provide more samples in all situations when there are more than 3 entities of the requested type on my server.

Thanks.

Built-in session auth refresh handler interfering with developer intention

Bug Description

According to the docs and session auth example, you should throw a z.errors.RefreshAuthError, inside an after-response middleware function.

But in reality, the platform was automatically adding a refresh method, handler.

(Registered here: https://github.com/zapier/zapier-platform/blob/master/packages/core/src/tools/create-app-request-client.js#L56-L64.)

This behaviour stops the App developer to handling 401 responses, like, wrong username/password.

I think, either a config option to opt-out the inclouding the handler, like OAuth2, or prioritising the developer-defined session refresh method would solve this issue.

Reproduction Steps

Try to catch the thrown error.

    appTester(App.authentication.test, bundle)
      .then(response => {
        response.status.should.eql(401);
        done();
      })
      .catch(error => {
        // This is not working. For 401 response, the platform throwing an error.
        error.message.should.containEql('Session key needs refreshing.');
        done();
      });

Version Info

  • Version info: zapier-platform-cli/9.1.0 darwin-x64 node-v10.19.0
  • Operating System: Mac OS X 10.15.3

Feature Request: Allow calling the `z.request` method within tests

In our Zapier App, we' touch a real API instance, instead of relying on mocking, because that makes we more confident about our tests.

Since doing that is slow, we're using the Sepia library to cache HTTP requests on tests (a HTTP request is only made by the first time for a given endpoint): https://github.com/linkedin/sepia

Well, it'd be really useful to do HTTP request directly on tests using the request method (currently only available inside the Zapier App as z.request), for example, to fetch a given record and pass as parameter to a given function. I'd expect that to execute middlewares, like the authentication one.

Zapier Platform Docs broken in Firefox

Bug Description

The Platform docs located at https://zapier.github.io/zapier-platform/ are quite broken in Firefox:
image

Issue still occurs with all extensions and tracking protection turned off.

Reproduction Steps

  1. Open Firefox (latest version or close to it)
  2. Navigate to https://zapier.github.io/zapier-platform/
  3. Scroll the page until you find overlapping content that is unreadable.

Misc

I had a small go at fixing the CSS myself but it seems like a pretty deep issue that casual inspect element hacking won't resolve. Best of luck

Validate: Message for incorrect outputField property unclear

When you have a trigger definition in a CLI app that looks like this:

module.exports = {
[...]

  operation: {
    perform: triggerCustomer,
    sample: sample,
    outputFields : [
    {
      key: 'isOptIn',
      label: 'Is Opted In',
      type: 'bool'
    } 
  } 
}

The problem is the type of the outputFields is set to bool when it should be boolean. Unfortunately the error message reads:

Ideally, this would narrow down the error to say that the outputFields field is wrong, not the parent operation, or even better to specifically point out that the type field is wrong.

Format of bundle.cleanedRequest

Hi, having been playing with this example app for the whole day, it's excellent, thanks.

One thing I'm not sure - should bundle.cleanedRequest be an object or an array of object?
I can see in the demo code triggers/recipe.js, in the getRecipe function, bundle.cleanedRequest is used as a single object. But in my case, it's an array - have to use in the way like bundle.cleanedRequest[0].id.

The data I post to hook url is like [{ id: '1', name: 'a' }], and I'm working with CLI.

Have I done something wrong?

3 severe vulnerabilities from lodash 4.17.11

npm audit reports 3 severe vulnerabilities from zapier-platform-cli and zapier-platform-core because of old version of lodash (4.17.11).

Updating lodash dependency would fix this.

Typescript bindings

This won't happen until we've got a 1.0 and a stable API, but bindings would be great. I'd be hapy to jump on it once we're ready!

All it'll be a .ts file in the repo and a line in the package.json

Look into supporting inputFields with list and children

Could we support list + children? How would it look?

Spun off from zapier/zapier-platform-cli#114 @ZenCocoon is this how you'd want it to work? A use case here would also help evaluate this in the future.

Definition

...
inputFields: [
  {
    key: "phones",
    label: "Phones",
    list: true,
    children: [
      { key: 'default', label: 'Default' },
      { key: 'home', label: 'Home' },
      { key: 'business', label: 'Business' },
    ]
  },
],
...

Output

...
"phones:" [
  { "default": "123123", "home": "123123", "business": "123123" },
  { "default": "123123", "home": "123123", "business": "123123" }
]

UI

?

SSO deploy key link navigates to incorrect URL

Bug Description

Running zapier login --sso outputs instructions in how to set up a deploy key.
Clicking the link that outputs in the following help will include the , at the end, navigating the user to a 404

See https://zapier.com/developer/partner-settings/deploy-keys/,

Reproduction Steps

  1. zapier login --sso
  2. Click the link in the deploy key generation text that is output to the console

Version Info

  • Version info: zapier-platform-cli/9.1.0
  • Operating System: darwin-x64

connectionLabel needs documentation

Bug Description

The connectionLabel property that it's recommended to define when setting up authentication isn't sufficiently documented (or at least not as far as I could find). I've tried various iterations of {{bundle.inputData.field}} in string and function form, but when connecting an account in Zapier, that string literal is displayed (if a function is used, I've assumed z and bundle are the two arguments, and when I connect, no connection label is shown).

To explain what I mean: when connecting an account to create a Zap, the app name is shown, and alongside that is the actual literal text "{{bundle.inputData.field}}", where "field" is the correct field defined in my API.

I assume this is just something that needs improved documentation, rather than a bug in how the connection label is specified, although I am using the following, as my API conforms to jsonapi.org specs, and therefore uses hyphens:

{{bundle.inputData['podcast-name']}}

Reproduction Steps

Create an authentication module like this:

module.exports = {
  type: 'custom',
  test: (z, bundle) => {...},
  connectionLabel: '{{bundle.inputData[\'podcast-name\']}}',
  fields: [...]
}

Version Info

  • Version info: 9.1.0
  • App ID: 4645

Publish new version for lodash vulnerability

Current Behavior

The 8.3.0 version has a dependency on lodash that fails npm audit checks.

Desired Behavior

Publish a new version that fixes this dependency.

I see that it was already fixed with #53 and #54, but I'm trying to build the code for a new integration into a larger code base and need the audit checks to pass.

Injected environment variables can't be used in any imports

This won't work in a Babel app:

import zapier from 'zapier-platform-core';
zapier.tools.env.inject()
import { authData } from './testUtils';

Where testUtils.js is:

export const authData = {
  api_key: process.env.API_KEY,
};

This is because Babel will hoist import so ./testUtils will be imported before zapier.tools.env.inject() runs.

I've tried to find workarounds, but the only viable seem to be either changing authData to be a function or don't use environment variables in imported scripts.

I wonder zapier-platform-core should automatically inject environment variables on its import if process.env.LOADED_MOCHA_OPTS === 'true' (which seems to be the only environment variable set if you run tests).

Any ideas?

How to Handle files in Zapier Platform UI

How do I handle a file a file response in my App when building in Zapier UI?

I've made a simple action that downloads a file from a URL, but there is no documentation around Files for Platform UI and how to return the response in the correct format for Zapier to recognise as a file.

It only is referred to in CLI documentation using Hydrate which doesn't appear to work in UI.

I want my app to download a file and pass it to the next app in Zapier.

https://platform.zapier.com/docs/actions

z.request() should be able to take custom beforeRequest and afterResponse functions

My particular use case is that I have a generic error handler configured in App.afterResponse. However, for some requests, 404 or other errors are ignorable errors (but would be considered errors for other requests).

Ideally, it would be possible to specify a custom afterResponse list of methods, which would be executed instead of the App.afterResponse. This would allow for custom error handling for those requests, while leaving the generic error handling in place for all other requests.

What would you like to change?

const App = {
  beforeRequest: [addAuthorizationHeader],
  afterResponse: [checkSuccessResponse],
}

It would be nice if I could override the middleware handlers for specific requests:

return z.request('http://my.website.com/api'
  {
    method: 'POST',
    afterResponse: [customCheckSuccessResponse],
  });

In this case, only customCheckSuccessResponse would be executed after the requests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.