@wise/dynamic-flow-client 4.5.4 → 4.5.6

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.
Files changed (37) hide show
  1. package/build/main.js +417 -579
  2. package/build/main.mjs +417 -579
  3. package/build/types/revamp/domain/components/AllOfComponent.d.ts +4 -5
  4. package/build/types/revamp/domain/components/ColumnsComponent.d.ts +1 -1
  5. package/build/types/revamp/domain/components/ConstComponent.d.ts +2 -3
  6. package/build/types/revamp/domain/components/ContainerComponent.d.ts +1 -2
  7. package/build/types/revamp/domain/components/DecisionComponent.d.ts +1 -1
  8. package/build/types/revamp/domain/components/FormComponent.d.ts +4 -4
  9. package/build/types/revamp/domain/components/HeadingComponent.d.ts +1 -1
  10. package/build/types/revamp/domain/components/InstructionsComponent.d.ts +1 -1
  11. package/build/types/revamp/domain/components/ListComponent.d.ts +1 -1
  12. package/build/types/revamp/domain/components/MarkdownComponent.d.ts +1 -1
  13. package/build/types/revamp/domain/components/ModalContentComponent.d.ts +1 -2
  14. package/build/types/revamp/domain/components/MultiSelectInputComponent.d.ts +5 -5
  15. package/build/types/revamp/domain/components/ObjectComponent.d.ts +4 -5
  16. package/build/types/revamp/domain/components/RepeatableComponent.d.ts +6 -7
  17. package/build/types/revamp/domain/components/ReviewComponent.d.ts +1 -1
  18. package/build/types/revamp/domain/components/RootDomainComponent.d.ts +5 -2
  19. package/build/types/revamp/domain/components/SelectInputComponent.d.ts +5 -5
  20. package/build/types/revamp/domain/components/TupleComponent.d.ts +4 -5
  21. package/build/types/revamp/domain/components/step/ExternalConfirmationComponent.d.ts +1 -2
  22. package/build/types/revamp/domain/components/step/StepDomainComponent.d.ts +6 -3
  23. package/build/types/revamp/domain/features/summary/summary-utils.d.ts +2 -2
  24. package/build/types/revamp/domain/features/validation/validation-functions.d.ts +2 -2
  25. package/build/types/revamp/domain/mappers/layout/boxLayoutToComponents.d.ts +2 -2
  26. package/build/types/revamp/domain/mappers/layout/columnsLayoutToComponent.d.ts +2 -2
  27. package/build/types/revamp/domain/mappers/layout/formLayoutToComponent.d.ts +2 -2
  28. package/build/types/revamp/domain/mappers/layout/modalLayoutToComponent.d.ts +2 -2
  29. package/build/types/revamp/domain/mappers/layout/modalToContent.d.ts +2 -2
  30. package/build/types/revamp/domain/mappers/mapLayoutToComponent.d.ts +2 -2
  31. package/build/types/revamp/domain/mappers/mapSchemaToComponent.d.ts +2 -2
  32. package/build/types/revamp/domain/mappers/mapStepSchemas.d.ts +2 -2
  33. package/build/types/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.d.ts +1 -1
  34. package/build/types/revamp/domain/types.d.ts +15 -18
  35. package/build/types/revamp/utils/analyse-step.d.ts +3 -0
  36. package/build/types/revamp/utils/component-utils.d.ts +4 -4
  37. package/package.json +4 -4
package/build/main.js CHANGED
@@ -1875,41 +1875,9 @@ var getComponentAlertProps = (component, rendererMapperProps) => "alert" in comp
1875
1875
  }, rendererMapperProps) : null;
1876
1876
 
1877
1877
  // src/revamp/useDynamicFlowCore.tsx
1878
- var import_dynamic_flow_types2 = require("@wise/dynamic-flow-types");
1879
1878
  var import_react3 = require("react");
1880
1879
  var import_react_intl7 = require("react-intl");
1881
1880
 
1882
- // src/revamp/utils/component-utils.ts
1883
- var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
1884
- (values) => values.reduce((acc, value) => mergeModels(acc, value), null)
1885
- );
1886
- var getSubmittableDataSync = (components) => components.map((component) => component.getSubmittableValueSync()).reduce((acc, value) => mergeModels(acc, value), null);
1887
- var getLocalValues = (components) => components.map((component) => component.getLocalValue()).reduce((acc, value) => mergeLocalValues(acc, value), null);
1888
- var mergeLocalValues = (valueA, valueB) => {
1889
- if (valueA === null) {
1890
- return valueB;
1891
- }
1892
- if (valueB === null) {
1893
- return valueA;
1894
- }
1895
- if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
1896
- return __spreadValues(__spreadValues({}, valueA), valueB);
1897
- }
1898
- return valueB;
1899
- };
1900
- var mergeModels = (valueA, valueB) => {
1901
- if (valueA === null) {
1902
- return valueB;
1903
- }
1904
- if (valueB === null) {
1905
- return valueA;
1906
- }
1907
- if (isObjectModel(valueA) && isObjectModel(valueB)) {
1908
- return __spreadValues(__spreadValues({}, valueA), valueB);
1909
- }
1910
- return valueB;
1911
- };
1912
-
1913
1881
  // src/revamp/domain/components/utils/component-utils.ts
1914
1882
  var getInputUpdateFunction = (updateComponent) => {
1915
1883
  return (component, updateFn) => {
@@ -1947,13 +1915,7 @@ var createRootDomainComponent = (updateComponent) => {
1947
1915
  return this.stepComponent ? this.stepComponent.getLocalValue() : null;
1948
1916
  },
1949
1917
  async getSubmittableValue() {
1950
- return this.stepComponent ? getSubmittableData([this.stepComponent, ...this.stepComponent.getModals()]) : null;
1951
- },
1952
- getSubmittableValueSync() {
1953
- return this.stepComponent ? getSubmittableDataSync([this.stepComponent, ...this.stepComponent.getModals()]) : null;
1954
- },
1955
- getSummary() {
1956
- return this.stepComponent ? this.stepComponent.getSummary() : {};
1918
+ return this.stepComponent ? this.stepComponent.getSubmittableValue() : null;
1957
1919
  },
1958
1920
  validate() {
1959
1921
  return this.stepComponent ? this.stepComponent.validate() : false;
@@ -1965,8 +1927,8 @@ var createRootDomainComponent = (updateComponent) => {
1965
1927
  getLoadingState() {
1966
1928
  return this.stepComponent ? this.stepComponent.loadingState : "initial";
1967
1929
  },
1968
- getInputComponents() {
1969
- return this.stepComponent ? this.stepComponent.inputComponents : [];
1930
+ getSchemaComponents() {
1931
+ return this.stepComponent ? this.stepComponent.schemaComponents : [];
1970
1932
  },
1971
1933
  getTrackEvent() {
1972
1934
  return this.stepComponent ? this.stepComponent.trackEvent : null;
@@ -1987,141 +1949,36 @@ var createRootDomainComponent = (updateComponent) => {
1987
1949
  return rootComponent;
1988
1950
  };
1989
1951
 
1990
- // src/revamp/domain/components/step/ExternalConfirmationComponent.ts
1991
- var createExternalConfirmation = (uid, url, updateComponent) => {
1992
- const update = getInputUpdateFunction(updateComponent);
1993
- return {
1994
- type: "external-confirmation",
1995
- uid,
1996
- url,
1997
- status: "initial",
1998
- onSuccess() {
1999
- update(this, (draft) => {
2000
- draft.status = "success";
2001
- });
2002
- },
2003
- onFailure() {
2004
- if (this.status === "initial") {
2005
- update(this, (draft) => {
2006
- draft.status = "failure";
2007
- });
2008
- }
2009
- },
2010
- onCancel() {
2011
- update(this, (draft) => {
2012
- draft.status = "dismissed";
2013
- });
2014
- },
2015
- getSubmittableValue: async () => null,
2016
- getSubmittableValueSync: () => null,
2017
- getLocalValue: () => null,
2018
- getSummary: () => ({}),
2019
- // Noop
2020
- validate: () => true
2021
- };
2022
- };
2023
-
2024
- // src/revamp/domain/features/summary/summary-utils.ts
2025
- var getSummariser = (schema) => (value) => {
2026
- const { summary, icon, image } = schema;
2027
- const stringValueOrNull = isString(value) ? value : null;
2028
- return summaryIfProvides(summary, { value: stringValueOrNull, icon, image });
2029
- };
2030
- var getConstSummary = (schema, model) => {
2031
- const { summary, icon, image } = schema;
2032
- const value = isString(model) ? model : null;
2033
- return summaryIfProvides(summary, { value, icon, image });
2034
- };
2035
- var summariseFromChildren = (components) => components.reduce(
2036
- (acc, component) => mergeSummaries(acc, component.getSummary()),
2037
- {}
2038
- );
2039
- var mergeSummaries = (summaryA, summaryB) => {
2040
- var _a, _b, _c, _d;
2041
- return {
2042
- title: (_a = summaryA.title) != null ? _a : summaryB.title,
2043
- description: (_b = summaryA.description) != null ? _b : summaryB.description,
2044
- icon: (_c = summaryA.icon) != null ? _c : summaryB.icon,
2045
- image: (_d = summaryA.image) != null ? _d : summaryB.image
2046
- };
2047
- };
2048
- var summaryIfProvides = (summary, { value, icon, image }) => {
2049
- if (!summary) {
2050
- return {};
2051
- }
2052
- return {
2053
- title: summary.providesTitle && value || void 0,
2054
- description: summary.providesDescription && value || void 0,
2055
- icon: summary.providesIcon && icon || void 0,
2056
- image: summary.providesImage && mapSpecImage(image != null ? image : void 0) || void 0
2057
- };
2058
- };
2059
-
2060
- // src/revamp/domain/components/step/StepDomainComponent.ts
2061
- var createStepComponent = (stepProps) => {
2062
- const _a = stepProps, { uid, stepPolling, stepRefreshAfter, updateComponent } = _a, rest = __objRest(_a, ["uid", "stepPolling", "stepRefreshAfter", "updateComponent"]);
1952
+ // src/revamp/domain/components/ModalContentComponent.ts
1953
+ var createModalContentComponent = (modalProps, updateComponent) => {
2063
1954
  const update = getInputUpdateFunction(updateComponent);
2064
- const component = __spreadProps(__spreadValues({
2065
- uid
2066
- }, rest), {
2067
- type: "step",
2068
- modals: [],
2069
- dismissModal() {
2070
- var _a2;
2071
- (_a2 = this.modals.at(-1)) == null ? void 0 : _a2.close();
2072
- },
2073
- dismissAllModals() {
2074
- this._update((draft) => {
2075
- draft.modals = draft.modals.map((m) => __spreadProps(__spreadValues({}, m), { open: false }));
2076
- });
2077
- },
2078
- showModal(modal) {
2079
- this._update((draft) => {
2080
- draft.modals = [...draft.modals, modal];
2081
- });
2082
- },
1955
+ const modalContentComponent = __spreadProps(__spreadValues({
1956
+ type: "modal-content",
1957
+ open: true
1958
+ }, modalProps), {
2083
1959
  _update(updateFn) {
2084
1960
  update(this, updateFn);
2085
1961
  },
2086
1962
  getChildren() {
2087
- return this.externalConfirmation ? [...this.layoutComponents, this.externalConfirmation] : this.layoutComponents;
2088
- },
2089
- getModals() {
2090
- return this.modals;
2091
- },
2092
- async getSubmittableValue() {
2093
- return getSubmittableData(this.inputComponents);
2094
- },
2095
- getSubmittableValueSync() {
2096
- return getSubmittableDataSync(this.inputComponents);
2097
- },
2098
- getSummary() {
2099
- return summariseFromChildren(this.getChildren());
2100
- },
2101
- getLocalValue() {
2102
- return getLocalValues(this.inputComponents);
2103
- },
2104
- validate() {
2105
- return this.inputComponents.every(
2106
- (inputComponent) => inputComponent.isSchemaReferencedInStep ? inputComponent.validate() : true
2107
- );
2108
- },
2109
- setLoadingState(loadingState) {
2110
- this._update((draft) => {
2111
- draft.loadingState = loadingState;
2112
- });
1963
+ return this.components;
2113
1964
  },
2114
- stop() {
2115
- stepPolling == null ? void 0 : stepPolling.stop();
2116
- stepRefreshAfter == null ? void 0 : stepRefreshAfter.stop();
2117
- this._update((draft) => {
2118
- draft.modals = [];
1965
+ close() {
1966
+ update(this, (draft) => {
1967
+ draft.open = false;
2119
1968
  });
2120
1969
  }
2121
1970
  });
2122
- return component;
1971
+ return modalContentComponent;
2123
1972
  };
2124
1973
 
1974
+ // src/revamp/domain/components/utils/getRandomId.ts
1975
+ var getRandomId = () => Math.random().toString(36).substring(2);
1976
+
1977
+ // src/revamp/domain/components/AlertComponent.ts
1978
+ var createAlertComponent = (alertProps) => __spreadValues({
1979
+ type: "alert"
1980
+ }, alertProps);
1981
+
2125
1982
  // src/revamp/domain/mappers/utils/behavior-utils.ts
2126
1983
  var getDomainLayerBehavior = ({
2127
1984
  action,
@@ -2161,73 +2018,6 @@ var getActionByReference = ($ref, actions = []) => {
2161
2018
  return action;
2162
2019
  };
2163
2020
 
2164
- // src/revamp/domain/features/polling/getStepPolling.ts
2165
- var getStepPolling = ({
2166
- pollingConfig,
2167
- onBehavior,
2168
- onPoll
2169
- }) => {
2170
- const { interval, delay = interval, maxAttempts, url, onError } = pollingConfig;
2171
- let abortController = new AbortController();
2172
- if (delay == null) {
2173
- throw new Error("Polling configuration must include delay or interval");
2174
- }
2175
- const onErrorBehavior = skipValidation(getDomainLayerBehavior(onError, []));
2176
- let attempts = 0;
2177
- const poll = () => {
2178
- attempts += 1;
2179
- abortController.abort();
2180
- abortController = new AbortController();
2181
- const { signal } = abortController;
2182
- onPoll(url, onErrorBehavior, signal).then((result) => {
2183
- if (result) {
2184
- stop();
2185
- return;
2186
- }
2187
- if (attempts >= maxAttempts && !signal.aborted) {
2188
- void onBehavior(onErrorBehavior);
2189
- stop();
2190
- }
2191
- }).catch(() => {
2192
- });
2193
- };
2194
- const intervalRef = setInterval(poll, delay * 1e3);
2195
- const stop = () => {
2196
- clearTimeout(intervalRef);
2197
- abortController.abort();
2198
- };
2199
- poll();
2200
- return { stop };
2201
- };
2202
-
2203
- // src/revamp/domain/features/refreshAfter/getStepRefreshAfter.ts
2204
- var ONE_SECOND = 1e3;
2205
- var getStepRefreshAfter = ({ refreshAfter, onRefresh }) => {
2206
- const targetTime = new Date(refreshAfter).getTime();
2207
- if (typeof refreshAfter !== "string" || Number.isNaN(targetTime)) {
2208
- throw new Error(`Invalid refreshAfter value: ${String(refreshAfter)}`);
2209
- }
2210
- const timeLeft = Math.max(targetTime - Date.now(), ONE_SECOND);
2211
- const timeout = setTimeout(() => {
2212
- void onRefresh("refreshAfter");
2213
- }, timeLeft);
2214
- return {
2215
- stop: () => clearTimeout(timeout)
2216
- };
2217
- };
2218
-
2219
- // src/revamp/domain/components/AlertComponent.ts
2220
- var createAlertComponent = (alertProps) => __spreadProps(__spreadValues({
2221
- type: "alert"
2222
- }, alertProps), {
2223
- getSubmittableValue: async () => null,
2224
- getSubmittableValueSync: () => null,
2225
- getLocalValue: () => null,
2226
- getSummary: () => ({}),
2227
- // Noop
2228
- validate: () => true
2229
- });
2230
-
2231
2021
  // src/revamp/domain/mappers/utils/call-to-action-utils.ts
2232
2022
  var getDomainLayerCallToAction = (callToAction, onBehavior, stepActions) => {
2233
2023
  if (!callToAction) {
@@ -2334,56 +2124,30 @@ var alertLayoutToComponent = (uid, { control, markdown, margin = "md", context =
2334
2124
  });
2335
2125
  };
2336
2126
 
2337
- // src/revamp/domain/features/validation/validation-functions.ts
2338
- var validateComponents = (components) => components.reduce((acc, component) => component.validate() && acc, true);
2339
- var getLocalValueValidator = (checks) => (currentValue) => checks.map((check) => check(currentValue)).filter(isString);
2340
-
2341
2127
  // src/revamp/domain/components/BoxComponent.ts
2342
2128
  var createBoxComponent = (boxProps) => __spreadProps(__spreadValues({}, boxProps), {
2343
2129
  type: "box",
2344
2130
  getChildren() {
2345
2131
  return this.components;
2346
- },
2347
- async getSubmittableValue() {
2348
- return getSubmittableData(this.components);
2349
- },
2350
- getSubmittableValueSync() {
2351
- return getSubmittableDataSync(this.components);
2352
- },
2353
- getSummary() {
2354
- return summariseFromChildren(this.getChildren());
2355
- },
2356
- getLocalValue() {
2357
- return getLocalValues(this.components);
2358
- },
2359
- validate() {
2360
- return validateComponents(this.getChildren());
2361
2132
  }
2362
2133
  });
2363
2134
 
2364
2135
  // src/revamp/domain/mappers/layout/boxLayoutToComponents.ts
2365
- var boxLayoutToComponent = (uid, { border = false, components, control, margin = "md", width = "xl" }, mapperProps, inputComponents) => createBoxComponent({
2136
+ var boxLayoutToComponent = (uid, { border = false, components, control, margin = "md", width = "xl" }, mapperProps, schemaComponents) => createBoxComponent({
2366
2137
  uid,
2367
2138
  border,
2368
2139
  control,
2369
2140
  margin,
2370
2141
  width,
2371
2142
  components: components.map(
2372
- (component, index) => mapLayoutToComponent(`${uid}.box-${index}`, component, mapperProps, inputComponents)
2143
+ (component, index) => mapLayoutToComponent(`${uid}.box-${index}`, component, mapperProps, schemaComponents)
2373
2144
  )
2374
2145
  });
2375
2146
 
2376
2147
  // src/revamp/domain/components/ButtonComponent.ts
2377
- var createButtonComponent = (buttonProps) => __spreadProps(__spreadValues({
2148
+ var createButtonComponent = (buttonProps) => __spreadValues({
2378
2149
  type: "button"
2379
- }, buttonProps), {
2380
- getSubmittableValue: async () => null,
2381
- getSubmittableValueSync: () => null,
2382
- getLocalValue: () => null,
2383
- getSummary: () => ({}),
2384
- // Noop
2385
- validate: () => true
2386
- });
2150
+ }, buttonProps);
2387
2151
 
2388
2152
  // src/revamp/domain/mappers/layout/buttonLayoutToComponent.ts
2389
2153
  var buttonLayoutToComponent = (uid, button, mapperProps) => {
@@ -2465,26 +2229,11 @@ var createColumnsComponent = (columnsProps) => __spreadProps(__spreadValues({},
2465
2229
  type: "columns",
2466
2230
  getChildren() {
2467
2231
  return [...this.startComponents, ...this.endComponents];
2468
- },
2469
- async getSubmittableValue() {
2470
- return getSubmittableData(this.getChildren());
2471
- },
2472
- getSubmittableValueSync() {
2473
- return getSubmittableDataSync(this.getChildren());
2474
- },
2475
- getSummary() {
2476
- return summariseFromChildren(this.getChildren());
2477
- },
2478
- getLocalValue() {
2479
- return getLocalValues(this.getChildren());
2480
- },
2481
- validate() {
2482
- return validateComponents(this.getChildren());
2483
2232
  }
2484
2233
  });
2485
2234
 
2486
2235
  // src/revamp/domain/mappers/layout/columnsLayoutToComponent.ts
2487
- var columnsLayoutToComponent = (uid, { control, left, right, bias = "none", margin = "md" }, mapperProps, inputComponents) => createColumnsComponent({
2236
+ var columnsLayoutToComponent = (uid, { control, left, right, bias = "none", margin = "md" }, mapperProps, schemaComponents) => createColumnsComponent({
2488
2237
  uid,
2489
2238
  control,
2490
2239
  margin,
@@ -2494,25 +2243,18 @@ var columnsLayoutToComponent = (uid, { control, left, right, bias = "none", marg
2494
2243
  `${uid}.columns-start-${index}`,
2495
2244
  component,
2496
2245
  mapperProps,
2497
- inputComponents
2246
+ schemaComponents
2498
2247
  )
2499
2248
  ),
2500
2249
  endComponents: right.map(
2501
- (component, index) => mapLayoutToComponent(`${uid}.columns-end-${index}`, component, mapperProps, inputComponents)
2250
+ (component, index) => mapLayoutToComponent(`${uid}.columns-end-${index}`, component, mapperProps, schemaComponents)
2502
2251
  )
2503
2252
  });
2504
2253
 
2505
2254
  // src/revamp/domain/components/DecisionComponent.ts
2506
- var createDecisionComponent = (decisionProps) => __spreadProps(__spreadValues({
2255
+ var createDecisionComponent = (decisionProps) => __spreadValues({
2507
2256
  type: "decision"
2508
- }, decisionProps), {
2509
- getSubmittableValue: async () => null,
2510
- getSubmittableValueSync: () => null,
2511
- getLocalValue: () => null,
2512
- getSummary: () => ({}),
2513
- // Noop
2514
- validate: () => true
2515
- });
2257
+ }, decisionProps);
2516
2258
 
2517
2259
  // src/revamp/domain/mappers/utils/utils.ts
2518
2260
  var mapInlineAlert = (alert) => {
@@ -2569,16 +2311,9 @@ var mapOption = (option, onBehavior, stepActions = []) => {
2569
2311
  };
2570
2312
 
2571
2313
  // src/revamp/domain/components/StatusListComponent.ts
2572
- var createStatusListComponent = (statusListProps) => __spreadProps(__spreadValues({
2314
+ var createStatusListComponent = (statusListProps) => __spreadValues({
2573
2315
  type: "status-list"
2574
- }, statusListProps), {
2575
- getLocalValue: () => null,
2576
- getSubmittableValue: async () => null,
2577
- getSubmittableValueSync: () => null,
2578
- getSummary: () => ({}),
2579
- // Noop,
2580
- validate: () => true
2581
- });
2316
+ }, statusListProps);
2582
2317
 
2583
2318
  // src/revamp/domain/mappers/layout/deprecatedListLayoutToComponent.ts
2584
2319
  var isDeprecatedListLayout = (layout) => {
@@ -2613,16 +2348,9 @@ var mapLegacyStatus = (status) => {
2613
2348
  };
2614
2349
 
2615
2350
  // src/revamp/domain/components/DividerComponent.ts
2616
- var createDividerComponent = (props) => __spreadProps(__spreadValues({
2351
+ var createDividerComponent = (props) => __spreadValues({
2617
2352
  type: "divider"
2618
- }, props), {
2619
- getSubmittableValue: async () => null,
2620
- getSubmittableValueSync: () => null,
2621
- getLocalValue: () => null,
2622
- getSummary: () => ({}),
2623
- // Noop
2624
- validate: () => true
2625
- });
2353
+ }, props);
2626
2354
 
2627
2355
  // src/revamp/domain/mappers/layout/dividerLayoutToComponent.ts
2628
2356
  var dividerLayoutToComponent = (uid, { control, margin = "md" }) => createDividerComponent({ uid, control, margin });
@@ -2631,56 +2359,36 @@ var dividerLayoutToComponent = (uid, { control, margin = "md" }) => createDivide
2631
2359
  var createFormComponent = (formProps) => __spreadProps(__spreadValues({}, formProps), {
2632
2360
  type: "form",
2633
2361
  getChildren() {
2634
- return [this.inputComponent];
2635
- },
2636
- async getSubmittableValue() {
2637
- return this.inputComponent.getSubmittableValue();
2638
- },
2639
- getSubmittableValueSync() {
2640
- return this.inputComponent.getSubmittableValueSync();
2641
- },
2642
- getSummary() {
2643
- return this.inputComponent.getSummary();
2644
- },
2645
- getLocalValue() {
2646
- return this.inputComponent.getLocalValue();
2647
- },
2648
- validate() {
2649
- return this.inputComponent.validate();
2362
+ return [this.schemaComponent];
2650
2363
  }
2651
2364
  });
2652
2365
 
2653
2366
  // src/revamp/domain/mappers/layout/formLayoutToComponent.ts
2654
- var formLayoutToComponent = (uid, { schemaId, schema: schemaRef, control, margin = "md" }, inputComponents) => {
2367
+ var formLayoutToComponent = (uid, { schemaId, schema: schemaRef, control, margin = "md" }, schemaComponents) => {
2655
2368
  const id = schemaId != null ? schemaId : schemaRef == null ? void 0 : schemaRef.$ref;
2656
2369
  if (id == null) {
2657
2370
  throw new Error(
2658
2371
  "FormLayouts must refer to a schema. Set the `schemaId` property to the intended schema."
2659
2372
  );
2660
2373
  }
2661
- const inputComponent = inputComponents.find((component) => component.schemaId === id);
2662
- if (!inputComponent) {
2663
- throw new Error(`FormLayout with schemaId ${id} not found in inputComponents. The schema is probably missing in the step.schemas array.`);
2374
+ const schemaComponent = schemaComponents.find((component) => component.schemaId === id);
2375
+ if (!schemaComponent) {
2376
+ throw new Error(
2377
+ `FormLayout with schemaId ${id} not found in inputComponents. The schema is probably missing in the step.schemas array.`
2378
+ );
2664
2379
  }
2665
2380
  return createFormComponent({
2666
2381
  uid,
2667
- inputComponent,
2382
+ schemaComponent,
2668
2383
  control,
2669
2384
  margin
2670
2385
  });
2671
2386
  };
2672
2387
 
2673
2388
  // src/revamp/domain/components/HeadingComponent.ts
2674
- var createHeadingComponent = (headingProps) => __spreadProps(__spreadValues({
2389
+ var createHeadingComponent = (headingProps) => __spreadValues({
2675
2390
  type: "heading"
2676
- }, headingProps), {
2677
- getSubmittableValue: async () => null,
2678
- getSubmittableValueSync: () => null,
2679
- getSummary: () => ({}),
2680
- // Noop
2681
- getLocalValue: () => null,
2682
- validate: () => true
2683
- });
2391
+ }, headingProps);
2684
2392
 
2685
2393
  // src/revamp/domain/mappers/layout/headingLayoutToComponent.ts
2686
2394
  var headingLayoutToComponent = (uid, { align = "left", margin = "md", size = "md", control, text }) => createHeadingComponent({
@@ -2693,16 +2401,9 @@ var headingLayoutToComponent = (uid, { align = "left", margin = "md", size = "md
2693
2401
  });
2694
2402
 
2695
2403
  // src/revamp/domain/components/ImageComponent.ts
2696
- var createImageComponent = (imageProps) => __spreadProps(__spreadValues({
2404
+ var createImageComponent = (imageProps) => __spreadValues({
2697
2405
  type: "image"
2698
- }, imageProps), {
2699
- getSubmittableValue: async () => null,
2700
- getSubmittableValueSync: () => null,
2701
- getLocalValue: () => null,
2702
- getSummary: () => ({}),
2703
- // Noop
2704
- validate: () => true
2705
- });
2406
+ }, imageProps);
2706
2407
 
2707
2408
  // src/revamp/domain/mappers/layout/imageLayoutToComponent.ts
2708
2409
  var imageLayoutToComponent = (uid, {
@@ -2730,15 +2431,9 @@ var imageLayoutToComponent = (uid, {
2730
2431
  };
2731
2432
 
2732
2433
  // src/revamp/domain/components/MarkdownComponent.ts
2733
- var createMarkdownComponent = (markdownProps) => __spreadProps(__spreadValues({
2434
+ var createMarkdownComponent = (markdownProps) => __spreadValues({
2734
2435
  type: "markdown"
2735
- }, markdownProps), {
2736
- getSubmittableValue: async () => null,
2737
- getSubmittableValueSync: () => null,
2738
- getLocalValue: () => null,
2739
- getSummary: () => ({}),
2740
- validate: () => true
2741
- });
2436
+ }, markdownProps);
2742
2437
 
2743
2438
  // src/revamp/domain/mappers/layout/infoLayoutToComponent.ts
2744
2439
  var infoLayoutToComponent = (uid, { align = "left", control, margin = "md", markdown: content }) => createMarkdownComponent({
@@ -2750,16 +2445,9 @@ var infoLayoutToComponent = (uid, { align = "left", control, margin = "md", mark
2750
2445
  });
2751
2446
 
2752
2447
  // src/revamp/domain/components/InstructionsComponent.ts
2753
- var createInstructionsComponent = (instructionsProps) => __spreadProps(__spreadValues({
2448
+ var createInstructionsComponent = (instructionsProps) => __spreadValues({
2754
2449
  type: "instructions"
2755
- }, instructionsProps), {
2756
- getLocalValue: () => null,
2757
- getSubmittableValue: async () => null,
2758
- getSubmittableValueSync: () => null,
2759
- getSummary: () => ({}),
2760
- // Noop
2761
- validate: () => true
2762
- });
2450
+ }, instructionsProps);
2763
2451
 
2764
2452
  // src/revamp/domain/mappers/layout/instructionsLayoutToComponent.ts
2765
2453
  var instructionsLayoutToComponent = (uid, { control, items, margin = "md", title }) => createInstructionsComponent({
@@ -2773,16 +2461,9 @@ var instructionsLayoutToComponent = (uid, { control, items, margin = "md", title
2773
2461
  });
2774
2462
 
2775
2463
  // src/revamp/domain/components/ListComponent.ts
2776
- var createListComponent = (listProps) => __spreadProps(__spreadValues({
2464
+ var createListComponent = (listProps) => __spreadValues({
2777
2465
  type: "list"
2778
- }, listProps), {
2779
- getLocalValue: () => null,
2780
- getSubmittableValue: async () => null,
2781
- getSubmittableValueSync: () => null,
2782
- getSummary: () => ({}),
2783
- // noop
2784
- validate: () => true
2785
- });
2466
+ }, listProps);
2786
2467
 
2787
2468
  // src/revamp/domain/mappers/layout/listLayoutToComponent.ts
2788
2469
  var listLayoutToComponent = (uid, { callToAction, control, items, margin = "md", title }, mapperProps) => {
@@ -2817,16 +2498,9 @@ var mapSupportingValues = (item) => {
2817
2498
  };
2818
2499
 
2819
2500
  // src/revamp/domain/components/LoadingIndicatorComponent.ts
2820
- var createLoadingIndicatorComponent = (loadingIndicatorProps) => __spreadProps(__spreadValues({
2501
+ var createLoadingIndicatorComponent = (loadingIndicatorProps) => __spreadValues({
2821
2502
  type: "loading-indicator"
2822
- }, loadingIndicatorProps), {
2823
- getSubmittableValue: async () => null,
2824
- getSubmittableValueSync: () => null,
2825
- getLocalValue: () => null,
2826
- getSummary: () => ({}),
2827
- // Noop
2828
- validate: () => true
2829
- });
2503
+ }, loadingIndicatorProps);
2830
2504
 
2831
2505
  // src/revamp/domain/mappers/layout/loadingIndicatorLayoutToComponent.ts
2832
2506
  var loadingIndicatorLayoutToComponent = (uid, { size = "md", margin = "md", control }) => createLoadingIndicatorComponent({ uid, size, control, margin });
@@ -2846,32 +2520,17 @@ var createModalComponent = (modalProps) => __spreadProps(__spreadValues({
2846
2520
  }, modalProps), {
2847
2521
  getChildren() {
2848
2522
  return this.content.components;
2849
- },
2850
- getLocalValue() {
2851
- return getLocalValues(this.getChildren());
2852
- },
2853
- async getSubmittableValue() {
2854
- return getSubmittableData(this.getChildren());
2855
- },
2856
- getSubmittableValueSync() {
2857
- return getSubmittableDataSync(this.getChildren());
2858
- },
2859
- getSummary() {
2860
- return summariseFromChildren(this.getChildren());
2861
- },
2862
- validate() {
2863
- return validateComponents(this.getChildren());
2864
2523
  }
2865
2524
  });
2866
2525
 
2867
2526
  // src/revamp/domain/mappers/layout/modalLayoutToComponent.ts
2868
- var modalLayoutToComponent = (uid, { content, control, margin = "md", trigger }, mapperProps, inputComponents) => {
2527
+ var modalLayoutToComponent = (uid, { content, control, margin = "md", trigger }, mapperProps, schemaComponents) => {
2869
2528
  const { components, title } = content;
2870
2529
  return createModalComponent({
2871
2530
  uid,
2872
2531
  content: {
2873
2532
  components: components.map(
2874
- (component, index) => mapLayoutToComponent(`${uid}.modal-${index}`, component, mapperProps, inputComponents)
2533
+ (component, index) => mapLayoutToComponent(`${uid}.modal-${index}`, component, mapperProps, schemaComponents)
2875
2534
  ),
2876
2535
  title
2877
2536
  },
@@ -2882,16 +2541,9 @@ var modalLayoutToComponent = (uid, { content, control, margin = "md", trigger },
2882
2541
  };
2883
2542
 
2884
2543
  // src/revamp/domain/components/ParagraphComponent.ts
2885
- var createParagraphComponent = (paragraphProps) => __spreadProps(__spreadValues({
2544
+ var createParagraphComponent = (paragraphProps) => __spreadValues({
2886
2545
  type: "paragraph"
2887
- }, paragraphProps), {
2888
- getSubmittableValue: async () => null,
2889
- getSubmittableValueSync: () => null,
2890
- getSummary: () => ({}),
2891
- // Noop
2892
- getLocalValue: () => null,
2893
- validate: () => true
2894
- });
2546
+ }, paragraphProps);
2895
2547
 
2896
2548
  // src/revamp/domain/mappers/layout/paragraphLayoutToComponent.ts
2897
2549
  var paragraphLayoutToComponent = (uid, { align = "left", control, margin = "md", text }) => createParagraphComponent({
@@ -2903,16 +2555,9 @@ var paragraphLayoutToComponent = (uid, { align = "left", control, margin = "md",
2903
2555
  });
2904
2556
 
2905
2557
  // src/revamp/domain/components/ReviewComponent.ts
2906
- var createReviewComponent = (reviewProps) => __spreadProps(__spreadValues({
2558
+ var createReviewComponent = (reviewProps) => __spreadValues({
2907
2559
  type: "review"
2908
- }, reviewProps), {
2909
- getLocalValue: () => null,
2910
- getSubmittableValue: async () => null,
2911
- getSubmittableValueSync: () => null,
2912
- getSummary: () => ({}),
2913
- // Noop
2914
- validate: () => true
2915
- });
2560
+ }, reviewProps);
2916
2561
 
2917
2562
  // src/revamp/domain/mappers/layout/reviewLayoutToComponent.ts
2918
2563
  var reviewLayoutToComponent = (uid, { fields, title, callToAction, control, margin = "md", orientation, action }, { onBehavior, step }) => createReviewComponent({
@@ -3052,12 +2697,6 @@ var createSearchComponent = (searchProps, performSearch, onBehavior, updateCompo
3052
2697
  _update(updateFn) {
3053
2698
  update(this, updateFn);
3054
2699
  },
3055
- getSubmittableValue: async () => null,
3056
- getSubmittableValueSync: () => null,
3057
- getLocalValue: () => null,
3058
- getSummary: () => ({}),
3059
- // Noop
3060
- validate: () => true,
3061
2700
  onChange(query) {
3062
2701
  this._update((draft) => {
3063
2702
  draft.query = query;
@@ -3120,104 +2759,286 @@ var parseResponse = async (response) => {
3120
2759
  }
3121
2760
  return body.results;
3122
2761
  }
3123
- }
3124
- throw Error("error response");
3125
- };
3126
- var addQueryParameter = (url, key, value) => {
3127
- const [urlBase, urlQuery] = url.split("?");
3128
- const urlQueryParams = new URLSearchParams(urlQuery);
3129
- urlQueryParams.set(key, value);
3130
- return `${urlBase}?${urlQueryParams.toString()}`;
2762
+ }
2763
+ throw Error("error response");
2764
+ };
2765
+ var addQueryParameter = (url, key, value) => {
2766
+ const [urlBase, urlQuery] = url.split("?");
2767
+ const urlQueryParams = new URLSearchParams(urlQuery);
2768
+ urlQueryParams.set(key, value);
2769
+ return `${urlBase}?${urlQueryParams.toString()}`;
2770
+ };
2771
+ var isValidResponseBody = (body) => isObject(body) && "results" in body && isArray(body.results) && body.results.every(
2772
+ (result) => isObject(result) && "title" in result && "type" in result && "value" in result
2773
+ );
2774
+ var hashRequest = (query, config) => JSON.stringify({ query, config });
2775
+
2776
+ // src/revamp/domain/mappers/layout/searchLayoutToComponent.ts
2777
+ var searchLayoutToComponent = (uid, { control, emptyMessage = "", method, param, title, url, margin = "md" }, mapperProps) => {
2778
+ const { httpClient, onBehavior, updateComponent } = mapperProps;
2779
+ const search = getPerformSearchFunction(httpClient, { method, param, url });
2780
+ return createSearchComponent(
2781
+ {
2782
+ uid,
2783
+ control,
2784
+ emptyMessage,
2785
+ margin,
2786
+ title
2787
+ },
2788
+ search,
2789
+ onBehavior,
2790
+ updateComponent
2791
+ );
2792
+ };
2793
+
2794
+ // src/revamp/domain/mappers/layout/statusListLayoutToComponent.ts
2795
+ var statusListLayoutToComponent = (uid, { control, items, margin = "md", title }, { onBehavior, step }) => createStatusListComponent({
2796
+ uid,
2797
+ control,
2798
+ items: items.map((item) => {
2799
+ var _a;
2800
+ const callToAction = getDomainLayerCallToAction(
2801
+ item.callToAction,
2802
+ onBehavior,
2803
+ (_a = step.actions) != null ? _a : []
2804
+ );
2805
+ return __spreadProps(__spreadValues({}, item), { callToAction });
2806
+ }),
2807
+ margin,
2808
+ title
2809
+ });
2810
+
2811
+ // src/revamp/domain/mappers/mapLayoutToComponent.ts
2812
+ var mapLayoutToComponent = (uid, layout, mapperProps, schemaComponents) => {
2813
+ switch (layout.type) {
2814
+ case "alert":
2815
+ return alertLayoutToComponent(uid, layout, mapperProps);
2816
+ case "box":
2817
+ return boxLayoutToComponent(uid, layout, mapperProps, schemaComponents);
2818
+ case "button":
2819
+ return buttonLayoutToComponent(uid, layout, mapperProps);
2820
+ case "columns":
2821
+ return columnsLayoutToComponent(uid, layout, mapperProps, schemaComponents);
2822
+ case "decision":
2823
+ return decisionLayoutToComponent(uid, layout, mapperProps);
2824
+ case "divider":
2825
+ return dividerLayoutToComponent(uid, layout);
2826
+ case "form":
2827
+ return formLayoutToComponent(uid, layout, schemaComponents);
2828
+ case "heading":
2829
+ return headingLayoutToComponent(uid, layout);
2830
+ case "image":
2831
+ return imageLayoutToComponent(uid, layout);
2832
+ case "info":
2833
+ return infoLayoutToComponent(uid, layout);
2834
+ case "instructions":
2835
+ return instructionsLayoutToComponent(uid, layout);
2836
+ case "list":
2837
+ return isDeprecatedListLayout(layout) ? deprecatedListLayoutToComponent(uid, layout) : listLayoutToComponent(uid, layout, mapperProps);
2838
+ case "loading-indicator":
2839
+ return loadingIndicatorLayoutToComponent(uid, layout);
2840
+ case "markdown":
2841
+ return markdownLayoutToComponent(uid, layout);
2842
+ case "modal":
2843
+ return modalLayoutToComponent(uid, layout, mapperProps, schemaComponents);
2844
+ case "paragraph":
2845
+ return paragraphLayoutToComponent(uid, layout);
2846
+ case "review":
2847
+ return reviewLayoutToComponent(uid, layout, mapperProps);
2848
+ case "search":
2849
+ return searchLayoutToComponent(uid, layout, mapperProps);
2850
+ case "status-list":
2851
+ return statusListLayoutToComponent(uid, layout, mapperProps);
2852
+ default:
2853
+ throw new Error(`Invalid layout type in ${JSON.stringify(layout)}`);
2854
+ }
2855
+ };
2856
+
2857
+ // src/revamp/domain/mappers/layout/modalToContent.ts
2858
+ var modalToContent = (uid, { content, title }, mapperProps, schemaComponents) => createModalContentComponent(
2859
+ {
2860
+ uid: `${uid}-modal-${getRandomId()}`,
2861
+ title,
2862
+ components: content.map(
2863
+ (component, index) => mapLayoutToComponent(`${uid}.modal-${index}`, component, mapperProps, schemaComponents)
2864
+ )
2865
+ },
2866
+ mapperProps.updateComponent
2867
+ );
2868
+
2869
+ // src/revamp/domain/components/step/ExternalConfirmationComponent.ts
2870
+ var createExternalConfirmation = (uid, url, updateComponent) => {
2871
+ const update = getInputUpdateFunction(updateComponent);
2872
+ return {
2873
+ type: "external-confirmation",
2874
+ uid,
2875
+ url,
2876
+ status: "initial",
2877
+ onSuccess() {
2878
+ update(this, (draft) => {
2879
+ draft.status = "success";
2880
+ });
2881
+ },
2882
+ onFailure() {
2883
+ if (this.status === "initial") {
2884
+ update(this, (draft) => {
2885
+ draft.status = "failure";
2886
+ });
2887
+ }
2888
+ },
2889
+ onCancel() {
2890
+ update(this, (draft) => {
2891
+ draft.status = "dismissed";
2892
+ });
2893
+ }
2894
+ };
2895
+ };
2896
+
2897
+ // src/revamp/utils/component-utils.ts
2898
+ var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
2899
+ (values) => values.reduce((acc, value) => mergeModels(acc, value), null)
2900
+ );
2901
+ var getSubmittableDataSync = (components) => components.map((component) => component.getSubmittableValueSync()).reduce((acc, value) => mergeModels(acc, value), null);
2902
+ var getLocalValues = (components) => components.map((component) => component.getLocalValue()).reduce((acc, value) => mergeLocalValues(acc, value), null);
2903
+ var mergeLocalValues = (valueA, valueB) => {
2904
+ if (valueA === null) {
2905
+ return valueB;
2906
+ }
2907
+ if (valueB === null) {
2908
+ return valueA;
2909
+ }
2910
+ if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
2911
+ return __spreadValues(__spreadValues({}, valueA), valueB);
2912
+ }
2913
+ return valueB;
2914
+ };
2915
+ var mergeModels = (valueA, valueB) => {
2916
+ if (valueA === null) {
2917
+ return valueB;
2918
+ }
2919
+ if (valueB === null) {
2920
+ return valueA;
2921
+ }
2922
+ if (isObjectModel(valueA) && isObjectModel(valueB)) {
2923
+ return __spreadValues(__spreadValues({}, valueA), valueB);
2924
+ }
2925
+ return valueB;
2926
+ };
2927
+
2928
+ // src/revamp/domain/components/step/StepDomainComponent.ts
2929
+ var createStepComponent = (stepProps) => {
2930
+ const _a = stepProps, { uid, stepPolling, stepRefreshAfter, updateComponent } = _a, rest = __objRest(_a, ["uid", "stepPolling", "stepRefreshAfter", "updateComponent"]);
2931
+ const update = getInputUpdateFunction(updateComponent);
2932
+ const component = __spreadProps(__spreadValues({
2933
+ uid
2934
+ }, rest), {
2935
+ type: "step",
2936
+ modals: [],
2937
+ dismissModal() {
2938
+ var _a2;
2939
+ (_a2 = this.modals.at(-1)) == null ? void 0 : _a2.close();
2940
+ },
2941
+ dismissAllModals() {
2942
+ this._update((draft) => {
2943
+ draft.modals = draft.modals.map((m) => __spreadProps(__spreadValues({}, m), { open: false }));
2944
+ });
2945
+ },
2946
+ showModal(modal) {
2947
+ this._update((draft) => {
2948
+ draft.modals = [...draft.modals, modal];
2949
+ });
2950
+ },
2951
+ _update(updateFn) {
2952
+ update(this, updateFn);
2953
+ },
2954
+ getChildren() {
2955
+ return this.externalConfirmation ? [...this.layoutComponents, this.externalConfirmation] : this.layoutComponents;
2956
+ },
2957
+ getModals() {
2958
+ return this.modals;
2959
+ },
2960
+ async getSubmittableValue() {
2961
+ return getSubmittableData(this.schemaComponents);
2962
+ },
2963
+ getLocalValue() {
2964
+ return getLocalValues(this.schemaComponents);
2965
+ },
2966
+ validate() {
2967
+ return this.schemaComponents.every(
2968
+ (inputComponent) => inputComponent.isSchemaReferencedInStep ? inputComponent.validate() : true
2969
+ );
2970
+ },
2971
+ setLoadingState(loadingState) {
2972
+ this._update((draft) => {
2973
+ draft.loadingState = loadingState;
2974
+ });
2975
+ },
2976
+ stop() {
2977
+ stepPolling == null ? void 0 : stepPolling.stop();
2978
+ stepRefreshAfter == null ? void 0 : stepRefreshAfter.stop();
2979
+ this._update((draft) => {
2980
+ draft.modals = [];
2981
+ });
2982
+ }
2983
+ });
2984
+ return component;
3131
2985
  };
3132
- var isValidResponseBody = (body) => isObject(body) && "results" in body && isArray(body.results) && body.results.every(
3133
- (result) => isObject(result) && "title" in result && "type" in result && "value" in result
3134
- );
3135
- var hashRequest = (query, config) => JSON.stringify({ query, config });
3136
2986
 
3137
- // src/revamp/domain/mappers/layout/searchLayoutToComponent.ts
3138
- var searchLayoutToComponent = (uid, { control, emptyMessage = "", method, param, title, url, margin = "md" }, mapperProps) => {
3139
- const { httpClient, onBehavior, updateComponent } = mapperProps;
3140
- const search = getPerformSearchFunction(httpClient, { method, param, url });
3141
- return createSearchComponent(
3142
- {
3143
- uid,
3144
- control,
3145
- emptyMessage,
3146
- margin,
3147
- title
3148
- },
3149
- search,
3150
- onBehavior,
3151
- updateComponent
3152
- );
2987
+ // src/revamp/domain/features/polling/getStepPolling.ts
2988
+ var getStepPolling = ({
2989
+ pollingConfig,
2990
+ onBehavior,
2991
+ onPoll
2992
+ }) => {
2993
+ const { interval, delay = interval, maxAttempts, url, onError } = pollingConfig;
2994
+ let abortController = new AbortController();
2995
+ if (delay == null) {
2996
+ throw new Error("Polling configuration must include delay or interval");
2997
+ }
2998
+ const onErrorBehavior = skipValidation(getDomainLayerBehavior(onError, []));
2999
+ let attempts = 0;
3000
+ const poll = () => {
3001
+ attempts += 1;
3002
+ abortController.abort();
3003
+ abortController = new AbortController();
3004
+ const { signal } = abortController;
3005
+ onPoll(url, onErrorBehavior, signal).then((result) => {
3006
+ if (result) {
3007
+ stop();
3008
+ return;
3009
+ }
3010
+ if (attempts >= maxAttempts && !signal.aborted) {
3011
+ void onBehavior(onErrorBehavior);
3012
+ stop();
3013
+ }
3014
+ }).catch(() => {
3015
+ });
3016
+ };
3017
+ const intervalRef = setInterval(poll, delay * 1e3);
3018
+ const stop = () => {
3019
+ clearTimeout(intervalRef);
3020
+ abortController.abort();
3021
+ };
3022
+ poll();
3023
+ return { stop };
3153
3024
  };
3154
3025
 
3155
- // src/revamp/domain/mappers/layout/statusListLayoutToComponent.ts
3156
- var statusListLayoutToComponent = (uid, { control, items, margin = "md", title }, { onBehavior, step }) => createStatusListComponent({
3157
- uid,
3158
- control,
3159
- items: items.map((item) => {
3160
- var _a;
3161
- const callToAction = getDomainLayerCallToAction(
3162
- item.callToAction,
3163
- onBehavior,
3164
- (_a = step.actions) != null ? _a : []
3165
- );
3166
- return __spreadProps(__spreadValues({}, item), { callToAction });
3167
- }),
3168
- margin,
3169
- title
3170
- });
3171
-
3172
- // src/revamp/domain/mappers/mapLayoutToComponent.ts
3173
- var mapLayoutToComponent = (uid, layout, mapperProps, inputComponents) => {
3174
- switch (layout.type) {
3175
- case "alert":
3176
- return alertLayoutToComponent(uid, layout, mapperProps);
3177
- case "box":
3178
- return boxLayoutToComponent(uid, layout, mapperProps, inputComponents);
3179
- case "button":
3180
- return buttonLayoutToComponent(uid, layout, mapperProps);
3181
- case "columns":
3182
- return columnsLayoutToComponent(uid, layout, mapperProps, inputComponents);
3183
- case "decision":
3184
- return decisionLayoutToComponent(uid, layout, mapperProps);
3185
- case "divider":
3186
- return dividerLayoutToComponent(uid, layout);
3187
- case "form":
3188
- return formLayoutToComponent(uid, layout, inputComponents);
3189
- case "heading":
3190
- return headingLayoutToComponent(uid, layout);
3191
- case "image":
3192
- return imageLayoutToComponent(uid, layout);
3193
- case "info":
3194
- return infoLayoutToComponent(uid, layout);
3195
- case "instructions":
3196
- return instructionsLayoutToComponent(uid, layout);
3197
- case "list":
3198
- return isDeprecatedListLayout(layout) ? deprecatedListLayoutToComponent(uid, layout) : listLayoutToComponent(uid, layout, mapperProps);
3199
- case "loading-indicator":
3200
- return loadingIndicatorLayoutToComponent(uid, layout);
3201
- case "markdown":
3202
- return markdownLayoutToComponent(uid, layout);
3203
- case "modal":
3204
- return modalLayoutToComponent(uid, layout, mapperProps, inputComponents);
3205
- case "paragraph":
3206
- return paragraphLayoutToComponent(uid, layout);
3207
- case "review":
3208
- return reviewLayoutToComponent(uid, layout, mapperProps);
3209
- case "search":
3210
- return searchLayoutToComponent(uid, layout, mapperProps);
3211
- case "status-list":
3212
- return statusListLayoutToComponent(uid, layout, mapperProps);
3213
- default:
3214
- throw new Error(`Invalid layout type in ${JSON.stringify(layout)}`);
3026
+ // src/revamp/domain/features/refreshAfter/getStepRefreshAfter.ts
3027
+ var ONE_SECOND = 1e3;
3028
+ var getStepRefreshAfter = ({ refreshAfter, onRefresh }) => {
3029
+ const targetTime = new Date(refreshAfter).getTime();
3030
+ if (typeof refreshAfter !== "string" || Number.isNaN(targetTime)) {
3031
+ throw new Error(`Invalid refreshAfter value: ${String(refreshAfter)}`);
3215
3032
  }
3033
+ const timeLeft = Math.max(targetTime - Date.now(), ONE_SECOND);
3034
+ const timeout = setTimeout(() => {
3035
+ void onRefresh("refreshAfter");
3036
+ }, timeLeft);
3037
+ return {
3038
+ stop: () => clearTimeout(timeout)
3039
+ };
3216
3040
  };
3217
3041
 
3218
- // src/revamp/domain/components/utils/getRandomId.ts
3219
- var getRandomId = () => Math.random().toString(36).substring(2);
3220
-
3221
3042
  // src/revamp/domain/components/utils/isExactLocalValueMatch.ts
3222
3043
  var isExactLocalValueMatch = (valueA, valueB) => {
3223
3044
  if (isArrayLocalValue(valueA) && isArrayLocalValue(valueB)) {
@@ -3387,6 +3208,10 @@ var getDebouncedPerformRefresh = (performRefresh, getValidationErrors) => {
3387
3208
  return debouncedFn;
3388
3209
  };
3389
3210
 
3211
+ // src/revamp/domain/features/validation/validation-functions.ts
3212
+ var validateComponents = (components) => components.reduce((acc, component) => component.validate() && acc, true);
3213
+ var getLocalValueValidator = (checks) => (currentValue) => checks.map((check) => check(currentValue)).filter(isString);
3214
+
3390
3215
  // src/revamp/domain/features/validationAsync/getComponentValidationAsync.ts
3391
3216
  var getComponentValidationAsync = (update, performValidationAsync) => (
3392
3217
  /**
@@ -3887,6 +3712,42 @@ var getPerformPersisAsyncFn = (schemaMapperProps, mapperProps) => {
3887
3712
  };
3888
3713
  var schemaHasValidationMessages = (schema) => Boolean("validationMessages" in schema && schema.validationMessages);
3889
3714
 
3715
+ // src/revamp/domain/features/summary/summary-utils.ts
3716
+ var getSummariser = (schema) => (value) => {
3717
+ const { summary, icon, image } = schema;
3718
+ const stringValueOrNull = isString(value) ? value : null;
3719
+ return summaryIfProvides(summary, { value: stringValueOrNull, icon, image });
3720
+ };
3721
+ var getConstSummary = (schema, model) => {
3722
+ const { summary, icon, image } = schema;
3723
+ const value = isString(model) ? model : null;
3724
+ return summaryIfProvides(summary, { value, icon, image });
3725
+ };
3726
+ var summariseFromChildren = (components) => components.reduce(
3727
+ (acc, component) => mergeSummaries(acc, component.getSummary()),
3728
+ {}
3729
+ );
3730
+ var mergeSummaries = (summaryA, summaryB) => {
3731
+ var _a, _b, _c, _d;
3732
+ return {
3733
+ title: (_a = summaryA.title) != null ? _a : summaryB.title,
3734
+ description: (_b = summaryA.description) != null ? _b : summaryB.description,
3735
+ icon: (_c = summaryA.icon) != null ? _c : summaryB.icon,
3736
+ image: (_d = summaryA.image) != null ? _d : summaryB.image
3737
+ };
3738
+ };
3739
+ var summaryIfProvides = (summary, { value, icon, image }) => {
3740
+ if (!summary) {
3741
+ return {};
3742
+ }
3743
+ return {
3744
+ title: summary.providesTitle && value || void 0,
3745
+ description: summary.providesDescription && value || void 0,
3746
+ icon: summary.providesIcon && icon || void 0,
3747
+ image: summary.providesImage && mapSpecImage(image != null ? image : void 0) || void 0
3748
+ };
3749
+ };
3750
+
3890
3751
  // src/revamp/domain/mappers/schema/utils/mapCommonSchemaProps.ts
3891
3752
  var mapCommonSchemaProps = (schemaMapperProps) => {
3892
3753
  var _a;
@@ -4524,7 +4385,7 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
4524
4385
  const children = options.map((option) => option.component);
4525
4386
  const selectedIndices = getInitialModelIndices(initialValue, children);
4526
4387
  const getValidationErrors = getLocalValueValidator(checks);
4527
- const inputComponent = __spreadProps(__spreadValues({
4388
+ const component = __spreadProps(__spreadValues({
4528
4389
  uid,
4529
4390
  type: "multi-select",
4530
4391
  children,
@@ -4584,13 +4445,13 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
4584
4445
  }
4585
4446
  });
4586
4447
  if (performRefresh) {
4587
- return inputComponent;
4448
+ return component;
4588
4449
  }
4589
4450
  if (performValidationAsync) {
4590
4451
  const validateAsync = getComponentValidationAsync(update, performValidationAsync);
4591
- return __spreadProps(__spreadValues({}, inputComponent), {
4452
+ return __spreadProps(__spreadValues({}, component), {
4592
4453
  onSelect(indices) {
4593
- inputComponent.onSelect.call(this, indices);
4454
+ component.onSelect.call(this, indices);
4594
4455
  if (this.validate()) {
4595
4456
  validateAsync(this, this.getLocalValue()).catch(() => {
4596
4457
  });
@@ -4598,7 +4459,7 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
4598
4459
  }
4599
4460
  });
4600
4461
  }
4601
- return inputComponent;
4462
+ return component;
4602
4463
  };
4603
4464
  var getInitialModelIndices = (model, options) => {
4604
4465
  if (!isArray(model)) {
@@ -5047,6 +4908,7 @@ var createConstComponent = (hiddenProps) => {
5047
4908
  uid,
5048
4909
  schemaId,
5049
4910
  analyticsId,
4911
+ hidden: true,
5050
4912
  getLocalValue: () => value,
5051
4913
  getSubmittableValue: async () => value,
5052
4914
  getSubmittableValueSync: () => value,
@@ -5959,7 +5821,7 @@ var mapStepSchemas = (uid, step, stepLocalValue, mapperProps, referencedSchemaId
5959
5821
  const isReferenced = (schemaId) => schemaId != null && referencedSchemaIds.includes(schemaId);
5960
5822
  return step.schemas.map((schema, i) => {
5961
5823
  var _a, _b;
5962
- const inputComponent = mapSchemaToComponent(
5824
+ const schemaComponent = mapSchemaToComponent(
5963
5825
  {
5964
5826
  uid: `${uid}.schemas-${i}.${schema.$id}`,
5965
5827
  schemaId: schema.$id,
@@ -5971,7 +5833,9 @@ var mapStepSchemas = (uid, step, stepLocalValue, mapperProps, referencedSchemaId
5971
5833
  },
5972
5834
  mapperProps
5973
5835
  );
5974
- return __spreadProps(__spreadValues({}, inputComponent), { isSchemaReferencedInStep: isReferenced(schema.$id) });
5836
+ return __spreadProps(__spreadValues({}, schemaComponent), {
5837
+ isSchemaReferencedInStep: isReferenced(schema.$id)
5838
+ });
5975
5839
  });
5976
5840
  };
5977
5841
 
@@ -6029,7 +5893,7 @@ var mapStepToComponent = (_a) => {
6029
5893
  const externalConfirmation = (external == null ? void 0 : external.url) ? createExternalConfirmation(`${uid}-external-confirmation`, external == null ? void 0 : external.url, updateComponent) : void 0;
6030
5894
  const mapperProps = __spreadProps(__spreadValues({}, restProps), { trackEvent, onBehavior, onRefresh });
6031
5895
  const referencedSchemaIds = getReferencedSchemaId(step);
6032
- const inputComponents = mapStepSchemas(
5896
+ const schemaComponents = mapStepSchemas(
6033
5897
  uid,
6034
5898
  step,
6035
5899
  stepLocalValue,
@@ -6037,13 +5901,13 @@ var mapStepToComponent = (_a) => {
6037
5901
  referencedSchemaIds
6038
5902
  );
6039
5903
  const layoutComponents = layout.map(
6040
- (layoutComponent, index) => mapLayoutToComponent(`${uid}.layout-${index}`, layoutComponent, mapperProps, inputComponents)
5904
+ (layoutComponent, index) => mapLayoutToComponent(`${uid}.layout-${index}`, layoutComponent, mapperProps, schemaComponents)
6041
5905
  );
6042
5906
  const stepComponent = createStepComponent({
6043
5907
  uid,
6044
5908
  back,
6045
5909
  layoutComponents,
6046
- inputComponents,
5910
+ schemaComponents,
6047
5911
  control,
6048
5912
  description,
6049
5913
  error: errors == null ? void 0 : errors.error,
@@ -6484,6 +6348,34 @@ var formatDateOptions = {
6484
6348
  dateStyle: "long"
6485
6349
  };
6486
6350
 
6351
+ // src/revamp/utils/analyse-step.ts
6352
+ var import_dynamic_flow_types2 = require("@wise/dynamic-flow-types");
6353
+ var analyseStep = (step, logEvent) => {
6354
+ validateStepTypes(step, logEvent);
6355
+ warnWhenPollingWithSchemas(step, logEvent);
6356
+ };
6357
+ var warnWhenPollingWithSchemas = (step, logEvent) => {
6358
+ var _a;
6359
+ const hasPolling = step.polling != null;
6360
+ const hasSchemas = step.schemas != null && step.schemas.length > 0;
6361
+ if (hasPolling && hasSchemas) {
6362
+ logEvent("warning", "DynamicFlow Polling and Schema Warning.", {
6363
+ message: "The provided step is configured with polling and schemas. Actions triggered from a polling response will not contain the schema values in their payload.",
6364
+ stepId: (_a = step.id) != null ? _a : step.key
6365
+ });
6366
+ }
6367
+ };
6368
+ var validateStepTypes = (step, logEvent) => {
6369
+ var _a;
6370
+ const validationResult = (0, import_dynamic_flow_types2.validateStep)(step);
6371
+ if (!validationResult.valid) {
6372
+ logEvent("info", "The provided step does not conform to the specification.", {
6373
+ stepId: (_a = step.id) != null ? _a : step.key,
6374
+ errors: validationResult.errors
6375
+ });
6376
+ }
6377
+ };
6378
+
6487
6379
  // src/revamp/utils/useStableCallback.tsx
6488
6380
  var import_react2 = require("react");
6489
6381
  function useStableCallback(handler) {
@@ -6494,55 +6386,6 @@ function useStableCallback(handler) {
6494
6386
  return (0, import_react2.useCallback)((...args) => ref.current ? ref.current(...args) : null, []);
6495
6387
  }
6496
6388
 
6497
- // src/revamp/domain/components/ModalContentComponent.ts
6498
- var createModalContentComponent = (modalProps, updateComponent) => {
6499
- const update = getInputUpdateFunction(updateComponent);
6500
- const modalContentComponent = __spreadProps(__spreadValues({
6501
- type: "modal-content",
6502
- open: true
6503
- }, modalProps), {
6504
- _update(updateFn) {
6505
- update(this, updateFn);
6506
- },
6507
- getChildren() {
6508
- return this.components;
6509
- },
6510
- getLocalValue() {
6511
- return getLocalValues(this.getChildren());
6512
- },
6513
- async getSubmittableValue() {
6514
- return getSubmittableData(this.getChildren());
6515
- },
6516
- getSubmittableValueSync() {
6517
- return getSubmittableDataSync(this.getChildren());
6518
- },
6519
- getSummary() {
6520
- return summariseFromChildren(this.getChildren());
6521
- },
6522
- validate() {
6523
- return validateComponents(this.getChildren());
6524
- },
6525
- close() {
6526
- update(this, (draft) => {
6527
- draft.open = false;
6528
- });
6529
- }
6530
- });
6531
- return modalContentComponent;
6532
- };
6533
-
6534
- // src/revamp/domain/mappers/layout/modalToContent.ts
6535
- var modalToContent = (uid, { content, title }, mapperProps, inputComponents) => createModalContentComponent(
6536
- {
6537
- uid: `${uid}-modal-${getRandomId()}`,
6538
- title,
6539
- components: content.map(
6540
- (component, index) => mapLayoutToComponent(`${uid}.modal-${index}`, component, mapperProps, inputComponents)
6541
- )
6542
- },
6543
- mapperProps.updateComponent
6544
- );
6545
-
6546
6389
  // src/revamp/useDynamicFlowCore.tsx
6547
6390
  function useDynamicFlowCore(props) {
6548
6391
  const _a = props, { flowId, initialAction, initialStep, displayStepTitle = true } = _a, rest = __objRest(_a, ["flowId", "initialAction", "initialStep", "displayStepTitle"]);
@@ -6611,12 +6454,7 @@ function useDynamicFlowCore(props) {
6611
6454
  rootComponentRef.current.stop();
6612
6455
  stepRef.current = newStep;
6613
6456
  etagRef.current = etag;
6614
- const validationResult = (0, import_dynamic_flow_types2.validateStep)(newStep);
6615
- if (!validationResult.valid) {
6616
- logEvent("info", "The provided step does not conform to the specification.", {
6617
- errors: validationResult.errors
6618
- });
6619
- }
6457
+ analyseStep(newStep, logEvent);
6620
6458
  try {
6621
6459
  const newStepComponent = mapStepToComponent(__spreadValues({
6622
6460
  stepLocalValue: localValue,
@@ -6704,7 +6542,7 @@ function useDynamicFlowCore(props) {
6704
6542
  step: stepRef.current,
6705
6543
  stepLocalValue: rootComponentRef.current.getLocalValue()
6706
6544
  }, getMapperProps()),
6707
- rootComponentRef.current.getInputComponents()
6545
+ rootComponentRef.current.getSchemaComponents()
6708
6546
  )
6709
6547
  );
6710
6548
  }