@wise/dynamic-flow-client 5.9.1 → 5.9.2-logging-bf0bd22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/main.js +7 -1
- package/build/main.mjs +7 -1
- package/package.json +9 -8
- package/build/DynamicFlowCore.js +0 -5
- package/build/common/errorBoundary/ErrorBoundary.js +0 -26
- package/build/common/errorBoundary/ErrorBoundary.test.js +0 -29
- package/build/common/errorBoundary/ErrorBoundaryAlert.js +0 -11
- package/build/common/makeHttpClient/api-utils.js +0 -3
- package/build/common/makeHttpClient/index.js +0 -1
- package/build/common/makeHttpClient/makeHttpClient.js +0 -10
- package/build/common/makeHttpClient/makeHttpClient.test.js +0 -186
- package/build/common/messages/external-confirmation.messages.js +0 -23
- package/build/common/messages/file-upload.messages.js +0 -13
- package/build/common/messages/generic-error.messages.js +0 -18
- package/build/common/messages/help.messages.js +0 -8
- package/build/common/messages/multi-file-upload.messages.js +0 -18
- package/build/common/messages/multi-select.messages.js +0 -8
- package/build/common/messages/paragraph.messages.js +0 -13
- package/build/common/messages/repeatable.messages.js +0 -23
- package/build/common/messages/search.messages.js +0 -8
- package/build/common/messages/validation.array.messages.js +0 -13
- package/build/common/messages/validation.messages.js +0 -53
- package/build/controller/FlowController.js +0 -368
- package/build/controller/executePoll.js +0 -49
- package/build/controller/executeRefresh.js +0 -39
- package/build/controller/executeRequest.js +0 -77
- package/build/controller/executeSubmission.js +0 -69
- package/build/controller/getErrorMessage.js +0 -7
- package/build/controller/getRequestAbortController.js +0 -13
- package/build/controller/getResponseType.js +0 -35
- package/build/controller/getSafeHttpClient.js +0 -8
- package/build/controller/getStepCounter.js +0 -16
- package/build/controller/handleErrorResponse.js +0 -26
- package/build/controller/makeSafeHttpClient.js +0 -8
- package/build/controller/response-utils.js +0 -72
- package/build/domain/components/AlertComponent.js +0 -1
- package/build/domain/components/AllOfComponent.js +0 -40
- package/build/domain/components/BooleanInputComponent.js +0 -50
- package/build/domain/components/BoxComponent.js +0 -3
- package/build/domain/components/ButtonComponent.js +0 -1
- package/build/domain/components/ColumnsComponent.js +0 -3
- package/build/domain/components/ConstComponent.js +0 -18
- package/build/domain/components/ContainerComponent.js +0 -3
- package/build/domain/components/DateInputComponent.js +0 -75
- package/build/domain/components/DecisionComponent.js +0 -1
- package/build/domain/components/DividerComponent.js +0 -1
- package/build/domain/components/FormComponent.js +0 -3
- package/build/domain/components/FormattedValueComponent.js +0 -44
- package/build/domain/components/HeadingComponent.js +0 -1
- package/build/domain/components/ImageComponent.js +0 -1
- package/build/domain/components/InstructionsComponent.js +0 -1
- package/build/domain/components/IntegerInputComponent.js +0 -74
- package/build/domain/components/ListComponent.js +0 -1
- package/build/domain/components/LoadingIndicatorComponent.js +0 -1
- package/build/domain/components/MarkdownComponent.js +0 -1
- package/build/domain/components/MediaComponent.js +0 -1
- package/build/domain/components/ModalComponent.js +0 -16
- package/build/domain/components/ModalLayoutComponent.js +0 -3
- package/build/domain/components/MoneyInputComponent.js +0 -57
- package/build/domain/components/MultiSelectInputComponent.js +0 -81
- package/build/domain/components/MultiUploadInputComponent.js +0 -88
- package/build/domain/components/NumberInputComponent.js +0 -73
- package/build/domain/components/ObjectComponent.js +0 -45
- package/build/domain/components/ParagraphComponent.js +0 -1
- package/build/domain/components/PersistAsyncComponent.js +0 -92
- package/build/domain/components/ProgressComponent.js +0 -1
- package/build/domain/components/RepeatableComponent.js +0 -103
- package/build/domain/components/ReviewComponent.js +0 -1
- package/build/domain/components/RootDomainComponent.js +0 -173
- package/build/domain/components/SectionComponent.js +0 -5
- package/build/domain/components/SelectInputComponent.js +0 -88
- package/build/domain/components/StatusListComponent.js +0 -1
- package/build/domain/components/SubflowDomainComponent.js +0 -9
- package/build/domain/components/TabsComponent.js +0 -1
- package/build/domain/components/TextInputComponent.js +0 -76
- package/build/domain/components/TupleComponent.js +0 -41
- package/build/domain/components/UploadInputComponent.js +0 -83
- package/build/domain/components/UpsellComponent.js +0 -25
- package/build/domain/components/searchComponent/SearchComponent.js +0 -92
- package/build/domain/components/searchComponent/SearchComponent.test.js +0 -190
- package/build/domain/components/step/ExternalConfirmationComponent.js +0 -28
- package/build/domain/components/step/StepDomainComponent.js +0 -78
- package/build/domain/components/step/ToolbarComponent.js +0 -1
- package/build/domain/components/utils/WithUpdate.js +0 -1
- package/build/domain/components/utils/component-utils.js +0 -12
- package/build/domain/components/utils/debounce.js +0 -34
- package/build/domain/components/utils/debounce.test.js +0 -67
- package/build/domain/components/utils/file-utils.js +0 -21
- package/build/domain/components/utils/file-utils.test.js +0 -27
- package/build/domain/components/utils/getRandomId.js +0 -1
- package/build/domain/components/utils/isExactLocalValueMatch.js +0 -14
- package/build/domain/components/utils/isOrWasValid.js +0 -5
- package/build/domain/components/utils/isPartialModelMatch.js +0 -18
- package/build/domain/components/utils/isPartialModelMatch.test.js +0 -74
- package/build/domain/features/eventNames.js +0 -24
- package/build/domain/features/events.js +0 -1
- package/build/domain/features/persistAsync/getComponentMultiPersistAsync.js +0 -50
- package/build/domain/features/persistAsync/getInitialPersistedState.js +0 -7
- package/build/domain/features/persistAsync/getPerformPersistAsync.js +0 -43
- package/build/domain/features/persistAsync/getPerformPersistAsync.test.js +0 -139
- package/build/domain/features/polling/getStepPolling.js +0 -43
- package/build/domain/features/polling/getStepPolling.test.js +0 -90
- package/build/domain/features/prefetch/getStepPrefetch.js +0 -43
- package/build/domain/features/prefetch/request-cache.js +0 -49
- package/build/domain/features/prefetch/request-cache.test.js +0 -70
- package/build/domain/features/refreshAfter/getStepRefreshAfter.js +0 -24
- package/build/domain/features/refreshAfter/getStepRefreshAfter.test.js +0 -40
- package/build/domain/features/schema-on-change/getDebouncedSchemaOnChange.js +0 -50
- package/build/domain/features/schema-on-change/getSchemaOnChange.js +0 -34
- package/build/domain/features/search/getPerformSearchFunction.js +0 -75
- package/build/domain/features/search/getPerformSearchFunction.test.js +0 -301
- package/build/domain/features/summary/summary-utils.js +0 -40
- package/build/domain/features/summary/summary-utils.test.js +0 -125
- package/build/domain/features/utils/http-utils.js +0 -21
- package/build/domain/features/utils/response-utils.js +0 -9
- package/build/domain/features/validation/spec-utils.js +0 -19
- package/build/domain/features/validation/validateStringPattern.js +0 -24
- package/build/domain/features/validation/validation-functions.js +0 -6
- package/build/domain/features/validation/validation-functions.test.js +0 -108
- package/build/domain/features/validation/value-checks.js +0 -125
- package/build/domain/features/validation/value-checks.test.js +0 -262
- package/build/domain/features/validationAsync/getComponentValidationAsync.js +0 -53
- package/build/domain/features/validationAsync/getComponentValidationAsync.test.js +0 -67
- package/build/domain/features/validationAsync/getInitialValidationAsyncState.js +0 -5
- package/build/domain/features/validationAsync/getPerformValidationAsync.js +0 -45
- package/build/domain/features/validationAsync/getPerformValidationAsync.test.js +0 -143
- package/build/domain/mappers/layout/alertLayoutToComponent.js +0 -16
- package/build/domain/mappers/layout/boxLayoutToComponent.js +0 -13
- package/build/domain/mappers/layout/buttonLayoutToComponent.js +0 -77
- package/build/domain/mappers/layout/columnsLayoutToComponent.js +0 -13
- package/build/domain/mappers/layout/decisionLayoutToComponent.js +0 -22
- package/build/domain/mappers/layout/deprecatedListLayoutToComponent.js +0 -30
- package/build/domain/mappers/layout/dividerLayoutToComponent.js +0 -2
- package/build/domain/mappers/layout/formLayoutToComponent.js +0 -19
- package/build/domain/mappers/layout/headingLayoutToComponent.js +0 -12
- package/build/domain/mappers/layout/imageLayoutToComponent.js +0 -20
- package/build/domain/mappers/layout/infoLayoutToComponent.js +0 -12
- package/build/domain/mappers/layout/instructionsLayoutToComponent.js +0 -12
- package/build/domain/mappers/layout/listLayoutToComponent.js +0 -39
- package/build/domain/mappers/layout/loadingIndicatorLayoutToComponent.js +0 -9
- package/build/domain/mappers/layout/markdownLayoutToComponent.js +0 -12
- package/build/domain/mappers/layout/mediaLayoutToComponent.js +0 -12
- package/build/domain/mappers/layout/modalLayoutToComponent.js +0 -17
- package/build/domain/mappers/layout/modalToComponent.js +0 -8
- package/build/domain/mappers/layout/paragraphLayoutToComponent.js +0 -12
- package/build/domain/mappers/layout/progressLayoutToComponent.js +0 -15
- package/build/domain/mappers/layout/reviewLayoutToComponent.js +0 -48
- package/build/domain/mappers/layout/searchLayoutToComponent.js +0 -44
- package/build/domain/mappers/layout/sectionLayoutToComponent.js +0 -15
- package/build/domain/mappers/layout/statusListLayoutToComponent.js +0 -15
- package/build/domain/mappers/layout/tabsLayoutToComponent.js +0 -16
- package/build/domain/mappers/layout/upsellLayoutToComponent.js +0 -25
- package/build/domain/mappers/mapLayoutToComponent.js +0 -81
- package/build/domain/mappers/mapSchemaToComponent.js +0 -61
- package/build/domain/mappers/mapSchemaToComponent.test.js +0 -112
- package/build/domain/mappers/mapStepSchemas.js +0 -15
- package/build/domain/mappers/mapStepToComponent.js +0 -133
- package/build/domain/mappers/mapStepToComponent.test.js +0 -221
- package/build/domain/mappers/mapToolbarToComponent.js +0 -15
- package/build/domain/mappers/schema/allOfSchemaToComponent.js +0 -16
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToComponent.js +0 -26
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiSelectComponent.js +0 -55
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiUploadComponent.js +0 -67
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToRepeatableComponent.js +0 -57
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToTupleComponent.js +0 -20
- package/build/domain/mappers/schema/blobSchemaToComponent.js +0 -15
- package/build/domain/mappers/schema/booleanSchemaToComponent.js +0 -29
- package/build/domain/mappers/schema/constSchemaToComponent.js +0 -23
- package/build/domain/mappers/schema/integerSchemaToComponent.js +0 -28
- package/build/domain/mappers/schema/numberSchemaToComponent.js +0 -26
- package/build/domain/mappers/schema/objectSchemaToComponent/assertDisplayOrder.js +0 -23
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToFormattedValueComponent.js +0 -9
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToMoneyInputComponent.js +0 -119
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToMoneyInputComponent.test.js +0 -96
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToObjectComponent.js +0 -31
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToObjectComponent.test.js +0 -99
- package/build/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.js +0 -66
- package/build/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.test.js +0 -225
- package/build/domain/mappers/schema/persistAsyncSchemaToComponent.js +0 -29
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToComponent.js +0 -18
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToComponent.test.js +0 -133
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToDateInputComponent.js +0 -48
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToTextInputComponent.js +0 -37
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToUploadInputComponent.js +0 -28
- package/build/domain/mappers/schema/tests/test-utils.js +0 -16
- package/build/domain/mappers/schema/types.js +0 -1
- package/build/domain/mappers/schema/utils/getPerformPersistAsyncFn.js +0 -19
- package/build/domain/mappers/schema/utils/getValidationAsyncInitialState.js +0 -23
- package/build/domain/mappers/schema/utils/mapCommonSchemaProps.js +0 -16
- package/build/domain/mappers/types.js +0 -1
- package/build/domain/mappers/utils/FeatureFlags.js +0 -22
- package/build/domain/mappers/utils/behavior-utils.js +0 -44
- package/build/domain/mappers/utils/call-to-action-utils.js +0 -21
- package/build/domain/mappers/utils/getAutocompleteString.js +0 -76
- package/build/domain/mappers/utils/getAutocompleteString.test.js +0 -21
- package/build/domain/mappers/utils/groupLayoutByPinned.js +0 -38
- package/build/domain/mappers/utils/groupLayoutByPinned.test.js +0 -166
- package/build/domain/mappers/utils/image.js +0 -9
- package/build/domain/mappers/utils/layout-utils.js +0 -11
- package/build/domain/mappers/utils/legacy-utils.js +0 -49
- package/build/domain/mappers/utils/media-utils.js +0 -14
- package/build/domain/mappers/utils/suggestions-utils.js +0 -26
- package/build/domain/mappers/utils/suggestions-utils.test.js +0 -36
- package/build/domain/mappers/utils/tags-utils.js +0 -1
- package/build/domain/mappers/utils/utils.js +0 -35
- package/build/domain/types.js +0 -1
- package/build/getSubflowCallbacks.js +0 -38
- package/build/i18n/index.js +0 -40
- package/build/index.js +0 -8
- package/build/renderers/CoreContainerRenderer.js +0 -5
- package/build/renderers/CoreRootRenderer.js +0 -12
- package/build/renderers/EmptyLoadingStateRenderer.js +0 -5
- package/build/renderers/getRenderFunction.js +0 -24
- package/build/renderers/getSchemaErrorMessageFunction.js +0 -97
- package/build/renderers/mappers/alertComponentToProps.js +0 -2
- package/build/renderers/mappers/allOfComponentToProps.js +0 -6
- package/build/renderers/mappers/booleanInputComponentToProps.js +0 -5
- package/build/renderers/mappers/boxComponentToProps.js +0 -13
- package/build/renderers/mappers/buttonComponentToProps.js +0 -4
- package/build/renderers/mappers/columnsComponentToProps.js +0 -11
- package/build/renderers/mappers/componentToRendererProps.js +0 -164
- package/build/renderers/mappers/constComponentToProps.js +0 -5
- package/build/renderers/mappers/containerComponentToProps.js +0 -7
- package/build/renderers/mappers/dateInputComponentToProps.js +0 -2
- package/build/renderers/mappers/decisionComponentToProps.js +0 -16
- package/build/renderers/mappers/dividerComponentToProps.js +0 -2
- package/build/renderers/mappers/externalComponentToProps.js +0 -3
- package/build/renderers/mappers/formComponentToProps.js +0 -12
- package/build/renderers/mappers/formattedValueComponentToProps.js +0 -5
- package/build/renderers/mappers/headingComponentToProps.js +0 -2
- package/build/renderers/mappers/hiddenComponentToProps.js +0 -4
- package/build/renderers/mappers/imageComponentToProps.js +0 -2
- package/build/renderers/mappers/instructionsComponentToProps.js +0 -2
- package/build/renderers/mappers/integerInputComponentToProps.js +0 -2
- package/build/renderers/mappers/listComponentToProps.js +0 -2
- package/build/renderers/mappers/loadingIndicatorComponentToProps.js +0 -2
- package/build/renderers/mappers/markdownComponentToProps.js +0 -2
- package/build/renderers/mappers/mediaComponentToProps.js +0 -2
- package/build/renderers/mappers/modalComponentToProps.js +0 -11
- package/build/renderers/mappers/modalLayoutComponentToProps.js +0 -16
- package/build/renderers/mappers/moneyInputComponentToProps.js +0 -36
- package/build/renderers/mappers/multiSelectComponentToProps.js +0 -23
- package/build/renderers/mappers/multiUploadInputComponentToProps.js +0 -12
- package/build/renderers/mappers/numberInputComponentToProps.js +0 -2
- package/build/renderers/mappers/objectComponentToProps.js +0 -8
- package/build/renderers/mappers/paragraphComponentToProps.js +0 -2
- package/build/renderers/mappers/persistAsyncComponentToProps.js +0 -8
- package/build/renderers/mappers/progressComponentToProps.js +0 -2
- package/build/renderers/mappers/repeatableComponentToProps.js +0 -30
- package/build/renderers/mappers/reviewComponentToProps.js +0 -2
- package/build/renderers/mappers/rootComponentToProps.js +0 -21
- package/build/renderers/mappers/searchComponentToProps.js +0 -57
- package/build/renderers/mappers/sectionComponentToProps.js +0 -6
- package/build/renderers/mappers/selectInputComponentToProps.js +0 -34
- package/build/renderers/mappers/statusListComponentToProps.js +0 -2
- package/build/renderers/mappers/subflowComponentToRendererProps.js +0 -4
- package/build/renderers/mappers/tabsComponentToProps.js +0 -14
- package/build/renderers/mappers/textInputComponentToProps.js +0 -2
- package/build/renderers/mappers/tupleComponentToProps.js +0 -8
- package/build/renderers/mappers/uploadInputComponentToProps.js +0 -8
- package/build/renderers/mappers/upsellComponentToProps.js +0 -2
- package/build/renderers/mappers/utils/getValidationState.js +0 -12
- package/build/renderers/mappers/utils/inputComponentToProps.js +0 -26
- package/build/renderers/mappers/utils/mapErrorsToValidationState.js +0 -9
- package/build/renderers/mappers/utils/pick.js +0 -8
- package/build/renderers/mappers/utils/selectInputOptionsToProps.js +0 -11
- package/build/renderers/stepComponentToProps.js +0 -32
- package/build/renderers/utils.js +0 -69
- package/build/renderers/utils.test.js +0 -70
- package/build/stories/dev-tools/ContainerQueries.story.js +0 -66
- package/build/stories/dev-tools/Debugger.story.js +0 -38
- package/build/stories/dev-tools/FixtureSelect.story.js +0 -23
- package/build/stories/dev-tools/TestServer.story.js +0 -32
- package/build/stories/examples/NativeFlow.story.js +0 -80
- package/build/stories/examples/Recipients.story.js +0 -568
- package/build/stories/spec/behavior/Copy.story.js +0 -59
- package/build/stories/spec/behavior/Modal.story.js +0 -76
- package/build/stories/spec/behavior/Subflow.story.js +0 -267
- package/build/stories/spec/layouts/Decision.story.js +0 -241
- package/build/stories/spec/layouts/Image.story.js +0 -42
- package/build/stories/spec/layouts/Modal.story.js +0 -81
- package/build/stories/spec/layouts/Search.story.js +0 -325
- package/build/stories/spec/layouts/Upsell.story.js +0 -55
- package/build/stories/spec/layouts/button/Button.story.js +0 -100
- package/build/stories/spec/layouts/button/PinnedButton.story.js +0 -81
- package/build/stories/spec/response/ActionResponse.story.js +0 -66
- package/build/stories/spec/schemas/MultiSelect.story.js +0 -148
- package/build/stories/spec/schemas/Upload.story.js +0 -168
- package/build/stories/spec/schemas/const/ConstLayout.story.js +0 -159
- package/build/stories/spec/schemas/const/ObjectConst.story.js +0 -94
- package/build/stories/spec/schemas/features/PersistAsync.story.js +0 -211
- package/build/stories/spec/schemas/features/ValidationAsync.story.js +0 -103
- package/build/stories/spec/schemas/object/FormattedValue.story.js +0 -92
- package/build/stories/spec/schemas/object/MoneyInput.story.js +0 -240
- package/build/stories/spec/schemas/oneOf/OneOfInitialisation.story.js +0 -55
- package/build/stories/spec/schemas/oneOf/OneOfWithSingleOption.story.js +0 -114
- package/build/stories/spec/step/Controls.story.js +0 -109
- package/build/stories/spec/step/DFModal.story.js +0 -58
- package/build/stories/spec/step/Footer.story.js +0 -70
- package/build/stories/spec/step/Navigation.story.js +0 -20
- package/build/stories/spec/step/Tags.story.js +0 -39
- package/build/stories/spec/step/ToolBar.story.js +0 -60
- package/build/stories/spec/step/features/ErrorHandling.story.js +0 -92
- package/build/stories/spec/step/features/External.story.js +0 -44
- package/build/stories/spec/step/features/Polling.story.js +0 -108
- package/build/stories/spec/step/features/RefreshAfter.story.js +0 -92
- package/build/stories/spec/step/features/refresh/Refresh.story.js +0 -258
- package/build/stories/spec/step/features/refresh/RefreshWithPersistAsync.story.js +0 -958
- package/build/stories/types.js +0 -1
- package/build/stories/utils/fixtureHttpClient.js +0 -70
- package/build/stories/utils/getBasicStep.js +0 -223
- package/build/stories/utils/mockSearchHandler.js +0 -71
- package/build/stories/utils/render-utils.js +0 -41
- package/build/stories/visual-tests/layouts/NotUsingListItem.story.js +0 -17
- package/build/test-utils/DynamicFlowWise.js +0 -32
- package/build/test-utils/DynamicFlowWiseModal.js +0 -34
- package/build/test-utils/NeptuneProviders.js +0 -11
- package/build/test-utils/component-utils.js +0 -5
- package/build/test-utils/fetch-utils.js +0 -45
- package/build/test-utils/getMergedTestRenderers.js +0 -34
- package/build/test-utils/getRandomId.js +0 -1
- package/build/test-utils/index.js +0 -3
- package/build/test-utils/rtl-utils.js +0 -7
- package/build/test-utils/step-utils.js +0 -6
- package/build/test-utils/wait.js +0 -3
- package/build/tests/AlertLayout.test.js +0 -78
- package/build/tests/ArrayTuple.test.js +0 -118
- package/build/tests/ButtonLayout.test.js +0 -308
- package/build/tests/ConstLayout.test.js +0 -95
- package/build/tests/DateInput.test.js +0 -163
- package/build/tests/DecisionLayout.test.js +0 -146
- package/build/tests/DynamicFlow.test.js +0 -147
- package/build/tests/External.test.js +0 -169
- package/build/tests/Flow.test.js +0 -328
- package/build/tests/FormLayout.test.js +0 -28
- package/build/tests/FormattedValue.test.js +0 -107
- package/build/tests/ImageRenderer.test.js +0 -78
- package/build/tests/InitialAction.test.js +0 -179
- package/build/tests/InitialStep.test.js +0 -168
- package/build/tests/InstructionsLayout.test.js +0 -45
- package/build/tests/ListLayout.test.js +0 -145
- package/build/tests/Logging.test.js +0 -53
- package/build/tests/ModalBehavior.test.js +0 -149
- package/build/tests/MoneyInput.test.js +0 -316
- package/build/tests/MultiUpload.test.js +0 -293
- package/build/tests/NativeBack.test.js +0 -267
- package/build/tests/OneOfInitialisation.test.js +0 -571
- package/build/tests/PersistAsync.test.js +0 -686
- package/build/tests/Polling.test.js +0 -617
- package/build/tests/Prefetching.test.js +0 -230
- package/build/tests/RefreshAfter.test.js +0 -63
- package/build/tests/RefreshOnChange.ResponseHandling.test.js +0 -205
- package/build/tests/RefreshOnChange.test.js +0 -233
- package/build/tests/RefreshOnChange.with.Segmented.test.js +0 -348
- package/build/tests/RefreshOnChange.with.Tabs.test.js +0 -358
- package/build/tests/RefreshOnChangePreserve.test.js +0 -224
- package/build/tests/RendererProps.test.js +0 -342
- package/build/tests/Repeatable.test.js +0 -107
- package/build/tests/Rerendering.test.js +0 -67
- package/build/tests/ReviewLayout.test.js +0 -274
- package/build/tests/SchemaOnChange.test.js +0 -133
- package/build/tests/SchemaReferences.test.js +0 -88
- package/build/tests/ScrollToError.test.js +0 -217
- package/build/tests/SegmentedControl.test.js +0 -49
- package/build/tests/SingleFileUpload.test.js +0 -88
- package/build/tests/StatusList.test.js +0 -85
- package/build/tests/Subflow.test.js +0 -710
- package/build/tests/Submission.ResponseHandling.test.js +0 -557
- package/build/tests/Submission.merging.test.js +0 -202
- package/build/tests/Submission.test.js +0 -603
- package/build/tests/Tags.test.js +0 -475
- package/build/tests/Upsell.test.js +0 -126
- package/build/tests/ValidationAsync.test.js +0 -295
- package/build/tests/legacy/Actions.test.js +0 -158
- package/build/tests/legacy/BackButton.test.js +0 -114
- package/build/tests/legacy/HiddenSchemas.test.js +0 -246
- package/build/tests/legacy/MultiSelect.test.js +0 -497
- package/build/tests/legacy/MultipleFileUploadSchema.test.js +0 -341
- package/build/tests/legacy/PersistAsync.blob-schema.test.js +0 -224
- package/build/tests/legacy/PersistAsync.string-schema.test.js +0 -211
- package/build/tests/legacy/RefreshStepOnChange.debouncing.test.js +0 -209
- package/build/tests/legacy/RefreshStepOnChange.test.js +0 -424
- package/build/tests/legacy/Search.test.js +0 -437
- package/build/tests/renderers/MultiSelectInputRendererProps.test.js +0 -58
- package/build/tests/renderers/SelectInputRendererProps.test.js +0 -43
- package/build/tests/renderers/TextInputRenderer.test.js +0 -51
- package/build/types.js +0 -1
- package/build/useDynamicFlow.js +0 -104
- package/build/useDynamicFlowModal.js +0 -58
- package/build/utils/analyse-step.js +0 -14
- package/build/utils/component-utils.js +0 -8
- package/build/utils/component-utils.test.js +0 -113
- package/build/utils/getScrollToTop.js +0 -12
- package/build/utils/normalise-flow-id.js +0 -1
- package/build/utils/normalise-flow-id.test.js +0 -24
- package/build/utils/openLinkInNewTab.js +0 -10
- package/build/utils/recursiveMerge.js +0 -40
- package/build/utils/recursiveMerge.test.js +0 -93
- package/build/utils/type-utils.js +0 -21
- package/build/utils/type-validators.js +0 -11
- package/build/utils/type-validators.test.js +0 -180
- package/build/utils/useStableCallback.js +0 -15
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { createRootDomainComponent } from '../domain/components/RootDomainComponent';
|
|
13
|
-
import { createSubflowDomainComponent } from '../domain/components/SubflowDomainComponent';
|
|
14
|
-
import { normaliseRequestCache } from '../domain/features/prefetch/request-cache';
|
|
15
|
-
import { modalToComponent } from '../domain/mappers/layout/modalToComponent';
|
|
16
|
-
import { mapStepToComponent } from '../domain/mappers/mapStepToComponent';
|
|
17
|
-
import { getSubflowCallbacks } from '../getSubflowCallbacks';
|
|
18
|
-
import { analyseStep } from '../utils/analyse-step';
|
|
19
|
-
import { executePoll } from './executePoll';
|
|
20
|
-
import { executeRefresh } from './executeRefresh';
|
|
21
|
-
import { executeSubmission } from './executeSubmission';
|
|
22
|
-
import { getErrorMessage } from './getErrorMessage';
|
|
23
|
-
import { getRequestAbortController } from './getRequestAbortController';
|
|
24
|
-
import { getStepCounter } from './getStepCounter';
|
|
25
|
-
const noop = () => { };
|
|
26
|
-
export const createFlowController = (props) => {
|
|
27
|
-
const { flowId, initialAction, initialStep, backConfig, features, getErrorMessageFunctions, scrollToTop, httpClient, onChange, onCancellation, onCompletion, onCopy, onLink, onError, onEvent, onLog, onValueChange } = props, rest = __rest(props, ["flowId", "initialAction", "initialStep", "backConfig", "features", "getErrorMessageFunctions", "scrollToTop", "httpClient", "onChange", "onCancellation", "onCompletion", "onCopy", "onLink", "onError", "onEvent", "onLog", "onValueChange"]);
|
|
28
|
-
const rootComponent = createRootDomainComponent(onChange, scrollToTop, backConfig, normaliseRequestCache(rest.requestCache));
|
|
29
|
-
const stepCount = getStepCounter();
|
|
30
|
-
const abortController = getRequestAbortController();
|
|
31
|
-
const createStep = (newStep, etag) => {
|
|
32
|
-
// TODO remove, move to root domain component
|
|
33
|
-
if (rootComponent.hasStep()) {
|
|
34
|
-
stepCount.increment();
|
|
35
|
-
}
|
|
36
|
-
const component = createStepComponent(newStep, etag, null);
|
|
37
|
-
if (component) {
|
|
38
|
-
rootComponent.pushStep(component);
|
|
39
|
-
rootComponent.setLoadingState('idle');
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const updateStep = (newStep, etag) => {
|
|
43
|
-
var _a;
|
|
44
|
-
const component = createStepComponent(newStep, etag, (_a = rootComponent.getLocalValue()) !== null && _a !== void 0 ? _a : null);
|
|
45
|
-
if (component) {
|
|
46
|
-
rootComponent.updateStep(component);
|
|
47
|
-
rootComponent.setLoadingState('idle');
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
const getMapperProps = () => ({
|
|
51
|
-
uid: `${rootComponent.uid}:${stepCount.current}`,
|
|
52
|
-
loadingState: 'idle',
|
|
53
|
-
onComponentUpdate: onChange,
|
|
54
|
-
flowRequestCache: rootComponent.requestCache,
|
|
55
|
-
getErrorMessageFunctions,
|
|
56
|
-
trackEvent,
|
|
57
|
-
logEvent,
|
|
58
|
-
features,
|
|
59
|
-
httpClient,
|
|
60
|
-
onBehavior,
|
|
61
|
-
onPoll,
|
|
62
|
-
onValueChange,
|
|
63
|
-
});
|
|
64
|
-
const createStepComponent = (newStep, etag, localValue) => {
|
|
65
|
-
rootComponent.stop();
|
|
66
|
-
analyseStep(newStep, logEvent);
|
|
67
|
-
try {
|
|
68
|
-
return mapStepToComponent(Object.assign({ stepLocalValue: localValue, step: newStep, etag }, getMapperProps()));
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
closeWithError(error);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
const getStep = () => {
|
|
75
|
-
var _a;
|
|
76
|
-
const stepComponent = rootComponent.getStep();
|
|
77
|
-
return (_a = stepComponent === null || stepComponent === void 0 ? void 0 : stepComponent.step) !== null && _a !== void 0 ? _a : initialStep;
|
|
78
|
-
};
|
|
79
|
-
const trackEvent = (eventName, properties) => {
|
|
80
|
-
var _a, _b;
|
|
81
|
-
const step = getStep();
|
|
82
|
-
const stepId = (_b = (_a = step === null || step === void 0 ? void 0 : step.id) !== null && _a !== void 0 ? _a : step === null || step === void 0 ? void 0 : step.key) !== null && _b !== void 0 ? _b : null;
|
|
83
|
-
const analytics = step === null || step === void 0 ? void 0 : step.analytics;
|
|
84
|
-
const metadata = Object.assign(Object.assign(Object.assign(Object.assign({ flowId, integrationId: flowId }, (step ? { stepCount: stepCount.current } : {})), (stepId !== null ? { stepId } : {})), analytics), properties);
|
|
85
|
-
try {
|
|
86
|
-
onEvent === null || onEvent === void 0 ? void 0 : onEvent(`Dynamic Flow - ${eventName}`, Object.assign({}, metadata));
|
|
87
|
-
}
|
|
88
|
-
catch (_c) { }
|
|
89
|
-
};
|
|
90
|
-
const logEvent = (level, message, properties) => {
|
|
91
|
-
var _a, _b;
|
|
92
|
-
const step = getStep();
|
|
93
|
-
const stepId = (_b = (_a = step === null || step === void 0 ? void 0 : step.id) !== null && _a !== void 0 ? _a : step === null || step === void 0 ? void 0 : step.key) !== null && _b !== void 0 ? _b : null;
|
|
94
|
-
try {
|
|
95
|
-
onLog === null || onLog === void 0 ? void 0 : onLog(level, message, Object.assign(Object.assign(Object.assign(Object.assign({}, properties), { flowId }), (stepId !== null ? { stepId } : {})), (rootComponent.hasStep() || initialStep ? { stepCount: stepCount.current } : {})));
|
|
96
|
-
}
|
|
97
|
-
catch (_c) { }
|
|
98
|
-
};
|
|
99
|
-
const closeWithError = (error, analytics, statusCode) => {
|
|
100
|
-
rootComponent.stop();
|
|
101
|
-
trackEvent('Failed', Object.assign({}, analytics));
|
|
102
|
-
logEvent('error', 'Dynamic Flow failed', { errorMessage: getErrorMessage(error), analytics });
|
|
103
|
-
onError(error, statusCode);
|
|
104
|
-
};
|
|
105
|
-
const closeWithCancellation = () => {
|
|
106
|
-
trackEvent('Cancelled');
|
|
107
|
-
onCancellation === null || onCancellation === void 0 ? void 0 : onCancellation();
|
|
108
|
-
};
|
|
109
|
-
const onBehavior = async (behavior) => {
|
|
110
|
-
var _a, _b, _c;
|
|
111
|
-
switch (behavior.type) {
|
|
112
|
-
case 'back': {
|
|
113
|
-
if (behavior.action) {
|
|
114
|
-
onAction(behavior.action, null)
|
|
115
|
-
.then(() => {
|
|
116
|
-
rootComponent.clearStack();
|
|
117
|
-
})
|
|
118
|
-
.catch(() => { });
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
if (features.isEnabled('nativeBack')) {
|
|
122
|
-
if (rootComponent.stepStack.length > 1) {
|
|
123
|
-
rootComponent.navigateBack();
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
closeWithCancellation();
|
|
127
|
-
}
|
|
128
|
-
rootComponent.setLoadingState('idle');
|
|
129
|
-
}
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
case 'action': {
|
|
133
|
-
if (rootComponent.isBusy()) {
|
|
134
|
-
return { abort: () => { } };
|
|
135
|
-
}
|
|
136
|
-
rootComponent.dismissAllModals();
|
|
137
|
-
const { action } = behavior;
|
|
138
|
-
const skipValidation = action.method === 'GET' || Boolean(action.skipValidation);
|
|
139
|
-
const canSubmit = skipValidation || rootComponent.validate();
|
|
140
|
-
try {
|
|
141
|
-
if (canSubmit) {
|
|
142
|
-
rootComponent.setLoadingState('submitting');
|
|
143
|
-
const model = await rootComponent.getSubmittableValue();
|
|
144
|
-
void onAction(action, model);
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
rootComponent.setLoadingState('idle');
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
catch (_d) {
|
|
151
|
-
// It's ok to ignore errors here because when this only throw when persisting fails.
|
|
152
|
-
// And when persisting fails, the UI is already showing an error.
|
|
153
|
-
// If persisting succeeded before, then it would NOT FAIL now,
|
|
154
|
-
// because we don't re-try persisting for successful fields when submitting.
|
|
155
|
-
rootComponent.setLoadingState('idle');
|
|
156
|
-
}
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
case 'copy': {
|
|
160
|
-
navigator.clipboard
|
|
161
|
-
.writeText(behavior.content)
|
|
162
|
-
.then(() => onCopy === null || onCopy === void 0 ? void 0 : onCopy(behavior.content))
|
|
163
|
-
.catch(() => onCopy === null || onCopy === void 0 ? void 0 : onCopy(null));
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
case 'non-merging-action': {
|
|
167
|
-
rootComponent.dismissAllModals();
|
|
168
|
-
const { action } = behavior;
|
|
169
|
-
rootComponent.setLoadingState('submitting');
|
|
170
|
-
void onAction(action, null);
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
case 'refresh': {
|
|
174
|
-
rootComponent.dismissAllModals();
|
|
175
|
-
void onRefresh({ refreshUrl: behavior.url, analytics: behavior.analytics });
|
|
176
|
-
return {
|
|
177
|
-
abort: () => {
|
|
178
|
-
abortController.abort();
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
case 'link': {
|
|
183
|
-
onLink(behavior.url);
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
|
-
case 'modal': {
|
|
187
|
-
const currentStep = (_a = rootComponent.getStep()) === null || _a === void 0 ? void 0 : _a.step;
|
|
188
|
-
if (currentStep) {
|
|
189
|
-
rootComponent.showModal(modalToComponent(rootComponent.uid, behavior, Object.assign(Object.assign({ step: currentStep, stepLocalValue: rootComponent.getLocalValue() }, getMapperProps()), { registerSubmissionBehavior: () => { } }), rootComponent.getSchemaComponents()));
|
|
190
|
-
}
|
|
191
|
-
rootComponent.setLoadingState('idle');
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
case 'dismiss':
|
|
195
|
-
rootComponent.dismissModal();
|
|
196
|
-
break;
|
|
197
|
-
case 'subflow': {
|
|
198
|
-
rootComponent.setLoadingState('submitting');
|
|
199
|
-
const { launchConfig } = behavior;
|
|
200
|
-
const { request, presentation } = launchConfig;
|
|
201
|
-
const callbacks = getSubflowCallbacks({
|
|
202
|
-
behavior,
|
|
203
|
-
close: () => rootComponent.closeSubflow(),
|
|
204
|
-
onBehavior,
|
|
205
|
-
onError: closeWithError,
|
|
206
|
-
onEvent: onEvent !== null && onEvent !== void 0 ? onEvent : noop,
|
|
207
|
-
restart: () => {
|
|
208
|
-
rootComponent.setLoadingState('idle');
|
|
209
|
-
rootComponent.start();
|
|
210
|
-
},
|
|
211
|
-
});
|
|
212
|
-
const component = createSubflowDomainComponent(Object.assign(Object.assign({}, callbacks), { initialRequest: request, requestCache: (_c = (_b = rootComponent.getStep()) === null || _b === void 0 ? void 0 : _b.requestCache) !== null && _c !== void 0 ? _c : rootComponent.requestCache, presentation }), onChange);
|
|
213
|
-
rootComponent.stop();
|
|
214
|
-
rootComponent.addSubflow(component);
|
|
215
|
-
break;
|
|
216
|
-
}
|
|
217
|
-
case 'none':
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
return { abort: () => { } };
|
|
221
|
-
};
|
|
222
|
-
const onAction = async (action, model) => {
|
|
223
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
224
|
-
try {
|
|
225
|
-
rootComponent.setLoadingState('submitting');
|
|
226
|
-
const command = await executeSubmission({
|
|
227
|
-
action,
|
|
228
|
-
model,
|
|
229
|
-
isInitial: !rootComponent.hasStep(),
|
|
230
|
-
requestCache: (_b = (_a = rootComponent.getStep()) === null || _a === void 0 ? void 0 : _a.requestCache) !== null && _b !== void 0 ? _b : rootComponent.requestCache,
|
|
231
|
-
httpClient,
|
|
232
|
-
trackEvent,
|
|
233
|
-
logEvent,
|
|
234
|
-
});
|
|
235
|
-
switch (command.type) {
|
|
236
|
-
case 'complete': {
|
|
237
|
-
onCompletion(command.result);
|
|
238
|
-
rootComponent.stop();
|
|
239
|
-
trackEvent('Succeeded');
|
|
240
|
-
break;
|
|
241
|
-
}
|
|
242
|
-
case 'replace-step': {
|
|
243
|
-
const isFirstStep = !rootComponent.hasStep();
|
|
244
|
-
rootComponent.closeSubflow();
|
|
245
|
-
createStep(command.step, command.etag);
|
|
246
|
-
trackEvent('Step Shown', { isFirstStep });
|
|
247
|
-
break;
|
|
248
|
-
}
|
|
249
|
-
case 'error': {
|
|
250
|
-
rootComponent.setLoadingState('idle');
|
|
251
|
-
const genericErrorMessage = getErrorMessageFunctions().genericErrorWithRetry();
|
|
252
|
-
const errors = (_d = (_c = command.body) === null || _c === void 0 ? void 0 : _c.errors) !== null && _d !== void 0 ? _d : { error: genericErrorMessage };
|
|
253
|
-
const currentStep = rootComponent.getStep();
|
|
254
|
-
if (currentStep) {
|
|
255
|
-
updateStep(Object.assign(Object.assign({}, currentStep.step), { errors, // but with the new errors
|
|
256
|
-
model, polling: undefined, external: undefined }), (_f = (_e = rootComponent.getStep()) === null || _e === void 0 ? void 0 : _e.etag) !== null && _f !== void 0 ? _f : null);
|
|
257
|
-
}
|
|
258
|
-
else {
|
|
259
|
-
const errorMessage = ((_h = (_g = command.body) === null || _g === void 0 ? void 0 : _g.errors) === null || _h === void 0 ? void 0 : _h.error) || ((_j = command.httpError) === null || _j === void 0 ? void 0 : _j.message) || 'Initial request failed';
|
|
260
|
-
closeWithError(new Error(errorMessage, {
|
|
261
|
-
cause: `method: ${action.method}, url: ${action.url}`,
|
|
262
|
-
}), {}, (_k = command.httpError) === null || _k === void 0 ? void 0 : _k.statusCode);
|
|
263
|
-
}
|
|
264
|
-
break;
|
|
265
|
-
}
|
|
266
|
-
case 'refresh': {
|
|
267
|
-
const { refreshUrl, errors = {} } = command.body;
|
|
268
|
-
void onRefresh({ refreshUrl, errorsOverride: errors });
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
case 'behavior': {
|
|
272
|
-
void onBehavior(command.behavior);
|
|
273
|
-
rootComponent.setLoadingState('idle');
|
|
274
|
-
break;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
catch (error) {
|
|
279
|
-
closeWithError(error);
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
const onRefresh = async ({ refreshUrl, errorsOverride, analytics, }) => {
|
|
283
|
-
var _a, _b, _c;
|
|
284
|
-
try {
|
|
285
|
-
rootComponent.setLoadingState('refreshing');
|
|
286
|
-
const model = rootComponent.getSubmittableValueSync();
|
|
287
|
-
const command = await executeRefresh({
|
|
288
|
-
abortSignal: abortController.abortAndGetNewSignal(),
|
|
289
|
-
url: (_a = refreshUrl !== null && refreshUrl !== void 0 ? refreshUrl : rootComponent.getRefreshUrl()) !== null && _a !== void 0 ? _a : '',
|
|
290
|
-
model,
|
|
291
|
-
etag: (_c = (_b = rootComponent.getStep()) === null || _b === void 0 ? void 0 : _b.etag) !== null && _c !== void 0 ? _c : null,
|
|
292
|
-
analytics,
|
|
293
|
-
httpClient,
|
|
294
|
-
trackEvent,
|
|
295
|
-
logEvent,
|
|
296
|
-
});
|
|
297
|
-
switch (command.type) {
|
|
298
|
-
case 'refresh-step':
|
|
299
|
-
{
|
|
300
|
-
const errors = errorsOverride !== null && errorsOverride !== void 0 ? errorsOverride : command.step.errors;
|
|
301
|
-
updateStep(Object.assign(Object.assign({}, command.step), { errors }), command.etag);
|
|
302
|
-
}
|
|
303
|
-
break;
|
|
304
|
-
case 'noop':
|
|
305
|
-
rootComponent.setLoadingState('idle');
|
|
306
|
-
break;
|
|
307
|
-
case 'error': {
|
|
308
|
-
closeWithError(new Error('Failed to refresh'), command.body.analytics, command.statusCode);
|
|
309
|
-
break;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
catch (error) {
|
|
314
|
-
// this should never happen. executeRefresh never throws
|
|
315
|
-
closeWithError(error, undefined);
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
const onPoll = async (url, errorBehavior, signal) => {
|
|
319
|
-
const command = await executePoll({
|
|
320
|
-
httpClient,
|
|
321
|
-
url,
|
|
322
|
-
errorBehavior,
|
|
323
|
-
signal,
|
|
324
|
-
trackEvent,
|
|
325
|
-
});
|
|
326
|
-
switch (command.type) {
|
|
327
|
-
case 'replace-step':
|
|
328
|
-
createStep(command.step, command.etag);
|
|
329
|
-
return true;
|
|
330
|
-
case 'behavior':
|
|
331
|
-
void onBehavior(command.behavior);
|
|
332
|
-
return true;
|
|
333
|
-
case 'complete':
|
|
334
|
-
onCompletion(command.result);
|
|
335
|
-
return true;
|
|
336
|
-
case 'continue':
|
|
337
|
-
return false;
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
let initState = 'initial';
|
|
341
|
-
if (initialStep) {
|
|
342
|
-
initState = 'created';
|
|
343
|
-
trackEvent('Initiated');
|
|
344
|
-
createStep(initialStep, null);
|
|
345
|
-
trackEvent('Step Shown', { isFirstStep: true });
|
|
346
|
-
}
|
|
347
|
-
const start = () => {
|
|
348
|
-
if (initState === 'initial' && initialAction) {
|
|
349
|
-
initState = 'created';
|
|
350
|
-
trackEvent('Initiated');
|
|
351
|
-
rootComponent.setLoadingState('submitting');
|
|
352
|
-
void onAction(Object.assign({ method: 'GET' }, initialAction), null).then(() => {
|
|
353
|
-
initState = 'started';
|
|
354
|
-
rootComponent.start();
|
|
355
|
-
});
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
|
-
if (initState === 'created') {
|
|
359
|
-
initState = 'started';
|
|
360
|
-
rootComponent.start();
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
return {
|
|
364
|
-
rootComponent,
|
|
365
|
-
start,
|
|
366
|
-
cancel: closeWithCancellation,
|
|
367
|
-
};
|
|
368
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { getResponseTypeFromHeader } from './getResponseType';
|
|
2
|
-
import { assertActionResponseBody, assertStepResponseBody, isActionResponseBody, parseResponseBodyAsJsonElement, } from './response-utils';
|
|
3
|
-
export const executePoll = async (props) => {
|
|
4
|
-
const { errorBehavior, signal, url, httpClient, trackEvent } = props;
|
|
5
|
-
try {
|
|
6
|
-
const response = await httpClient(url !== null && url !== void 0 ? url : '', {
|
|
7
|
-
method: 'GET',
|
|
8
|
-
signal,
|
|
9
|
-
});
|
|
10
|
-
if (!response.ok) {
|
|
11
|
-
trackEvent('Polling Failed', { url, statusCode: response.status, variant: 'revamp' });
|
|
12
|
-
return { type: 'behavior', behavior: errorBehavior };
|
|
13
|
-
}
|
|
14
|
-
const responseType = getResponseTypeFromHeader(response.headers);
|
|
15
|
-
const body = await parseResponseBodyAsJsonElement(response);
|
|
16
|
-
try {
|
|
17
|
-
switch (responseType) {
|
|
18
|
-
case 'step': {
|
|
19
|
-
const etag = response.headers.get('etag') || null;
|
|
20
|
-
assertStepResponseBody(body);
|
|
21
|
-
return { type: 'replace-step', step: body, etag };
|
|
22
|
-
}
|
|
23
|
-
case 'exit': {
|
|
24
|
-
return { type: 'complete', result: body };
|
|
25
|
-
}
|
|
26
|
-
case 'action': {
|
|
27
|
-
assertActionResponseBody(body);
|
|
28
|
-
return { type: 'behavior', behavior: actionResponseBodyToBehavior(body) };
|
|
29
|
-
}
|
|
30
|
-
default: {
|
|
31
|
-
if (isActionResponseBody(body)) {
|
|
32
|
-
return { type: 'behavior', behavior: actionResponseBodyToBehavior(body) };
|
|
33
|
-
}
|
|
34
|
-
return { type: 'continue' };
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch (_a) {
|
|
39
|
-
return { type: 'behavior', behavior: errorBehavior };
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
catch (_b) {
|
|
43
|
-
return { type: 'continue' };
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
const actionResponseBodyToBehavior = (body) => ({
|
|
47
|
-
type: 'non-merging-action',
|
|
48
|
-
action: body.action,
|
|
49
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { getErrorMessage } from './getErrorMessage';
|
|
2
|
-
import { assertStepResponseBody, isErrorResponseBody, parseResponseBodyAsJsonElement, } from './response-utils';
|
|
3
|
-
export const executeRefresh = async (props) => {
|
|
4
|
-
const { abortSignal, url, model, etag, analytics, httpClient, trackEvent, logEvent } = props;
|
|
5
|
-
trackEvent('Refresh Triggered', analytics);
|
|
6
|
-
try {
|
|
7
|
-
const response = await httpClient(url !== null && url !== void 0 ? url : '', {
|
|
8
|
-
method: 'POST',
|
|
9
|
-
body: JSON.stringify(model),
|
|
10
|
-
headers: Object.assign({ 'Content-Type': 'application/json' }, (etag ? { 'If-None-Match': etag } : {})),
|
|
11
|
-
signal: abortSignal,
|
|
12
|
-
});
|
|
13
|
-
if (response.status === 304) {
|
|
14
|
-
trackEvent('Refresh Succeeded', analytics);
|
|
15
|
-
return { type: 'noop' };
|
|
16
|
-
}
|
|
17
|
-
if (!response.ok) {
|
|
18
|
-
const responseBody = await parseResponseBodyAsJsonElement(response).catch(() => ({}));
|
|
19
|
-
const body = isErrorResponseBody(responseBody) ? responseBody : {};
|
|
20
|
-
trackEvent('Refresh Failed', Object.assign(Object.assign(Object.assign({}, analytics), body.analytics), { statusCode: response.status }));
|
|
21
|
-
logEvent('error', 'Dynamic Flow - Refresh Failed', Object.assign(Object.assign({}, analytics), { statusCode: response.status }));
|
|
22
|
-
return { type: 'error', body, statusCode: response.status };
|
|
23
|
-
}
|
|
24
|
-
const newEtag = response.headers.get('etag') || null;
|
|
25
|
-
const body = await parseResponseBodyAsJsonElement(response);
|
|
26
|
-
assertStepResponseBody(body);
|
|
27
|
-
trackEvent('Refresh Succeeded', analytics);
|
|
28
|
-
return { type: 'refresh-step', step: body, etag: newEtag };
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
if (error instanceof DOMException && error.name === 'AbortError') {
|
|
32
|
-
trackEvent('Refresh Aborted', analytics);
|
|
33
|
-
return { type: 'noop' };
|
|
34
|
-
}
|
|
35
|
-
trackEvent('Refresh Failed', analytics);
|
|
36
|
-
logEvent('error', 'Dynamic Flow - Refresh Failed', Object.assign(Object.assign({}, analytics), { errorMessage: getErrorMessage(error) }));
|
|
37
|
-
return { type: 'error', body: {} };
|
|
38
|
-
}
|
|
39
|
-
};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { handleErrorResponse } from './handleErrorResponse';
|
|
2
|
-
import { getResponseType } from './getResponseType';
|
|
3
|
-
import { assertActionResponseBody, assertModalResponseBody, assertStepResponseBody, assertSubflowResponseBody, parseResponseBodyAsJsonElement, } from './response-utils';
|
|
4
|
-
import { makeSafeHttpClient } from './makeSafeHttpClient';
|
|
5
|
-
import { normaliseBehavior } from '../domain/mappers/utils/behavior-utils';
|
|
6
|
-
export const executeRequest = async (props) => {
|
|
7
|
-
const { exit, request, requestCache, httpClient, trackEvent, logEvent } = props;
|
|
8
|
-
const { url, method, body } = request;
|
|
9
|
-
const response = await getCachedOrFetch([
|
|
10
|
-
url,
|
|
11
|
-
{
|
|
12
|
-
method,
|
|
13
|
-
body: body ? JSON.stringify(body) : undefined,
|
|
14
|
-
headers: { 'Content-Type': 'application/json' },
|
|
15
|
-
},
|
|
16
|
-
], requestCache, httpClient);
|
|
17
|
-
if (!response) {
|
|
18
|
-
const extra = { errorMessage: 'Network Error' };
|
|
19
|
-
trackEvent('Request Failed', extra);
|
|
20
|
-
logEvent('error', 'Dynamic Flow - Request Failed Unexpectedly', extra);
|
|
21
|
-
return { type: 'error' };
|
|
22
|
-
}
|
|
23
|
-
if (!response.ok) {
|
|
24
|
-
return handleErrorResponse(response, undefined, trackEvent);
|
|
25
|
-
}
|
|
26
|
-
const responseBody = await parseResponseBodyAsJsonElement(response);
|
|
27
|
-
const responseType = getResponseType(response.headers, responseBody);
|
|
28
|
-
if (exit) {
|
|
29
|
-
return { type: 'complete', result: responseBody };
|
|
30
|
-
}
|
|
31
|
-
switch (responseType) {
|
|
32
|
-
case 'step': {
|
|
33
|
-
const etag = response.headers.get('etag') || null;
|
|
34
|
-
assertStepResponseBody(responseBody);
|
|
35
|
-
return { type: 'replace-step', step: responseBody, etag };
|
|
36
|
-
}
|
|
37
|
-
case 'exit': {
|
|
38
|
-
return { type: 'complete', result: responseBody };
|
|
39
|
-
}
|
|
40
|
-
case 'action': {
|
|
41
|
-
assertActionResponseBody(responseBody);
|
|
42
|
-
return {
|
|
43
|
-
type: 'behavior',
|
|
44
|
-
behavior: {
|
|
45
|
-
type: 'action',
|
|
46
|
-
action: responseBody.action,
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
case 'subflow': {
|
|
51
|
-
assertSubflowResponseBody(responseBody);
|
|
52
|
-
return {
|
|
53
|
-
type: 'behavior',
|
|
54
|
-
behavior: Object.assign(Object.assign({}, responseBody), { type: 'subflow', onCompletion: responseBody.onCompletion
|
|
55
|
-
? normaliseBehavior(responseBody.onCompletion, [])
|
|
56
|
-
: undefined, onError: responseBody.onError ? normaliseBehavior(responseBody.onError, []) : undefined }),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
case 'modal': {
|
|
60
|
-
assertModalResponseBody(responseBody);
|
|
61
|
-
return { type: 'behavior', behavior: Object.assign(Object.assign({}, responseBody), { type: 'modal' }) };
|
|
62
|
-
}
|
|
63
|
-
default: {
|
|
64
|
-
throw new Error(`Unsupported response type: ${String(responseType)}`);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
const getCachedOrFetch = async (requestParams, requestCache, httpClient) => {
|
|
69
|
-
const cachedPromise = requestCache.get(requestParams);
|
|
70
|
-
if (cachedPromise) {
|
|
71
|
-
const cachedResponse = await cachedPromise;
|
|
72
|
-
if (cachedResponse === null || cachedResponse === void 0 ? void 0 : cachedResponse.ok) {
|
|
73
|
-
return cachedResponse;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return makeSafeHttpClient(httpClient)(...requestParams);
|
|
77
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { recursiveMerge } from '../utils/recursiveMerge';
|
|
2
|
-
import { getErrorMessage } from './getErrorMessage';
|
|
3
|
-
import { executeRequest } from './executeRequest';
|
|
4
|
-
export const executeSubmission = async (props) => {
|
|
5
|
-
const { httpClient, requestCache, trackEvent, logEvent } = props;
|
|
6
|
-
const triggerAction = async (action, model, isInitial) => {
|
|
7
|
-
var _a, _b;
|
|
8
|
-
const { exit, url, result = null, id: actionId } = action;
|
|
9
|
-
const trackSubmissionEvent = !isInitial ? trackEvent : () => { };
|
|
10
|
-
trackSubmissionEvent('Action Triggered', { actionId });
|
|
11
|
-
if (exit && !url) {
|
|
12
|
-
trackSubmissionEvent('Action Succeeded', { actionId });
|
|
13
|
-
return { type: 'complete', result };
|
|
14
|
-
}
|
|
15
|
-
try {
|
|
16
|
-
const command = await executeRequest({
|
|
17
|
-
exit,
|
|
18
|
-
request: createRequestFromAction(action, model),
|
|
19
|
-
requestCache,
|
|
20
|
-
httpClient,
|
|
21
|
-
trackEvent: (name, properties) => {
|
|
22
|
-
trackSubmissionEvent(name, Object.assign(Object.assign({}, properties), { actionId }));
|
|
23
|
-
},
|
|
24
|
-
logEvent,
|
|
25
|
-
});
|
|
26
|
-
switch (command.type) {
|
|
27
|
-
case 'error': {
|
|
28
|
-
trackSubmissionEvent('Action Failed', Object.assign({ actionId, statusCode: (_a = command.httpError) === null || _a === void 0 ? void 0 : _a.statusCode }, (_b = command.body) === null || _b === void 0 ? void 0 : _b.analytics));
|
|
29
|
-
return command;
|
|
30
|
-
}
|
|
31
|
-
case 'behavior': {
|
|
32
|
-
if (command.behavior.type === 'action') {
|
|
33
|
-
trackSubmissionEvent('Action Succeeded', { actionId });
|
|
34
|
-
return await executeSubmission({
|
|
35
|
-
action: command.behavior.action,
|
|
36
|
-
isInitial: false,
|
|
37
|
-
model: null,
|
|
38
|
-
requestCache,
|
|
39
|
-
httpClient,
|
|
40
|
-
trackEvent,
|
|
41
|
-
logEvent,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
trackSubmissionEvent('Action Succeeded', { actionId });
|
|
45
|
-
return command;
|
|
46
|
-
}
|
|
47
|
-
case 'complete': {
|
|
48
|
-
trackSubmissionEvent('Action Succeeded', { actionId });
|
|
49
|
-
return Object.assign(Object.assign({}, command), { result: recursiveMerge(command.result, result) });
|
|
50
|
-
}
|
|
51
|
-
default: {
|
|
52
|
-
trackSubmissionEvent('Action Succeeded', { actionId });
|
|
53
|
-
return command;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
const errorMessage = getErrorMessage(error);
|
|
59
|
-
trackSubmissionEvent('Action Failed', { actionId, errorMessage });
|
|
60
|
-
logEvent('error', 'Dynamic Flow - Action Failed Unexpectedly', { actionId, errorMessage });
|
|
61
|
-
throw error;
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
return triggerAction(props.action, props.model, props.isInitial);
|
|
65
|
-
};
|
|
66
|
-
export const createRequestFromAction = (action, model) => {
|
|
67
|
-
var _a, _b, _c;
|
|
68
|
-
return (Object.assign(Object.assign({}, action), { url: (_a = action.url) !== null && _a !== void 0 ? _a : '', method: (_b = action.method) !== null && _b !== void 0 ? _b : 'POST', body: action.method === 'GET' ? undefined : recursiveMerge(model, (_c = action.data) !== null && _c !== void 0 ? _c : null) }));
|
|
69
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export const getRequestAbortController = () => {
|
|
2
|
-
let abortController = new AbortController();
|
|
3
|
-
return {
|
|
4
|
-
abortAndGetNewSignal() {
|
|
5
|
-
abortController.abort();
|
|
6
|
-
abortController = new AbortController();
|
|
7
|
-
return abortController.signal;
|
|
8
|
-
},
|
|
9
|
-
abort() {
|
|
10
|
-
abortController.abort();
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { isObject } from '../utils/type-validators';
|
|
2
|
-
const responseTypes = ['step', 'action', 'exit', 'modal', 'subflow'];
|
|
3
|
-
/**
|
|
4
|
-
* Returns either 'step', 'action', or 'exit' based on the response headers and body.
|
|
5
|
-
* This function takes a response body parameter because, for legacy reasons, we still need to consider the body
|
|
6
|
-
* to determine the response type, in cases where the response headers are not set.
|
|
7
|
-
* Ideally it should just be a matter of checking the "X-Df-Response-Type" response header.
|
|
8
|
-
*/
|
|
9
|
-
export const getResponseType = (headers, body) => {
|
|
10
|
-
const headerResponseType = getResponseTypeFromHeader(headers);
|
|
11
|
-
if (headerResponseType) {
|
|
12
|
-
return headerResponseType;
|
|
13
|
-
}
|
|
14
|
-
if (isObject(body) && body.action) {
|
|
15
|
-
// TODO: use Zod to validate the action object
|
|
16
|
-
return 'action';
|
|
17
|
-
}
|
|
18
|
-
return 'step';
|
|
19
|
-
};
|
|
20
|
-
export const getResponseTypeFromHeader = (headers) => {
|
|
21
|
-
if (headers === null || headers === void 0 ? void 0 : headers.has('X-Df-Response-Type')) {
|
|
22
|
-
const type = headers.get('X-Df-Response-Type');
|
|
23
|
-
assertDFResponseType(type);
|
|
24
|
-
return type;
|
|
25
|
-
}
|
|
26
|
-
if (headers === null || headers === void 0 ? void 0 : headers.has('X-Df-Exit')) {
|
|
27
|
-
return 'exit';
|
|
28
|
-
}
|
|
29
|
-
return undefined;
|
|
30
|
-
};
|
|
31
|
-
function assertDFResponseType(type) {
|
|
32
|
-
if (!responseTypes.includes(type)) {
|
|
33
|
-
throw new Error("Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit', 'error', 'modal', 'subflow'.");
|
|
34
|
-
}
|
|
35
|
-
}
|