@wise/dynamic-flow-client 0.4.2 → 0.4.3
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 +9606 -0
- package/build/main.min.js +31 -0
- package/build/types/index.d.ts +11 -15
- package/build/types/types/index.d.ts +15 -0
- package/package.json +6 -5
- package/build/common/constants/DateMode.js +0 -7
- package/build/common/constants/FormControlType.js +0 -20
- package/build/common/constants/MonthFormat.js +0 -7
- package/build/common/constants/SchemaType.js +0 -14
- package/build/common/constants/Size.js +0 -10
- package/build/common/constants/index.js +0 -21
- package/build/common/contexts/dynamicFlowContexts/DynamicFlowContexts.js +0 -29
- package/build/common/contexts/dynamicFlowContexts/usePendingPromiseCounter.js +0 -19
- package/build/common/contexts/eventsContext/EventsContext.js +0 -22
- package/build/common/contexts/fetcherContexts/FetcherContexts.js +0 -29
- package/build/common/contexts/index.js +0 -20
- package/build/common/contexts/logContext/LogContext.js +0 -27
- package/build/common/hooks/index.js +0 -23
- package/build/common/hooks/useDebouncedFunction/useDebouncedFunction.js +0 -13
- package/build/common/hooks/useExternal/useExternal.js +0 -19
- package/build/common/hooks/useExternalStepPolling/useExternalStepPolling.js +0 -62
- package/build/common/hooks/usePersistAsync/usePersistAsync.js +0 -98
- package/build/common/hooks/usePolling/usePolling.js +0 -52
- package/build/common/hooks/usePrevious/usePrevious.js +0 -12
- package/build/common/hooks/useStepPolling/useStepPolling.js +0 -49
- package/build/common/makeFetcher/index.js +0 -17
- package/build/common/makeFetcher/makeFetcher.js +0 -23
- package/build/common/messages.js +0 -10
- package/build/common/utils/api-utils.js +0 -19
- package/build/common/utils/date-utils.js +0 -27
- package/build/common/utils/debounce.js +0 -38
- package/build/common/utils/file-utils.js +0 -38
- package/build/common/utils/id-utils.js +0 -8
- package/build/common/utils/index.js +0 -24
- package/build/common/utils/is-equal.js +0 -25
- package/build/common/utils/schema-utils.js +0 -55
- package/build/common/utils/step-utils.js +0 -47
- package/build/common/validators/index.js +0 -28
- package/build/common/validators/models/model-validators.js +0 -69
- package/build/common/validators/models/models.utils.js +0 -117
- package/build/common/validators/schemas/schema-validators.js +0 -99
- package/build/common/validators/types/type-validators.js +0 -21
- package/build/common/validators/validationFailures/validation-failures.js +0 -151
- package/build/common/validators/validationFailures/validation-failures.utils.js +0 -49
- package/build/common/validators/values/value-validators.js +0 -7
- package/build/dynamicFlow/DynamicFlow.js +0 -250
- package/build/dynamicFlow/DynamicFlowStep.js +0 -25
- package/build/dynamicFlow/DynamicFlowTypes.js +0 -8
- package/build/dynamicFlow/index.js +0 -8
- package/build/dynamicFlow/stories/DynamicFlow.story.js +0 -36
- package/build/dynamicFlow/stories/EditableDynamicFlow.js +0 -54
- package/build/dynamicFlow/stories/fixtureFetcher.js +0 -60
- package/build/dynamicFlow/utils/errorBoundary/ErrorBoundary.js +0 -29
- package/build/dynamicFlow/utils/errorBoundary/ErrorBoundary.messages.js +0 -15
- package/build/dynamicFlow/utils/errorBoundary/ErrorBoundaryAlert.js +0 -18
- package/build/dynamicFlow/utils/index.js +0 -26
- package/build/dynamicFlow/utils/responseParsers/response-parsers.js +0 -66
- package/build/dynamicFlow/utils/useDebouncedRefresh/useDebouncedRefresh.js +0 -27
- package/build/dynamicFlow/utils/useDynamicFlowState.js +0 -91
- package/build/dynamicFlow/utils/useLoader.js +0 -15
- package/build/fixtures/components/alert.js +0 -33
- package/build/fixtures/components/box.js +0 -22
- package/build/fixtures/components/button.js +0 -56
- package/build/fixtures/components/columns.js +0 -38
- package/build/fixtures/components/copyable.js +0 -24
- package/build/fixtures/components/decision.js +0 -56
- package/build/fixtures/components/heading.js +0 -16
- package/build/fixtures/components/image.js +0 -25
- package/build/fixtures/components/index.js +0 -32
- package/build/fixtures/components/info.js +0 -35
- package/build/fixtures/components/list.js +0 -36
- package/build/fixtures/components/loading-indicator.js +0 -18
- package/build/fixtures/components/paragraph.js +0 -30
- package/build/fixtures/components/review.js +0 -62
- package/build/fixtures/examples/camera-capture.js +0 -123
- package/build/fixtures/examples/index.js +0 -16
- package/build/fixtures/examples/recipient-update.js +0 -252
- package/build/fixtures/examples/recipient.js +0 -315
- package/build/fixtures/examples/single-file-upload.js +0 -100
- package/build/fixtures/examples/step-validation-errors.js +0 -77
- package/build/fixtures/features/action-response.js +0 -31
- package/build/fixtures/features/external.js +0 -33
- package/build/fixtures/features/index.js +0 -16
- package/build/fixtures/features/persist-async.js +0 -46
- package/build/fixtures/features/polling.js +0 -35
- package/build/fixtures/features/validation-async.js +0 -40
- package/build/fixtures/index.js +0 -38
- package/build/fixtures/jsonSchemaForm/allOf.js +0 -121
- package/build/fixtures/jsonSchemaForm/audRecipient.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/audRecipient.js +0 -1106
- package/build/fixtures/jsonSchemaForm/currency.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/currency.js +0 -50
- package/build/fixtures/jsonSchemaForm/multipleFileUploadBase64.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/multipleFileUploadBase64.js +0 -39
- package/build/fixtures/jsonSchemaForm/multipleFileUploadBlob.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/multipleFileUploadBlob.js +0 -38
- package/build/fixtures/jsonSchemaForm/oneOf.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/oneOf.js +0 -121
- package/build/fixtures/jsonSchemaForm/oneOfTabs.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/oneOfTabs.js +0 -55
- package/build/fixtures/jsonSchemaForm/promotedOneOf.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/promotedOneOf.js +0 -58
- package/build/fixtures/jsonSchemaForm/promotedOneOfCheckbox.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/promotedOneOfCheckbox.js +0 -104
- package/build/fixtures/jsonSchemaForm/simple.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/simple.js +0 -50
- package/build/fixtures/jsonSchemaForm/uploadPersistAsync.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/uploadPersistAsync.js +0 -73
- package/build/fixtures/jsonSchemaForm/validationAsync.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/validationAsync.js +0 -25
- package/build/fixtures/layouts/all.js +0 -178
- package/build/fixtures/layouts/final-step-layout.js +0 -41
- package/build/fixtures/layouts/index.js +0 -18
- package/build/fixtures/layouts/list.js +0 -35
- package/build/fixtures/layouts/pay-in.js +0 -99
- package/build/fixtures/layouts/review.js +0 -162
- package/build/fixtures/layouts/success.js +0 -68
- package/build/fixtures/responses/action-response-final.js +0 -26
- package/build/fixtures/responses/action.js +0 -4
- package/build/fixtures/responses/exit.js +0 -4
- package/build/fixtures/responses/index.js +0 -14
- package/build/fixtures/responses/recipient-update-final.js +0 -26
- package/build/fixtures/schemas/basic-form.js +0 -41
- package/build/fixtures/schemas/index.js +0 -14
- package/build/fixtures/schemas/number-and-integer.js +0 -43
- package/build/fixtures/schemas/one-of.js +0 -222
- package/build/fixtures/schemas/string-formats.js +0 -64
- package/build/fixtures/utils/image-util.js +0 -22
- package/build/formControl/FormControl.js +0 -213
- package/build/formControl/index.js +0 -8
- package/build/formControl/utils/index.js +0 -17
- package/build/formControl/utils/value-utils.js +0 -111
- package/build/i18n/index.js +0 -36
- package/build/index.d.ts +0 -11
- package/build/index.js +0 -38
- package/build/jsonSchemaForm/JsonSchemaForm.js +0 -22
- package/build/jsonSchemaForm/allOfSchema/AllOfSchema.js +0 -46
- package/build/jsonSchemaForm/allOfSchema/index.js +0 -8
- package/build/jsonSchemaForm/arrayTypeSchema/ArraySchema.js +0 -19
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.js +0 -20
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/index.js +0 -8
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.js +0 -86
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.messages.js +0 -20
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/index.js +0 -8
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/index.js +0 -18
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/upload-utils.js +0 -38
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/useFormattedDefaultErrorMessages.js +0 -20
- package/build/jsonSchemaForm/arrayTypeSchema/index.js +0 -8
- package/build/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.js +0 -91
- package/build/jsonSchemaForm/basicTypeSchema/index.js +0 -8
- package/build/jsonSchemaForm/controlFeedback/ControlFeedback.js +0 -73
- package/build/jsonSchemaForm/controlFeedback/ControlFeedback.messages.js +0 -55
- package/build/jsonSchemaForm/controlFeedback/index.js +0 -8
- package/build/jsonSchemaForm/genericSchema/GenericSchema.js +0 -118
- package/build/jsonSchemaForm/genericSchema/index.js +0 -8
- package/build/jsonSchemaForm/help/Help.js +0 -14
- package/build/jsonSchemaForm/help/Help.messages.js +0 -10
- package/build/jsonSchemaForm/help/index.js +0 -8
- package/build/jsonSchemaForm/index.js +0 -8
- package/build/jsonSchemaForm/objectSchema/ObjectSchema.js +0 -62
- package/build/jsonSchemaForm/objectSchema/index.js +0 -8
- package/build/jsonSchemaForm/oneOfSchema/OneOfSchema.js +0 -135
- package/build/jsonSchemaForm/oneOfSchema/index.js +0 -8
- package/build/jsonSchemaForm/oneOfSchema/utils/const-schema-utils.js +0 -13
- package/build/jsonSchemaForm/oneOfSchema/utils/index.js +0 -18
- package/build/jsonSchemaForm/oneOfSchema/utils/one-of-utils.js +0 -69
- package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.js +0 -20
- package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.messages.js +0 -10
- package/build/jsonSchemaForm/persistAsyncSchema/index.js +0 -8
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.js +0 -119
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/index.js +0 -8
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.js +0 -66
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.js +0 -36
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/index.js +0 -8
- package/build/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.js +0 -58
- package/build/jsonSchemaForm/promotedOneOfSchema/index.js +0 -8
- package/build/jsonSchemaForm/promotedOneOfSchema/promoted-one-of-utils.js +0 -12
- package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfCheckboxControl.js +0 -18
- package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfControl.js +0 -25
- package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfRadioControl.js +0 -23
- package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.js +0 -58
- package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.js +0 -15
- package/build/jsonSchemaForm/readOnlySchema/index.js +0 -8
- package/build/jsonSchemaForm/schemaFormControl/SchemaFormControl.js +0 -98
- package/build/jsonSchemaForm/schemaFormControl/index.js +0 -8
- package/build/jsonSchemaForm/schemaFormControl/utils/currency-utils.js +0 -77
- package/build/jsonSchemaForm/schemaFormControl/utils/index.js +0 -17
- package/build/jsonSchemaForm/schemaFormControl/utils/mapping-utils.js +0 -110
- package/build/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.js +0 -89
- package/build/jsonSchemaForm/validationAsyncSchema/index.js +0 -8
- package/build/layout/DynamicLayout.js +0 -52
- package/build/layout/alert/DynamicAlert.js +0 -31
- package/build/layout/box/DynamicBox.js +0 -32
- package/build/layout/button/DynamicButton.js +0 -49
- package/build/layout/columns/DynamicColumns.js +0 -29
- package/build/layout/decision/DynamicDecision.js +0 -29
- package/build/layout/divider/DynamicDivider.js +0 -10
- package/build/layout/external/DynamicExternal.js +0 -25
- package/build/layout/external/DynamicExternal.messages.js +0 -10
- package/build/layout/form/DynamicForm.js +0 -16
- package/build/layout/heading/DynamicHeading.js +0 -22
- package/build/layout/icon/DynamicIcon.js +0 -49
- package/build/layout/image/DynamicImage.js +0 -62
- package/build/layout/index.js +0 -40
- package/build/layout/info/DynamicInfo.js +0 -9
- package/build/layout/list/DynamicList.js +0 -21
- package/build/layout/loadingIndicator/DynamicLoadingIndicator.js +0 -12
- package/build/layout/paragraph/DynamicParagraph.js +0 -30
- package/build/layout/paragraph/DynamicParagraph.messages.js +0 -15
- package/build/layout/paragraph/useSnackBarIfAvailable.js +0 -13
- package/build/layout/review/DynamicReview.js +0 -23
- package/build/layout/utils.js +0 -33
- package/build/step/cameraStep/CameraStep.js +0 -84
- package/build/step/cameraStep/cameraCapture/CameraCapture.js +0 -70
- package/build/step/cameraStep/cameraCapture/CameraCapture.messages.js +0 -20
- package/build/step/cameraStep/cameraCapture/components/index.js +0 -18
- package/build/step/cameraStep/cameraCapture/hooks/index.js +0 -29
- package/build/step/cameraStep/cameraCapture/index.js +0 -8
- package/build/step/cameraStep/cameraCapture/overlay/Overlay.js +0 -68
- package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.js +0 -13
- package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.messages.js +0 -15
- package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.js +0 -14
- package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.messages.js +0 -20
- package/build/step/cameraStep/cameraCapture/screens/index.js +0 -10
- package/build/step/cameraStep/cameraCapture/tracking/index.js +0 -22
- package/build/step/cameraStep/cameraCapture/utils/index.js +0 -51
- package/build/step/cameraStep/index.js +0 -8
- package/build/step/externalConfirmationStep/ExternalConfirmationStep.js +0 -68
- package/build/step/externalConfirmationStep/ExternalConfirmationStep.messages.js +0 -25
- package/build/step/externalConfirmationStep/index.js +0 -8
- package/build/step/index.js +0 -12
- package/build/step/layoutStep/LayoutStep.js +0 -35
- package/build/step/layoutStep/index.js +0 -8
- package/build/step/layoutStep/utils/index.js +0 -7
- package/build/step/layoutStep/utils/inline-reference-utils.js +0 -78
- package/build/step/layoutStep/utils/layout-utils.js +0 -203
- package/build/types/common/FormControl.js +0 -2
- package/build/types/index.js +0 -42
- package/build/types/specification/Action.js +0 -2
- package/build/types/specification/FileUploadSchema.js +0 -8
- package/build/types/specification/LayoutComponent.js +0 -2
- package/build/types/specification/Model.js +0 -30
- package/build/types/specification/PersistAsync.js +0 -2
- package/build/types/specification/Polling.js +0 -2
- package/build/types/specification/Promotion.js +0 -2
- package/build/types/specification/Schema.js +0 -67
- package/build/types/specification/Step.js +0 -6
- package/build/types/specification/ValidationAsync.js +0 -2
- package/build/types/specification/core.js +0 -2
- /package/build/{common → types/common}/constants/DateMode.d.ts +0 -0
- /package/build/{common → types/common}/constants/FormControlType.d.ts +0 -0
- /package/build/{common → types/common}/constants/MonthFormat.d.ts +0 -0
- /package/build/{common → types/common}/constants/SchemaType.d.ts +0 -0
- /package/build/{common → types/common}/constants/Size.d.ts +0 -0
- /package/build/{common → types/common}/constants/index.d.ts +0 -0
- /package/build/{common → types/common}/contexts/dynamicFlowContexts/DynamicFlowContexts.d.ts +0 -0
- /package/build/{common → types/common}/contexts/dynamicFlowContexts/usePendingPromiseCounter.d.ts +0 -0
- /package/build/{common → types/common}/contexts/eventsContext/EventsContext.d.ts +0 -0
- /package/build/{common → types/common}/contexts/fetcherContexts/FetcherContexts.d.ts +0 -0
- /package/build/{common → types/common}/contexts/index.d.ts +0 -0
- /package/build/{common → types/common}/contexts/logContext/LogContext.d.ts +0 -0
- /package/build/{common → types/common}/hooks/index.d.ts +0 -0
- /package/build/{common → types/common}/hooks/useDebouncedFunction/useDebouncedFunction.d.ts +0 -0
- /package/build/{common → types/common}/hooks/useExternal/useExternal.d.ts +0 -0
- /package/build/{common → types/common}/hooks/useExternalStepPolling/useExternalStepPolling.d.ts +0 -0
- /package/build/{common → types/common}/hooks/usePersistAsync/usePersistAsync.d.ts +0 -0
- /package/build/{common → types/common}/hooks/usePolling/usePolling.d.ts +0 -0
- /package/build/{common → types/common}/hooks/usePrevious/usePrevious.d.ts +0 -0
- /package/build/{common → types/common}/hooks/useStepPolling/useStepPolling.d.ts +0 -0
- /package/build/{common → types/common}/makeFetcher/index.d.ts +0 -0
- /package/build/{common → types/common}/makeFetcher/makeFetcher.d.ts +0 -0
- /package/build/{common → types/common}/messages.d.ts +0 -0
- /package/build/{common → types/common}/utils/api-utils.d.ts +0 -0
- /package/build/{common → types/common}/utils/date-utils.d.ts +0 -0
- /package/build/{common → types/common}/utils/debounce.d.ts +0 -0
- /package/build/{common → types/common}/utils/file-utils.d.ts +0 -0
- /package/build/{common → types/common}/utils/id-utils.d.ts +0 -0
- /package/build/{common → types/common}/utils/index.d.ts +0 -0
- /package/build/{common → types/common}/utils/is-equal.d.ts +0 -0
- /package/build/{common → types/common}/utils/schema-utils.d.ts +0 -0
- /package/build/{common → types/common}/utils/step-utils.d.ts +0 -0
- /package/build/{common → types/common}/validators/index.d.ts +0 -0
- /package/build/{common → types/common}/validators/models/model-validators.d.ts +0 -0
- /package/build/{common → types/common}/validators/models/models.utils.d.ts +0 -0
- /package/build/{common → types/common}/validators/schemas/schema-validators.d.ts +0 -0
- /package/build/{common → types/common}/validators/types/type-validators.d.ts +0 -0
- /package/build/{common → types/common}/validators/validationFailures/validation-failures.d.ts +0 -0
- /package/build/{common → types/common}/validators/validationFailures/validation-failures.utils.d.ts +0 -0
- /package/build/{common → types/common}/validators/values/value-validators.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/DynamicFlow.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/DynamicFlowStep.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/DynamicFlowTypes.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/index.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/stories/DynamicFlow.story.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/stories/EditableDynamicFlow.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/stories/fixtureFetcher.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/utils/errorBoundary/ErrorBoundary.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/utils/errorBoundary/ErrorBoundary.messages.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/utils/errorBoundary/ErrorBoundaryAlert.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/utils/index.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/utils/responseParsers/response-parsers.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/utils/useDebouncedRefresh/useDebouncedRefresh.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/utils/useDynamicFlowState.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/utils/useLoader.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/alert.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/box.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/button.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/columns.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/copyable.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/decision.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/heading.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/image.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/index.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/info.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/list.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/loading-indicator.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/paragraph.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/review.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/examples/camera-capture.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/examples/index.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/examples/recipient-update.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/examples/recipient.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/examples/single-file-upload.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/examples/step-validation-errors.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/features/action-response.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/features/external.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/features/index.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/features/persist-async.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/features/polling.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/features/validation-async.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/index.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/jsonSchemaForm/allOf.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/layouts/all.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/layouts/final-step-layout.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/layouts/index.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/layouts/list.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/layouts/pay-in.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/layouts/review.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/layouts/success.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/responses/action-response-final.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/responses/action.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/responses/exit.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/responses/index.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/responses/recipient-update-final.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/schemas/basic-form.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/schemas/index.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/schemas/number-and-integer.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/schemas/one-of.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/schemas/string-formats.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/utils/image-util.d.ts +0 -0
- /package/build/{formControl → types/formControl}/FormControl.d.ts +0 -0
- /package/build/{formControl → types/formControl}/index.d.ts +0 -0
- /package/build/{formControl → types/formControl}/utils/index.d.ts +0 -0
- /package/build/{formControl → types/formControl}/utils/value-utils.d.ts +0 -0
- /package/build/{i18n → types/i18n}/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/JsonSchemaForm.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/allOfSchema/AllOfSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/allOfSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/ArraySchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/arrayListSchema/ArrayListSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/arrayListSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.messages.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/upload-utils.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/useFormattedDefaultErrorMessages.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/basicTypeSchema/BasicTypeSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/basicTypeSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/controlFeedback/ControlFeedback.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/controlFeedback/ControlFeedback.messages.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/controlFeedback/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/genericSchema/GenericSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/genericSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/help/Help.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/help/Help.messages.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/help/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/objectSchema/ObjectSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/objectSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/oneOfSchema/OneOfSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/oneOfSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/oneOfSchema/utils/const-schema-utils.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/oneOfSchema/utils/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/oneOfSchema/utils/one-of-utils.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/persistAsyncSchema/PersistAsyncSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/persistAsyncSchema/PersistAsyncSchema.messages.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/persistAsyncSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/persistAsyncSchema/persistAsyncBasicSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/persistAsyncSchema/persistAsyncBlobSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/promotedOneOfSchema/PromotedOneOfSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/promotedOneOfSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/promotedOneOfSchema/promoted-one-of-utils.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfCheckboxControl.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfControl.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfRadioControl.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/readOnlySchema/ReadOnlySchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/readOnlySchema/ReadOnlySchema.messages.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/readOnlySchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/schemaFormControl/SchemaFormControl.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/schemaFormControl/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/schemaFormControl/utils/currency-utils.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/schemaFormControl/utils/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/schemaFormControl/utils/mapping-utils.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/validationAsyncSchema/ValidationAsyncSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/validationAsyncSchema/index.d.ts +0 -0
- /package/build/{layout → types/layout}/DynamicLayout.d.ts +0 -0
- /package/build/{layout → types/layout}/alert/DynamicAlert.d.ts +0 -0
- /package/build/{layout → types/layout}/box/DynamicBox.d.ts +0 -0
- /package/build/{layout → types/layout}/button/DynamicButton.d.ts +0 -0
- /package/build/{layout → types/layout}/columns/DynamicColumns.d.ts +0 -0
- /package/build/{layout → types/layout}/decision/DynamicDecision.d.ts +0 -0
- /package/build/{layout → types/layout}/divider/DynamicDivider.d.ts +0 -0
- /package/build/{layout → types/layout}/external/DynamicExternal.d.ts +0 -0
- /package/build/{layout → types/layout}/external/DynamicExternal.messages.d.ts +0 -0
- /package/build/{layout → types/layout}/form/DynamicForm.d.ts +0 -0
- /package/build/{layout → types/layout}/heading/DynamicHeading.d.ts +0 -0
- /package/build/{layout → types/layout}/icon/DynamicIcon.d.ts +0 -0
- /package/build/{layout → types/layout}/image/DynamicImage.d.ts +0 -0
- /package/build/{layout → types/layout}/index.d.ts +0 -0
- /package/build/{layout → types/layout}/info/DynamicInfo.d.ts +0 -0
- /package/build/{layout → types/layout}/list/DynamicList.d.ts +0 -0
- /package/build/{layout → types/layout}/loadingIndicator/DynamicLoadingIndicator.d.ts +0 -0
- /package/build/{layout → types/layout}/paragraph/DynamicParagraph.d.ts +0 -0
- /package/build/{layout → types/layout}/paragraph/DynamicParagraph.messages.d.ts +0 -0
- /package/build/{layout → types/layout}/paragraph/useSnackBarIfAvailable.d.ts +0 -0
- /package/build/{layout → types/layout}/review/DynamicReview.d.ts +0 -0
- /package/build/{layout → types/layout}/utils.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/CameraStep.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/CameraCapture.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/CameraCapture.messages.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/components/index.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/hooks/index.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/index.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/overlay/Overlay.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.messages.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.messages.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/screens/index.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/tracking/index.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/utils/index.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/index.d.ts +0 -0
- /package/build/{step → types/step}/externalConfirmationStep/ExternalConfirmationStep.d.ts +0 -0
- /package/build/{step → types/step}/externalConfirmationStep/ExternalConfirmationStep.messages.d.ts +0 -0
- /package/build/{step → types/step}/externalConfirmationStep/index.d.ts +0 -0
- /package/build/{step → types/step}/index.d.ts +0 -0
- /package/build/{step → types/step}/layoutStep/LayoutStep.d.ts +0 -0
- /package/build/{step → types/step}/layoutStep/index.d.ts +0 -0
- /package/build/{step → types/step}/layoutStep/utils/index.d.ts +0 -0
- /package/build/{step → types/step}/layoutStep/utils/inline-reference-utils.d.ts +0 -0
- /package/build/{step → types/step}/layoutStep/utils/layout-utils.d.ts +0 -0
- /package/build/types/{common → types/common}/FormControl.d.ts +0 -0
- /package/build/types/{specification → types/specification}/Action.d.ts +0 -0
- /package/build/types/{specification → types/specification}/FileUploadSchema.d.ts +0 -0
- /package/build/types/{specification → types/specification}/LayoutComponent.d.ts +0 -0
- /package/build/types/{specification → types/specification}/Model.d.ts +0 -0
- /package/build/types/{specification → types/specification}/PersistAsync.d.ts +0 -0
- /package/build/types/{specification → types/specification}/Polling.d.ts +0 -0
- /package/build/types/{specification → types/specification}/Promotion.d.ts +0 -0
- /package/build/types/{specification → types/specification}/Schema.d.ts +0 -0
- /package/build/types/{specification → types/specification}/Step.d.ts +0 -0
- /package/build/types/{specification → types/specification}/ValidationAsync.d.ts +0 -0
- /package/build/types/{specification → types/specification}/core.d.ts +0 -0
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isValidSchema = void 0;
|
|
4
|
-
const types_1 = require("../../../types");
|
|
5
|
-
const type_validators_1 = require("../types/type-validators");
|
|
6
|
-
const validation_failures_1 = require("../validationFailures/validation-failures");
|
|
7
|
-
function isValidStringSchema(value, schema) {
|
|
8
|
-
return !(0, validation_failures_1.getStringValidationFailures)(value, schema).length;
|
|
9
|
-
}
|
|
10
|
-
function isValidNumberSchema(value, schema) {
|
|
11
|
-
return !(0, validation_failures_1.getNumberValidationFailures)(value, schema).length;
|
|
12
|
-
}
|
|
13
|
-
function isValidIntegerSchema(value, schema) {
|
|
14
|
-
return !(0, validation_failures_1.getIntegerValidationFailures)(value, schema).length;
|
|
15
|
-
}
|
|
16
|
-
function isValidBooleanSchema(value, schema) {
|
|
17
|
-
return !(0, validation_failures_1.getBooleanValidationFailures)(value, schema).length;
|
|
18
|
-
}
|
|
19
|
-
function isValidConstSchema(value, schema) {
|
|
20
|
-
return !(0, validation_failures_1.getConstValidationFailures)(value, schema).length;
|
|
21
|
-
}
|
|
22
|
-
function isValidObjectSchema(value, schema) {
|
|
23
|
-
if (!(0, type_validators_1.isObject)(value) || schema.type !== 'object' || !(0, type_validators_1.isObject)(schema.properties)) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
return Object.keys(schema.properties)
|
|
27
|
-
.map((propertyName) => isObjectPropertyValid(value[propertyName], schema.properties[propertyName], schema.required && schema.required.includes(propertyName)))
|
|
28
|
-
.every((property) => property);
|
|
29
|
-
}
|
|
30
|
-
function isObjectPropertyValid(propertyValue, propertySchema, isRequired) {
|
|
31
|
-
if (typeof propertyValue === 'undefined') {
|
|
32
|
-
return !isRequired;
|
|
33
|
-
}
|
|
34
|
-
return isValidSchema(propertyValue, propertySchema);
|
|
35
|
-
}
|
|
36
|
-
function isValidArraySchema(value, schema) {
|
|
37
|
-
if (schema.type !== 'array' || !(0, type_validators_1.isObject)(schema.items)) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
if ((0, validation_failures_1.getArrayValidationFailures)(value, schema).length > 0) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
return (Array.isArray(value) &&
|
|
44
|
-
(0, types_1.isListArraySchema)(schema) && // TupleArraySchema not yet supported
|
|
45
|
-
value.map((item) => isValidSchema(item, schema.items)).every((valid) => valid));
|
|
46
|
-
}
|
|
47
|
-
function isValidOneOfSchema(value, schema) {
|
|
48
|
-
if (!(0, type_validators_1.isArray)(schema.oneOf)) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
return schema.oneOf.some((childSchema) => isValidSchema(value, childSchema));
|
|
52
|
-
}
|
|
53
|
-
function isValidAllOfSchema(value, schema) {
|
|
54
|
-
if (!(0, type_validators_1.isArray)(schema.allOf)) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
return schema.allOf
|
|
58
|
-
.map((childSchema) => isValidSchema(value, childSchema))
|
|
59
|
-
.every((valid) => valid);
|
|
60
|
-
}
|
|
61
|
-
function isValidBlobSchema(value, schema) {
|
|
62
|
-
return !(0, validation_failures_1.getBlobValidationFailures)(value, schema).length;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Validate any value against a given schema
|
|
66
|
-
*
|
|
67
|
-
* @param value
|
|
68
|
-
* @param schema
|
|
69
|
-
*/
|
|
70
|
-
function isValidSchema(value, schema) {
|
|
71
|
-
if (schema.oneOf) {
|
|
72
|
-
return isValidOneOfSchema(value, schema);
|
|
73
|
-
}
|
|
74
|
-
if (schema.allOf) {
|
|
75
|
-
return isValidAllOfSchema(value, schema);
|
|
76
|
-
}
|
|
77
|
-
if (schema.const) {
|
|
78
|
-
return isValidConstSchema(value, schema);
|
|
79
|
-
}
|
|
80
|
-
switch (schema.type) {
|
|
81
|
-
case 'string':
|
|
82
|
-
return isValidStringSchema(value, schema);
|
|
83
|
-
case 'number':
|
|
84
|
-
return isValidNumberSchema(value, schema);
|
|
85
|
-
case 'integer':
|
|
86
|
-
return isValidIntegerSchema(value, schema);
|
|
87
|
-
case 'boolean':
|
|
88
|
-
return isValidBooleanSchema(value, schema);
|
|
89
|
-
case 'array':
|
|
90
|
-
return isValidArraySchema(value, schema);
|
|
91
|
-
case 'object':
|
|
92
|
-
return isValidObjectSchema(value, schema);
|
|
93
|
-
case 'blob':
|
|
94
|
-
return isValidBlobSchema(value, schema);
|
|
95
|
-
default:
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.isValidSchema = isValidSchema;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isUndefined = exports.isNull = exports.isArray = exports.isObject = exports.isBoolean = exports.isInteger = exports.isNumber = exports.isString = void 0;
|
|
4
|
-
const isString = (value) => typeof value === 'string';
|
|
5
|
-
exports.isString = isString;
|
|
6
|
-
const isNumber = (value) => typeof value === 'number' && !Number.isNaN(value);
|
|
7
|
-
exports.isNumber = isNumber;
|
|
8
|
-
const isInteger = (value) => {
|
|
9
|
-
return (0, exports.isNumber)(value) && Math.floor(value) === value;
|
|
10
|
-
};
|
|
11
|
-
exports.isInteger = isInteger;
|
|
12
|
-
const isBoolean = (value) => typeof value === 'boolean';
|
|
13
|
-
exports.isBoolean = isBoolean;
|
|
14
|
-
const isObject = (value) => !(0, exports.isNull)(value) && !(0, exports.isUndefined)(value) && (value === null || value === void 0 ? void 0 : value.constructor) === Object;
|
|
15
|
-
exports.isObject = isObject;
|
|
16
|
-
const isArray = (value) => Array.isArray(value);
|
|
17
|
-
exports.isArray = isArray;
|
|
18
|
-
const isNull = (value) => value === null;
|
|
19
|
-
exports.isNull = isNull;
|
|
20
|
-
const isUndefined = (value) => typeof value === 'undefined';
|
|
21
|
-
exports.isUndefined = isUndefined;
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBlobValidationFailures = exports.getObjectValidationFailures = exports.getArrayValidationFailures = exports.getConstValidationFailures = exports.getBooleanValidationFailures = exports.getIntegerValidationFailures = exports.getNumberValidationFailures = exports.getStringValidationFailures = exports.getValidationFailures = void 0;
|
|
4
|
-
const types_1 = require("../../../types");
|
|
5
|
-
const Schema_1 = require("../../../types/specification/Schema");
|
|
6
|
-
const type_validators_1 = require("../types/type-validators");
|
|
7
|
-
const validation_failures_utils_1 = require("./validation-failures.utils");
|
|
8
|
-
function getValidationFailures(value, schema, isRequired) {
|
|
9
|
-
if (schema.const) {
|
|
10
|
-
return getConstValidationFailures(value, schema, isRequired);
|
|
11
|
-
}
|
|
12
|
-
if ((0, type_validators_1.isNull)(value)) {
|
|
13
|
-
return isRequired ? ['required'] : [];
|
|
14
|
-
}
|
|
15
|
-
if ((0, Schema_1.isStringSchema)(schema)) {
|
|
16
|
-
return getStringValidationFailures(value, schema, isRequired);
|
|
17
|
-
}
|
|
18
|
-
switch (schema.type) {
|
|
19
|
-
case 'number':
|
|
20
|
-
return getNumberValidationFailures(value, schema, isRequired);
|
|
21
|
-
case 'integer':
|
|
22
|
-
return getIntegerValidationFailures(value, schema, isRequired);
|
|
23
|
-
case 'boolean':
|
|
24
|
-
return getBooleanValidationFailures(value, schema, isRequired);
|
|
25
|
-
case 'array':
|
|
26
|
-
return getArrayValidationFailures(value, schema, isRequired);
|
|
27
|
-
case 'object':
|
|
28
|
-
return getObjectValidationFailures(value, schema);
|
|
29
|
-
default:
|
|
30
|
-
return [];
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.getValidationFailures = getValidationFailures;
|
|
34
|
-
function getStringValidationFailures(value, schema, isRequired) {
|
|
35
|
-
if (!(0, type_validators_1.isString)(value) && !(0, type_validators_1.isNull)(value)) {
|
|
36
|
-
return ['type'];
|
|
37
|
-
}
|
|
38
|
-
if (value === '' && isRequired) {
|
|
39
|
-
return ['required'];
|
|
40
|
-
}
|
|
41
|
-
const failures = [];
|
|
42
|
-
if (!(0, validation_failures_utils_1.isValidRequired)(value, isRequired)) {
|
|
43
|
-
failures.push('required');
|
|
44
|
-
}
|
|
45
|
-
if (!(0, validation_failures_utils_1.isValidMinLength)(value, schema.minLength)) {
|
|
46
|
-
failures.push('minLength');
|
|
47
|
-
}
|
|
48
|
-
if (!(0, validation_failures_utils_1.isValidMaxLength)(value, schema.maxLength)) {
|
|
49
|
-
failures.push('maxLength');
|
|
50
|
-
}
|
|
51
|
-
if (!(0, validation_failures_utils_1.isValidPattern)(value, schema.pattern)) {
|
|
52
|
-
failures.push('pattern');
|
|
53
|
-
}
|
|
54
|
-
if (!(0, validation_failures_utils_1.isValidMinimum)(value, schema.minimum)) {
|
|
55
|
-
failures.push('minimum');
|
|
56
|
-
}
|
|
57
|
-
if (!(0, validation_failures_utils_1.isValidMaximum)(value, schema.maximum)) {
|
|
58
|
-
failures.push('maximum');
|
|
59
|
-
}
|
|
60
|
-
return failures;
|
|
61
|
-
}
|
|
62
|
-
exports.getStringValidationFailures = getStringValidationFailures;
|
|
63
|
-
function getNumberValidationFailures(value, schema, isRequired) {
|
|
64
|
-
if (!(0, type_validators_1.isNumber)(value) && !(0, type_validators_1.isNull)(value)) {
|
|
65
|
-
return ['type'];
|
|
66
|
-
}
|
|
67
|
-
const failures = [];
|
|
68
|
-
if (!(0, validation_failures_utils_1.isValidRequired)(value, isRequired)) {
|
|
69
|
-
failures.push('required');
|
|
70
|
-
}
|
|
71
|
-
if (!(0, validation_failures_utils_1.isValidMinimum)(value, schema.minimum)) {
|
|
72
|
-
failures.push('minimum');
|
|
73
|
-
}
|
|
74
|
-
if (!(0, validation_failures_utils_1.isValidMaximum)(value, schema.maximum)) {
|
|
75
|
-
failures.push('maximum');
|
|
76
|
-
}
|
|
77
|
-
return failures;
|
|
78
|
-
}
|
|
79
|
-
exports.getNumberValidationFailures = getNumberValidationFailures;
|
|
80
|
-
function getIntegerValidationFailures(value, schema, isRequired) {
|
|
81
|
-
if (!(0, type_validators_1.isInteger)(value)) {
|
|
82
|
-
return ['type'];
|
|
83
|
-
}
|
|
84
|
-
return getNumberValidationFailures(value, schema, isRequired);
|
|
85
|
-
}
|
|
86
|
-
exports.getIntegerValidationFailures = getIntegerValidationFailures;
|
|
87
|
-
function getBooleanValidationFailures(value, _schema, isRequired) {
|
|
88
|
-
if (!(0, type_validators_1.isBoolean)(value) && !(0, type_validators_1.isNull)(value)) {
|
|
89
|
-
return ['type'];
|
|
90
|
-
}
|
|
91
|
-
const failures = [];
|
|
92
|
-
if (!(0, validation_failures_utils_1.isValidRequired)(value, isRequired)) {
|
|
93
|
-
failures.push('required');
|
|
94
|
-
}
|
|
95
|
-
return failures;
|
|
96
|
-
}
|
|
97
|
-
exports.getBooleanValidationFailures = getBooleanValidationFailures;
|
|
98
|
-
function getConstValidationFailures(value, schema, isRequired) {
|
|
99
|
-
if (!(0, validation_failures_utils_1.isValidRequired)(value, isRequired)) {
|
|
100
|
-
return ['required'];
|
|
101
|
-
}
|
|
102
|
-
if (value !== schema.const) {
|
|
103
|
-
return ['const'];
|
|
104
|
-
}
|
|
105
|
-
return [];
|
|
106
|
-
}
|
|
107
|
-
exports.getConstValidationFailures = getConstValidationFailures;
|
|
108
|
-
function getArrayValidationFailures(value, schema, isRequired) {
|
|
109
|
-
if (!(0, type_validators_1.isArray)(value) && !(0, type_validators_1.isNull)(value)) {
|
|
110
|
-
return ['type'];
|
|
111
|
-
}
|
|
112
|
-
if (!(0, validation_failures_utils_1.isValidRequiredArray)(value, isRequired)) {
|
|
113
|
-
return ['required'];
|
|
114
|
-
}
|
|
115
|
-
const failures = [];
|
|
116
|
-
if (!(0, validation_failures_utils_1.isValidMinItems)(value, schema.minItems)) {
|
|
117
|
-
failures.push('minItems');
|
|
118
|
-
}
|
|
119
|
-
if (!(0, validation_failures_utils_1.isValidMaxItems)(value, schema.maxItems)) {
|
|
120
|
-
failures.push('maxItems');
|
|
121
|
-
}
|
|
122
|
-
return failures;
|
|
123
|
-
}
|
|
124
|
-
exports.getArrayValidationFailures = getArrayValidationFailures;
|
|
125
|
-
function getBlobValidationFailures(value, _schema) {
|
|
126
|
-
if ((0, type_validators_1.isNull)(value)) {
|
|
127
|
-
return ['type'];
|
|
128
|
-
}
|
|
129
|
-
return [];
|
|
130
|
-
}
|
|
131
|
-
exports.getBlobValidationFailures = getBlobValidationFailures;
|
|
132
|
-
/**
|
|
133
|
-
* When validating an object we only checking that it is an object and that it
|
|
134
|
-
* has the required properties, we do not check if the properties are valid.
|
|
135
|
-
*
|
|
136
|
-
* @param value
|
|
137
|
-
* @param schema
|
|
138
|
-
*/
|
|
139
|
-
function getObjectValidationFailures(value, schema) {
|
|
140
|
-
if (!(0, types_1.isObjectModel)(value)) {
|
|
141
|
-
return ['type'];
|
|
142
|
-
}
|
|
143
|
-
if (!(0, type_validators_1.isArray)(schema.required)) {
|
|
144
|
-
return [];
|
|
145
|
-
}
|
|
146
|
-
const allPresent = schema.required
|
|
147
|
-
.map((property) => typeof value[property] !== 'undefined')
|
|
148
|
-
.reduce((propertyInModel, validSoFar) => propertyInModel && validSoFar, true);
|
|
149
|
-
return allPresent ? [] : ['required'];
|
|
150
|
-
}
|
|
151
|
-
exports.getObjectValidationFailures = getObjectValidationFailures;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isValidRequiredArray = exports.isValidMaxItems = exports.isValidMinItems = exports.isValidMinimum = exports.isValidMaximum = exports.isValidPattern = exports.isValidMaxLength = exports.isValidMinLength = exports.isValidRequired = void 0;
|
|
4
|
-
const validators_1 = require("../../validators");
|
|
5
|
-
function isValidRequired(value, isRequired = false) {
|
|
6
|
-
return !isRequired || !(0, validators_1.isUndefined)(value);
|
|
7
|
-
}
|
|
8
|
-
exports.isValidRequired = isValidRequired;
|
|
9
|
-
function isValidRequiredArray(value, isRequired = false) {
|
|
10
|
-
return !isRequired || (0, validators_1.isArray)(value);
|
|
11
|
-
}
|
|
12
|
-
exports.isValidRequiredArray = isValidRequiredArray;
|
|
13
|
-
function isValidMinLength(value, minLength) {
|
|
14
|
-
return !(0, validators_1.isNumber)(minLength) || ((0, validators_1.isString)(value) && value.length >= minLength);
|
|
15
|
-
}
|
|
16
|
-
exports.isValidMinLength = isValidMinLength;
|
|
17
|
-
function isValidMaxLength(value, maxLength) {
|
|
18
|
-
return !(0, validators_1.isNumber)(maxLength) || ((0, validators_1.isString)(value) && value.length <= maxLength);
|
|
19
|
-
}
|
|
20
|
-
exports.isValidMaxLength = isValidMaxLength;
|
|
21
|
-
function isValidPattern(value, pattern) {
|
|
22
|
-
if (pattern === undefined) {
|
|
23
|
-
return true; // no pattern, therefore the value is valid
|
|
24
|
-
}
|
|
25
|
-
if (value === undefined || value === null) {
|
|
26
|
-
return false; // no value, but there's a pattern, therefore the value is NOT valid
|
|
27
|
-
}
|
|
28
|
-
const regex = new RegExp(pattern);
|
|
29
|
-
return !!regex.test(value);
|
|
30
|
-
}
|
|
31
|
-
exports.isValidPattern = isValidPattern;
|
|
32
|
-
function isValidMaximum(value, maximum) {
|
|
33
|
-
return ((!(0, validators_1.isNumber)(maximum) && !(0, validators_1.isString)(maximum)) ||
|
|
34
|
-
(((0, validators_1.isNumber)(value) || (0, validators_1.isString)(value)) && value <= maximum));
|
|
35
|
-
}
|
|
36
|
-
exports.isValidMaximum = isValidMaximum;
|
|
37
|
-
function isValidMinimum(value, minimum) {
|
|
38
|
-
return ((!(0, validators_1.isNumber)(minimum) && !(0, validators_1.isString)(minimum)) ||
|
|
39
|
-
(((0, validators_1.isNumber)(value) || (0, validators_1.isString)(value)) && value >= minimum));
|
|
40
|
-
}
|
|
41
|
-
exports.isValidMinimum = isValidMinimum;
|
|
42
|
-
function isValidMinItems(value, minItems) {
|
|
43
|
-
return !(0, validators_1.isNumber)(minItems) || ((0, validators_1.isArray)(value) && value.length >= minItems);
|
|
44
|
-
}
|
|
45
|
-
exports.isValidMinItems = isValidMinItems;
|
|
46
|
-
function isValidMaxItems(value, maxItems) {
|
|
47
|
-
return !(0, validators_1.isNumber)(maxItems) || ((0, validators_1.isArray)(value) && value.length <= maxItems);
|
|
48
|
-
}
|
|
49
|
-
exports.isValidMaxItems = isValidMaxItems;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isEmpty = void 0;
|
|
4
|
-
const type_validators_1 = require("../types/type-validators");
|
|
5
|
-
const isEmpty = (value) => ((0, type_validators_1.isString)(value) && value.length === 0) ||
|
|
6
|
-
(((0, type_validators_1.isObject)(value) || (0, type_validators_1.isArray)(value)) && Object.keys(value).length === 0);
|
|
7
|
-
exports.isEmpty = isEmpty;
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const react_intl_1 = require("react-intl");
|
|
6
|
-
const contexts_1 = require("../common/contexts");
|
|
7
|
-
const validators_1 = require("../common/validators");
|
|
8
|
-
const types_1 = require("../types");
|
|
9
|
-
const DynamicFlowStep_1 = require("./DynamicFlowStep");
|
|
10
|
-
const utils_1 = require("./utils");
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
12
|
-
const noop = () => { };
|
|
13
|
-
/**
|
|
14
|
-
* ## DynamicFlow
|
|
15
|
-
*
|
|
16
|
-
* The dynamic flow component is responsible for the asynchronous actions occuring
|
|
17
|
-
* within a dynamic flow, managing transitions between steps as well as refreshing
|
|
18
|
-
* requirements. It doesn't control any view logic, but takes the step definition
|
|
19
|
-
* and reformats it to use a LayoutStep for presentation.
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
const DynamicFlowComponent = ({ flowId, fetcher, flowUrl, initialAction, initialStep, loaderConfig, displayStepTitle = true, onComplete, onStepChange = noop, onError, onEvent = noop, onLog = noop, }) => {
|
|
23
|
-
const { locale } = (0, react_intl_1.useIntl)();
|
|
24
|
-
const { formErrors, globalError, step, models, etag, modelIsValid, setFormErrors, setGlobalError, setStepAndEtag, setSchemaModel, } = (0, utils_1.useDynamicFlowState)(initialStep);
|
|
25
|
-
const [submitted, setSubmitted] = (0, react_1.useState)(false);
|
|
26
|
-
const { loadingState, setLoadingState, loader } = (0, utils_1.useLoader)(loaderConfig, initialStep ? 'idle' : 'initial');
|
|
27
|
-
const logWarning = (0, contexts_1.getLogger)('warning', onLog, flowId, step === null || step === void 0 ? void 0 : step.key);
|
|
28
|
-
const logError = (0, contexts_1.getLogger)('error', onLog, flowId, step === null || step === void 0 ? void 0 : step.key);
|
|
29
|
-
const logCritical = (0, contexts_1.getLogger)('critical', onLog, flowId, step === null || step === void 0 ? void 0 : step.key);
|
|
30
|
-
const analyticsMetadata = (0, react_1.useMemo)(() => { var _a; return (Object.assign({ flowId, stepId: step === null || step === void 0 ? void 0 : step.key }, ((_a = step === null || step === void 0 ? void 0 : step.analytics) !== null && _a !== void 0 ? _a : {}))); }, [flowId, step]);
|
|
31
|
-
const dispatchEvent = (0, react_1.useMemo)(() => (0, contexts_1.getEventDispatcher)(onEvent, analyticsMetadata), [onEvent, analyticsMetadata]);
|
|
32
|
-
const triggerActionRequest = (0, react_1.useCallback)(({ action, data, etag }) => {
|
|
33
|
-
const { url, method = 'POST' } = action;
|
|
34
|
-
return fetcher(url !== null && url !== void 0 ? url : '', {
|
|
35
|
-
method,
|
|
36
|
-
headers: Object.assign({ 'accept-language': locale, 'Content-Type': 'application/json' }, (etag ? { 'If-None-Match': etag } : {})),
|
|
37
|
-
credentials: 'include',
|
|
38
|
-
body: method === 'GET' ? undefined : JSON.stringify(data),
|
|
39
|
-
});
|
|
40
|
-
}, [fetcher, locale]);
|
|
41
|
-
const fetchNextStep = async (action, data = {}) => {
|
|
42
|
-
setLoadingState(loadingState === 'initial' ? 'initial' : 'submission');
|
|
43
|
-
try {
|
|
44
|
-
dispatchEvent('Dynamic Flow - Step Submitted', { actionId: action.$id });
|
|
45
|
-
const response = await triggerActionRequest({ action, data });
|
|
46
|
-
return handleFetchResponse(response, 'submission');
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
handleFetchError(error, 'Error fetching next step');
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const fetchRefreshStep = async (action, data, etag) => {
|
|
53
|
-
setLoadingState('refresh');
|
|
54
|
-
try {
|
|
55
|
-
dispatchEvent('Dynamic Flow - Step Refreshed', { status: 'pending' });
|
|
56
|
-
const response = await triggerActionRequest({ action, data, etag });
|
|
57
|
-
await handleFetchResponse(response, 'refresh');
|
|
58
|
-
setLoadingState('idle');
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
handleFetchError(error, 'Error fetching refresh step');
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
const fetchExitResult = async (action, data) => {
|
|
65
|
-
try {
|
|
66
|
-
const response = await triggerActionRequest({ action, data });
|
|
67
|
-
const exitResult = await (0, utils_1.parseExitResponse)(response);
|
|
68
|
-
onCloseWithEvent(Object.assign(Object.assign({}, exitResult), action.result));
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
handleFetchError(error, 'Error fetching exit result');
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
const debouncedFetchRefresh = (0, utils_1.useDebouncedRefresh)(fetchRefreshStep);
|
|
75
|
-
const onCloseWithEvent = (0, react_1.useCallback)((result) => {
|
|
76
|
-
dispatchEvent('Dynamic Flow - Flow Finished', { result: 'success' });
|
|
77
|
-
onComplete(result);
|
|
78
|
-
}, [onComplete, dispatchEvent]);
|
|
79
|
-
(0, react_1.useEffect)(() => {
|
|
80
|
-
dispatchEvent('Dynamic Flow - Flow Started', {});
|
|
81
|
-
}, []);
|
|
82
|
-
(0, react_1.useEffect)(() => {
|
|
83
|
-
if (!initialStep) {
|
|
84
|
-
const action = Object.assign({ $id: '#initial-step-request', method: 'GET' }, initialAction);
|
|
85
|
-
void fetchNextStep(action, action.data);
|
|
86
|
-
}
|
|
87
|
-
}, [flowUrl, fetcher, locale, JSON.stringify(initialStep), JSON.stringify(initialAction)]);
|
|
88
|
-
const handleFetchResponse = async (response, fetchType) => {
|
|
89
|
-
if (response.ok) {
|
|
90
|
-
try {
|
|
91
|
-
const parsedResponse = await (0, utils_1.parseFetchResponse)(response);
|
|
92
|
-
switch (parsedResponse.type) {
|
|
93
|
-
case 'action':
|
|
94
|
-
void fetchNextStep(parsedResponse.action, parsedResponse.action.data);
|
|
95
|
-
return;
|
|
96
|
-
case 'exit':
|
|
97
|
-
return onCloseWithEvent(parsedResponse.result);
|
|
98
|
-
case 'step':
|
|
99
|
-
default: {
|
|
100
|
-
const { step, etag } = parsedResponse;
|
|
101
|
-
return fetchType === 'submission'
|
|
102
|
-
? updateStepAfterSubmission(step, etag)
|
|
103
|
-
: updateStepAfterRefresh(step, etag);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
return handleFetchError(error, 'Error parsing fetch response');
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return handleErrorResponse(response, fetchType);
|
|
112
|
-
};
|
|
113
|
-
const updateStepAfterSubmission = (newStep, etag) => {
|
|
114
|
-
const previousStep = step;
|
|
115
|
-
setStepAndEtag(newStep, etag);
|
|
116
|
-
onStepChange(newStep, previousStep);
|
|
117
|
-
setSubmitted(false);
|
|
118
|
-
setLoadingState('idle');
|
|
119
|
-
dispatchEvent('Dynamic Flow - Step Started', Object.assign({ stepId: newStep.key }, newStep === null || newStep === void 0 ? void 0 : newStep.analytics));
|
|
120
|
-
};
|
|
121
|
-
const updateStepAfterRefresh = (step, etag) => {
|
|
122
|
-
setStepAndEtag(step, etag);
|
|
123
|
-
setLoadingState('idle');
|
|
124
|
-
dispatchEvent('Dynamic Flow - Step Refreshed', { status: 'success' });
|
|
125
|
-
};
|
|
126
|
-
const handleErrorResponse = async (response, fetchType) => {
|
|
127
|
-
if (response.status === 304) {
|
|
128
|
-
setLoadingState('idle');
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
try {
|
|
132
|
-
const errorBody = await (0, utils_1.parseErrorResponse)(response);
|
|
133
|
-
if (errorBody.refreshFormUrl) {
|
|
134
|
-
const action = { url: errorBody === null || errorBody === void 0 ? void 0 : errorBody.refreshFormUrl, method: 'POST' };
|
|
135
|
-
await fetchRefreshStep(action, combineModels(models), etag);
|
|
136
|
-
}
|
|
137
|
-
if (errorBody.validation) {
|
|
138
|
-
setFormErrors(errorBody.validation);
|
|
139
|
-
}
|
|
140
|
-
if (errorBody.error) {
|
|
141
|
-
setGlobalError(errorBody.error);
|
|
142
|
-
}
|
|
143
|
-
if (!errorBody.refreshFormUrl && !errorBody.validation && !errorBody.error) {
|
|
144
|
-
logError('Invalid response', 'Response body must contain at least one of the following properties: refreshFormUrl, validation, or error.');
|
|
145
|
-
throw errorBody;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
catch (error) {
|
|
149
|
-
if (fetchType === 'refresh') {
|
|
150
|
-
dispatchEvent('Dynamic Flow - Step Refreshed', { status: 'failure' });
|
|
151
|
-
}
|
|
152
|
-
dispatchEvent('Dynamic Flow - Flow Finished', { status: 'failure' });
|
|
153
|
-
onError(error, response.status);
|
|
154
|
-
logError('Invalid response', 'Error response body must be an object.');
|
|
155
|
-
}
|
|
156
|
-
setLoadingState('idle');
|
|
157
|
-
};
|
|
158
|
-
const handleFetchError = (error, message) => {
|
|
159
|
-
logCritical('Error fetching', message);
|
|
160
|
-
onError(error);
|
|
161
|
-
setLoadingState('idle');
|
|
162
|
-
};
|
|
163
|
-
const onModelChange = (onModelChangeProps) => {
|
|
164
|
-
const { model, formSchema } = onModelChangeProps;
|
|
165
|
-
const { $id = '' } = formSchema;
|
|
166
|
-
setGlobalError(null);
|
|
167
|
-
if (!(0, types_1.isObjectModel)(model)) {
|
|
168
|
-
// TODO: MC-3224
|
|
169
|
-
logCritical('Invalid model on change', 'onModelChange was called but the model argument is not an object');
|
|
170
|
-
}
|
|
171
|
-
const objectModel = model;
|
|
172
|
-
setSchemaModel($id, objectModel, (updatedModels) => {
|
|
173
|
-
refreshOnChangeIfNeeded(onModelChangeProps, updatedModels);
|
|
174
|
-
});
|
|
175
|
-
};
|
|
176
|
-
const refreshOnChangeIfNeeded = (props, updatedModels) => {
|
|
177
|
-
const { triggerSchema } = props;
|
|
178
|
-
if (shouldTriggerRefresh(props)) {
|
|
179
|
-
const url = triggerSchema.refreshFormUrl || (step === null || step === void 0 ? void 0 : step.refreshFormUrl);
|
|
180
|
-
const action = { url, method: 'POST' };
|
|
181
|
-
debouncedFetchRefresh(action, combineModels(updatedModels), etag, triggerSchema);
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
const onAction = async (action) => {
|
|
185
|
-
const { data, method, exit, url, result } = action;
|
|
186
|
-
const submissionData = Object.assign(Object.assign({}, combineModels(models)), data);
|
|
187
|
-
// Temporary tracking properties specific to recipient creation
|
|
188
|
-
// the submissionData object typically contains PII
|
|
189
|
-
// but we're only taking "currency" and "type" which are not PII.
|
|
190
|
-
const extraLoggingProps = {
|
|
191
|
-
url: action.url,
|
|
192
|
-
method: action.method,
|
|
193
|
-
currency: submissionData.currency,
|
|
194
|
-
type: submissionData.type,
|
|
195
|
-
};
|
|
196
|
-
if (loadingState !== 'idle' || action.disabled) {
|
|
197
|
-
logWarning('Action supressed', loadingState !== 'idle'
|
|
198
|
-
? `onAction was supressed because loadingState is ${loadingState}`
|
|
199
|
-
: `onAction was supressed because action is disabled`, extraLoggingProps);
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
if (exit) {
|
|
203
|
-
if (url) {
|
|
204
|
-
if (isSubmissionMethod(method)) {
|
|
205
|
-
setFormErrors(null);
|
|
206
|
-
setSubmitted(true);
|
|
207
|
-
if (modelIsValid) {
|
|
208
|
-
await fetchExitResult(action, submissionData);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
await fetchExitResult(action);
|
|
213
|
-
}
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
onCloseWithEvent(result);
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
if (isSubmissionMethod(method)) {
|
|
220
|
-
setFormErrors(null);
|
|
221
|
-
setSubmitted(true);
|
|
222
|
-
if (modelIsValid) {
|
|
223
|
-
void fetchNextStep(action, submissionData);
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
dispatchEvent('Dynamic Flow - onAction supressed', Object.assign({ reason: 'invalid model' }, extraLoggingProps));
|
|
227
|
-
}
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
void fetchNextStep(action);
|
|
231
|
-
};
|
|
232
|
-
return ((0, jsx_runtime_1.jsx)(contexts_1.LogProvider, Object.assign({ flowId: flowId, stepId: step === null || step === void 0 ? void 0 : step.key, onLog: onLog }, { children: (0, jsx_runtime_1.jsx)(contexts_1.EventsContextProvider, Object.assign({ metadata: analyticsMetadata, onEvent: onEvent }, { children: (0, jsx_runtime_1.jsx)(contexts_1.DynamicFlowProvider, Object.assign({ loading: loadingState !== 'idle' }, { children: (0, jsx_runtime_1.jsx)(contexts_1.FetcherProvider, Object.assign({ fetcher: fetcher }, { children: loader !== null ? (loader) : ((0, jsx_runtime_1.jsx)(DynamicFlowStep_1.DynamicFlowStep, { step: step, model: combineModels(models), submitted: submitted, globalError: globalError, formErrors: formErrors, stepLayoutOptions: { displayStepTitle }, onAction: (action) => {
|
|
233
|
-
void onAction(action);
|
|
234
|
-
}, onModelChange: onModelChange })) })) })) })) })));
|
|
235
|
-
};
|
|
236
|
-
const DynamicFlow = (props) => ((0, jsx_runtime_1.jsx)(utils_1.ErrorBoundary, Object.assign({ onError: props.onError }, { children: (0, jsx_runtime_1.jsx)(DynamicFlowComponent, Object.assign({}, props)) })));
|
|
237
|
-
exports.default = DynamicFlow;
|
|
238
|
-
const combineModels = (formModels) => {
|
|
239
|
-
return Object.values(formModels).reduce((previous, model) => (Object.assign(Object.assign({}, previous), model)), {});
|
|
240
|
-
};
|
|
241
|
-
const isSubmissionMethod = (method = 'POST') => {
|
|
242
|
-
const submissionMethods = ['POST', 'PUT', 'PATCH'];
|
|
243
|
-
return submissionMethods.includes(method.toUpperCase());
|
|
244
|
-
};
|
|
245
|
-
const shouldTriggerRefresh = (props) => {
|
|
246
|
-
const { type, triggerSchema, triggerModel, lastTriggerModel = null } = props;
|
|
247
|
-
const isValid = () => (0, validators_1.isValidSchema)(triggerModel, triggerSchema);
|
|
248
|
-
const wasValid = () => (0, validators_1.isValidSchema)(lastTriggerModel, triggerSchema);
|
|
249
|
-
return type !== 'init' && (triggerSchema === null || triggerSchema === void 0 ? void 0 : triggerSchema.refreshFormOnChange) && (isValid() || wasValid());
|
|
250
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DynamicFlowStep = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const hooks_1 = require("../common/hooks");
|
|
6
|
-
const utils_1 = require("../common/utils");
|
|
7
|
-
const layout_1 = require("../layout");
|
|
8
|
-
const step_1 = require("../step");
|
|
9
|
-
const DynamicFlowStep = (props) => {
|
|
10
|
-
var _a;
|
|
11
|
-
const { step, globalError } = props;
|
|
12
|
-
const externalUrl = (_a = step === null || step === void 0 ? void 0 : step.external) === null || _a === void 0 ? void 0 : _a.url;
|
|
13
|
-
const { requiresManualTrigger, dismissConfirmation } = (0, hooks_1.useExternal)(externalUrl);
|
|
14
|
-
if (step === undefined) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
if (externalUrl && requiresManualTrigger) {
|
|
18
|
-
return (0, jsx_runtime_1.jsx)(step_1.ExternalConfirmationStep, { url: externalUrl, onClose: dismissConfirmation });
|
|
19
|
-
}
|
|
20
|
-
if ((0, utils_1.getStepType)(step) === 'camera') {
|
|
21
|
-
return (0, jsx_runtime_1.jsx)(step_1.CameraStep, Object.assign({}, props, { step: step }));
|
|
22
|
-
}
|
|
23
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [globalError ? ((0, jsx_runtime_1.jsx)(layout_1.DynamicAlert, { component: { context: 'negative', markdown: globalError, margin: 'lg' } })) : null, (0, jsx_runtime_1.jsx)(step_1.LayoutStep, Object.assign({}, props, { stepSpecification: step }))] }));
|
|
24
|
-
};
|
|
25
|
-
exports.DynamicFlowStep = DynamicFlowStep;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSchema = void 0;
|
|
4
|
-
// TODO HD Move this out of types
|
|
5
|
-
function isSchema(schema) {
|
|
6
|
-
return Object.prototype.hasOwnProperty.call(schema, '$ref') === false;
|
|
7
|
-
}
|
|
8
|
-
exports.isSchema = isSchema;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var DynamicFlow_1 = require("./DynamicFlow");
|
|
8
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(DynamicFlow_1).default; } });
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getObjectKeys = void 0;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const addon_actions_1 = require("@storybook/addon-actions");
|
|
9
|
-
const react_1 = require("@storybook/react");
|
|
10
|
-
const fixtures_1 = require("../../fixtures");
|
|
11
|
-
const DynamicFlow_1 = __importDefault(require("../DynamicFlow"));
|
|
12
|
-
const EditableDynamicFlow_1 = __importDefault(require("./EditableDynamicFlow"));
|
|
13
|
-
const fixtureFetcher_1 = require("./fixtureFetcher");
|
|
14
|
-
exports.getObjectKeys = Object.keys;
|
|
15
|
-
const storyMap = {};
|
|
16
|
-
const allStepNames = (0, exports.getObjectKeys)(fixtures_1.fixtures.steps);
|
|
17
|
-
allStepNames.forEach((stepName) => {
|
|
18
|
-
var _a;
|
|
19
|
-
const label = (_a = fixtures_1.fixtures.steps[stepName].key) !== null && _a !== void 0 ? _a : stepName;
|
|
20
|
-
const [group, name] = label.split('/');
|
|
21
|
-
if (!storyMap[group]) {
|
|
22
|
-
storyMap[group] = (0, react_1.storiesOf)(`Dynamic Flow/${group}`, module);
|
|
23
|
-
}
|
|
24
|
-
storyMap[group].add(name, () => ((0, jsx_runtime_1.jsx)(DynamicFlow_1.default, { flowId: "storybook", initialAction: { method: 'GET', url: `/steps/${stepName}` }, fetcher: fixtureFetcher_1.fixtureFetcher, loaderConfig: { size: 'xl', initial: true, submission: false }, onComplete: (0, addon_actions_1.action)('onComplete'), onStepChange: (0, addon_actions_1.action)('onStepChange'), onError: (0, addon_actions_1.action)('onError'), onEvent: (0, addon_actions_1.action)('onEvent'), onLog: (0, addon_actions_1.action)('onLog') }, stepName)));
|
|
25
|
-
});
|
|
26
|
-
const editable = (0, react_1.storiesOf)(`Dynamic Flow/Editable`, module);
|
|
27
|
-
editable.add('Dynamic Flow', EditableDynamicFlow_1.default, {
|
|
28
|
-
argTypes: {
|
|
29
|
-
initialStepName: {
|
|
30
|
-
label: 'Initial Step',
|
|
31
|
-
control: 'select',
|
|
32
|
-
options: Object.keys(fixtures_1.fixtures.steps),
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
args: { initialStepName: Object.keys(fixtures_1.fixtures)[0] },
|
|
36
|
-
});
|