@wise/dynamic-flow-client 3.19.3 → 3.19.5

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/build/main.js CHANGED
@@ -10403,23 +10403,27 @@ var executeSubmission = async (props) => {
10403
10403
  trackSubmissionEvent("Action Succeeded", { actionId });
10404
10404
  return { type: "complete", result };
10405
10405
  }
10406
- try {
10407
- const makeRequestBody = () => {
10408
- var _a;
10409
- if (method === "GET") {
10410
- return void 0;
10411
- }
10412
- const payload = mergeModels(model, (_a = action.data) != null ? _a : null);
10413
- return payload !== null ? JSON.stringify(payload) : null;
10414
- };
10415
- const response = await httpClient(url != null ? url : "", {
10416
- method,
10417
- body: makeRequestBody(),
10418
- headers: { "Content-Type": "application/json" }
10419
- });
10420
- if (!response.ok) {
10421
- return await handleErrorResponse(response, actionId);
10406
+ const makeRequestBody = () => {
10407
+ var _a;
10408
+ if (method === "GET") {
10409
+ return void 0;
10422
10410
  }
10411
+ const payload = mergeModels(model, (_a = action.data) != null ? _a : null);
10412
+ return payload !== null ? JSON.stringify(payload) : null;
10413
+ };
10414
+ const response = await getSafeHttpClient(httpClient)(url != null ? url : "", {
10415
+ method,
10416
+ body: makeRequestBody(),
10417
+ headers: { "Content-Type": "application/json" }
10418
+ });
10419
+ if (!response) {
10420
+ trackEvent("Action Failed", { actionId });
10421
+ return { type: "error", body: {} };
10422
+ }
10423
+ if (!response.ok) {
10424
+ return handleErrorResponse(response, actionId);
10425
+ }
10426
+ try {
10423
10427
  const responseType = await getResponseType(response);
10424
10428
  const body = await parseResponseBodyAsJsonElement(response);
10425
10429
  if (exit) {
@@ -10464,6 +10468,13 @@ var executeSubmission = async (props) => {
10464
10468
  };
10465
10469
  return triggerAction(props.action, props.model, props.isInitial);
10466
10470
  };
10471
+ var getSafeHttpClient = (httpClient) => async (input, init) => {
10472
+ try {
10473
+ return await httpClient(input, init);
10474
+ } catch (e) {
10475
+ return null;
10476
+ }
10477
+ };
10467
10478
 
10468
10479
  // src/revamp/renderers/getSchemaErrorMessageFunction.ts
10469
10480
  var import_formatting = require("@transferwise/formatting");