Skip to content
This repository has been archived by the owner on Jul 12, 2019. It is now read-only.

Introduce z.dehydrateFile #112

Merged
merged 7 commits into from
Sep 25, 2018
Merged

Introduce z.dehydrateFile #112

merged 7 commits into from
Sep 25, 2018

Conversation

eliangcs
Copy link
Member

@eliangcs eliangcs commented Sep 19, 2018

Adds z.dehydrateFile to CLI. Requires https://github.com/zapier/zapier/pull/19954.

z.dehydrateFile has two function signatures:

  • z.dehydrateFile(func, inputData): Nothing different from z.dehydrate(func, inputData) except that we're annotating the payload with an "it's for a file" tag. So the backend knows not to hydrate it too early in Zap editor.
  • z.dehydrateFile(url, request, meta): We'll run hydrators.zapierDefaultFileHydrator, which is injected at runtime as part of the app initialization. zapierDefaultFileHydrator provides the default implementation for the most common use cases. It downloads the file from the trigger-side app and uploads it to S3 with z.stashFile.

@eliangcs eliangcs changed the title Add z.dehydrateFile (WIP) Add z.dehydrateFile Sep 19, 2018
@eliangcs eliangcs changed the title (WIP) Add z.dehydrateFile (WIP) Introduce z.dehydrateFile Sep 19, 2018
@eliangcs eliangcs changed the title (WIP) Introduce z.dehydrateFile Introduce z.dehydrateFile Sep 20, 2018
Copy link
Contributor

@bcooksey bcooksey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this locally on my machine, both with a function and a simple URL. Confirmed that we no longer hydrate too eagerly during Zap setup, that the default hydrator works, the function version works, and the caching let the editor keep using the same S3 URL.

Big wins!

}
}).should.throw(
'We could not find your function/array/object anywhere on your App definition.'
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement on these tests!

});
};

const dehydrateFileFromFunc = (func, inputData) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fromRequest and fromFunc threw me off a bit on first read cause it made me go "wait, we should be hydrating from a request or a func." I see now that it's communicating "dehydrate, with request as hydration options" or "dehydrate, with func as hydration options", but that doesn't make a very good method name. Unfortunately don't have anything better, so happy to roll with this for now.

@eliangcs eliangcs merged commit 1e69c35 into master Sep 25, 2018
@eliangcs eliangcs deleted the z.dehydrateFile branch September 25, 2018 07:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants