Skip to content

Commit

Permalink
add dehyrateFile and improve overloads for stashFile (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
xavdid authored Jun 10, 2020
1 parent 57f9b04 commit bb4bfcb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3681,7 +3681,7 @@ <h3 id="file-dehydration">File Dehydration</h3>
<div class="row-height">
<div class="col-md-5 col-sm-12 col-height docs-primary">
<p><em>New in v7.3.0.</em></p><p>The method <code>z.dehydrateFile(func, inputData)</code> allows you to download a file lazily. It takes the identical arguments as <code>z.dehydrate(func, inputData)</code> does.</p><p>An example can be found in the <a href="#stashing-files">Stashing Files</a> section.</p><p>What makes <code>z.dehydrateFile</code> different from <code>z.dehydrate</code> has to do with efficiency and when Zapier chooses to hydrate data. Knowing which pointers give us back files helps us delay downloading files until its absolutely necessary. A good example is users creating Zaps in the Zap Editor. If a pointer is made by <code>z.dehydrate</code>, the Zap Editor will hydrate the data immediately after pulling in samples. This allows users to map fields from the hydrated data into the subsequent steps of the Zap. If, however, the pointer is made by <code>z.dehydrateFile</code>, the Zap Editor will wait to hydrate the file. There&apos;s nothing in binary file data for users to map in the subsequent steps.</p><blockquote>
<p><code>z.dehydrateFile(func, inputData)</code> is new in v7.3.0. We used to recommend to use <code>z.dehydrate(func, inputData)</code> for files, but it&apos;s not the case anymore. Please change it to <code>z.dehydrateFile(func, inputData)</code> for a better user expereience.</p>
<p><code>z.dehydrateFile(func, inputData)</code> is new in v7.3.0. We used to recommend to use <code>z.dehydrate(func, inputData)</code> for files, but it&apos;s not the case anymore. Please change it to <code>z.dehydrateFile(func, inputData)</code> for a better user experience.</p>
</blockquote>
</div>
<div class="col-md-7 col-sm-12 col-height is-empty docs-code">
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/README-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ An example can be found in the [Stashing Files](#stashing-files) section.

What makes `z.dehydrateFile` different from `z.dehydrate` has to do with efficiency and when Zapier chooses to hydrate data. Knowing which pointers give us back files helps us delay downloading files until its absolutely necessary. A good example is users creating Zaps in the Zap Editor. If a pointer is made by `z.dehydrate`, the Zap Editor will hydrate the data immediately after pulling in samples. This allows users to map fields from the hydrated data into the subsequent steps of the Zap. If, however, the pointer is made by `z.dehydrateFile`, the Zap Editor will wait to hydrate the file. There's nothing in binary file data for users to map in the subsequent steps.

> `z.dehydrateFile(func, inputData)` is new in v7.3.0. We used to recommend to use `z.dehydrate(func, inputData)` for files, but it's not the case anymore. Please change it to `z.dehydrateFile(func, inputData)` for a better user expereience.
> `z.dehydrateFile(func, inputData)` is new in v7.3.0. We used to recommend to use `z.dehydrate(func, inputData)` for files, but it's not the case anymore. Please change it to `z.dehydrateFile(func, inputData)` for a better user experience.
## Stashing Files

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2228,7 +2228,7 @@ An example can be found in the [Stashing Files](#stashing-files) section.

What makes `z.dehydrateFile` different from `z.dehydrate` has to do with efficiency and when Zapier chooses to hydrate data. Knowing which pointers give us back files helps us delay downloading files until its absolutely necessary. A good example is users creating Zaps in the Zap Editor. If a pointer is made by `z.dehydrate`, the Zap Editor will hydrate the data immediately after pulling in samples. This allows users to map fields from the hydrated data into the subsequent steps of the Zap. If, however, the pointer is made by `z.dehydrateFile`, the Zap Editor will wait to hydrate the file. There's nothing in binary file data for users to map in the subsequent steps.

> `z.dehydrateFile(func, inputData)` is new in v7.3.0. We used to recommend to use `z.dehydrate(func, inputData)` for files, but it's not the case anymore. Please change it to `z.dehydrateFile(func, inputData)` for a better user expereience.
> `z.dehydrateFile(func, inputData)` is new in v7.3.0. We used to recommend to use `z.dehydrate(func, inputData)` for files, but it's not the case anymore. Please change it to `z.dehydrateFile(func, inputData)` for a better user experience.
## Stashing Files

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3681,7 +3681,7 @@ <h3 id="file-dehydration">File Dehydration</h3>
<div class="row-height">
<div class="col-md-5 col-sm-12 col-height docs-primary">
<p><em>New in v7.3.0.</em></p><p>The method <code>z.dehydrateFile(func, inputData)</code> allows you to download a file lazily. It takes the identical arguments as <code>z.dehydrate(func, inputData)</code> does.</p><p>An example can be found in the <a href="#stashing-files">Stashing Files</a> section.</p><p>What makes <code>z.dehydrateFile</code> different from <code>z.dehydrate</code> has to do with efficiency and when Zapier chooses to hydrate data. Knowing which pointers give us back files helps us delay downloading files until its absolutely necessary. A good example is users creating Zaps in the Zap Editor. If a pointer is made by <code>z.dehydrate</code>, the Zap Editor will hydrate the data immediately after pulling in samples. This allows users to map fields from the hydrated data into the subsequent steps of the Zap. If, however, the pointer is made by <code>z.dehydrateFile</code>, the Zap Editor will wait to hydrate the file. There&apos;s nothing in binary file data for users to map in the subsequent steps.</p><blockquote>
<p><code>z.dehydrateFile(func, inputData)</code> is new in v7.3.0. We used to recommend to use <code>z.dehydrate(func, inputData)</code> for files, but it&apos;s not the case anymore. Please change it to <code>z.dehydrateFile(func, inputData)</code> for a better user expereience.</p>
<p><code>z.dehydrateFile(func, inputData)</code> is new in v7.3.0. We used to recommend to use <code>z.dehydrate(func, inputData)</code> for files, but it&apos;s not the case anymore. Please change it to <code>z.dehydrateFile(func, inputData)</code> for a better user experience.</p>
</blockquote>
</div>
<div class="col-md-7 col-sm-12 col-height is-empty docs-code">
Expand Down
12 changes: 8 additions & 4 deletions packages/core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ export interface RawHttpResponse extends BaseHttpResponse {
body: NodeJS.ReadableStream;
}

type DehydrateFunc = <T>(
func: (z: ZObject, bundle: Bundle<T>) => any,
inputData: object
) => string;

export interface ZObject {
request: {
// most specific overloads go first
Expand All @@ -130,10 +135,8 @@ export interface ZObject {

console: Console;

dehydrate: <T>(
func: (z: this, bundle: Bundle<T>) => any,
inputData: object
) => string;
dehydrate: DehydrateFunc;
dehydrateFile: DehydrateFunc;

cursor: {
get: () => Promise<string>;
Expand All @@ -151,6 +154,7 @@ export interface ZObject {
filename?: string,
contentType?: string
): string;
(input: Promise<RawHttpResponse>): string;
(input: Promise<string>): string;
};

Expand Down

0 comments on commit bb4bfcb

Please sign in to comment.