@wise/dynamic-flow-client 5.0.1-exp-css-28d60ea → 5.1.1
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/README.md +7 -2
- package/build/main.css +1 -1
- package/build/main.js +286 -184
- package/build/main.mjs +286 -184
- package/build/types/domain/components/step/StepDomainComponent.d.ts +4 -2
- package/build/types/domain/features/polling/getStepPolling.d.ts +3 -2
- package/build/types/domain/mappers/layout/alertLayoutToComponent.d.ts +1 -1
- package/build/types/domain/mappers/layout/decisionLayoutToComponent.d.ts +1 -1
- package/build/types/domain/mappers/layout/reviewLayoutToComponent.d.ts +1 -1
- package/build/types/domain/mappers/layout/searchLayoutToComponent.d.ts +1 -1
- package/build/types/domain/mappers/layout/statusListLayoutToComponent.d.ts +1 -1
- package/build/types/domain/mappers/mapStepToComponent.d.ts +1 -1
- package/build/types/domain/mappers/schema/types.d.ts +2 -1
- package/build/types/domain/mappers/utils/behavior-utils.d.ts +5 -2
- package/build/types/domain/mappers/utils/call-to-action-utils.d.ts +3 -2
- package/build/types/domain/mappers/utils/utils.d.ts +3 -2
- package/build/types/domain/prefetching/request-cache.d.ts +9 -0
- package/build/types/flow/executeSubmission.d.ts +4 -1
- package/build/types/flow/makeSafeHttpClient.d.ts +2 -0
- package/build/types/flow/makeSubmissionRequest.d.ts +3 -0
- package/package.json +25 -35
- package/build/types/domain/mappers/schema/tests/test-utils.d.ts +0 -34
- package/build/types/test-utils/NeptuneProviders.d.ts +0 -5
- package/build/types/test-utils/getRandomId.d.ts +0 -1
- package/build/types/test-utils/index.d.ts +0 -2
- package/build/types/test-utils/rtl-utils.d.ts +0 -2
- package/build/types/tests/renderers/TextInputRenderer.test.d.ts +0 -1
package/build/main.js
CHANGED
|
@@ -1175,15 +1175,16 @@ var createAlertComponent = (alertProps) => __spreadValues({
|
|
|
1175
1175
|
}, alertProps);
|
|
1176
1176
|
|
|
1177
1177
|
// src/domain/mappers/utils/behavior-utils.ts
|
|
1178
|
-
var getDomainLayerBehavior = ({
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
return normaliseBehavior(behavior, stepActions);
|
|
1178
|
+
var getDomainLayerBehavior = ({ action, behavior: specBehavior }, stepActions, registerSubmissionBehavior) => {
|
|
1179
|
+
if (specBehavior) {
|
|
1180
|
+
const behavior = normaliseBehavior(specBehavior, stepActions);
|
|
1181
|
+
registerSubmissionBehavior == null ? void 0 : registerSubmissionBehavior(behavior);
|
|
1182
|
+
return behavior;
|
|
1184
1183
|
}
|
|
1185
1184
|
if (action) {
|
|
1186
|
-
|
|
1185
|
+
const behavior = actionToBehavior(action, stepActions);
|
|
1186
|
+
registerSubmissionBehavior == null ? void 0 : registerSubmissionBehavior(behavior);
|
|
1187
|
+
return behavior;
|
|
1187
1188
|
}
|
|
1188
1189
|
return { type: "none" };
|
|
1189
1190
|
};
|
|
@@ -1213,14 +1214,17 @@ var getActionByReference = ($ref, actions = []) => {
|
|
|
1213
1214
|
};
|
|
1214
1215
|
|
|
1215
1216
|
// src/domain/mappers/utils/call-to-action-utils.ts
|
|
1216
|
-
var getDomainLayerCallToAction = (callToAction,
|
|
1217
|
+
var getDomainLayerCallToAction = (callToAction, mapperProps) => {
|
|
1218
|
+
var _a;
|
|
1217
1219
|
if (!callToAction) {
|
|
1218
1220
|
return void 0;
|
|
1219
1221
|
}
|
|
1222
|
+
const { step, onBehavior, registerSubmissionBehavior } = mapperProps;
|
|
1223
|
+
const stepActions = (_a = step.actions) != null ? _a : [];
|
|
1220
1224
|
const { title = "", accessibilityDescription, action, behavior } = callToAction;
|
|
1221
1225
|
return getCallToAction(
|
|
1222
1226
|
{ title, accessibilityDescription },
|
|
1223
|
-
getDomainLayerBehavior({ action, behavior }, stepActions),
|
|
1227
|
+
getDomainLayerBehavior({ action, behavior }, stepActions, registerSubmissionBehavior),
|
|
1224
1228
|
onBehavior
|
|
1225
1229
|
);
|
|
1226
1230
|
};
|
|
@@ -1309,22 +1313,21 @@ var mapLegacyActionTypeToControl = (type) => type && type in legacyActionTypeToC
|
|
|
1309
1313
|
var alertLayoutToComponent = (uid, {
|
|
1310
1314
|
control,
|
|
1311
1315
|
markdown,
|
|
1312
|
-
margin
|
|
1313
|
-
context
|
|
1316
|
+
margin,
|
|
1317
|
+
context,
|
|
1314
1318
|
callToAction,
|
|
1315
1319
|
analyticsId,
|
|
1316
1320
|
tags
|
|
1317
|
-
},
|
|
1318
|
-
|
|
1319
|
-
const cta = callToAction ? getDomainLayerCallToAction(callToAction, onBehavior, (_a = step.actions) != null ? _a : []) : void 0;
|
|
1321
|
+
}, mapperProps) => {
|
|
1322
|
+
const cta = callToAction ? getDomainLayerCallToAction(callToAction, mapperProps) : void 0;
|
|
1320
1323
|
return createAlertComponent({
|
|
1321
1324
|
uid,
|
|
1322
1325
|
analyticsId,
|
|
1323
1326
|
control,
|
|
1324
1327
|
markdown,
|
|
1325
|
-
margin,
|
|
1328
|
+
margin: margin != null ? margin : "md",
|
|
1326
1329
|
callToAction: cta,
|
|
1327
|
-
context: mapLegacyContext(context),
|
|
1330
|
+
context: mapLegacyContext(context != null ? context : "neutral"),
|
|
1328
1331
|
tags
|
|
1329
1332
|
});
|
|
1330
1333
|
};
|
|
@@ -1350,8 +1353,8 @@ var boxLayoutToComponent = (uid, {
|
|
|
1350
1353
|
border = false,
|
|
1351
1354
|
components,
|
|
1352
1355
|
control,
|
|
1353
|
-
margin
|
|
1354
|
-
width
|
|
1356
|
+
margin,
|
|
1357
|
+
width,
|
|
1355
1358
|
analyticsId,
|
|
1356
1359
|
tags
|
|
1357
1360
|
}, mapperProps, schemaComponents) => createBoxComponent({
|
|
@@ -1359,8 +1362,8 @@ var boxLayoutToComponent = (uid, {
|
|
|
1359
1362
|
analyticsId,
|
|
1360
1363
|
border,
|
|
1361
1364
|
control,
|
|
1362
|
-
margin,
|
|
1363
|
-
width,
|
|
1365
|
+
margin: margin != null ? margin : "md",
|
|
1366
|
+
width: width != null ? width : "xl",
|
|
1364
1367
|
tags,
|
|
1365
1368
|
components: components.map((component, index) => {
|
|
1366
1369
|
const shouldRemoveMargin = index === components.length - 1 && component.margin === void 0;
|
|
@@ -1398,14 +1401,18 @@ var buttonLayoutToComponentWithBehavior = (uid, button, mapperProps) => {
|
|
|
1398
1401
|
context,
|
|
1399
1402
|
control,
|
|
1400
1403
|
disabled,
|
|
1401
|
-
margin
|
|
1404
|
+
margin,
|
|
1402
1405
|
pinOrder,
|
|
1403
1406
|
size,
|
|
1404
1407
|
title,
|
|
1405
1408
|
analyticsId,
|
|
1406
1409
|
tags
|
|
1407
1410
|
} = button;
|
|
1408
|
-
const behavior = getDomainLayerBehavior(
|
|
1411
|
+
const behavior = getDomainLayerBehavior(
|
|
1412
|
+
button,
|
|
1413
|
+
(_a = mapperProps.step.actions) != null ? _a : [],
|
|
1414
|
+
mapperProps.registerSubmissionBehavior
|
|
1415
|
+
);
|
|
1409
1416
|
const onClick = () => {
|
|
1410
1417
|
void onBehavior(behavior);
|
|
1411
1418
|
};
|
|
@@ -1415,7 +1422,7 @@ var buttonLayoutToComponentWithBehavior = (uid, button, mapperProps) => {
|
|
|
1415
1422
|
context: mapLegacyContext(context != null ? context : "neutral"),
|
|
1416
1423
|
control,
|
|
1417
1424
|
disabled: disabled != null ? disabled : false,
|
|
1418
|
-
margin,
|
|
1425
|
+
margin: margin != null ? margin : "md",
|
|
1419
1426
|
pinOrder,
|
|
1420
1427
|
size,
|
|
1421
1428
|
title: title != null ? title : "",
|
|
@@ -1489,12 +1496,12 @@ var createColumnsComponent = (columnsProps) => __spreadProps(__spreadValues({},
|
|
|
1489
1496
|
});
|
|
1490
1497
|
|
|
1491
1498
|
// src/domain/mappers/layout/columnsLayoutToComponent.ts
|
|
1492
|
-
var columnsLayoutToComponent = (uid, { control, left, right, bias
|
|
1499
|
+
var columnsLayoutToComponent = (uid, { control, left, right, bias, margin, analyticsId, tags }, mapperProps, schemaComponents) => createColumnsComponent({
|
|
1493
1500
|
uid,
|
|
1494
1501
|
analyticsId,
|
|
1495
1502
|
control,
|
|
1496
|
-
margin,
|
|
1497
|
-
bias: mapLegacyBias(bias),
|
|
1503
|
+
margin: margin != null ? margin : "md",
|
|
1504
|
+
bias: mapLegacyBias(bias != null ? bias : "none"),
|
|
1498
1505
|
tags,
|
|
1499
1506
|
startComponents: left.map(
|
|
1500
1507
|
(component, index) => mapLayoutToComponent(
|
|
@@ -1549,9 +1556,10 @@ var mapInlineAlert = (alert) => {
|
|
|
1549
1556
|
context: alert.context ? mapLegacyContext(alert.context) : "neutral"
|
|
1550
1557
|
} : void 0;
|
|
1551
1558
|
};
|
|
1552
|
-
var mapAdditionalInfo = (info,
|
|
1559
|
+
var mapAdditionalInfo = (info, mapperProps) => {
|
|
1560
|
+
const { onBehavior, registerSubmissionBehavior } = mapperProps;
|
|
1553
1561
|
if (info) {
|
|
1554
|
-
const behavior = getDomainLayerBehavior(info, []);
|
|
1562
|
+
const behavior = getDomainLayerBehavior(info, [], registerSubmissionBehavior);
|
|
1555
1563
|
return {
|
|
1556
1564
|
text: info.text,
|
|
1557
1565
|
href: behavior.type === "link" ? behavior.url : void 0,
|
|
@@ -1574,24 +1582,25 @@ var mapSchemaAlert = (alert) => {
|
|
|
1574
1582
|
var decisionLayoutToComponent = (uid, {
|
|
1575
1583
|
analyticsId,
|
|
1576
1584
|
control,
|
|
1577
|
-
margin
|
|
1585
|
+
margin,
|
|
1578
1586
|
options,
|
|
1579
1587
|
tags,
|
|
1580
1588
|
title
|
|
1581
|
-
},
|
|
1589
|
+
}, mapperProps) => createDecisionComponent({
|
|
1582
1590
|
uid,
|
|
1583
1591
|
analyticsId,
|
|
1584
1592
|
control,
|
|
1585
|
-
margin,
|
|
1586
|
-
options: options.map((option) => mapOption(option,
|
|
1593
|
+
margin: margin != null ? margin : "md",
|
|
1594
|
+
options: options.map((option) => mapOption(option, mapperProps)),
|
|
1587
1595
|
tags,
|
|
1588
1596
|
title
|
|
1589
1597
|
});
|
|
1590
|
-
var mapOption = (option,
|
|
1591
|
-
var _a;
|
|
1592
|
-
const
|
|
1598
|
+
var mapOption = (option, mapperProps) => {
|
|
1599
|
+
var _a, _b;
|
|
1600
|
+
const { step, onBehavior, registerSubmissionBehavior } = mapperProps;
|
|
1601
|
+
const behavior = getDomainLayerBehavior(option, (_a = step.actions) != null ? _a : [], registerSubmissionBehavior);
|
|
1593
1602
|
return __spreadProps(__spreadValues({}, option), {
|
|
1594
|
-
disabled: (
|
|
1603
|
+
disabled: (_b = option.disabled) != null ? _b : false,
|
|
1595
1604
|
href: behavior.type === "link" ? behavior.url : void 0,
|
|
1596
1605
|
media: getDomainLayerMedia(option),
|
|
1597
1606
|
inlineAlert: mapInlineAlert(option.inlineAlert),
|
|
@@ -1612,7 +1621,7 @@ var createStatusListComponent = (statusListProps) => __spreadValues({
|
|
|
1612
1621
|
var isDeprecatedListLayout = (layout) => {
|
|
1613
1622
|
return layout.items.some((item) => item.status);
|
|
1614
1623
|
};
|
|
1615
|
-
var deprecatedListLayoutToComponent = (uid, { analyticsId, control, items, margin
|
|
1624
|
+
var deprecatedListLayoutToComponent = (uid, { analyticsId, control, items, margin, title, tags }) => createStatusListComponent({
|
|
1616
1625
|
uid,
|
|
1617
1626
|
analyticsId,
|
|
1618
1627
|
control,
|
|
@@ -1623,7 +1632,7 @@ var deprecatedListLayoutToComponent = (uid, { analyticsId, control, items, margi
|
|
|
1623
1632
|
status: status ? mapLegacyStatus(status) : void 0,
|
|
1624
1633
|
tags: itemTags
|
|
1625
1634
|
})),
|
|
1626
|
-
margin,
|
|
1635
|
+
margin: margin != null ? margin : "md",
|
|
1627
1636
|
title,
|
|
1628
1637
|
tags
|
|
1629
1638
|
});
|
|
@@ -1646,7 +1655,7 @@ var createDividerComponent = (props) => __spreadValues({
|
|
|
1646
1655
|
}, props);
|
|
1647
1656
|
|
|
1648
1657
|
// src/domain/mappers/layout/dividerLayoutToComponent.ts
|
|
1649
|
-
var dividerLayoutToComponent = (uid, { control, margin
|
|
1658
|
+
var dividerLayoutToComponent = (uid, { control, margin, analyticsId, tags }) => createDividerComponent({ uid, analyticsId, control, margin: margin != null ? margin : "md", tags });
|
|
1650
1659
|
|
|
1651
1660
|
// src/domain/components/FormComponent.ts
|
|
1652
1661
|
var createFormComponent = (formProps) => __spreadProps(__spreadValues({}, formProps), {
|
|
@@ -1658,7 +1667,7 @@ var createFormComponent = (formProps) => __spreadProps(__spreadValues({}, formPr
|
|
|
1658
1667
|
});
|
|
1659
1668
|
|
|
1660
1669
|
// src/domain/mappers/layout/formLayoutToComponent.ts
|
|
1661
|
-
var formLayoutToComponent = (uid, { analyticsId, schemaId, schema: schemaRef, control, margin
|
|
1670
|
+
var formLayoutToComponent = (uid, { analyticsId, schemaId, schema: schemaRef, control, margin, tags }, schemaComponents) => {
|
|
1662
1671
|
const id = schemaId != null ? schemaId : schemaRef == null ? void 0 : schemaRef.$ref;
|
|
1663
1672
|
if (id == null) {
|
|
1664
1673
|
throw new Error(
|
|
@@ -1676,7 +1685,7 @@ var formLayoutToComponent = (uid, { analyticsId, schemaId, schema: schemaRef, co
|
|
|
1676
1685
|
analyticsId,
|
|
1677
1686
|
schemaComponent,
|
|
1678
1687
|
control,
|
|
1679
|
-
margin,
|
|
1688
|
+
margin: margin != null ? margin : "md",
|
|
1680
1689
|
tags
|
|
1681
1690
|
});
|
|
1682
1691
|
};
|
|
@@ -1688,13 +1697,13 @@ var createHeadingComponent = (headingProps) => __spreadValues({
|
|
|
1688
1697
|
}, headingProps);
|
|
1689
1698
|
|
|
1690
1699
|
// src/domain/mappers/layout/headingLayoutToComponent.ts
|
|
1691
|
-
var headingLayoutToComponent = (uid, { analyticsId, align
|
|
1700
|
+
var headingLayoutToComponent = (uid, { analyticsId, align, margin, size, control, tags, text }) => createHeadingComponent({
|
|
1692
1701
|
uid,
|
|
1693
1702
|
analyticsId,
|
|
1694
|
-
align: mapLegacyAlign(align),
|
|
1703
|
+
align: mapLegacyAlign(align != null ? align : "left"),
|
|
1695
1704
|
control,
|
|
1696
|
-
margin,
|
|
1697
|
-
size,
|
|
1705
|
+
margin: margin != null ? margin : "md",
|
|
1706
|
+
size: size != null ? size : "md",
|
|
1698
1707
|
tags,
|
|
1699
1708
|
text
|
|
1700
1709
|
});
|
|
@@ -1709,11 +1718,11 @@ var createImageComponent = (imageProps) => __spreadValues({
|
|
|
1709
1718
|
var imageLayoutToComponent = (uid, {
|
|
1710
1719
|
analyticsId,
|
|
1711
1720
|
accessibilityDescription,
|
|
1712
|
-
align
|
|
1721
|
+
align,
|
|
1713
1722
|
content,
|
|
1714
1723
|
control,
|
|
1715
|
-
margin
|
|
1716
|
-
size
|
|
1724
|
+
margin,
|
|
1725
|
+
size,
|
|
1717
1726
|
tags,
|
|
1718
1727
|
text,
|
|
1719
1728
|
url
|
|
@@ -1722,14 +1731,14 @@ var imageLayoutToComponent = (uid, {
|
|
|
1722
1731
|
return createImageComponent({
|
|
1723
1732
|
uid,
|
|
1724
1733
|
analyticsId,
|
|
1725
|
-
align: mapLegacyAlign(align),
|
|
1734
|
+
align: mapLegacyAlign(align != null ? align : "center"),
|
|
1726
1735
|
content: content ? {
|
|
1727
1736
|
uri: (_b = (_a = content.uri) != null ? _a : content.url) != null ? _b : "",
|
|
1728
1737
|
accessibilityDescription: (_c = content.accessibilityDescription) != null ? _c : content.text
|
|
1729
1738
|
} : { accessibilityDescription: accessibilityDescription != null ? accessibilityDescription : text, uri: url != null ? url : "" },
|
|
1730
1739
|
control,
|
|
1731
|
-
margin,
|
|
1732
|
-
size,
|
|
1740
|
+
margin: margin != null ? margin : "md",
|
|
1741
|
+
size: size != null ? size : "md",
|
|
1733
1742
|
tags
|
|
1734
1743
|
});
|
|
1735
1744
|
};
|
|
@@ -1741,13 +1750,13 @@ var createMarkdownComponent = (markdownProps) => __spreadValues({
|
|
|
1741
1750
|
}, markdownProps);
|
|
1742
1751
|
|
|
1743
1752
|
// src/domain/mappers/layout/infoLayoutToComponent.ts
|
|
1744
|
-
var infoLayoutToComponent = (uid, { analyticsId, align
|
|
1753
|
+
var infoLayoutToComponent = (uid, { analyticsId, align, control, margin, markdown: content, tags }) => createMarkdownComponent({
|
|
1745
1754
|
uid,
|
|
1746
1755
|
analyticsId,
|
|
1747
|
-
align: mapLegacyAlign(align),
|
|
1756
|
+
align: mapLegacyAlign(align != null ? align : "left"),
|
|
1748
1757
|
content,
|
|
1749
1758
|
control,
|
|
1750
|
-
margin,
|
|
1759
|
+
margin: margin != null ? margin : "md",
|
|
1751
1760
|
tags,
|
|
1752
1761
|
size: "md"
|
|
1753
1762
|
});
|
|
@@ -1759,7 +1768,7 @@ var createInstructionsComponent = (instructionsProps) => __spreadValues({
|
|
|
1759
1768
|
}, instructionsProps);
|
|
1760
1769
|
|
|
1761
1770
|
// src/domain/mappers/layout/instructionsLayoutToComponent.ts
|
|
1762
|
-
var instructionsLayoutToComponent = (uid, { analyticsId, control, items, margin
|
|
1771
|
+
var instructionsLayoutToComponent = (uid, { analyticsId, control, items, margin, tags, title }) => createInstructionsComponent({
|
|
1763
1772
|
uid,
|
|
1764
1773
|
analyticsId,
|
|
1765
1774
|
control,
|
|
@@ -1767,7 +1776,7 @@ var instructionsLayoutToComponent = (uid, { analyticsId, control, items, margin
|
|
|
1767
1776
|
context: mapLegacyContext(item.context),
|
|
1768
1777
|
tags: mapTags(item)
|
|
1769
1778
|
})),
|
|
1770
|
-
margin,
|
|
1779
|
+
margin: margin != null ? margin : "md",
|
|
1771
1780
|
tags,
|
|
1772
1781
|
title
|
|
1773
1782
|
});
|
|
@@ -1779,22 +1788,19 @@ var createListComponent = (listProps) => __spreadValues({
|
|
|
1779
1788
|
}, listProps);
|
|
1780
1789
|
|
|
1781
1790
|
// src/domain/mappers/layout/listLayoutToComponent.ts
|
|
1782
|
-
var listLayoutToComponent = (uid, { analyticsId, callToAction, control, items, margin
|
|
1783
|
-
var _a;
|
|
1784
|
-
const { step, onBehavior } = mapperProps;
|
|
1791
|
+
var listLayoutToComponent = (uid, { analyticsId, callToAction, control, items, margin, tags, title }, mapperProps) => {
|
|
1785
1792
|
return createListComponent({
|
|
1786
1793
|
uid,
|
|
1787
1794
|
analyticsId,
|
|
1788
1795
|
control,
|
|
1789
1796
|
items: items.map((item) => mapItem(item, mapperProps)),
|
|
1790
|
-
callToAction: getDomainLayerCallToAction(callToAction,
|
|
1791
|
-
margin,
|
|
1797
|
+
callToAction: getDomainLayerCallToAction(callToAction, mapperProps),
|
|
1798
|
+
margin: margin != null ? margin : "md",
|
|
1792
1799
|
tags,
|
|
1793
1800
|
title
|
|
1794
1801
|
});
|
|
1795
1802
|
};
|
|
1796
1803
|
var mapItem = (item, mapperProps) => {
|
|
1797
|
-
var _b;
|
|
1798
1804
|
const _a = item, {
|
|
1799
1805
|
value,
|
|
1800
1806
|
subvalue,
|
|
@@ -1818,14 +1824,13 @@ var mapItem = (item, mapperProps) => {
|
|
|
1818
1824
|
"additionalInfo",
|
|
1819
1825
|
"inlineAlert"
|
|
1820
1826
|
]);
|
|
1821
|
-
const { step, onBehavior } = mapperProps;
|
|
1822
1827
|
return __spreadProps(__spreadValues({}, rest), {
|
|
1823
1828
|
description: description != null ? description : subtitle,
|
|
1824
1829
|
media: getDomainLayerMedia({ icon, image, media }),
|
|
1825
1830
|
supportingValues: mapSupportingValues(item),
|
|
1826
|
-
additionalInfo: mapAdditionalInfo(additionalInfo,
|
|
1831
|
+
additionalInfo: mapAdditionalInfo(additionalInfo, mapperProps),
|
|
1827
1832
|
inlineAlert: mapInlineAlert(inlineAlert),
|
|
1828
|
-
callToAction: getDomainLayerCallToAction(callToAction,
|
|
1833
|
+
callToAction: getDomainLayerCallToAction(callToAction, mapperProps),
|
|
1829
1834
|
tags: mapTags(rest)
|
|
1830
1835
|
});
|
|
1831
1836
|
};
|
|
@@ -1844,33 +1849,33 @@ var createLoadingIndicatorComponent = (loadingIndicatorProps) => __spreadValues(
|
|
|
1844
1849
|
}, loadingIndicatorProps);
|
|
1845
1850
|
|
|
1846
1851
|
// src/domain/mappers/layout/loadingIndicatorLayoutToComponent.ts
|
|
1847
|
-
var loadingIndicatorLayoutToComponent = (uid, { analyticsId, control, margin
|
|
1852
|
+
var loadingIndicatorLayoutToComponent = (uid, { analyticsId, control, margin, size, tags }) => createLoadingIndicatorComponent({
|
|
1848
1853
|
uid,
|
|
1849
1854
|
analyticsId,
|
|
1850
1855
|
control,
|
|
1851
|
-
margin,
|
|
1852
|
-
size,
|
|
1856
|
+
margin: margin != null ? margin : "md",
|
|
1857
|
+
size: size != null ? size : "md",
|
|
1853
1858
|
tags
|
|
1854
1859
|
});
|
|
1855
1860
|
|
|
1856
1861
|
// src/domain/mappers/layout/markdownLayoutToComponent.ts
|
|
1857
1862
|
var markdownLayoutToComponent = (uid, {
|
|
1858
1863
|
analyticsId,
|
|
1859
|
-
align
|
|
1860
|
-
margin
|
|
1864
|
+
align,
|
|
1865
|
+
margin,
|
|
1861
1866
|
control,
|
|
1862
1867
|
content,
|
|
1863
|
-
size
|
|
1868
|
+
size,
|
|
1864
1869
|
tags
|
|
1865
1870
|
}) => createMarkdownComponent({
|
|
1866
1871
|
uid,
|
|
1867
1872
|
analyticsId,
|
|
1868
|
-
align: mapLegacyAlign(align),
|
|
1873
|
+
align: mapLegacyAlign(align != null ? align : "left"),
|
|
1869
1874
|
control,
|
|
1870
1875
|
content,
|
|
1871
|
-
margin,
|
|
1876
|
+
margin: margin != null ? margin : "md",
|
|
1872
1877
|
tags,
|
|
1873
|
-
size
|
|
1878
|
+
size: size != null ? size : "md"
|
|
1874
1879
|
});
|
|
1875
1880
|
|
|
1876
1881
|
// src/domain/components/ModalLayoutComponent.ts
|
|
@@ -1884,7 +1889,7 @@ var createModalComponent = (modalProps) => __spreadProps(__spreadValues({
|
|
|
1884
1889
|
});
|
|
1885
1890
|
|
|
1886
1891
|
// src/domain/mappers/layout/modalLayoutToComponent.ts
|
|
1887
|
-
var modalLayoutToComponent = (uid, { analyticsId, content, control, margin
|
|
1892
|
+
var modalLayoutToComponent = (uid, { analyticsId, content, control, margin, tags, trigger }, mapperProps, schemaComponents) => {
|
|
1888
1893
|
const { components, title } = content;
|
|
1889
1894
|
return createModalComponent({
|
|
1890
1895
|
uid,
|
|
@@ -1896,7 +1901,7 @@ var modalLayoutToComponent = (uid, { analyticsId, content, control, margin = "md
|
|
|
1896
1901
|
title
|
|
1897
1902
|
},
|
|
1898
1903
|
control,
|
|
1899
|
-
margin,
|
|
1904
|
+
margin: margin != null ? margin : "md",
|
|
1900
1905
|
tags,
|
|
1901
1906
|
trigger
|
|
1902
1907
|
});
|
|
@@ -1909,15 +1914,15 @@ var createParagraphComponent = (paragraphProps) => __spreadValues({
|
|
|
1909
1914
|
}, paragraphProps);
|
|
1910
1915
|
|
|
1911
1916
|
// src/domain/mappers/layout/paragraphLayoutToComponent.ts
|
|
1912
|
-
var paragraphLayoutToComponent = (uid, { analyticsId, align
|
|
1917
|
+
var paragraphLayoutToComponent = (uid, { analyticsId, align, control, margin, size, tags, text }) => createParagraphComponent({
|
|
1913
1918
|
uid,
|
|
1914
1919
|
analyticsId,
|
|
1915
1920
|
text,
|
|
1916
1921
|
control,
|
|
1917
|
-
align: mapLegacyAlign(align),
|
|
1918
|
-
margin,
|
|
1922
|
+
align: mapLegacyAlign(align != null ? align : "left"),
|
|
1923
|
+
margin: margin != null ? margin : "md",
|
|
1919
1924
|
tags,
|
|
1920
|
-
size
|
|
1925
|
+
size: size != null ? size : "md"
|
|
1921
1926
|
});
|
|
1922
1927
|
|
|
1923
1928
|
// src/domain/components/ReviewComponent.ts
|
|
@@ -1933,35 +1938,34 @@ var reviewLayoutToComponent = (uid, {
|
|
|
1933
1938
|
title,
|
|
1934
1939
|
callToAction,
|
|
1935
1940
|
control,
|
|
1936
|
-
margin
|
|
1941
|
+
margin,
|
|
1937
1942
|
tags,
|
|
1938
1943
|
orientation,
|
|
1939
1944
|
action
|
|
1940
|
-
},
|
|
1945
|
+
}, mapperProps) => createReviewComponent({
|
|
1941
1946
|
uid,
|
|
1942
1947
|
analyticsId,
|
|
1943
|
-
callToAction: getCallToAction2({
|
|
1948
|
+
callToAction: getCallToAction2({ mapperProps, callToAction, action }),
|
|
1944
1949
|
control: getOrientationControl({ control, orientation }),
|
|
1945
|
-
fields: fields.map((field) => mapReviewField(field,
|
|
1946
|
-
margin,
|
|
1950
|
+
fields: fields.map((field) => mapReviewField(field, mapperProps)),
|
|
1951
|
+
margin: margin != null ? margin : "md",
|
|
1947
1952
|
tags,
|
|
1948
1953
|
title
|
|
1949
1954
|
});
|
|
1950
1955
|
var getCallToAction2 = ({
|
|
1951
|
-
onBehavior,
|
|
1952
1956
|
callToAction,
|
|
1953
1957
|
action,
|
|
1954
|
-
|
|
1958
|
+
mapperProps
|
|
1955
1959
|
}) => {
|
|
1956
1960
|
if (callToAction) {
|
|
1957
|
-
return getDomainLayerCallToAction(callToAction,
|
|
1961
|
+
return getDomainLayerCallToAction(callToAction, mapperProps);
|
|
1958
1962
|
}
|
|
1959
1963
|
if (action == null ? void 0 : action.title) {
|
|
1960
1964
|
return {
|
|
1961
1965
|
type: "action",
|
|
1962
1966
|
title: action.title,
|
|
1963
1967
|
onClick: () => {
|
|
1964
|
-
void onBehavior({ type: "action", action });
|
|
1968
|
+
void mapperProps.onBehavior({ type: "action", action });
|
|
1965
1969
|
}
|
|
1966
1970
|
};
|
|
1967
1971
|
}
|
|
@@ -1979,17 +1983,16 @@ var getOrientationControl = ({
|
|
|
1979
1983
|
}
|
|
1980
1984
|
return void 0;
|
|
1981
1985
|
};
|
|
1982
|
-
var mapReviewField = (field,
|
|
1983
|
-
var _a
|
|
1986
|
+
var mapReviewField = (field, mapperProps) => {
|
|
1987
|
+
var _a;
|
|
1984
1988
|
return __spreadProps(__spreadValues({}, field), {
|
|
1985
1989
|
media: getDomainLayerMedia(field),
|
|
1986
1990
|
help: (_a = field.help) == null ? void 0 : _a.markdown,
|
|
1987
1991
|
inlineAlert: mapInlineAlert(field.inlineAlert),
|
|
1988
|
-
additionalInfo: mapAdditionalInfo(field.additionalInfo,
|
|
1992
|
+
additionalInfo: mapAdditionalInfo(field.additionalInfo, mapperProps),
|
|
1989
1993
|
callToAction: getCallToAction2({
|
|
1990
|
-
onBehavior,
|
|
1991
1994
|
callToAction: field.callToAction,
|
|
1992
|
-
|
|
1995
|
+
mapperProps
|
|
1993
1996
|
}),
|
|
1994
1997
|
tags: mapTags(field)
|
|
1995
1998
|
});
|
|
@@ -2156,17 +2159,7 @@ var isValidResponseBody = (body) => isObject(body) && "results" in body && isArr
|
|
|
2156
2159
|
var hashRequest = (query, config) => JSON.stringify({ query, config });
|
|
2157
2160
|
|
|
2158
2161
|
// src/domain/mappers/layout/searchLayoutToComponent.ts
|
|
2159
|
-
var searchLayoutToComponent = (uid, {
|
|
2160
|
-
analyticsId,
|
|
2161
|
-
control,
|
|
2162
|
-
emptyMessage = "",
|
|
2163
|
-
method,
|
|
2164
|
-
param,
|
|
2165
|
-
title,
|
|
2166
|
-
url,
|
|
2167
|
-
margin = "md",
|
|
2168
|
-
tags
|
|
2169
|
-
}, mapperProps) => {
|
|
2162
|
+
var searchLayoutToComponent = (uid, { analyticsId, control, emptyMessage, method, param, title, url, margin, tags }, mapperProps) => {
|
|
2170
2163
|
const { httpClient, onBehavior, updateComponent } = mapperProps;
|
|
2171
2164
|
const search = getPerformSearchFunction(httpClient, { method, param, url });
|
|
2172
2165
|
return createSearchComponent(
|
|
@@ -2174,8 +2167,8 @@ var searchLayoutToComponent = (uid, {
|
|
|
2174
2167
|
uid,
|
|
2175
2168
|
analyticsId,
|
|
2176
2169
|
control,
|
|
2177
|
-
emptyMessage,
|
|
2178
|
-
margin,
|
|
2170
|
+
emptyMessage: emptyMessage != null ? emptyMessage : "",
|
|
2171
|
+
margin: margin != null ? margin : "md",
|
|
2179
2172
|
tags,
|
|
2180
2173
|
title
|
|
2181
2174
|
},
|
|
@@ -2186,20 +2179,15 @@ var searchLayoutToComponent = (uid, {
|
|
|
2186
2179
|
};
|
|
2187
2180
|
|
|
2188
2181
|
// src/domain/mappers/layout/statusListLayoutToComponent.ts
|
|
2189
|
-
var statusListLayoutToComponent = (uid, { analyticsId, control, items, margin
|
|
2182
|
+
var statusListLayoutToComponent = (uid, { analyticsId, control, items, margin, tags, title }, mapperProps) => createStatusListComponent({
|
|
2190
2183
|
uid,
|
|
2191
2184
|
analyticsId,
|
|
2192
2185
|
control,
|
|
2193
2186
|
items: items.map((item) => {
|
|
2194
|
-
|
|
2195
|
-
const callToAction = getDomainLayerCallToAction(
|
|
2196
|
-
item.callToAction,
|
|
2197
|
-
onBehavior,
|
|
2198
|
-
(_a = step.actions) != null ? _a : []
|
|
2199
|
-
);
|
|
2187
|
+
const callToAction = getDomainLayerCallToAction(item.callToAction, mapperProps);
|
|
2200
2188
|
return __spreadProps(__spreadValues({}, item), { callToAction, tags: mapTags(item) });
|
|
2201
2189
|
}),
|
|
2202
|
-
margin,
|
|
2190
|
+
margin: margin != null ? margin : "md",
|
|
2203
2191
|
tags,
|
|
2204
2192
|
title
|
|
2205
2193
|
});
|
|
@@ -2216,8 +2204,7 @@ var createSectionComponent = (props) => {
|
|
|
2216
2204
|
};
|
|
2217
2205
|
|
|
2218
2206
|
// src/domain/mappers/layout/sectionLayoutToComponent.ts
|
|
2219
|
-
var sectionLayoutToComponent = (uid, { analyticsId, control, title, components, callToAction, margin
|
|
2220
|
-
var _a;
|
|
2207
|
+
var sectionLayoutToComponent = (uid, { analyticsId, control, title, components, callToAction, margin, tags }, mapperProps, schemaComponents) => {
|
|
2221
2208
|
return createSectionComponent({
|
|
2222
2209
|
uid,
|
|
2223
2210
|
analyticsId,
|
|
@@ -2226,12 +2213,8 @@ var sectionLayoutToComponent = (uid, { analyticsId, control, title, components,
|
|
|
2226
2213
|
components: components.map(
|
|
2227
2214
|
(component, index) => mapLayoutToComponent(`${uid}.section-${index}`, component, mapperProps, schemaComponents)
|
|
2228
2215
|
),
|
|
2229
|
-
margin,
|
|
2230
|
-
callToAction: getDomainLayerCallToAction(
|
|
2231
|
-
callToAction,
|
|
2232
|
-
mapperProps.onBehavior,
|
|
2233
|
-
(_a = mapperProps.step.actions) != null ? _a : []
|
|
2234
|
-
),
|
|
2216
|
+
margin: margin != null ? margin : "md",
|
|
2217
|
+
callToAction: getDomainLayerCallToAction(callToAction, mapperProps),
|
|
2235
2218
|
tags
|
|
2236
2219
|
});
|
|
2237
2220
|
};
|
|
@@ -2243,11 +2226,11 @@ var createTabsComponent = (tabsProps) => __spreadProps(__spreadValues({}, tabsPr
|
|
|
2243
2226
|
});
|
|
2244
2227
|
|
|
2245
2228
|
// src/domain/mappers/layout/tabsLayoutToComponent.ts
|
|
2246
|
-
var tabsLayoutToComponent = (uid, { analyticsId, control, margin
|
|
2229
|
+
var tabsLayoutToComponent = (uid, { analyticsId, control, margin, tags, tabs }, mapperProps, schemaComponents) => createTabsComponent({
|
|
2247
2230
|
uid,
|
|
2248
2231
|
analyticsId,
|
|
2249
2232
|
control,
|
|
2250
|
-
margin,
|
|
2233
|
+
margin: margin != null ? margin : "md",
|
|
2251
2234
|
tags,
|
|
2252
2235
|
tabs: mapTabs(tabs, uid, mapperProps, schemaComponents)
|
|
2253
2236
|
});
|
|
@@ -2273,11 +2256,11 @@ var createProgressComponent = (progressProps) => __spreadValues({
|
|
|
2273
2256
|
// src/domain/mappers/layout/progressLayoutToComponent.ts
|
|
2274
2257
|
var progressLayoutToComponent = (uid, {
|
|
2275
2258
|
analyticsId,
|
|
2276
|
-
context
|
|
2259
|
+
context,
|
|
2277
2260
|
control,
|
|
2278
2261
|
description,
|
|
2279
2262
|
help,
|
|
2280
|
-
margin
|
|
2263
|
+
margin,
|
|
2281
2264
|
progress,
|
|
2282
2265
|
progressText,
|
|
2283
2266
|
tags,
|
|
@@ -2285,11 +2268,11 @@ var progressLayoutToComponent = (uid, {
|
|
|
2285
2268
|
}) => createProgressComponent({
|
|
2286
2269
|
uid,
|
|
2287
2270
|
analyticsId,
|
|
2288
|
-
context: mapLegacyContext(context),
|
|
2271
|
+
context: mapLegacyContext(context != null ? context : "neutral"),
|
|
2289
2272
|
control,
|
|
2290
2273
|
description,
|
|
2291
2274
|
help: help == null ? void 0 : help.markdown,
|
|
2292
|
-
margin,
|
|
2275
|
+
margin: margin != null ? margin : "md",
|
|
2293
2276
|
progress,
|
|
2294
2277
|
progressText,
|
|
2295
2278
|
tags,
|
|
@@ -2360,34 +2343,39 @@ var modalToComponent = (uid, { content, title }, mapperProps, schemaComponents)
|
|
|
2360
2343
|
mapperProps.updateComponent
|
|
2361
2344
|
);
|
|
2362
2345
|
|
|
2363
|
-
// src/domain/
|
|
2364
|
-
var
|
|
2365
|
-
const
|
|
2346
|
+
// src/domain/prefetching/request-cache.ts
|
|
2347
|
+
var makeRequestCache = () => {
|
|
2348
|
+
const cache = /* @__PURE__ */ new Map();
|
|
2366
2349
|
return {
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
uid,
|
|
2370
|
-
url,
|
|
2371
|
-
status: "initial",
|
|
2372
|
-
onSuccess() {
|
|
2373
|
-
update(this, (draft) => {
|
|
2374
|
-
draft.status = "success";
|
|
2375
|
-
});
|
|
2350
|
+
has: (...requestParams) => {
|
|
2351
|
+
return cache.has(makeKey(...requestParams));
|
|
2376
2352
|
},
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
update(this, (draft) => {
|
|
2380
|
-
draft.status = "failure";
|
|
2381
|
-
});
|
|
2382
|
-
}
|
|
2353
|
+
get: (...requestParams) => {
|
|
2354
|
+
return cache.get(makeKey(...requestParams));
|
|
2383
2355
|
},
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2356
|
+
delete: (...requestParams) => {
|
|
2357
|
+
return cache.delete(makeKey(...requestParams));
|
|
2358
|
+
},
|
|
2359
|
+
set: (...[input, init, response]) => {
|
|
2360
|
+
return cache.set(makeKey(input, init), response);
|
|
2361
|
+
},
|
|
2362
|
+
clear: () => {
|
|
2363
|
+
cache.clear();
|
|
2388
2364
|
}
|
|
2389
2365
|
};
|
|
2390
2366
|
};
|
|
2367
|
+
var makeKey = (...requestParams) => {
|
|
2368
|
+
var _a, _b;
|
|
2369
|
+
const [input, init] = requestParams;
|
|
2370
|
+
const url = typeof input === "string" || input instanceof URL ? input.toString() : input.url;
|
|
2371
|
+
const key = JSON.stringify({
|
|
2372
|
+
url,
|
|
2373
|
+
method: (_a = init == null ? void 0 : init.method) != null ? _a : "GET",
|
|
2374
|
+
headers: (init == null ? void 0 : init.headers) ? Array.from(new Headers(init.headers).entries()) : [],
|
|
2375
|
+
body: (_b = init == null ? void 0 : init.body) != null ? _b : null
|
|
2376
|
+
});
|
|
2377
|
+
return key;
|
|
2378
|
+
};
|
|
2391
2379
|
|
|
2392
2380
|
// src/utils/recursiveMerge.ts
|
|
2393
2381
|
function recursiveMerge(valueA, valueB) {
|
|
@@ -2428,6 +2416,57 @@ function mergeArrays(valueA, valueB) {
|
|
|
2428
2416
|
);
|
|
2429
2417
|
}
|
|
2430
2418
|
|
|
2419
|
+
// src/flow/makeSubmissionRequest.ts
|
|
2420
|
+
var makeSubmissionRequest = (action, model) => {
|
|
2421
|
+
var _a, _b;
|
|
2422
|
+
return [
|
|
2423
|
+
(_a = action.url) != null ? _a : "",
|
|
2424
|
+
{
|
|
2425
|
+
method: (_b = action.method) != null ? _b : "POST",
|
|
2426
|
+
body: makeRequestBody(action, model),
|
|
2427
|
+
headers: { "Content-Type": "application/json" }
|
|
2428
|
+
}
|
|
2429
|
+
];
|
|
2430
|
+
};
|
|
2431
|
+
var makeRequestBody = (action, model) => {
|
|
2432
|
+
var _a, _b;
|
|
2433
|
+
const method = (_a = action.method) != null ? _a : "POST";
|
|
2434
|
+
if (method === "GET") {
|
|
2435
|
+
return void 0;
|
|
2436
|
+
}
|
|
2437
|
+
const payload = recursiveMerge(model, (_b = action.data) != null ? _b : null);
|
|
2438
|
+
return payload !== null ? JSON.stringify(payload) : null;
|
|
2439
|
+
};
|
|
2440
|
+
|
|
2441
|
+
// src/domain/components/step/ExternalConfirmationComponent.ts
|
|
2442
|
+
var createExternalConfirmation = (uid, url, updateComponent) => {
|
|
2443
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
2444
|
+
return {
|
|
2445
|
+
type: "external-confirmation",
|
|
2446
|
+
kind: "layout",
|
|
2447
|
+
uid,
|
|
2448
|
+
url,
|
|
2449
|
+
status: "initial",
|
|
2450
|
+
onSuccess() {
|
|
2451
|
+
update(this, (draft) => {
|
|
2452
|
+
draft.status = "success";
|
|
2453
|
+
});
|
|
2454
|
+
},
|
|
2455
|
+
onFailure() {
|
|
2456
|
+
if (this.status === "initial") {
|
|
2457
|
+
update(this, (draft) => {
|
|
2458
|
+
draft.status = "failure";
|
|
2459
|
+
});
|
|
2460
|
+
}
|
|
2461
|
+
},
|
|
2462
|
+
onCancel() {
|
|
2463
|
+
update(this, (draft) => {
|
|
2464
|
+
draft.status = "dismissed";
|
|
2465
|
+
});
|
|
2466
|
+
}
|
|
2467
|
+
};
|
|
2468
|
+
};
|
|
2469
|
+
|
|
2431
2470
|
// src/utils/component-utils.ts
|
|
2432
2471
|
var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
|
|
2433
2472
|
(values) => values.reduce((acc, value) => recursiveMerge(acc, value), null)
|
|
@@ -2507,7 +2546,8 @@ var getStepPolling = ({
|
|
|
2507
2546
|
pollingConfig,
|
|
2508
2547
|
logEvent,
|
|
2509
2548
|
onBehavior,
|
|
2510
|
-
onPoll
|
|
2549
|
+
onPoll,
|
|
2550
|
+
registerSubmissionBehavior
|
|
2511
2551
|
}) => {
|
|
2512
2552
|
const { interval, delay = interval, maxAttempts, url, onError } = pollingConfig;
|
|
2513
2553
|
let abortController = new AbortController();
|
|
@@ -2515,7 +2555,7 @@ var getStepPolling = ({
|
|
|
2515
2555
|
if (delay == null) {
|
|
2516
2556
|
throw new Error("Polling configuration must include delay or interval");
|
|
2517
2557
|
}
|
|
2518
|
-
const onErrorBehavior = getDomainLayerBehavior(onError, []);
|
|
2558
|
+
const onErrorBehavior = getDomainLayerBehavior(onError, [], registerSubmissionBehavior);
|
|
2519
2559
|
let attempts = 0;
|
|
2520
2560
|
const poll = () => {
|
|
2521
2561
|
attempts += 1;
|
|
@@ -4830,11 +4870,12 @@ var objectSchemaToMoneyInputComponent = (schemaMapperProps, mapperProps) => {
|
|
|
4830
4870
|
);
|
|
4831
4871
|
};
|
|
4832
4872
|
var createMoneyInputSubComponents = (schemaMapperProps, mapperProps) => {
|
|
4833
|
-
const { schema: objectSchema } = schemaMapperProps;
|
|
4873
|
+
const { schema: objectSchema, model } = schemaMapperProps;
|
|
4834
4874
|
const amountKey = getAmountSchemaKey(objectSchema, mapperProps);
|
|
4835
4875
|
const currencyKey = getCurrencySchemaKey(objectSchema, mapperProps);
|
|
4836
4876
|
const currencySchema = objectSchema.properties[currencyKey];
|
|
4837
4877
|
const customSchemaMapperProps = __spreadProps(__spreadValues({}, schemaMapperProps), {
|
|
4878
|
+
model: getSanitizedModel(amountKey, model),
|
|
4838
4879
|
schema: isOneOfSchema(currencySchema) ? objectSchema : replaceKeyInObjectSchema(objectSchema, currencyKey, { oneOf: [currencySchema] })
|
|
4839
4880
|
});
|
|
4840
4881
|
const componentMap = createComponentMap(customSchemaMapperProps, mapperProps, "money");
|
|
@@ -4846,6 +4887,18 @@ var createMoneyInputSubComponents = (schemaMapperProps, mapperProps) => {
|
|
|
4846
4887
|
const checks = getMinMaxChecks(objectSchema, amountKey, mapperProps);
|
|
4847
4888
|
return { amountKey, amountComponent, currencyKey, currencyComponent, extraValues, checks };
|
|
4848
4889
|
};
|
|
4890
|
+
var isNumberString = (value) => {
|
|
4891
|
+
return typeof value === "string" && !Number.isNaN(Number.parseFloat(value)) && /^\d*(?:\.\d*)?$/.test(value);
|
|
4892
|
+
};
|
|
4893
|
+
var getSanitizedModel = (key, value) => {
|
|
4894
|
+
if (isObject(value)) {
|
|
4895
|
+
const amount = value[key];
|
|
4896
|
+
if (!isNumberString(amount)) {
|
|
4897
|
+
return __spreadProps(__spreadValues({}, value), { [key]: null });
|
|
4898
|
+
}
|
|
4899
|
+
}
|
|
4900
|
+
return value;
|
|
4901
|
+
};
|
|
4849
4902
|
var getAmountSchemaKey = ({ displayOrder, properties }, mapperProps) => {
|
|
4850
4903
|
var _a;
|
|
4851
4904
|
const entry = displayOrder.map((key) => ({ key, schema: properties[key] })).find(({ schema }) => isAmountSchema(schema));
|
|
@@ -5647,7 +5700,11 @@ var mapToolbarToComponent = (uid, toolbar, mapperProps) => {
|
|
|
5647
5700
|
tags: toolbar.tags,
|
|
5648
5701
|
items: toolbar.items.map((item) => {
|
|
5649
5702
|
const context = item.context ? mapLegacyContext(item.context) : void 0;
|
|
5650
|
-
const behavior = getDomainLayerBehavior(
|
|
5703
|
+
const behavior = getDomainLayerBehavior(
|
|
5704
|
+
{ behavior: item.behavior },
|
|
5705
|
+
[],
|
|
5706
|
+
mapperProps.registerSubmissionBehavior
|
|
5707
|
+
);
|
|
5651
5708
|
return __spreadProps(__spreadValues({}, item), {
|
|
5652
5709
|
context: context ? mapLegacyContext(context) : void 0,
|
|
5653
5710
|
disabled: !!item.disabled,
|
|
@@ -5743,16 +5800,29 @@ var mapStepToComponent = (_a) => {
|
|
|
5743
5800
|
title,
|
|
5744
5801
|
tags
|
|
5745
5802
|
} = step;
|
|
5803
|
+
const submissionRequestsCache = makeRequestCache();
|
|
5804
|
+
const submissionBehaviors = [];
|
|
5805
|
+
const registerSubmissionBehavior = (behavior) => {
|
|
5806
|
+
if (behavior.type === "action" && behavior.action.prefetch) {
|
|
5807
|
+
submissionBehaviors.push(behavior);
|
|
5808
|
+
}
|
|
5809
|
+
};
|
|
5746
5810
|
const back = mapBackNavigation(navigation, onBehavior, Boolean(features.nativeBack));
|
|
5747
5811
|
const stepId = id || key;
|
|
5748
5812
|
if (stepId === void 0) {
|
|
5749
5813
|
throw new Error("Step must have an id or a key");
|
|
5750
5814
|
}
|
|
5751
5815
|
const uid = `${rootUid}.${stepId != null ? stepId : "step"}`;
|
|
5752
|
-
const stepPolling = polling ? getStepPolling({
|
|
5816
|
+
const stepPolling = polling ? getStepPolling({
|
|
5817
|
+
pollingConfig: polling,
|
|
5818
|
+
logEvent,
|
|
5819
|
+
onBehavior,
|
|
5820
|
+
onPoll,
|
|
5821
|
+
registerSubmissionBehavior
|
|
5822
|
+
}) : void 0;
|
|
5753
5823
|
const stepRefreshAfter = refreshAfter ? getStepRefreshAfter({ refreshAfter, logEvent, onBehavior }) : void 0;
|
|
5754
5824
|
const externalConfirmation = (external == null ? void 0 : external.url) ? createExternalConfirmation(`${uid}-external-confirmation`, external == null ? void 0 : external.url, updateComponent) : void 0;
|
|
5755
|
-
const mapperProps = __spreadProps(__spreadValues({}, restProps), { trackEvent, onBehavior });
|
|
5825
|
+
const mapperProps = __spreadProps(__spreadValues({}, restProps), { trackEvent, onBehavior, registerSubmissionBehavior });
|
|
5756
5826
|
const referencedSchemaIds = getReferencedSchemaId(step);
|
|
5757
5827
|
const schemaComponents = mapStepSchemas(
|
|
5758
5828
|
uid,
|
|
@@ -5796,11 +5866,18 @@ var mapStepToComponent = (_a) => {
|
|
|
5796
5866
|
title: !features.hideStepTitle ? title : void 0,
|
|
5797
5867
|
tags,
|
|
5798
5868
|
stackBehavior: (_a2 = navigation == null ? void 0 : navigation.stackBehavior) != null ? _a2 : "default",
|
|
5869
|
+
submissionRequestsCache,
|
|
5799
5870
|
step,
|
|
5800
5871
|
updateComponent,
|
|
5801
5872
|
trackEvent,
|
|
5802
5873
|
onBehavior
|
|
5803
5874
|
});
|
|
5875
|
+
executePrefetch({
|
|
5876
|
+
httpClient: mapperProps.httpClient,
|
|
5877
|
+
model: stepComponent.getSubmittableValueSync(),
|
|
5878
|
+
behaviors: submissionBehaviors,
|
|
5879
|
+
requestsCache: submissionRequestsCache
|
|
5880
|
+
});
|
|
5804
5881
|
return stepComponent;
|
|
5805
5882
|
};
|
|
5806
5883
|
var getReferencedSchemaId = (step) => {
|
|
@@ -5821,6 +5898,22 @@ var mapBackNavigation = (navigation, onBehavior, isNativeBackEnabled) => {
|
|
|
5821
5898
|
}
|
|
5822
5899
|
} : void 0;
|
|
5823
5900
|
};
|
|
5901
|
+
var executePrefetch = (props) => {
|
|
5902
|
+
const {
|
|
5903
|
+
httpClient,
|
|
5904
|
+
behaviors: submissionBehaviors,
|
|
5905
|
+
model,
|
|
5906
|
+
requestsCache: submissionRequestsCache
|
|
5907
|
+
} = props;
|
|
5908
|
+
submissionBehaviors.forEach((behavior) => {
|
|
5909
|
+
const requestParams = makeSubmissionRequest(behavior.action, model);
|
|
5910
|
+
try {
|
|
5911
|
+
const responsePromise = httpClient(...requestParams).catch(() => null);
|
|
5912
|
+
submissionRequestsCache.set(...requestParams, responsePromise);
|
|
5913
|
+
} catch (e) {
|
|
5914
|
+
}
|
|
5915
|
+
});
|
|
5916
|
+
};
|
|
5824
5917
|
|
|
5825
5918
|
// src/flow/getResponseType.ts
|
|
5826
5919
|
var responseTypes = ["step", "action", "exit", "modal"];
|
|
@@ -5949,11 +6042,20 @@ var executeRefresh = async (props) => {
|
|
|
5949
6042
|
}
|
|
5950
6043
|
};
|
|
5951
6044
|
|
|
6045
|
+
// src/flow/makeSafeHttpClient.ts
|
|
6046
|
+
var makeSafeHttpClient = (httpClient) => async (...props) => {
|
|
6047
|
+
try {
|
|
6048
|
+
return await httpClient(...props);
|
|
6049
|
+
} catch (e) {
|
|
6050
|
+
return null;
|
|
6051
|
+
}
|
|
6052
|
+
};
|
|
6053
|
+
|
|
5952
6054
|
// src/flow/executeSubmission.ts
|
|
5953
6055
|
var executeSubmission = async (props) => {
|
|
5954
|
-
const { httpClient, trackEvent, logEvent } = props;
|
|
6056
|
+
const { httpClient, requestCache, trackEvent, logEvent } = props;
|
|
5955
6057
|
const triggerAction = async (action, model, isInitial) => {
|
|
5956
|
-
const { exit, url,
|
|
6058
|
+
const { exit, url, result = null, id: actionId } = action;
|
|
5957
6059
|
const trackSubmissionEvent = !isInitial ? trackEvent : () => {
|
|
5958
6060
|
};
|
|
5959
6061
|
trackSubmissionEvent("Action Triggered", { actionId });
|
|
@@ -5961,19 +6063,8 @@ var executeSubmission = async (props) => {
|
|
|
5961
6063
|
trackSubmissionEvent("Action Succeeded", { actionId });
|
|
5962
6064
|
return { type: "complete", result };
|
|
5963
6065
|
}
|
|
5964
|
-
const
|
|
5965
|
-
|
|
5966
|
-
if (method === "GET") {
|
|
5967
|
-
return void 0;
|
|
5968
|
-
}
|
|
5969
|
-
const payload = recursiveMerge(model, (_a = action.data) != null ? _a : null);
|
|
5970
|
-
return payload !== null ? JSON.stringify(payload) : null;
|
|
5971
|
-
};
|
|
5972
|
-
const response = await getSafeHttpClient(httpClient)(url != null ? url : "", {
|
|
5973
|
-
method,
|
|
5974
|
-
body: makeRequestBody(),
|
|
5975
|
-
headers: { "Content-Type": "application/json" }
|
|
5976
|
-
});
|
|
6066
|
+
const requestParams = makeSubmissionRequest(action, model);
|
|
6067
|
+
const response = await getCachedOrFetch(requestParams, requestCache, httpClient);
|
|
5977
6068
|
if (!response) {
|
|
5978
6069
|
const extra = { actionId, errorMessage: "Network Error" };
|
|
5979
6070
|
trackEvent("Action Failed", extra);
|
|
@@ -6046,12 +6137,18 @@ var executeSubmission = async (props) => {
|
|
|
6046
6137
|
};
|
|
6047
6138
|
return triggerAction(props.action, props.model, props.isInitial);
|
|
6048
6139
|
};
|
|
6049
|
-
var
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6140
|
+
var getCachedOrFetch = async (requestParams, requestCache, httpClient) => {
|
|
6141
|
+
if (requestCache == null ? void 0 : requestCache.has(...requestParams)) {
|
|
6142
|
+
const cachedPromise = requestCache.get(...requestParams);
|
|
6143
|
+
requestCache.delete(...requestParams);
|
|
6144
|
+
if (cachedPromise) {
|
|
6145
|
+
const cachedResponse = await cachedPromise;
|
|
6146
|
+
if (cachedResponse == null ? void 0 : cachedResponse.ok) {
|
|
6147
|
+
return cachedResponse;
|
|
6148
|
+
}
|
|
6149
|
+
}
|
|
6054
6150
|
}
|
|
6151
|
+
return makeSafeHttpClient(httpClient)(...requestParams);
|
|
6055
6152
|
};
|
|
6056
6153
|
|
|
6057
6154
|
// src/renderers/getSchemaErrorMessageFunction.ts
|
|
@@ -6503,10 +6600,14 @@ function useDynamicFlowCore(props) {
|
|
|
6503
6600
|
modalToComponent(
|
|
6504
6601
|
rootComponentRef.current.uid,
|
|
6505
6602
|
behavior,
|
|
6506
|
-
__spreadValues({
|
|
6603
|
+
__spreadProps(__spreadValues({
|
|
6507
6604
|
step: currentStep,
|
|
6508
6605
|
stepLocalValue: rootComponentRef.current.getLocalValue()
|
|
6509
|
-
}, getMapperProps()),
|
|
6606
|
+
}, getMapperProps()), {
|
|
6607
|
+
registerSubmissionBehavior: () => {
|
|
6608
|
+
}
|
|
6609
|
+
// this means actions in modal responses won't have prefetching
|
|
6610
|
+
}),
|
|
6510
6611
|
rootComponentRef.current.getSchemaComponents()
|
|
6511
6612
|
)
|
|
6512
6613
|
);
|
|
@@ -6525,13 +6626,14 @@ function useDynamicFlowCore(props) {
|
|
|
6525
6626
|
}, []);
|
|
6526
6627
|
const onAction = (0, import_react3.useCallback)(
|
|
6527
6628
|
async (action, model) => {
|
|
6528
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
6629
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
6529
6630
|
try {
|
|
6530
6631
|
rootComponentRef.current.setLoadingState("submitting");
|
|
6531
6632
|
const command = await executeSubmission({
|
|
6532
6633
|
action,
|
|
6533
6634
|
model,
|
|
6534
6635
|
isInitial: !rootComponentRef.current.hasStep(),
|
|
6636
|
+
requestCache: (_a2 = rootComponentRef.current.getStep()) == null ? void 0 : _a2.submissionRequestsCache,
|
|
6535
6637
|
httpClient,
|
|
6536
6638
|
trackEvent: trackCoreEvent,
|
|
6537
6639
|
logEvent
|
|
@@ -6552,7 +6654,7 @@ function useDynamicFlowCore(props) {
|
|
|
6552
6654
|
case "error": {
|
|
6553
6655
|
rootComponentRef.current.setLoadingState("idle");
|
|
6554
6656
|
const genericErrorMessage = getErrorMessageFunctions().genericErrorWithRetry();
|
|
6555
|
-
const errors = (
|
|
6657
|
+
const errors = (_c = (_b = command.body) == null ? void 0 : _b.errors) != null ? _c : { error: genericErrorMessage };
|
|
6556
6658
|
const currentStep = rootComponentRef.current.getStep();
|
|
6557
6659
|
if (currentStep) {
|
|
6558
6660
|
updateStep(
|
|
@@ -6566,16 +6668,16 @@ function useDynamicFlowCore(props) {
|
|
|
6566
6668
|
external: void 0
|
|
6567
6669
|
// and no external, to avoid retriggering it
|
|
6568
6670
|
}),
|
|
6569
|
-
(
|
|
6671
|
+
(_e = (_d = rootComponentRef.current.getStep()) == null ? void 0 : _d.etag) != null ? _e : null
|
|
6570
6672
|
);
|
|
6571
6673
|
} else {
|
|
6572
|
-
const errorMessage = ((
|
|
6674
|
+
const errorMessage = ((_g = (_f = command.body) == null ? void 0 : _f.errors) == null ? void 0 : _g.error) || ((_h = command.httpError) == null ? void 0 : _h.message) || "Initial request failed";
|
|
6573
6675
|
closeWithError(
|
|
6574
6676
|
new Error(errorMessage, {
|
|
6575
6677
|
cause: `method: ${action.method}, url: ${action.url}`
|
|
6576
6678
|
}),
|
|
6577
6679
|
{},
|
|
6578
|
-
(
|
|
6680
|
+
(_i = command.httpError) == null ? void 0 : _i.statusCode
|
|
6579
6681
|
);
|
|
6580
6682
|
}
|
|
6581
6683
|
break;
|