@wise/dynamic-flow-client 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/main.js +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 +7 -6
- 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,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useStepPolling = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const __1 = require("..");
|
|
6
|
-
const contexts_1 = require("../../contexts");
|
|
7
|
-
function useStepPolling(polling, onAction) {
|
|
8
|
-
const fetcher = (0, contexts_1.useFetcher)();
|
|
9
|
-
const asyncFn = (0, react_1.useMemo)(() => {
|
|
10
|
-
if (polling) {
|
|
11
|
-
return () => {
|
|
12
|
-
return fetcher(polling.url).then((response) => {
|
|
13
|
-
if (response.ok) {
|
|
14
|
-
return response
|
|
15
|
-
.json()
|
|
16
|
-
.then((pollingResponse) => pollingResponse)
|
|
17
|
-
.catch((error) => null);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
throw new Error('failed');
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|
|
28
|
-
}, [polling, fetcher]);
|
|
29
|
-
const onPollingResponse = (0, react_1.useCallback)((pollingResponse) => {
|
|
30
|
-
if (pollingResponse === null || pollingResponse === void 0 ? void 0 : pollingResponse.action) {
|
|
31
|
-
onAction(pollingResponse.action);
|
|
32
|
-
return false; // stop polling
|
|
33
|
-
}
|
|
34
|
-
return true; // continue polling
|
|
35
|
-
}, [onAction]);
|
|
36
|
-
(0, __1.usePolling)({
|
|
37
|
-
asyncFn,
|
|
38
|
-
interval: 1000 * ((polling === null || polling === void 0 ? void 0 : polling.interval) || 0),
|
|
39
|
-
maxAttempts: (polling === null || polling === void 0 ? void 0 : polling.maxAttempts) || 0,
|
|
40
|
-
maxConsecutiveFails: 1,
|
|
41
|
-
onPollingResponse,
|
|
42
|
-
onFailure: (0, react_1.useCallback)(() => {
|
|
43
|
-
if (polling) {
|
|
44
|
-
onAction(polling.onError.action);
|
|
45
|
-
}
|
|
46
|
-
}, [onAction, polling]),
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
exports.useStepPolling = useStepPolling;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./makeFetcher"), exports);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeFetcher = void 0;
|
|
4
|
-
const api_utils_1 = require("../utils/api-utils");
|
|
5
|
-
const makeFetcher = (baseUrl, additionalHeaders) => (input, init) => {
|
|
6
|
-
const resource = applyBaseUrl(input, baseUrl || '');
|
|
7
|
-
const headers = mergeHeaders(init === null || init === void 0 ? void 0 : init.headers, additionalHeaders);
|
|
8
|
-
return fetch(resource, Object.assign(Object.assign({}, (init || {})), { headers }));
|
|
9
|
-
};
|
|
10
|
-
exports.makeFetcher = makeFetcher;
|
|
11
|
-
const applyBaseUrl = (input, baseUrl) => {
|
|
12
|
-
return typeof input === 'string' && (0, api_utils_1.isRelativePath)(input) ? baseUrl + input : input;
|
|
13
|
-
};
|
|
14
|
-
const mergeHeaders = (initHeaders, additionalHeaders) => {
|
|
15
|
-
if (!initHeaders && !additionalHeaders) {
|
|
16
|
-
return {};
|
|
17
|
-
}
|
|
18
|
-
const headers = new Headers(initHeaders);
|
|
19
|
-
for (const [key, value] of Object.entries(additionalHeaders || {})) {
|
|
20
|
-
headers.set(key, value);
|
|
21
|
-
}
|
|
22
|
-
return headers;
|
|
23
|
-
};
|
package/build/common/messages.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const react_intl_1 = require("react-intl");
|
|
4
|
-
exports.default = (0, react_intl_1.defineMessages)({
|
|
5
|
-
required: {
|
|
6
|
-
id: 'dynamicFlows.DefaultErrorMessages.required',
|
|
7
|
-
defaultMessage: 'Please fill out this field.',
|
|
8
|
-
description: 'Customer has left the required field empty',
|
|
9
|
-
},
|
|
10
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isRelativePath = exports.getJson = exports.isStatus422 = exports.isStatus2xx = void 0;
|
|
4
|
-
function isStatus2xx(status) {
|
|
5
|
-
return status >= 200 && status < 300;
|
|
6
|
-
}
|
|
7
|
-
exports.isStatus2xx = isStatus2xx;
|
|
8
|
-
function isStatus422(status) {
|
|
9
|
-
return status === 422;
|
|
10
|
-
}
|
|
11
|
-
exports.isStatus422 = isStatus422;
|
|
12
|
-
function getJson(response) {
|
|
13
|
-
return response.json();
|
|
14
|
-
}
|
|
15
|
-
exports.getJson = getJson;
|
|
16
|
-
function isRelativePath(url = '') {
|
|
17
|
-
return (['https://', 'http://', 'data:'].some((prefix) => url.slice(0, prefix.length) === prefix && url.length > prefix.length) === false);
|
|
18
|
-
}
|
|
19
|
-
exports.isRelativePath = isRelativePath;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dateToDateString = exports.dateStringToDate = void 0;
|
|
4
|
-
const validators_1 = require("../validators");
|
|
5
|
-
// function taken from: https://stackoverflow.com/questions/23593052/format-javascript-date-as-yyyy-mm-dd
|
|
6
|
-
function formatDate(date) {
|
|
7
|
-
const d = new Date(date);
|
|
8
|
-
const month = `${d.getMonth() + 1}`;
|
|
9
|
-
const day = `${d.getDate()}`;
|
|
10
|
-
const year = d.getFullYear();
|
|
11
|
-
const formattedMonth = month.length < 2 ? `0${month}` : month;
|
|
12
|
-
const formattedDay = day.length < 2 ? `0${day}` : day;
|
|
13
|
-
return [year, formattedMonth, formattedDay].join('-');
|
|
14
|
-
}
|
|
15
|
-
const dateStringToDate = (dateString) => {
|
|
16
|
-
if (!dateString) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
const [year, month, date] = dateString.split('-').map((number) => parseInt(number, 10));
|
|
20
|
-
if (!(0, validators_1.isNumber)(year) || !(0, validators_1.isNumber)(month) || !(0, validators_1.isNumber)(date)) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
return new Date(year, month - 1, date);
|
|
24
|
-
};
|
|
25
|
-
exports.dateStringToDate = dateStringToDate;
|
|
26
|
-
const dateToDateString = (date) => formatDate(date);
|
|
27
|
-
exports.dateToDateString = dateToDateString;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.debounce = void 0;
|
|
4
|
-
const debounce = (callback, waitMs) => {
|
|
5
|
-
let timeoutId;
|
|
6
|
-
let lastArgs;
|
|
7
|
-
const clearTimer = () => {
|
|
8
|
-
if (timeoutId) {
|
|
9
|
-
clearTimeout(timeoutId);
|
|
10
|
-
timeoutId = null;
|
|
11
|
-
}
|
|
12
|
-
lastArgs = null;
|
|
13
|
-
};
|
|
14
|
-
const debouncedFn = (...args) => {
|
|
15
|
-
lastArgs = args;
|
|
16
|
-
if (timeoutId !== null) {
|
|
17
|
-
clearTimeout(timeoutId);
|
|
18
|
-
}
|
|
19
|
-
timeoutId = setTimeout(() => {
|
|
20
|
-
callback(...lastArgs);
|
|
21
|
-
timeoutId = null;
|
|
22
|
-
lastArgs = null;
|
|
23
|
-
}, waitMs);
|
|
24
|
-
};
|
|
25
|
-
debouncedFn.cancel = () => {
|
|
26
|
-
if (timeoutId !== null) {
|
|
27
|
-
clearTimer();
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
debouncedFn.flush = () => {
|
|
31
|
-
if (timeoutId !== null) {
|
|
32
|
-
callback(...lastArgs);
|
|
33
|
-
clearTimer();
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
return debouncedFn;
|
|
37
|
-
};
|
|
38
|
-
exports.debounce = debounce;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.areFilesSame = exports.toBase64 = exports.toKilobytes = void 0;
|
|
4
|
-
function toKilobytes(sizeInBytes) {
|
|
5
|
-
const ONE_KB_IN_BYTES = 1024;
|
|
6
|
-
return Math.floor(sizeInBytes / ONE_KB_IN_BYTES);
|
|
7
|
-
}
|
|
8
|
-
exports.toKilobytes = toKilobytes;
|
|
9
|
-
//TODO: Refactor: This is duplicate logic as in CameraStep.tsx
|
|
10
|
-
const toBase64 = (file) => {
|
|
11
|
-
return new Promise((resolve, reject) => {
|
|
12
|
-
// we can safely assume the type of reader.result is string
|
|
13
|
-
// because we're calling reader.readAsDataURL
|
|
14
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/FileReader/result
|
|
15
|
-
const reader = new FileReader();
|
|
16
|
-
reader.readAsDataURL(file);
|
|
17
|
-
reader.addEventListener('load', () => resolve(reader.result));
|
|
18
|
-
reader.addEventListener('error', (error) => reject(error));
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
exports.toBase64 = toBase64;
|
|
22
|
-
function areFilesSame(newFiles, files) {
|
|
23
|
-
const fileIdToExistingFileMap = files.reduce((map, fileObject) => {
|
|
24
|
-
return Object.assign(Object.assign({}, map), { [fileObject.id]: fileObject });
|
|
25
|
-
}, {});
|
|
26
|
-
for (const newFile of newFiles) {
|
|
27
|
-
const existingFileObject = fileIdToExistingFileMap[newFile.id];
|
|
28
|
-
const fileDoesNotExistAlready = !existingFileObject;
|
|
29
|
-
if (fileDoesNotExistAlready) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
if (existingFileObject.status !== newFile.status) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
exports.areFilesSame = areFilesSame;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateRandomId = void 0;
|
|
4
|
-
const generateRandomId = (prefix = '') => {
|
|
5
|
-
const prefixString = prefix ? `${prefix}-` : '';
|
|
6
|
-
return `${prefixString}${Math.floor(100000000 * Math.random())}`;
|
|
7
|
-
};
|
|
8
|
-
exports.generateRandomId = generateRandomId;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./api-utils"), exports);
|
|
18
|
-
__exportStar(require("./date-utils"), exports);
|
|
19
|
-
__exportStar(require("./debounce"), exports);
|
|
20
|
-
__exportStar(require("./is-equal"), exports);
|
|
21
|
-
__exportStar(require("./file-utils"), exports);
|
|
22
|
-
__exportStar(require("./id-utils"), exports);
|
|
23
|
-
__exportStar(require("./schema-utils"), exports);
|
|
24
|
-
__exportStar(require("./step-utils"), exports);
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isEqual = void 0;
|
|
4
|
-
const isEqual = (a, b) => {
|
|
5
|
-
if (a === b) {
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
9
|
-
return a.length === b.length && a.every((item, index) => (0, exports.isEqual)(item, b[index]));
|
|
10
|
-
}
|
|
11
|
-
if (isNonNullObject(a) && isNonNullObject(b) && isObjectEquals(a, b)) {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
return false;
|
|
15
|
-
};
|
|
16
|
-
exports.isEqual = isEqual;
|
|
17
|
-
const isObjectEquals = (a, b) => {
|
|
18
|
-
const keysA = Object.keys(a);
|
|
19
|
-
const keysB = Object.keys(b);
|
|
20
|
-
return (keysA.length === keysB.length &&
|
|
21
|
-
keysA.every((key) => Object.prototype.hasOwnProperty.call(b, key) && (0, exports.isEqual)(a[key], b[key])));
|
|
22
|
-
};
|
|
23
|
-
const isNonNullObject = (a) => {
|
|
24
|
-
return typeof a === 'object' && a !== null;
|
|
25
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.shouldDebounceSchema = exports.getSchemaType = exports.isAllOfSchema = exports.isOneOfSchema = exports.isPromotedOneOfSchema = exports.isReadOnlySchema = void 0;
|
|
4
|
-
const types_1 = require("../../types");
|
|
5
|
-
const constants_1 = require("../constants");
|
|
6
|
-
const isReadOnlySchema = (schema) => !!schema.readOnly && (0, types_1.isBasicSchema)(schema);
|
|
7
|
-
exports.isReadOnlySchema = isReadOnlySchema;
|
|
8
|
-
const isPromotedOneOfSchema = (schema) => !!schema.oneOf && !!schema.promotion;
|
|
9
|
-
exports.isPromotedOneOfSchema = isPromotedOneOfSchema;
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated Please use isOneOfSchema type guard function from "dynamic-flow-types"
|
|
12
|
-
*/
|
|
13
|
-
exports.isOneOfSchema = types_1.isOneOfSchema;
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated Please use isAllOfSchema type guard function from "dynamic-flow-types"
|
|
16
|
-
*/
|
|
17
|
-
exports.isAllOfSchema = types_1.isAllOfSchema;
|
|
18
|
-
const getSchemaType = (schema) => {
|
|
19
|
-
// Order of application is important here
|
|
20
|
-
if ((0, exports.isReadOnlySchema)(schema)) {
|
|
21
|
-
return constants_1.SchemaType.READ_ONLY;
|
|
22
|
-
}
|
|
23
|
-
if ((0, types_1.isPersistAsyncSchema)(schema)) {
|
|
24
|
-
return constants_1.SchemaType.PERSIST_ASYNC;
|
|
25
|
-
}
|
|
26
|
-
if ((0, types_1.isValidationAsyncSchema)(schema)) {
|
|
27
|
-
return constants_1.SchemaType.VALIDATION_ASYNC;
|
|
28
|
-
}
|
|
29
|
-
if ((0, types_1.isObjectSchema)(schema)) {
|
|
30
|
-
return constants_1.SchemaType.OBJECT;
|
|
31
|
-
}
|
|
32
|
-
if ((0, types_1.isArraySchema)(schema)) {
|
|
33
|
-
return constants_1.SchemaType.ARRAY;
|
|
34
|
-
}
|
|
35
|
-
if ((0, exports.isPromotedOneOfSchema)(schema)) {
|
|
36
|
-
return constants_1.SchemaType.PROMOTED_ONE_OF;
|
|
37
|
-
}
|
|
38
|
-
if ((0, exports.isOneOfSchema)(schema)) {
|
|
39
|
-
return constants_1.SchemaType.ONE_OF;
|
|
40
|
-
}
|
|
41
|
-
if ((0, exports.isAllOfSchema)(schema)) {
|
|
42
|
-
return constants_1.SchemaType.ALL_OF;
|
|
43
|
-
}
|
|
44
|
-
if ((0, types_1.isBasicSchema)(schema)) {
|
|
45
|
-
return constants_1.SchemaType.BASIC;
|
|
46
|
-
}
|
|
47
|
-
return null;
|
|
48
|
-
};
|
|
49
|
-
exports.getSchemaType = getSchemaType;
|
|
50
|
-
function shouldDebounceSchema(schema) {
|
|
51
|
-
return ((0, exports.getSchemaType)(schema) === constants_1.SchemaType.BASIC &&
|
|
52
|
-
schema.type !== 'boolean' &&
|
|
53
|
-
schema.format !== 'base64url');
|
|
54
|
-
}
|
|
55
|
-
exports.shouldDebounceSchema = shouldDebounceSchema;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getStepType = exports.filterHiddenSchemas = exports.stepType = void 0;
|
|
4
|
-
const types_1 = require("../../types");
|
|
5
|
-
exports.stepType = {
|
|
6
|
-
LAYOUT: 'layout',
|
|
7
|
-
CAMERA: 'camera',
|
|
8
|
-
};
|
|
9
|
-
const isCameraStep = (step) => {
|
|
10
|
-
return isFormStep(step) && hasSingleAction(step) && hasSingleFileUploadSchemaWithCameraOnly(step);
|
|
11
|
-
};
|
|
12
|
-
const isFormStep = (step) => (step === null || step === void 0 ? void 0 : step.type) === 'form';
|
|
13
|
-
const hasSingleAction = (step) => { var _a; return ((_a = step === null || step === void 0 ? void 0 : step.actions) === null || _a === void 0 ? void 0 : _a.length) === 1; };
|
|
14
|
-
const hasSingleFileUploadSchemaWithCameraOnly = (step) => {
|
|
15
|
-
if (!step.schemas) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
const schemas = (0, exports.filterHiddenSchemas)(step.schemas);
|
|
19
|
-
if ((schemas === null || schemas === void 0 ? void 0 : schemas.length) !== 1) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
const firstSchema = schemas[0];
|
|
23
|
-
if (!(0, types_1.isObjectSchema)(firstSchema) || Object.values(firstSchema.properties).length !== 1) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
const childSchema = Object.values(firstSchema.properties)[0];
|
|
27
|
-
if (!(0, types_1.isFileUploadSchema)(childSchema)) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
return childSchema.source === 'camera';
|
|
31
|
-
};
|
|
32
|
-
const filterHiddenSchemas = (schemas) => {
|
|
33
|
-
return schemas.filter((schema) => {
|
|
34
|
-
if ((0, types_1.isObjectSchema)(schema)) {
|
|
35
|
-
return Object.values((schema === null || schema === void 0 ? void 0 : schema.properties) || {}).find((schema) => (schema === null || schema === void 0 ? void 0 : schema.hidden) !== true);
|
|
36
|
-
}
|
|
37
|
-
return (schema === null || schema === void 0 ? void 0 : schema.hidden) !== true;
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
exports.filterHiddenSchemas = filterHiddenSchemas;
|
|
41
|
-
const getStepType = (step) => {
|
|
42
|
-
if (isCameraStep(step)) {
|
|
43
|
-
return exports.stepType.CAMERA;
|
|
44
|
-
}
|
|
45
|
-
return exports.stepType.LAYOUT;
|
|
46
|
-
};
|
|
47
|
-
exports.getStepType = getStepType;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getArrayValidationFailures = exports.getValidationFailures = exports.isValidSchema = exports.getValidBasicModelOrNull = exports.getValidObjectModelParts = exports.getValidModelParts = void 0;
|
|
18
|
-
var model_validators_1 = require("./models/model-validators");
|
|
19
|
-
Object.defineProperty(exports, "getValidModelParts", { enumerable: true, get: function () { return model_validators_1.getValidModelParts; } });
|
|
20
|
-
Object.defineProperty(exports, "getValidObjectModelParts", { enumerable: true, get: function () { return model_validators_1.getValidObjectModelParts; } });
|
|
21
|
-
Object.defineProperty(exports, "getValidBasicModelOrNull", { enumerable: true, get: function () { return model_validators_1.getValidBasicModelOrNull; } });
|
|
22
|
-
var schema_validators_1 = require("./schemas/schema-validators");
|
|
23
|
-
Object.defineProperty(exports, "isValidSchema", { enumerable: true, get: function () { return schema_validators_1.isValidSchema; } });
|
|
24
|
-
var validation_failures_1 = require("./validationFailures/validation-failures");
|
|
25
|
-
Object.defineProperty(exports, "getValidationFailures", { enumerable: true, get: function () { return validation_failures_1.getValidationFailures; } });
|
|
26
|
-
Object.defineProperty(exports, "getArrayValidationFailures", { enumerable: true, get: function () { return validation_failures_1.getArrayValidationFailures; } });
|
|
27
|
-
__exportStar(require("./types/type-validators"), exports);
|
|
28
|
-
__exportStar(require("./values/value-validators"), exports);
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getValidObjectModelParts = exports.getValidBasicModelOrNull = exports.getValidModelParts = void 0;
|
|
4
|
-
const types_1 = require("../../../types");
|
|
5
|
-
const types_2 = require("../../../types");
|
|
6
|
-
const validators_1 = require("../../validators");
|
|
7
|
-
const models_utils_1 = require("./models.utils");
|
|
8
|
-
const getValidModelParts = (model, schema) => {
|
|
9
|
-
if ((0, types_1.isObjectModel)(model)) {
|
|
10
|
-
return getValidObjectModelParts(model, schema);
|
|
11
|
-
}
|
|
12
|
-
if ((0, types_1.isArrayModel)(model)) {
|
|
13
|
-
return getValidArrayModelParts(model, schema);
|
|
14
|
-
}
|
|
15
|
-
return getValidBasicModelOrNull(model, schema);
|
|
16
|
-
};
|
|
17
|
-
exports.getValidModelParts = getValidModelParts;
|
|
18
|
-
function getValidBasicModelOrNull(model, schema) {
|
|
19
|
-
if ((0, validators_1.isNull)(model)) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
if (schema.oneOf) {
|
|
23
|
-
return (0, models_utils_1.cleanBasicModelWithOneOfSchema)(model, schema);
|
|
24
|
-
}
|
|
25
|
-
if (!(0, validators_1.isUndefined)(schema.const) && model === schema.const) {
|
|
26
|
-
return model;
|
|
27
|
-
}
|
|
28
|
-
if (schema.type) {
|
|
29
|
-
switch (schema.type) {
|
|
30
|
-
case 'string':
|
|
31
|
-
return (0, models_utils_1.cleanModelWithStringSchema)(model);
|
|
32
|
-
case 'number':
|
|
33
|
-
case 'integer':
|
|
34
|
-
return (0, models_utils_1.cleanModelWithNumberSchema)(model);
|
|
35
|
-
case 'boolean':
|
|
36
|
-
return (0, models_utils_1.cleanModelWithBooleanSchema)(model);
|
|
37
|
-
default:
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
// Unrecognised schema
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
exports.getValidBasicModelOrNull = getValidBasicModelOrNull;
|
|
45
|
-
function getValidObjectModelParts(model, schema) {
|
|
46
|
-
if ((0, types_1.isBasicSchema)(schema) || (0, types_1.isArraySchema)(schema) || (0, validators_1.isNull)(model)) {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
if (schema.allOf) {
|
|
50
|
-
return (0, models_utils_1.cleanObjectModelWithAllOfSchema)(model, schema);
|
|
51
|
-
}
|
|
52
|
-
if (schema.oneOf) {
|
|
53
|
-
return (0, models_utils_1.cleanObjectModelWithOneOfSchema)(model, schema);
|
|
54
|
-
}
|
|
55
|
-
if (!(0, validators_1.isUndefined)(schema.const) && model === schema.const) {
|
|
56
|
-
return model;
|
|
57
|
-
}
|
|
58
|
-
return (0, types_1.isObjectSchema)(schema) ? (0, models_utils_1.cleanObjectModelWithObjectSchema)(model, schema) : null;
|
|
59
|
-
}
|
|
60
|
-
exports.getValidObjectModelParts = getValidObjectModelParts;
|
|
61
|
-
function getValidArrayModelParts(model, schema) {
|
|
62
|
-
if ((0, types_2.isOneOfSchema)(schema)) {
|
|
63
|
-
return (0, models_utils_1.cleanArrayModelWithOneOfSchema)(model, schema);
|
|
64
|
-
}
|
|
65
|
-
if (!(0, types_1.isArraySchema)(schema)) {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
return (0, models_utils_1.cleanModelWithArraySchema)(model, schema);
|
|
69
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cleanObjectModelWithOneOfSchema = exports.cleanObjectModelWithAllOfSchema = exports.cleanObjectModelWithObjectSchema = exports.cleanModelWithArraySchema = exports.cleanModelWithBooleanSchema = exports.cleanModelWithNumberSchema = exports.cleanModelWithStringSchema = exports.cleanArrayModelWithOneOfSchema = exports.cleanBasicModelWithOneOfSchema = void 0;
|
|
4
|
-
const types_1 = require("../../../types");
|
|
5
|
-
const type_validators_1 = require("../types/type-validators");
|
|
6
|
-
const value_validators_1 = require("../values/value-validators");
|
|
7
|
-
const model_validators_1 = require("./model-validators");
|
|
8
|
-
function cleanBasicModelWithOneOfSchema(model, schema) {
|
|
9
|
-
return schema.oneOf.some((nestedSchema) => (0, model_validators_1.getValidBasicModelOrNull)(model, nestedSchema) === model)
|
|
10
|
-
? model
|
|
11
|
-
: null;
|
|
12
|
-
}
|
|
13
|
-
exports.cleanBasicModelWithOneOfSchema = cleanBasicModelWithOneOfSchema;
|
|
14
|
-
function cleanArrayModelWithOneOfSchema(model, schema) {
|
|
15
|
-
var _a;
|
|
16
|
-
const validModels = schema.oneOf
|
|
17
|
-
.map((nestedSchema) => getValidArrayModelOrNull(model, nestedSchema))
|
|
18
|
-
.filter((item) => item !== null);
|
|
19
|
-
if (validModels.length === 0) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
return (_a = validModels.find((model) => model.some((item) => item !== null))) !== null && _a !== void 0 ? _a : validModels[0];
|
|
23
|
-
}
|
|
24
|
-
exports.cleanArrayModelWithOneOfSchema = cleanArrayModelWithOneOfSchema;
|
|
25
|
-
function getValidArrayModelOrNull(model, schema) {
|
|
26
|
-
if (!(0, types_1.isArraySchema)(schema)) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
if (!(0, types_1.isListArraySchema)(schema)) {
|
|
30
|
-
return null; // we don't support tuples at the moment
|
|
31
|
-
}
|
|
32
|
-
return cleanModelWithArraySchema(model, schema);
|
|
33
|
-
}
|
|
34
|
-
function cleanModelWithStringSchema(model) {
|
|
35
|
-
return (0, type_validators_1.isString)(model) && !(0, value_validators_1.isEmpty)(model) ? model : null;
|
|
36
|
-
}
|
|
37
|
-
exports.cleanModelWithStringSchema = cleanModelWithStringSchema;
|
|
38
|
-
function cleanModelWithNumberSchema(model) {
|
|
39
|
-
return (0, type_validators_1.isNumber)(model) ? model : null;
|
|
40
|
-
}
|
|
41
|
-
exports.cleanModelWithNumberSchema = cleanModelWithNumberSchema;
|
|
42
|
-
function cleanModelWithBooleanSchema(model) {
|
|
43
|
-
return (0, type_validators_1.isBoolean)(model) ? model : null;
|
|
44
|
-
}
|
|
45
|
-
exports.cleanModelWithBooleanSchema = cleanModelWithBooleanSchema;
|
|
46
|
-
function cleanModelWithArraySchema(model, schema) {
|
|
47
|
-
if (!(0, type_validators_1.isArray)(model)) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
if (!(0, types_1.isListArraySchema)(schema)) {
|
|
51
|
-
return null; // we don't support tuples at the moment
|
|
52
|
-
}
|
|
53
|
-
if (model.length > 0) {
|
|
54
|
-
const expectedType = typeof model[0];
|
|
55
|
-
if (!model.every((item) => typeof item === expectedType)) {
|
|
56
|
-
return new Array(model.length).fill(null);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return model.map((childModel) => (0, model_validators_1.getValidBasicModelOrNull)(childModel, schema.items));
|
|
60
|
-
}
|
|
61
|
-
exports.cleanModelWithArraySchema = cleanModelWithArraySchema;
|
|
62
|
-
function cleanObjectModelWithObjectSchema(model, schema) {
|
|
63
|
-
return Object.keys(schema.properties).reduce((cleanedModel, property) => {
|
|
64
|
-
// If the property exists in the model, clean it, and add it
|
|
65
|
-
if (model && !(0, type_validators_1.isUndefined)(model[property])) {
|
|
66
|
-
const subModel = model[property];
|
|
67
|
-
const subSchema = schema.properties[property];
|
|
68
|
-
const newValue = (0, model_validators_1.getValidModelParts)(subModel, subSchema);
|
|
69
|
-
if (!(0, type_validators_1.isNull)(newValue)) {
|
|
70
|
-
return Object.assign(Object.assign({}, cleanedModel), { [property]: newValue });
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return cleanedModel;
|
|
74
|
-
}, {});
|
|
75
|
-
}
|
|
76
|
-
exports.cleanObjectModelWithObjectSchema = cleanObjectModelWithObjectSchema;
|
|
77
|
-
function cleanObjectModelWithAllOfSchema(model, schema) {
|
|
78
|
-
return schema.allOf.reduce((cleanObjectModel, nestedSchema) => {
|
|
79
|
-
const validSubsetOfModel = (0, model_validators_1.getValidObjectModelParts)(model, nestedSchema);
|
|
80
|
-
if ((0, types_1.isObjectModel)(validSubsetOfModel)) {
|
|
81
|
-
// Extend model with valid subset
|
|
82
|
-
return Object.assign(Object.assign({}, cleanObjectModel), validSubsetOfModel);
|
|
83
|
-
}
|
|
84
|
-
return cleanObjectModel;
|
|
85
|
-
}, {});
|
|
86
|
-
}
|
|
87
|
-
exports.cleanObjectModelWithAllOfSchema = cleanObjectModelWithAllOfSchema;
|
|
88
|
-
function cleanObjectModelWithOneOfSchema(model, schema) {
|
|
89
|
-
return schema.oneOf
|
|
90
|
-
.map((nestedSchema) => (0, model_validators_1.getValidObjectModelParts)(model, nestedSchema))
|
|
91
|
-
.reduce((combined, current) => {
|
|
92
|
-
// If we didn't find anything valid yet, and current is good, return it
|
|
93
|
-
if ((0, type_validators_1.isNull)(combined)) {
|
|
94
|
-
return current;
|
|
95
|
-
}
|
|
96
|
-
// If we're dealing with two objects, deep merge them into one
|
|
97
|
-
if ((0, types_1.isObjectModel)(combined) && (0, types_1.isObjectModel)(current)) {
|
|
98
|
-
return deepMergeObject(combined, current);
|
|
99
|
-
}
|
|
100
|
-
// If the current one is null, return what we already had
|
|
101
|
-
if ((0, type_validators_1.isNull)(current)) {
|
|
102
|
-
return combined;
|
|
103
|
-
}
|
|
104
|
-
return current;
|
|
105
|
-
}, null);
|
|
106
|
-
}
|
|
107
|
-
exports.cleanObjectModelWithOneOfSchema = cleanObjectModelWithOneOfSchema;
|
|
108
|
-
function deepMergeObject(object1, object2) {
|
|
109
|
-
return Object.keys(object2).reduce((acc, property) => {
|
|
110
|
-
const object1Property = object1[property];
|
|
111
|
-
const object2Property = object2[property];
|
|
112
|
-
if ((0, types_1.isObjectModel)(object1Property) && (0, types_1.isObjectModel)(object2Property)) {
|
|
113
|
-
return Object.assign(Object.assign({}, acc), { [property]: deepMergeObject(object1Property, object2Property) });
|
|
114
|
-
}
|
|
115
|
-
return Object.assign(Object.assign({}, acc), { [property]: object2[property] });
|
|
116
|
-
}, Object.assign({}, object1));
|
|
117
|
-
}
|