Skip to content

Commit

Permalink
Document performResume default implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
eliangcs committed Jun 13, 2024
1 parent 75ee196 commit 825e93c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3163,7 +3163,7 @@ <h3 id="zgeneratecallbackurl"><code>z.generateCallbackUrl()</code></h3>
<div class="col-md-5 col-sm-12 col-height docs-primary">
<blockquote>
<p>We recommend using <code>bundle.meta.isLoadingSample</code> to determine if the execution is happening in the foreground (IE: during Zap setup) as using <code>z.generateCallbackUrl()</code> can be inappropriate given the disconnect. Instead, wait for the long running request without generating a callback, or if you must, return stubbed data.</p>
</blockquote><p>And finally, in a <code>performResume</code> to handle the final step which will receive three bundle properties:</p><ul>
</blockquote><p>By default the payload <code>POST</code>ed to the callback URL will augment the data returned from the initial <code>perform</code> to compose the final value.</p><p>If you need to customize what the final value should be you can define a <code>performResume</code> method that receives three bundle properties:</p><ul>
<li><code>bundle.outputData</code> is <code>{&quot;hello&quot;: &quot;world&quot;}</code>, the data returned from the initial <code>perform</code></li>
<li><code>bundle.cleanedRequest</code> is <code>{&quot;foo&quot;: &quot;bar&quot;}</code>, the payload from the callback URL</li>
<li><code>bundle.rawRequest</code> is the full request object corresponding to <code>bundle.cleanedRequest</code></li>
Expand All @@ -3172,6 +3172,8 @@ <h3 id="zgeneratecallbackurl"><code>z.generateCallbackUrl()</code></h3>
<div class="col-md-7 col-sm-12 col-height docs-code">
<pre><code class="lang-js"><span class="hljs-keyword">const</span> performResume = <span class="hljs-keyword">async</span> (z, bundle) =&gt; {
<span class="hljs-comment">// this will give a final value of: {&quot;hello&quot;: &quot;world&quot;, &quot;foo&quot;: &quot;bar&quot;}</span>
<span class="hljs-comment">// which is the default behavior when a custom `performResume` is not</span>
<span class="hljs-comment">// defined.</span>
<span class="hljs-keyword">return</span> { ...bundle.outputData, ...bundle.cleanedRequest };
};
</code></pre>
Expand Down
6 changes: 5 additions & 1 deletion packages/cli/README-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,9 @@ Content-Type: application/json
```
> We recommend using `bundle.meta.isLoadingSample` to determine if the execution is happening in the foreground (IE: during Zap setup) as using `z.generateCallbackUrl()` can be inappropriate given the disconnect. Instead, wait for the long running request without generating a callback, or if you must, return stubbed data.
And finally, in a `performResume` to handle the final step which will receive three bundle properties:
By default the payload `POST`ed to the callback URL will augment the data returned from the initial `perform` to compose the final value.
If you need to customize what the final value should be you can define a `performResume` method that receives three bundle properties:
* `bundle.outputData` is `{"hello": "world"}`, the data returned from the initial `perform`
* `bundle.cleanedRequest` is `{"foo": "bar"}`, the payload from the callback URL
Expand All @@ -956,6 +958,8 @@ And finally, in a `performResume` to handle the final step which will receive th
```js
const performResume = async (z, bundle) => {
// this will give a final value of: {"hello": "world", "foo": "bar"}
// which is the default behavior when a custom `performResume` is not
// defined.
return { ...bundle.outputData, ...bundle.cleanedRequest };
};
```
Expand Down
6 changes: 5 additions & 1 deletion packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1922,7 +1922,9 @@ Content-Type: application/json
```
> We recommend using `bundle.meta.isLoadingSample` to determine if the execution is happening in the foreground (IE: during Zap setup) as using `z.generateCallbackUrl()` can be inappropriate given the disconnect. Instead, wait for the long running request without generating a callback, or if you must, return stubbed data.
And finally, in a `performResume` to handle the final step which will receive three bundle properties:
By default the payload `POST`ed to the callback URL will augment the data returned from the initial `perform` to compose the final value.
If you need to customize what the final value should be you can define a `performResume` method that receives three bundle properties:
* `bundle.outputData` is `{"hello": "world"}`, the data returned from the initial `perform`
* `bundle.cleanedRequest` is `{"foo": "bar"}`, the payload from the callback URL
Expand All @@ -1931,6 +1933,8 @@ And finally, in a `performResume` to handle the final step which will receive th
```js
const performResume = async (z, bundle) => {
// this will give a final value of: {"hello": "world", "foo": "bar"}
// which is the default behavior when a custom `performResume` is not
// defined.
return { ...bundle.outputData, ...bundle.cleanedRequest };
};
```
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3163,7 +3163,7 @@ <h3 id="zgeneratecallbackurl"><code>z.generateCallbackUrl()</code></h3>
<div class="col-md-5 col-sm-12 col-height docs-primary">
<blockquote>
<p>We recommend using <code>bundle.meta.isLoadingSample</code> to determine if the execution is happening in the foreground (IE: during Zap setup) as using <code>z.generateCallbackUrl()</code> can be inappropriate given the disconnect. Instead, wait for the long running request without generating a callback, or if you must, return stubbed data.</p>
</blockquote><p>And finally, in a <code>performResume</code> to handle the final step which will receive three bundle properties:</p><ul>
</blockquote><p>By default the payload <code>POST</code>ed to the callback URL will augment the data returned from the initial <code>perform</code> to compose the final value.</p><p>If you need to customize what the final value should be you can define a <code>performResume</code> method that receives three bundle properties:</p><ul>
<li><code>bundle.outputData</code> is <code>{&quot;hello&quot;: &quot;world&quot;}</code>, the data returned from the initial <code>perform</code></li>
<li><code>bundle.cleanedRequest</code> is <code>{&quot;foo&quot;: &quot;bar&quot;}</code>, the payload from the callback URL</li>
<li><code>bundle.rawRequest</code> is the full request object corresponding to <code>bundle.cleanedRequest</code></li>
Expand All @@ -3172,6 +3172,8 @@ <h3 id="zgeneratecallbackurl"><code>z.generateCallbackUrl()</code></h3>
<div class="col-md-7 col-sm-12 col-height docs-code">
<pre><code class="lang-js"><span class="hljs-keyword">const</span> performResume = <span class="hljs-keyword">async</span> (z, bundle) =&gt; {
<span class="hljs-comment">// this will give a final value of: {&quot;hello&quot;: &quot;world&quot;, &quot;foo&quot;: &quot;bar&quot;}</span>
<span class="hljs-comment">// which is the default behavior when a custom `performResume` is not</span>
<span class="hljs-comment">// defined.</span>
<span class="hljs-keyword">return</span> { ...bundle.outputData, ...bundle.cleanedRequest };
};
</code></pre>
Expand Down

0 comments on commit 825e93c

Please sign in to comment.