@wise/dynamic-flow-client 4.3.2 → 4.3.4

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
@@ -6090,9 +6090,14 @@ var executePoll = async (props) => {
6090
6090
  }
6091
6091
  };
6092
6092
 
6093
+ // src/revamp/flow/getErrorMessage.ts
6094
+ var getErrorMessage = (error) => {
6095
+ return error instanceof Error ? error.message : typeof error === "string" ? error : `Unknown Error: type is ${typeof error}`;
6096
+ };
6097
+
6093
6098
  // src/revamp/flow/executeRefresh.ts
6094
6099
  var executeRefresh = async (props) => {
6095
- const { abortSignal, url, model, schemaId, etag, httpClient, trackEvent } = props;
6100
+ const { abortSignal, url, model, schemaId, etag, httpClient, trackEvent, logEvent } = props;
6096
6101
  trackEvent("Refresh Triggered", { schema: schemaId });
6097
6102
  try {
6098
6103
  const response = await httpClient(url != null ? url : "", {
@@ -6114,6 +6119,7 @@ var executeRefresh = async (props) => {
6114
6119
  schema: schemaId,
6115
6120
  statusCode: response.status
6116
6121
  }));
6122
+ logEvent("error", "Dynamic Flow - Refresh Failed", { schemaId, statusCode: response.status });
6117
6123
  return { type: "error", body: body2, statusCode: response.status };
6118
6124
  }
6119
6125
  const newEtag = response.headers.get("etag") || null;
@@ -6127,13 +6133,17 @@ var executeRefresh = async (props) => {
6127
6133
  return { type: "noop" };
6128
6134
  }
6129
6135
  trackEvent("Refresh Failed", { schema: schemaId });
6136
+ logEvent("error", "Dynamic Flow - Refresh Failed", {
6137
+ schemaId,
6138
+ errorMessage: getErrorMessage(error)
6139
+ });
6130
6140
  return { type: "error", body: {} };
6131
6141
  }
6132
6142
  };
6133
6143
 
6134
6144
  // src/revamp/flow/executeSubmission.ts
6135
6145
  var executeSubmission = async (props) => {
6136
- const { httpClient, trackEvent } = props;
6146
+ const { httpClient, trackEvent, logEvent } = props;
6137
6147
  const triggerAction = async (action, model, isInitial) => {
6138
6148
  const { exit, url, method = "POST", result = null, id: actionId } = action;
6139
6149
  const trackSubmissionEvent = !isInitial ? trackEvent : () => {
@@ -6157,7 +6167,9 @@ var executeSubmission = async (props) => {
6157
6167
  headers: { "Content-Type": "application/json" }
6158
6168
  });
6159
6169
  if (!response) {
6160
- trackEvent("Action Failed", { actionId });
6170
+ const extra = { actionId, errorMessage: "Network Error" };
6171
+ trackEvent("Action Failed", extra);
6172
+ logEvent("error", "Dynamic Flow - Action Failed Unexpectedly", extra);
6161
6173
  return { type: "error", body: {} };
6162
6174
  }
6163
6175
  if (!response.ok) {
@@ -6190,7 +6202,9 @@ var executeSubmission = async (props) => {
6190
6202
  }
6191
6203
  }
6192
6204
  } catch (error) {
6193
- trackSubmissionEvent("Action Failed", { actionId });
6205
+ const errorMessage = getErrorMessage(error);
6206
+ trackSubmissionEvent("Action Failed", { actionId, errorMessage });
6207
+ logEvent("error", "Dynamic Flow - Action Failed Unexpectedly", { actionId, errorMessage });
6194
6208
  throw error;
6195
6209
  }
6196
6210
  };
@@ -6507,18 +6521,12 @@ function useDynamicFlowCore(props) {
6507
6521
  () => getSchemaErrorMessageFunction(formatMessage, locale),
6508
6522
  [formatMessage, locale]
6509
6523
  );
6510
- const [rootComponent, setRootComponent] = (0, import_react3.useState)(
6511
- createRootDomainComponent()
6512
- );
6513
- const rootComponentRef = (0, import_react3.useRef)(rootComponent);
6524
+ const rerender = useRerender();
6525
+ const rootComponentRef = (0, import_react3.useRef)(createRootDomainComponent());
6514
6526
  const updateComponent = (0, import_react3.useCallback)(
6515
6527
  (id, update) => {
6516
6528
  update(findComponent([rootComponentRef.current], id, logEvent));
6517
- setRootComponent(() => {
6518
- const newRootDomainComponent = __spreadValues({}, rootComponentRef.current);
6519
- rootComponentRef.current = newRootDomainComponent;
6520
- return newRootDomainComponent;
6521
- });
6529
+ rerender();
6522
6530
  },
6523
6531
  // eslint-disable-next-line react-hooks/exhaustive-deps
6524
6532
  []
@@ -6541,6 +6549,9 @@ function useDynamicFlowCore(props) {
6541
6549
  createStep(initialStep, null);
6542
6550
  trackCoreEvent("Step Shown", { isFirstStep: true });
6543
6551
  }
6552
+ return () => {
6553
+ rootComponentRef.current.stop();
6554
+ };
6544
6555
  }, []);
6545
6556
  const createStep = (0, import_react3.useCallback)((newStep, etag) => {
6546
6557
  if (rootComponentRef.current.hasStep()) {
@@ -6624,7 +6635,9 @@ function useDynamicFlowCore(props) {
6624
6635
  );
6625
6636
  const closeWithError = (0, import_react3.useCallback)(
6626
6637
  (error, analytics, statusCode) => {
6638
+ rootComponentRef.current.stop();
6627
6639
  trackCoreEvent("Failed", __spreadValues({}, analytics));
6640
+ logEvent("error", "Dynamic Flow failed", { errorMessage: getErrorMessage(error), analytics });
6628
6641
  onError(error, statusCode);
6629
6642
  },
6630
6643
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -6640,11 +6653,13 @@ function useDynamicFlowCore(props) {
6640
6653
  model,
6641
6654
  isInitial: stepRef.current === null,
6642
6655
  httpClient,
6643
- trackEvent: trackCoreEvent
6656
+ trackEvent: trackCoreEvent,
6657
+ logEvent
6644
6658
  });
6645
6659
  switch (command.type) {
6646
6660
  case "complete": {
6647
6661
  onCompletion(command.result);
6662
+ rootComponentRef.current.stop();
6648
6663
  trackCoreEvent("Succeeded");
6649
6664
  break;
6650
6665
  }
@@ -6673,7 +6688,13 @@ function useDynamicFlowCore(props) {
6673
6688
  etagRef.current
6674
6689
  );
6675
6690
  } else {
6676
- closeWithError(new Error("Initial request failed"), {}, command.statusCode);
6691
+ closeWithError(
6692
+ new Error("Initial request failed", {
6693
+ cause: `method: ${action.method}, url: ${action.url}`
6694
+ }),
6695
+ {},
6696
+ command.statusCode
6697
+ );
6677
6698
  }
6678
6699
  break;
6679
6700
  }
@@ -6700,7 +6721,8 @@ function useDynamicFlowCore(props) {
6700
6721
  schemaId,
6701
6722
  etag: etagRef.current,
6702
6723
  httpClient,
6703
- trackEvent: trackCoreEvent
6724
+ trackEvent: trackCoreEvent,
6725
+ logEvent
6704
6726
  });
6705
6727
  switch (command.type) {
6706
6728
  case "refresh-step":
@@ -6756,13 +6778,17 @@ function useDynamicFlowCore(props) {
6756
6778
  );
6757
6779
  return { rootComponent: rootComponentRef.current };
6758
6780
  }
6781
+ var useRerender = () => {
6782
+ const [, setState] = (0, import_react3.useState)({});
6783
+ return (0, import_react3.useCallback)(() => setState({}), []);
6784
+ };
6759
6785
 
6760
6786
  // src/revamp/DynamicFlowCore.tsx
6761
6787
  var import_jsx_runtime6 = require("react/jsx-runtime");
6762
6788
  function DynamicFlowCore(props) {
6763
6789
  var _a;
6764
6790
  const { rootComponent } = useDynamicFlowCore(props);
6765
- const { renderers, httpClient, onEvent, onError } = props;
6791
+ const { renderers, httpClient, onEvent, onError, onLog } = props;
6766
6792
  const render = (0, import_react4.useMemo)(
6767
6793
  () => getRenderFunction([CoreRootRenderer, CoreContainerRenderer, ...renderers]),
6768
6794
  [renderers]
@@ -6780,6 +6806,7 @@ function DynamicFlowCore(props) {
6780
6806
  onError: (error) => {
6781
6807
  onEvent == null ? void 0 : onEvent("Dynamic Flow - Failed", { error });
6782
6808
  onError == null ? void 0 : onError(error);
6809
+ onLog == null ? void 0 : onLog("error", "Dynamic Flow - ErrorBoundary", { errorMessage: getErrorMessage(error) });
6783
6810
  },
6784
6811
  children: render(tree)
6785
6812
  }
package/build/main.mjs CHANGED
@@ -6047,9 +6047,14 @@ var executePoll = async (props) => {
6047
6047
  }
6048
6048
  };
6049
6049
 
6050
+ // src/revamp/flow/getErrorMessage.ts
6051
+ var getErrorMessage = (error) => {
6052
+ return error instanceof Error ? error.message : typeof error === "string" ? error : `Unknown Error: type is ${typeof error}`;
6053
+ };
6054
+
6050
6055
  // src/revamp/flow/executeRefresh.ts
6051
6056
  var executeRefresh = async (props) => {
6052
- const { abortSignal, url, model, schemaId, etag, httpClient, trackEvent } = props;
6057
+ const { abortSignal, url, model, schemaId, etag, httpClient, trackEvent, logEvent } = props;
6053
6058
  trackEvent("Refresh Triggered", { schema: schemaId });
6054
6059
  try {
6055
6060
  const response = await httpClient(url != null ? url : "", {
@@ -6071,6 +6076,7 @@ var executeRefresh = async (props) => {
6071
6076
  schema: schemaId,
6072
6077
  statusCode: response.status
6073
6078
  }));
6079
+ logEvent("error", "Dynamic Flow - Refresh Failed", { schemaId, statusCode: response.status });
6074
6080
  return { type: "error", body: body2, statusCode: response.status };
6075
6081
  }
6076
6082
  const newEtag = response.headers.get("etag") || null;
@@ -6084,13 +6090,17 @@ var executeRefresh = async (props) => {
6084
6090
  return { type: "noop" };
6085
6091
  }
6086
6092
  trackEvent("Refresh Failed", { schema: schemaId });
6093
+ logEvent("error", "Dynamic Flow - Refresh Failed", {
6094
+ schemaId,
6095
+ errorMessage: getErrorMessage(error)
6096
+ });
6087
6097
  return { type: "error", body: {} };
6088
6098
  }
6089
6099
  };
6090
6100
 
6091
6101
  // src/revamp/flow/executeSubmission.ts
6092
6102
  var executeSubmission = async (props) => {
6093
- const { httpClient, trackEvent } = props;
6103
+ const { httpClient, trackEvent, logEvent } = props;
6094
6104
  const triggerAction = async (action, model, isInitial) => {
6095
6105
  const { exit, url, method = "POST", result = null, id: actionId } = action;
6096
6106
  const trackSubmissionEvent = !isInitial ? trackEvent : () => {
@@ -6114,7 +6124,9 @@ var executeSubmission = async (props) => {
6114
6124
  headers: { "Content-Type": "application/json" }
6115
6125
  });
6116
6126
  if (!response) {
6117
- trackEvent("Action Failed", { actionId });
6127
+ const extra = { actionId, errorMessage: "Network Error" };
6128
+ trackEvent("Action Failed", extra);
6129
+ logEvent("error", "Dynamic Flow - Action Failed Unexpectedly", extra);
6118
6130
  return { type: "error", body: {} };
6119
6131
  }
6120
6132
  if (!response.ok) {
@@ -6147,7 +6159,9 @@ var executeSubmission = async (props) => {
6147
6159
  }
6148
6160
  }
6149
6161
  } catch (error) {
6150
- trackSubmissionEvent("Action Failed", { actionId });
6162
+ const errorMessage = getErrorMessage(error);
6163
+ trackSubmissionEvent("Action Failed", { actionId, errorMessage });
6164
+ logEvent("error", "Dynamic Flow - Action Failed Unexpectedly", { actionId, errorMessage });
6151
6165
  throw error;
6152
6166
  }
6153
6167
  };
@@ -6464,18 +6478,12 @@ function useDynamicFlowCore(props) {
6464
6478
  () => getSchemaErrorMessageFunction(formatMessage, locale),
6465
6479
  [formatMessage, locale]
6466
6480
  );
6467
- const [rootComponent, setRootComponent] = useState(
6468
- createRootDomainComponent()
6469
- );
6470
- const rootComponentRef = useRef2(rootComponent);
6481
+ const rerender = useRerender();
6482
+ const rootComponentRef = useRef2(createRootDomainComponent());
6471
6483
  const updateComponent = useCallback2(
6472
6484
  (id, update) => {
6473
6485
  update(findComponent([rootComponentRef.current], id, logEvent));
6474
- setRootComponent(() => {
6475
- const newRootDomainComponent = __spreadValues({}, rootComponentRef.current);
6476
- rootComponentRef.current = newRootDomainComponent;
6477
- return newRootDomainComponent;
6478
- });
6486
+ rerender();
6479
6487
  },
6480
6488
  // eslint-disable-next-line react-hooks/exhaustive-deps
6481
6489
  []
@@ -6498,6 +6506,9 @@ function useDynamicFlowCore(props) {
6498
6506
  createStep(initialStep, null);
6499
6507
  trackCoreEvent("Step Shown", { isFirstStep: true });
6500
6508
  }
6509
+ return () => {
6510
+ rootComponentRef.current.stop();
6511
+ };
6501
6512
  }, []);
6502
6513
  const createStep = useCallback2((newStep, etag) => {
6503
6514
  if (rootComponentRef.current.hasStep()) {
@@ -6581,7 +6592,9 @@ function useDynamicFlowCore(props) {
6581
6592
  );
6582
6593
  const closeWithError = useCallback2(
6583
6594
  (error, analytics, statusCode) => {
6595
+ rootComponentRef.current.stop();
6584
6596
  trackCoreEvent("Failed", __spreadValues({}, analytics));
6597
+ logEvent("error", "Dynamic Flow failed", { errorMessage: getErrorMessage(error), analytics });
6585
6598
  onError(error, statusCode);
6586
6599
  },
6587
6600
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -6597,11 +6610,13 @@ function useDynamicFlowCore(props) {
6597
6610
  model,
6598
6611
  isInitial: stepRef.current === null,
6599
6612
  httpClient,
6600
- trackEvent: trackCoreEvent
6613
+ trackEvent: trackCoreEvent,
6614
+ logEvent
6601
6615
  });
6602
6616
  switch (command.type) {
6603
6617
  case "complete": {
6604
6618
  onCompletion(command.result);
6619
+ rootComponentRef.current.stop();
6605
6620
  trackCoreEvent("Succeeded");
6606
6621
  break;
6607
6622
  }
@@ -6630,7 +6645,13 @@ function useDynamicFlowCore(props) {
6630
6645
  etagRef.current
6631
6646
  );
6632
6647
  } else {
6633
- closeWithError(new Error("Initial request failed"), {}, command.statusCode);
6648
+ closeWithError(
6649
+ new Error("Initial request failed", {
6650
+ cause: `method: ${action.method}, url: ${action.url}`
6651
+ }),
6652
+ {},
6653
+ command.statusCode
6654
+ );
6634
6655
  }
6635
6656
  break;
6636
6657
  }
@@ -6657,7 +6678,8 @@ function useDynamicFlowCore(props) {
6657
6678
  schemaId,
6658
6679
  etag: etagRef.current,
6659
6680
  httpClient,
6660
- trackEvent: trackCoreEvent
6681
+ trackEvent: trackCoreEvent,
6682
+ logEvent
6661
6683
  });
6662
6684
  switch (command.type) {
6663
6685
  case "refresh-step":
@@ -6713,13 +6735,17 @@ function useDynamicFlowCore(props) {
6713
6735
  );
6714
6736
  return { rootComponent: rootComponentRef.current };
6715
6737
  }
6738
+ var useRerender = () => {
6739
+ const [, setState] = useState({});
6740
+ return useCallback2(() => setState({}), []);
6741
+ };
6716
6742
 
6717
6743
  // src/revamp/DynamicFlowCore.tsx
6718
6744
  import { jsx as jsx6 } from "react/jsx-runtime";
6719
6745
  function DynamicFlowCore(props) {
6720
6746
  var _a;
6721
6747
  const { rootComponent } = useDynamicFlowCore(props);
6722
- const { renderers, httpClient, onEvent, onError } = props;
6748
+ const { renderers, httpClient, onEvent, onError, onLog } = props;
6723
6749
  const render = useMemo2(
6724
6750
  () => getRenderFunction([CoreRootRenderer, CoreContainerRenderer, ...renderers]),
6725
6751
  [renderers]
@@ -6737,6 +6763,7 @@ function DynamicFlowCore(props) {
6737
6763
  onError: (error) => {
6738
6764
  onEvent == null ? void 0 : onEvent("Dynamic Flow - Failed", { error });
6739
6765
  onError == null ? void 0 : onError(error);
6766
+ onLog == null ? void 0 : onLog("error", "Dynamic Flow - ErrorBoundary", { errorMessage: getErrorMessage(error) });
6740
6767
  },
6741
6768
  children: render(tree)
6742
6769
  }
@@ -7111,7 +7138,7 @@ function isReference(block) {
7111
7138
  }
7112
7139
 
7113
7140
  // src/legacy/dynamicFlow/DynamicFlow.tsx
7114
- import { useCallback as useCallback11, useEffect as useEffect21, useMemo as useMemo21, useState as useState26 } from "react";
7141
+ import { useCallback as useCallback11, useEffect as useEffect22, useMemo as useMemo21, useState as useState26 } from "react";
7115
7142
  import { useIntl as useIntl23 } from "react-intl";
7116
7143
 
7117
7144
  // src/legacy/common/contexts/dynamicFlowContexts/DynamicFlowContexts.tsx
@@ -7968,12 +7995,12 @@ function useDebouncedFunction(callback, waitMs) {
7968
7995
  }
7969
7996
 
7970
7997
  // src/legacy/common/hooks/useExternal/useExternal.tsx
7971
- import { useEffect as useEffect2, useState as useState3 } from "react";
7998
+ import { useEffect as useEffect3, useState as useState3 } from "react";
7972
7999
  function useExternal(url) {
7973
8000
  const [externalWindow, setExternalWindow] = useState3(null);
7974
8001
  const [hasManuallyTriggered, setHasManuallyTriggered] = useState3(false);
7975
8002
  const dismissConfirmation = () => setHasManuallyTriggered(true);
7976
- useEffect2(() => {
8003
+ useEffect3(() => {
7977
8004
  if (url) {
7978
8005
  setHasManuallyTriggered(false);
7979
8006
  setExternalWindow(window.open(url, "_blank"));
@@ -8046,7 +8073,7 @@ import { useState as useState20 } from "react";
8046
8073
  import { useIntl as useIntl17 } from "react-intl";
8047
8074
 
8048
8075
  // src/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.tsx
8049
- import { useEffect as useEffect13, useState as useState19 } from "react";
8076
+ import { useEffect as useEffect14, useState as useState19 } from "react";
8050
8077
  import { useIntl as useIntl16 } from "react-intl";
8051
8078
 
8052
8079
  // src/legacy/common/constants/DateMode.ts
@@ -8095,7 +8122,7 @@ var Size = {
8095
8122
 
8096
8123
  // src/legacy/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.tsx
8097
8124
  import classNames10 from "classnames";
8098
- import { useEffect as useEffect12, useMemo as useMemo16, useState as useState18 } from "react";
8125
+ import { useEffect as useEffect13, useMemo as useMemo16, useState as useState18 } from "react";
8099
8126
 
8100
8127
  // src/legacy/layout/alert/DynamicAlert.tsx
8101
8128
  import { Alert as Alert2 } from "@transferwise/components";
@@ -8562,7 +8589,7 @@ var DynamicDivider_default = DynamicDivider;
8562
8589
 
8563
8590
  // src/legacy/layout/external/DynamicExternal.tsx
8564
8591
  import { Button as Button2, Loader, Size as Size2 } from "@transferwise/components";
8565
- import { useCallback as useCallback6, useEffect as useEffect3, useMemo as useMemo9 } from "react";
8592
+ import { useCallback as useCallback6, useEffect as useEffect4, useMemo as useMemo9 } from "react";
8566
8593
  import { useIntl as useIntl3 } from "react-intl";
8567
8594
 
8568
8595
  // src/legacy/layout/external/DynamicExternal.messages.ts
@@ -8584,7 +8611,7 @@ var DynamicExternal = ({ component, onAction }) => {
8584
8611
  () => window.open(requestUrl, "df-external-window"),
8585
8612
  [requestUrl]
8586
8613
  );
8587
- useEffect3(() => {
8614
+ useEffect4(() => {
8588
8615
  openExternalUrl();
8589
8616
  }, [openExternalUrl]);
8590
8617
  const pollingConfiguration = useMemo9(() => {
@@ -8602,7 +8629,7 @@ var DynamicExternal = ({ component, onAction }) => {
8602
8629
  var DynamicExternal_default = DynamicExternal;
8603
8630
 
8604
8631
  // src/legacy/jsonSchemaForm/genericSchema/GenericSchema.tsx
8605
- import { useEffect as useEffect10 } from "react";
8632
+ import { useEffect as useEffect11 } from "react";
8606
8633
 
8607
8634
  // src/legacy/jsonSchemaForm/allOfSchema/AllOfSchema.tsx
8608
8635
  import { Header as Header2 } from "@transferwise/components";
@@ -8895,7 +8922,7 @@ function getValidationMessages(schema, required, defaultErrorMessages) {
8895
8922
  // src/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multiSelectSchema/MultiSelectSchema.tsx
8896
8923
  import { SelectInput, SelectInputOptionContent } from "@transferwise/components";
8897
8924
  import classNames3 from "classnames";
8898
- import { useEffect as useEffect4, useMemo as useMemo11, useState as useState6 } from "react";
8925
+ import { useEffect as useEffect5, useMemo as useMemo11, useState as useState6 } from "react";
8899
8926
  import { useIntl as useIntl6 } from "react-intl";
8900
8927
 
8901
8928
  // src/legacy/jsonSchemaForm/schemaFormControl/utils/mapping-utils.tsx
@@ -9016,7 +9043,7 @@ function MultiSelectSchema({
9016
9043
  const id = useMemo11(() => schema.$id || generateRandomId(), [schema.$id]);
9017
9044
  const [changed, setChanged] = useState6(false);
9018
9045
  const [selected, setSelected] = useState6(getInitialModelIndices2(model, options));
9019
- useEffect4(
9046
+ useEffect5(
9020
9047
  () => {
9021
9048
  if (selected) {
9022
9049
  broadcastModelChange(selected);
@@ -9604,7 +9631,7 @@ var ArraySchema_default = ArraySchema;
9604
9631
  // src/legacy/jsonSchemaForm/objectSchema/ObjectSchema.tsx
9605
9632
  import { Header as Header4 } from "@transferwise/components";
9606
9633
  import classNames5 from "classnames";
9607
- import { useState as useState9, useEffect as useEffect5 } from "react";
9634
+ import { useState as useState9, useEffect as useEffect6 } from "react";
9608
9635
  import { Fragment as Fragment6, jsx as jsx33, jsxs as jsxs10 } from "react/jsx-runtime";
9609
9636
  var getSchemaColumnClasses2 = (width) => ({
9610
9637
  "col-xs-12": true,
@@ -9624,7 +9651,7 @@ function ObjectSchema(props) {
9624
9651
  props.onChange(__spreadProps(__spreadValues({}, onChangeProps), { model }));
9625
9652
  };
9626
9653
  const isRequired = (propertyName) => props.schema.required && props.schema.required.includes(propertyName);
9627
- useEffect5(() => {
9654
+ useEffect6(() => {
9628
9655
  const newModel = getValidObjectModelParts(model, props.schema) || {};
9629
9656
  setModel(newModel);
9630
9657
  if (!isEqual(newModel, model)) {
@@ -9681,7 +9708,7 @@ var ObjectSchema_default = ObjectSchema;
9681
9708
  // src/legacy/jsonSchemaForm/oneOfSchema/OneOfSchema.tsx
9682
9709
  import { Header as Header5 } from "@transferwise/components";
9683
9710
  import classNames6 from "classnames";
9684
- import { useEffect as useEffect7, useMemo as useMemo13, useState as useState10 } from "react";
9711
+ import { useEffect as useEffect8, useMemo as useMemo13, useState as useState10 } from "react";
9685
9712
 
9686
9713
  // src/legacy/jsonSchemaForm/help/Help.tsx
9687
9714
  import { Markdown, Info } from "@transferwise/components";
@@ -9715,7 +9742,7 @@ function Help(props) {
9715
9742
  var Help_default = Help;
9716
9743
 
9717
9744
  // src/legacy/jsonSchemaForm/schemaFormControl/SchemaFormControl.tsx
9718
- import { useEffect as useEffect6 } from "react";
9745
+ import { useEffect as useEffect7 } from "react";
9719
9746
  import { useIntl as useIntl10 } from "react-intl";
9720
9747
 
9721
9748
  // src/legacy/formControl/FormControl.tsx
@@ -10437,7 +10464,7 @@ function SchemaFormControl(props) {
10437
10464
  onChange(getValidBasicModelOrNull(value2, schema), type, metadata);
10438
10465
  };
10439
10466
  const controlType = getControlType(schema);
10440
- useEffect6(() => {
10467
+ useEffect7(() => {
10441
10468
  warnIfInvalidSchema(schema, log, controlType);
10442
10469
  }, [JSON.stringify(schema), log, controlType]);
10443
10470
  const options = schema.values || getOptions(schema, controlType);
@@ -10509,7 +10536,7 @@ function OneOfSchema(props) {
10509
10536
  searchValueLength: searchValue.length
10510
10537
  });
10511
10538
  };
10512
- useEffect7(() => {
10539
+ useEffect8(() => {
10513
10540
  const modelIndex = getValidIndexFromValue(props.schema, props.model);
10514
10541
  const defaultIndex = getValidIndexFromValue(props.schema, props.schema.default);
10515
10542
  if (modelIndex === -1 && defaultIndex >= 0) {
@@ -10667,7 +10694,7 @@ var OneOfSchema_default = OneOfSchema;
10667
10694
 
10668
10695
  // src/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.tsx
10669
10696
  import classNames7 from "classnames";
10670
- import { useEffect as useEffect8, useState as useState11 } from "react";
10697
+ import { useEffect as useEffect9, useState as useState11 } from "react";
10671
10698
  import { useIntl as useIntl11 } from "react-intl";
10672
10699
 
10673
10700
  // src/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.tsx
@@ -10738,7 +10765,7 @@ function PersistAsyncBlobSchema(props) {
10738
10765
  const intl = useIntl11();
10739
10766
  const httpClient = useHttpClient();
10740
10767
  const onEvent = useEventDispatcher();
10741
- useEffect8(() => {
10768
+ useEffect9(() => {
10742
10769
  if (submitted) {
10743
10770
  setValidations(getValidationFailures(model, schema, Boolean(required)));
10744
10771
  } else {
@@ -11042,7 +11069,7 @@ function getValueFromOption(option) {
11042
11069
  }
11043
11070
 
11044
11071
  // src/legacy/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.tsx
11045
- import { useEffect as useEffect9, useRef as useRef3, useState as useState13 } from "react";
11072
+ import { useEffect as useEffect10, useRef as useRef3, useState as useState13 } from "react";
11046
11073
  import { jsx as jsx46 } from "react/jsx-runtime";
11047
11074
  function ValidationAsyncSchema(props) {
11048
11075
  const { schema, model, required = false, submitted, errors, onChange } = props;
@@ -11057,7 +11084,7 @@ function ValidationAsyncSchema(props) {
11057
11084
  const httpClient = useHttpClient();
11058
11085
  const onEvent = useEventDispatcher();
11059
11086
  const log = useLogger();
11060
- useEffect9(() => {
11087
+ useEffect10(() => {
11061
11088
  if (!schema.validationAsync.method) {
11062
11089
  log.warning(
11063
11090
  "Invalid schema or model",
@@ -11139,7 +11166,7 @@ function GenericSchemaForm(props) {
11139
11166
  const schemaProps = __spreadProps(__spreadValues({}, props), { model, errors, hideTitle, disabled });
11140
11167
  const type = getSchemaType(schema);
11141
11168
  const log = useLogger();
11142
- useEffect10(() => {
11169
+ useEffect11(() => {
11143
11170
  if (!isValidGenericSchema(schema, model, errors)) {
11144
11171
  log.error(
11145
11172
  "Invalid schema or model",
@@ -11276,14 +11303,14 @@ var DynamicInfo = ({ component }) => {
11276
11303
 
11277
11304
  // src/legacy/layout/image/DynamicImage.tsx
11278
11305
  import { Image } from "@transferwise/components";
11279
- import { useEffect as useEffect11, useState as useState14 } from "react";
11306
+ import { useEffect as useEffect12, useState as useState14 } from "react";
11280
11307
  import { jsx as jsx51 } from "react/jsx-runtime";
11281
11308
  function DynamicImage({ component: image }) {
11282
11309
  var _a, _b, _c;
11283
11310
  const { content, url, size, text, margin, accessibilityDescription } = image;
11284
11311
  const httpClient = useHttpClient();
11285
11312
  const [imageSource, setImageSource] = useState14("");
11286
- useEffect11(() => {
11313
+ useEffect12(() => {
11287
11314
  if (content) {
11288
11315
  const { uri, url: contentUrl } = content;
11289
11316
  if (uri && !uri.startsWith("urn:")) {
@@ -12084,9 +12111,9 @@ var BasicTypeSchema = (props) => {
12084
12111
  };
12085
12112
  const isConst = props.schema.const;
12086
12113
  const isHidden = props.schema.hidden || isConst;
12087
- useEffect12(refreshValidations, [props.model, props.submitted]);
12088
- useEffect12(onSchemaChange, [props.schema]);
12089
- useEffect12(() => {
12114
+ useEffect13(refreshValidations, [props.model, props.submitted]);
12115
+ useEffect13(onSchemaChange, [props.schema]);
12116
+ useEffect13(() => {
12090
12117
  var _a2;
12091
12118
  const newModel = (_a2 = props.model) != null ? _a2 : null;
12092
12119
  if (newModel !== model) {
@@ -12167,7 +12194,7 @@ function PersistAsyncBasicSchema(props) {
12167
12194
  const [persistAsyncError, setPersistAsyncError] = useState19(null);
12168
12195
  const [fieldSubmitted, setFieldSubmitted] = useState19(false);
12169
12196
  const [abortController, setAbortController] = useState19(null);
12170
- useEffect13(() => {
12197
+ useEffect14(() => {
12171
12198
  if (controlTypesWithPersistOnChange.has(
12172
12199
  // TODO: LOW avoid type assertion below -- control type may be nullish. consider ?? ''
12173
12200
  getControlType(schema.persistAsync.schema)
@@ -12329,7 +12356,7 @@ function hasStringMessage(value) {
12329
12356
  }
12330
12357
 
12331
12358
  // src/legacy/common/hooks/usePolling/usePolling.tsx
12332
- import { useEffect as useEffect14, useMemo as useMemo17, useRef as useRef5 } from "react";
12359
+ import { useEffect as useEffect15, useMemo as useMemo17, useRef as useRef5 } from "react";
12333
12360
  function usePolling({
12334
12361
  asyncFn,
12335
12362
  delay,
@@ -12350,7 +12377,7 @@ function usePolling({
12350
12377
  ),
12351
12378
  [asyncFn, maxAttempts, maxConsecutiveFails]
12352
12379
  );
12353
- useEffect14(() => {
12380
+ useEffect15(() => {
12354
12381
  if (delay > 0) {
12355
12382
  poll();
12356
12383
  const intervalReference = setInterval(() => {
@@ -12359,7 +12386,7 @@ function usePolling({
12359
12386
  return () => clearInterval(intervalReference);
12360
12387
  }
12361
12388
  }, [poll, delay]);
12362
- useEffect14(() => {
12389
+ useEffect15(() => {
12363
12390
  onPollingResponseReference.current = onPollingResponse;
12364
12391
  onFailureReference.current = onFailure;
12365
12392
  }, [onPollingResponse, onFailure]);
@@ -12390,10 +12417,10 @@ function createPollingClosure(asyncFn, maxAttempts, maxConsecutiveFails, onPolli
12390
12417
  }
12391
12418
 
12392
12419
  // src/legacy/common/hooks/usePrevious/usePrevious.js
12393
- import { useEffect as useEffect15, useRef as useRef6 } from "react";
12420
+ import { useEffect as useEffect16, useRef as useRef6 } from "react";
12394
12421
  var usePrevious = (value) => {
12395
12422
  const reference = useRef6();
12396
- useEffect15(() => {
12423
+ useEffect16(() => {
12397
12424
  reference.current = value;
12398
12425
  }, [value]);
12399
12426
  return reference.current;
@@ -12487,10 +12514,10 @@ var LayoutStep = (props) => {
12487
12514
  var LayoutStep_default = LayoutStep;
12488
12515
 
12489
12516
  // src/legacy/step/cameraStep/CameraStep.tsx
12490
- import { useEffect as useEffect20, useState as useState23 } from "react";
12517
+ import { useEffect as useEffect21, useState as useState23 } from "react";
12491
12518
 
12492
12519
  // src/common/cameraCapture/CameraCapture.tsx
12493
- import { useCallback as useCallback10, useEffect as useEffect19, useMemo as useMemo19, useRef as useRef8, useState as useState22 } from "react";
12520
+ import { useCallback as useCallback10, useEffect as useEffect20, useMemo as useMemo19, useRef as useRef8, useState as useState22 } from "react";
12494
12521
  import { useIntl as useIntl20 } from "react-intl";
12495
12522
  import Webcam from "react-webcam";
12496
12523
 
@@ -12635,7 +12662,7 @@ function OrientationLockOverlay() {
12635
12662
  var OrientationLockOverlay_default = OrientationLockOverlay;
12636
12663
 
12637
12664
  // src/common/cameraCapture/hooks/useFullScreenOrientationLock.ts
12638
- import { useCallback as useCallback9, useEffect as useEffect16 } from "react";
12665
+ import { useCallback as useCallback9, useEffect as useEffect17 } from "react";
12639
12666
  import screenfull from "screenfull";
12640
12667
 
12641
12668
  // src/common/cameraCapture/utils/index.ts
@@ -12752,7 +12779,7 @@ var useFullScreenOrientationLock = (shouldLockOrientation, onEvent) => {
12752
12779
  },
12753
12780
  [onEvent]
12754
12781
  );
12755
- useEffect16(() => {
12782
+ useEffect17(() => {
12756
12783
  var _a, _b;
12757
12784
  if (shouldLockOrientation) {
12758
12785
  (_b = (_a = window.screen) == null ? void 0 : _a.orientation) == null ? void 0 : _b.addEventListener(
@@ -12775,10 +12802,10 @@ var noop5 = () => {
12775
12802
  };
12776
12803
 
12777
12804
  // src/common/cameraCapture/hooks/useVideoConstraints.ts
12778
- import { useEffect as useEffect17, useState as useState21 } from "react";
12805
+ import { useEffect as useEffect18, useState as useState21 } from "react";
12779
12806
  var useVideoConstraints = (direction) => {
12780
12807
  const [videoConstraints, setVideoConstraints] = useState21();
12781
- useEffect17(() => {
12808
+ useEffect18(() => {
12782
12809
  void getVideoConstraints(direction).then(setVideoConstraints);
12783
12810
  }, [direction]);
12784
12811
  return { videoConstraints };
@@ -12803,7 +12830,7 @@ var getVideoConstraints = async (dir) => {
12803
12830
  };
12804
12831
 
12805
12832
  // src/common/cameraCapture/overlay/Overlay.tsx
12806
- import { useEffect as useEffect18, useRef as useRef7 } from "react";
12833
+ import { useEffect as useEffect19, useRef as useRef7 } from "react";
12807
12834
  import { Fragment as Fragment16, jsx as jsx67, jsxs as jsxs27 } from "react/jsx-runtime";
12808
12835
  var captureButtonHeight = 92;
12809
12836
  var reviewButtonsHeight = 120;
@@ -12814,7 +12841,7 @@ var reviewInstructionsHeight = 40;
12814
12841
  var overlayMaxWidth = 800;
12815
12842
  function Overlay({ overlay, outline, imageUrl, title, instructions, reviewInstructions }) {
12816
12843
  const svgReference = useRef7(null);
12817
- useEffect18(() => {
12844
+ useEffect19(() => {
12818
12845
  const listener = debounce2(() => {
12819
12846
  var _a;
12820
12847
  if ((_a = svgReference.current) == null ? void 0 : _a.innerHTML) {
@@ -12983,7 +13010,7 @@ function CameraCapture({
12983
13010
  setReviewImage(void 0);
12984
13011
  };
12985
13012
  const handleRetryCameraAccess = () => setMode("CAPTURE" /* CAPTURE */);
12986
- useEffect19(() => {
13013
+ useEffect20(() => {
12987
13014
  if (mode !== "CAPTURE" /* CAPTURE */) {
12988
13015
  exitFullScreen();
12989
13016
  }
@@ -13062,7 +13089,7 @@ function CameraStep(props) {
13062
13089
  const { overlay, outline } = assets || {};
13063
13090
  const { url: imageUrl } = image || {};
13064
13091
  const [captureClicked, setCaptureClicked] = useState23(false);
13065
- useEffect20(() => {
13092
+ useEffect21(() => {
13066
13093
  if (captureClicked) {
13067
13094
  onAction(action);
13068
13095
  }
@@ -13669,10 +13696,10 @@ var DynamicFlowComponent = ({
13669
13696
  },
13670
13697
  [onCompletion, dispatchEvent]
13671
13698
  );
13672
- useEffect21(() => {
13699
+ useEffect22(() => {
13673
13700
  dispatchEvent("Dynamic Flow - Flow Started", {});
13674
13701
  }, []);
13675
- useEffect21(() => {
13702
+ useEffect22(() => {
13676
13703
  if (!initialStep) {
13677
13704
  const action = __spreadValues({
13678
13705
  id: "#initial-step-request",
@@ -1,5 +1,5 @@
1
1
  import type { Model, Step, ErrorResponseBody } from '@wise/dynamic-flow-types/build/next';
2
- import type { AnalyticsEventDispatcher } from '../domain/features/events';
2
+ import type { AnalyticsEventDispatcher, LoggingEventDispatcher } from '../domain/features/events';
3
3
  type Command = {
4
4
  type: 'refresh-step';
5
5
  step: Step;
@@ -19,5 +19,6 @@ export declare const executeRefresh: (props: {
19
19
  etag: string | null;
20
20
  httpClient: typeof fetch;
21
21
  trackEvent: AnalyticsEventDispatcher;
22
+ logEvent: LoggingEventDispatcher;
22
23
  }) => Promise<Command>;
23
24
  export {};
@@ -1,5 +1,5 @@
1
1
  import type { Action, ErrorResponseBody, Model, Step } from '@wise/dynamic-flow-types/build/next';
2
- import type { AnalyticsEventDispatcher } from '../domain/features/events';
2
+ import type { AnalyticsEventDispatcher, LoggingEventDispatcher } from '../domain/features/events';
3
3
  type Command = {
4
4
  type: 'complete';
5
5
  result: Model;
@@ -27,5 +27,6 @@ export declare const executeSubmission: (props: {
27
27
  isInitial: boolean;
28
28
  httpClient: typeof fetch;
29
29
  trackEvent: AnalyticsEventDispatcher;
30
+ logEvent: LoggingEventDispatcher;
30
31
  }) => Promise<Command>;
31
32
  export {};
@@ -0,0 +1 @@
1
+ export declare const getErrorMessage: (error: unknown) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/dynamic-flow-client",
3
- "version": "4.3.2",
3
+ "version": "4.3.4",
4
4
  "description": "Dynamic Flow web client",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./build/main.js",