@wise/dynamic-flow-client 3.4.0-experimental-ed080a1 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/build/i18n/de.json +2 -1
  2. package/build/i18n/en.json +1 -0
  3. package/build/i18n/es.json +1 -0
  4. package/build/i18n/fr.json +1 -0
  5. package/build/i18n/hu.json +1 -0
  6. package/build/i18n/id.json +1 -0
  7. package/build/i18n/it.json +1 -0
  8. package/build/i18n/ja.json +1 -0
  9. package/build/i18n/pl.json +1 -0
  10. package/build/i18n/pt.json +1 -0
  11. package/build/i18n/ro.json +1 -0
  12. package/build/i18n/ru.json +1 -0
  13. package/build/i18n/th.json +1 -0
  14. package/build/i18n/tr.json +1 -0
  15. package/build/i18n/zh_CN.json +1 -0
  16. package/build/i18n/zh_HK.json +1 -0
  17. package/build/main.js +1116 -966
  18. package/build/main.min.js +1 -1
  19. package/build/main.mjs +945 -795
  20. package/build/types/common/messages/multi-select.messages.d.ts +8 -0
  21. package/build/types/legacy/common/utils/schema-utils.d.ts +4 -3
  22. package/build/types/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.d.ts +6 -6
  23. package/build/types/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multiSelectSchema/MultiSelectSchema.d.ts +9 -0
  24. package/build/types/revamp/domain/components/MultiUploadInputComponent.d.ts +1 -1
  25. package/package.json +3 -3
  26. package/build/common/httpClientContext/HttpClientContext.js +0 -35
  27. package/build/common/httpClientContext/index.js +0 -1
  28. package/build/common/makeHttpClient/index.js +0 -1
  29. package/build/common/makeHttpClient/makeHttpClient.js +0 -34
  30. package/build/common/messages/generic-error.messages.js +0 -18
  31. package/build/common/messages/help.messages.js +0 -8
  32. package/build/common/messages/multi-file-upload.messages.js +0 -18
  33. package/build/common/messages/paragraph.messages.js +0 -13
  34. package/build/common/messages/repeatable.messages.js +0 -23
  35. package/build/common/messages/validation.array.messages.js +0 -13
  36. package/build/common/messages/validation.messages.js +0 -53
  37. package/build/common/utils/api-utils.js +0 -4
  38. package/build/legacy/common/constants/DateMode.js +0 -4
  39. package/build/legacy/common/constants/FeatureName.js +0 -4
  40. package/build/legacy/common/constants/FormControlType.js +0 -21
  41. package/build/legacy/common/constants/MonthFormat.js +0 -4
  42. package/build/legacy/common/constants/Size.js +0 -7
  43. package/build/legacy/common/constants/index.js +0 -4
  44. package/build/legacy/common/contexts/dynamicFlowContexts/DynamicFlowContexts.js +0 -36
  45. package/build/legacy/common/contexts/dynamicFlowContexts/usePendingPromiseCounter.js +0 -13
  46. package/build/legacy/common/contexts/eventsContext/EventsContext.js +0 -38
  47. package/build/legacy/common/contexts/featureContext/FeatureContext.js +0 -22
  48. package/build/legacy/common/contexts/index.js +0 -3
  49. package/build/legacy/common/contexts/logContext/LogContext.js +0 -44
  50. package/build/legacy/common/hooks/index.js +0 -7
  51. package/build/legacy/common/hooks/useDebouncedFunction/useDebouncedFunction.js +0 -9
  52. package/build/legacy/common/hooks/useExternal/useExternal.js +0 -15
  53. package/build/legacy/common/hooks/useExternalStepPolling/useExternalStepPolling.js +0 -70
  54. package/build/legacy/common/hooks/usePersistAsync/usePersistAsync.js +0 -172
  55. package/build/legacy/common/hooks/usePolling/usePolling.js +0 -51
  56. package/build/legacy/common/hooks/usePrevious/usePrevious.js +0 -8
  57. package/build/legacy/common/hooks/useStepPolling/useStepPolling.js +0 -43
  58. package/build/legacy/common/messages.js +0 -8
  59. package/build/legacy/common/utils/api-utils.js +0 -6
  60. package/build/legacy/common/utils/date-utils.js +0 -22
  61. package/build/legacy/common/utils/debounce.js +0 -38
  62. package/build/legacy/common/utils/file-utils.js +0 -45
  63. package/build/legacy/common/utils/id-utils.js +0 -5
  64. package/build/legacy/common/utils/index.js +0 -11
  65. package/build/legacy/common/utils/is-equal.js +0 -21
  66. package/build/legacy/common/utils/misc-utils.js +0 -4
  67. package/build/legacy/common/utils/mobile-utils.js +0 -23
  68. package/build/legacy/common/utils/model-utils.js +0 -33
  69. package/build/legacy/common/utils/schema-utils.js +0 -97
  70. package/build/legacy/common/utils/step-utils.js +0 -32
  71. package/build/legacy/common/validators/index.js +0 -5
  72. package/build/legacy/common/validators/models/model-utils.js +0 -119
  73. package/build/legacy/common/validators/models/model-validators.js +0 -62
  74. package/build/legacy/common/validators/schemas/schema-validators.js +0 -101
  75. package/build/legacy/common/validators/types/type-validators.js +0 -14
  76. package/build/legacy/common/validators/validationFailures/validation-failures.js +0 -139
  77. package/build/legacy/common/validators/validationFailures/validation-failures.utils.js +0 -40
  78. package/build/legacy/common/validators/values/value-validators.js +0 -6
  79. package/build/legacy/dynamic-flow-types.js +0 -1
  80. package/build/legacy/dynamicFlow/BackButton.js +0 -22
  81. package/build/legacy/dynamicFlow/DynamicFlowStep.js +0 -37
  82. package/build/legacy/formControl/FormControl.js +0 -266
  83. package/build/legacy/formControl/index.js +0 -1
  84. package/build/legacy/formControl/utils/getAutocompleteString.js +0 -80
  85. package/build/legacy/formControl/utils/index.js +0 -2
  86. package/build/legacy/formControl/utils/value-utils.js +0 -108
  87. package/build/legacy/jsonSchemaForm/allOfSchema/AllOfSchema.js +0 -50
  88. package/build/legacy/jsonSchemaForm/allOfSchema/index.js +0 -1
  89. package/build/legacy/jsonSchemaForm/arrayTypeSchema/ArraySchema.js +0 -25
  90. package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.js +0 -30
  91. package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.js +0 -141
  92. package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/index.js +0 -1
  93. package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/index.js +0 -2
  94. package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/upload-utils.js +0 -79
  95. package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/useFormattedDefaultErrorMessages.js +0 -14
  96. package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/ItemSummary.js +0 -7
  97. package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchema.js +0 -134
  98. package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchemaStep.js +0 -85
  99. package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/utils/summary-utils.js +0 -135
  100. package/build/legacy/jsonSchemaForm/arrayTypeSchema/index.js +0 -1
  101. package/build/legacy/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.js +0 -111
  102. package/build/legacy/jsonSchemaForm/basicTypeSchema/index.js +0 -1
  103. package/build/legacy/jsonSchemaForm/controlFeedback/ControlFeedback.js +0 -86
  104. package/build/legacy/jsonSchemaForm/controlFeedback/index.js +0 -1
  105. package/build/legacy/jsonSchemaForm/help/Help.js +0 -20
  106. package/build/legacy/jsonSchemaForm/help/index.js +0 -1
  107. package/build/legacy/jsonSchemaForm/objectSchema/ObjectSchema.js +0 -77
  108. package/build/legacy/jsonSchemaForm/objectSchema/index.js +0 -1
  109. package/build/legacy/jsonSchemaForm/oneOfSchema/OneOfSchema.js +0 -155
  110. package/build/legacy/jsonSchemaForm/oneOfSchema/index.js +0 -1
  111. package/build/legacy/jsonSchemaForm/oneOfSchema/utils.js +0 -68
  112. package/build/legacy/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.js +0 -26
  113. package/build/legacy/jsonSchemaForm/persistAsyncSchema/index.js +0 -1
  114. package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.js +0 -165
  115. package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/index.js +0 -1
  116. package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.js +0 -131
  117. package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.js +0 -31
  118. package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/index.js +0 -1
  119. package/build/legacy/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.js +0 -72
  120. package/build/legacy/jsonSchemaForm/promotedOneOfSchema/index.js +0 -1
  121. package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promoted-one-of-utils.js +0 -8
  122. package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfCheckboxControl.js +0 -27
  123. package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfControl.js +0 -31
  124. package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfRadioControl.js +0 -32
  125. package/build/legacy/jsonSchemaForm/readOnlySchema/ReadOnlySchema.js +0 -54
  126. package/build/legacy/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.js +0 -13
  127. package/build/legacy/jsonSchemaForm/readOnlySchema/index.js +0 -1
  128. package/build/legacy/jsonSchemaForm/schemaFormControl/SchemaFormControl.js +0 -133
  129. package/build/legacy/jsonSchemaForm/schemaFormControl/index.js +0 -1
  130. package/build/legacy/jsonSchemaForm/schemaFormControl/utils/index.js +0 -1
  131. package/build/legacy/jsonSchemaForm/schemaFormControl/utils/mapping-utils.js +0 -107
  132. package/build/legacy/layout/DynamicLayout.js +0 -68
  133. package/build/legacy/layout/alert/DynamicAlert.js +0 -29
  134. package/build/legacy/layout/box/DynamicBox.js +0 -41
  135. package/build/legacy/layout/button/DynamicButton.js +0 -27
  136. package/build/legacy/layout/button/utils.js +0 -45
  137. package/build/legacy/layout/columns/DynamicColumns.js +0 -38
  138. package/build/legacy/layout/decision/DynamicDecision.js +0 -21
  139. package/build/legacy/layout/divider/DynamicDivider.js +0 -9
  140. package/build/legacy/layout/external/DynamicExternal.js +0 -32
  141. package/build/legacy/layout/external/DynamicExternal.messages.js +0 -8
  142. package/build/legacy/layout/form/DynamicForm.js +0 -22
  143. package/build/legacy/layout/heading/DynamicHeading.js +0 -51
  144. package/build/legacy/layout/icon/DynamicIcon.js +0 -17
  145. package/build/legacy/layout/icon/FlagIcon.js +0 -198
  146. package/build/legacy/layout/icon/NamedIcon.js +0 -19
  147. package/build/legacy/layout/image/DynamicImage.js +0 -111
  148. package/build/legacy/layout/index.js +0 -20
  149. package/build/legacy/layout/instructions/DynamicInstructions.js +0 -30
  150. package/build/legacy/layout/list/DynamicStatusList.js +0 -37
  151. package/build/legacy/layout/loadingIndicator/DynamicLoadingIndicator.js +0 -11
  152. package/build/legacy/layout/markdown/DynamicMarkdown.js +0 -23
  153. package/build/legacy/layout/modal/DynamicModal.js +0 -26
  154. package/build/legacy/layout/paragraph/DynamicParagraph.js +0 -46
  155. package/build/legacy/layout/paragraph/useSnackBarIfAvailable.js +0 -9
  156. package/build/legacy/layout/review/DynamicReview.js +0 -58
  157. package/build/legacy/layout/search/DynamicSearch.js +0 -58
  158. package/build/legacy/layout/search/SearchInput.js +0 -17
  159. package/build/legacy/layout/search/SearchResults.js +0 -31
  160. package/build/legacy/layout/search/useSearch.js +0 -137
  161. package/build/legacy/layout/utils/getNavigationOptionMedia.js +0 -28
  162. package/build/legacy/layout/utils/index.js +0 -32
  163. package/build/legacy/step/cameraStep/CameraStep.js +0 -124
  164. package/build/legacy/step/cameraStep/cameraCapture/CameraCapture.js +0 -161
  165. package/build/legacy/step/cameraStep/cameraCapture/CameraCapture.messages.js +0 -58
  166. package/build/legacy/step/cameraStep/cameraCapture/components/bottomBar/BottomBar.js +0 -28
  167. package/build/legacy/step/cameraStep/cameraCapture/components/index.js +0 -3
  168. package/build/legacy/step/cameraStep/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.js +0 -19
  169. package/build/legacy/step/cameraStep/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.messages.js +0 -8
  170. package/build/legacy/step/cameraStep/cameraCapture/hooks/useFullScreenOrientationLock.js +0 -60
  171. package/build/legacy/step/cameraStep/cameraCapture/hooks/useVideoConstraints.js +0 -80
  172. package/build/legacy/step/cameraStep/cameraCapture/index.js +0 -1
  173. package/build/legacy/step/cameraStep/cameraCapture/overlay/Overlay.js +0 -77
  174. package/build/legacy/step/cameraStep/cameraCapture/screens/cameraErrorScreen/CameraErrorScreen.js +0 -18
  175. package/build/legacy/step/cameraStep/cameraCapture/screens/index.js +0 -1
  176. package/build/legacy/step/cameraStep/cameraCapture/tracking/index.js +0 -109
  177. package/build/legacy/step/cameraStep/cameraCapture/types/index.js +0 -7
  178. package/build/legacy/step/cameraStep/cameraCapture/utils/index.js +0 -107
  179. package/build/legacy/step/cameraStep/index.js +0 -1
  180. package/build/legacy/step/externalConfirmationStep/ExternalConfirmationStep.js +0 -64
  181. package/build/legacy/step/externalConfirmationStep/ExternalConfirmationStep.messages.js +0 -23
  182. package/build/legacy/step/externalConfirmationStep/index.js +0 -1
  183. package/build/legacy/step/index.js +0 -3
  184. package/build/legacy/step/layoutStep/LayoutStep.js +0 -33
  185. package/build/legacy/step/layoutStep/index.js +0 -1
  186. package/build/legacy/step/layoutStep/utils/index.js +0 -2
  187. package/build/legacy/step/layoutStep/utils/inline-reference-utils.js +0 -105
  188. package/build/legacy/step/layoutStep/utils/layout-utils.js +0 -212
@@ -1,70 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import { useCallback, useMemo } from 'react';
13
- import { usePolling } from '..';
14
- import { useHttpClient } from '../../../../common/httpClientContext';
15
- /** @deprecated External step is no longer supported */
16
- export function useExternalStepPolling(polling, onAction) {
17
- var httpClient = useHttpClient();
18
- var asyncFn = useMemo(function () {
19
- if (polling) {
20
- return function () {
21
- return httpClient(polling.url)
22
- .then(function (response) {
23
- if (response.ok) {
24
- try {
25
- return response.json();
26
- }
27
- catch (_a) {
28
- throw new Error('failed');
29
- }
30
- }
31
- else {
32
- throw new Error('failed');
33
- }
34
- })["catch"](function (error) {
35
- throw new Error(error.message === 'failed' ? 'failed' : 'network failed');
36
- });
37
- };
38
- }
39
- return undefined;
40
- }, [polling, httpClient]);
41
- var onPollingResponse = useCallback(function (pollingResponse) {
42
- var responseHandlers = (polling === null || polling === void 0 ? void 0 : polling.responseHandlers) || [];
43
- var responseHandler = responseHandlers.find(function (handler) { return handler.result === pollingResponse.result; });
44
- if (responseHandler === null || responseHandler === void 0 ? void 0 : responseHandler.action) {
45
- var action = responseHandler.action;
46
- if (action.exit) {
47
- var mergedResult = __assign(__assign({}, (action.result || {})), (pollingResponse.data || {}));
48
- onAction(__assign(__assign({}, action), { result: mergedResult }));
49
- }
50
- else {
51
- var mergedData = __assign(__assign({}, (action.data || {})), (pollingResponse.data || {}));
52
- onAction(__assign(__assign({}, action), { data: mergedData }));
53
- }
54
- return false; // stop polling
55
- }
56
- return true; // continue polling
57
- }, [polling === null || polling === void 0 ? void 0 : polling.responseHandlers, onAction]);
58
- usePolling({
59
- asyncFn: asyncFn,
60
- interval: (polling === null || polling === void 0 ? void 0 : polling.interval) || 0,
61
- maxAttempts: (polling === null || polling === void 0 ? void 0 : polling.maxAttempts) || 0,
62
- maxConsecutiveFails: (polling === null || polling === void 0 ? void 0 : polling.maxConsecutiveFails) || 0,
63
- onPollingResponse: onPollingResponse,
64
- onFailure: useCallback(function () {
65
- if (polling) {
66
- onAction(polling.onError.action);
67
- }
68
- }, [onAction, polling])
69
- });
70
- }
@@ -1,172 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
- import { useState } from 'react';
49
- import { useIntl } from 'react-intl';
50
- import { isBlobSchema } from '../../utils';
51
- import { isNull, isObject, isNumber, isString, isValidSchema } from '../../validators';
52
- import messages from '../../../../common/messages/generic-error.messages';
53
- import { getErrorFromResponse } from '../../../jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema'; // FIXME: extract these functions form that schema component to either here or their own module
54
- import { useHttpClient } from '../../../../common/httpClientContext';
55
- export var usePersistAsync = function (persistAsync) {
56
- var _a = useState(null), abortController = _a[0], setAbortController = _a[1];
57
- var httpClient = useHttpClient();
58
- var intl = useIntl();
59
- var schema = persistAsync.schema;
60
- function handlePersistAsync(model) {
61
- return __awaiter(this, void 0, void 0, function () {
62
- var isInvalidSchema;
63
- return __generator(this, function (_a) {
64
- switch (_a.label) {
65
- case 0:
66
- isInvalidSchema = model instanceof Blob ? !isBlobSchema(schema) : !isValidSchema(model, schema);
67
- if (isNull(model) || isInvalidSchema) {
68
- handleError();
69
- }
70
- return [4 /*yield*/, performPersistAsync(model)];
71
- case 1:
72
- // eslint-disable-next-line @typescript-eslint/return-await
73
- return [2 /*return*/, _a.sent()];
74
- }
75
- });
76
- });
77
- }
78
- var abortCurrentRequestAndGetNewAbortSignal = function () {
79
- if (abortController) {
80
- abortController.abort();
81
- }
82
- var newAbortController = new AbortController();
83
- setAbortController(newAbortController);
84
- return newAbortController.signal;
85
- };
86
- function constructFetchInit(model) {
87
- var _a;
88
- var isBlob = isBlobSchema(schema);
89
- var signal = abortCurrentRequestAndGetNewAbortSignal();
90
- var requestKey = persistAsync.param;
91
- var requestBody = isBlob
92
- ? wrapInFormData(requestKey, model)
93
- : JSON.stringify((_a = {}, _a[requestKey] = model, _a));
94
- return {
95
- method: persistAsync.method,
96
- headers: __assign({}, (!isBlob && { 'Content-Type': 'application/json' })),
97
- body: requestBody,
98
- signal: signal
99
- };
100
- }
101
- function performPersistAsync(payload) {
102
- return __awaiter(this, void 0, void 0, function () {
103
- var response, jsonResponse, id, error_1;
104
- return __generator(this, function (_a) {
105
- switch (_a.label) {
106
- case 0:
107
- _a.trys.push([0, 3, , 4]);
108
- return [4 /*yield*/, httpClient(persistAsync.url, constructFetchInit(payload))];
109
- case 1:
110
- response = _a.sent();
111
- if (!response.ok) {
112
- // eslint-disable-next-line @typescript-eslint/return-await
113
- return [2 /*return*/, handleHTTPError(response)];
114
- }
115
- return [4 /*yield*/, response.json()];
116
- case 2:
117
- jsonResponse = _a.sent();
118
- if (isObject(jsonResponse)) {
119
- id = jsonResponse[persistAsync.idProperty];
120
- if (isString(id) || isNumber(id)) {
121
- return [2 /*return*/, { data: id }];
122
- }
123
- }
124
- return [2 /*return*/, handleError()];
125
- case 3:
126
- error_1 = _a.sent();
127
- return [2 /*return*/, handleError(error_1)];
128
- case 4: return [2 /*return*/];
129
- }
130
- });
131
- });
132
- }
133
- function handleHTTPError(response) {
134
- return __awaiter(this, void 0, void 0, function () {
135
- var jsonResponse, error;
136
- return __generator(this, function (_a) {
137
- switch (_a.label) {
138
- case 0:
139
- if (!(response.status === 422)) return [3 /*break*/, 2];
140
- return [4 /*yield*/, response.json()];
141
- case 1:
142
- jsonResponse = _a.sent();
143
- if (isObject(jsonResponse)) {
144
- error = getErrorFromResponse(persistAsync.param, jsonResponse);
145
- if (isString(error)) {
146
- throw new Error(error);
147
- }
148
- }
149
- _a.label = 2;
150
- case 2: throw new Error(intl.formatMessage(messages.genericErrorRetryHint));
151
- }
152
- });
153
- });
154
- }
155
- var handleError = function (error) {
156
- var message = hasStringMessage(error)
157
- ? error.message
158
- : intl.formatMessage(messages.genericErrorRetryHint);
159
- throw new Error(message);
160
- };
161
- return handlePersistAsync;
162
- };
163
- function wrapInFormData(key, value) {
164
- var formData = new FormData();
165
- if (value !== null) {
166
- formData.append(key, value);
167
- }
168
- return formData;
169
- }
170
- function hasStringMessage(value) {
171
- return isObject(value) && 'message' in value && typeof value.message === 'string';
172
- }
@@ -1,51 +0,0 @@
1
- import { useEffect, useMemo, useRef } from 'react';
2
- export function usePolling(_a) {
3
- var asyncFn = _a.asyncFn, interval = _a.interval, maxAttempts = _a.maxAttempts, maxConsecutiveFails = _a.maxConsecutiveFails, onPollingResponse = _a.onPollingResponse, onFailure = _a.onFailure;
4
- var onPollingResponseReference = useRef(onPollingResponse);
5
- var onFailureReference = useRef(onFailure);
6
- var poll = useMemo(function () {
7
- return createPollingClosure(asyncFn, maxAttempts, maxConsecutiveFails, function (pollingResponse) { return onPollingResponseReference.current(pollingResponse); }, function () { return onFailureReference.current(); });
8
- }, [asyncFn, maxAttempts, maxConsecutiveFails]);
9
- // eslint-disable-next-line consistent-return
10
- useEffect(function () {
11
- if (interval > 0) {
12
- var intervalReference_1 = setInterval(function () {
13
- poll();
14
- }, interval);
15
- return function () { return clearInterval(intervalReference_1); };
16
- }
17
- }, [poll, interval]);
18
- useEffect(function () {
19
- onPollingResponseReference.current = onPollingResponse;
20
- onFailureReference.current = onFailure;
21
- }, [onPollingResponse, onFailure]);
22
- }
23
- export function createPollingClosure(asyncFn, maxAttempts, maxConsecutiveFails, onPollingResponse, onFailure) {
24
- var isPolling = true;
25
- var consecutiveFailures = 0;
26
- var attemptCount = 0;
27
- return asyncFn
28
- ? function () {
29
- if (isPolling) {
30
- attemptCount++;
31
- asyncFn()
32
- .then(function (pollingResponse) {
33
- consecutiveFailures = 0;
34
- isPolling = onPollingResponse(pollingResponse);
35
- })["catch"](function (error) {
36
- // do not fail on network errors
37
- if (error.message !== 'network failed') {
38
- consecutiveFailures += 1;
39
- }
40
- })["finally"](function () {
41
- if (consecutiveFailures >= maxConsecutiveFails || attemptCount >= maxAttempts) {
42
- onFailure();
43
- isPolling = false;
44
- }
45
- });
46
- }
47
- }
48
- : function () {
49
- //
50
- };
51
- }
@@ -1,8 +0,0 @@
1
- import { useEffect, useRef } from 'react';
2
- export var usePrevious = function (value) {
3
- var reference = useRef();
4
- useEffect(function () {
5
- reference.current = value;
6
- }, [value]);
7
- return reference.current;
8
- };
@@ -1,43 +0,0 @@
1
- import { useCallback, useMemo } from 'react';
2
- import { usePolling } from '..';
3
- import { useHttpClient } from '../../../../common/httpClientContext';
4
- export function useStepPolling(polling, onAction) {
5
- var httpClient = useHttpClient();
6
- var asyncFn = useMemo(function () {
7
- if (polling) {
8
- return function () {
9
- return httpClient(polling.url)
10
- .then(function (response) {
11
- if (response.ok) {
12
- return response
13
- .json()
14
- .then(function (pollingResponse) { return pollingResponse; })["catch"](function (error) { return null; });
15
- }
16
- throw new Error('failed');
17
- })["catch"](function (error) {
18
- throw new Error(error.message === 'failed' ? 'failed' : 'network failed');
19
- });
20
- };
21
- }
22
- return undefined;
23
- }, [polling, httpClient]);
24
- var onPollingResponse = useCallback(function (pollingResponse) {
25
- if (pollingResponse === null || pollingResponse === void 0 ? void 0 : pollingResponse.action) {
26
- onAction(pollingResponse.action);
27
- return false; // stop polling
28
- }
29
- return true; // continue polling
30
- }, [onAction]);
31
- usePolling({
32
- asyncFn: asyncFn,
33
- interval: 1000 * ((polling === null || polling === void 0 ? void 0 : polling.interval) || 0),
34
- maxAttempts: (polling === null || polling === void 0 ? void 0 : polling.maxAttempts) || 0,
35
- maxConsecutiveFails: 1,
36
- onPollingResponse: onPollingResponse,
37
- onFailure: useCallback(function () {
38
- if (polling) {
39
- onAction(polling.onError.action);
40
- }
41
- }, [onAction, polling])
42
- });
43
- }
@@ -1,8 +0,0 @@
1
- import { defineMessages } from 'react-intl';
2
- export default defineMessages({
3
- required: {
4
- id: 'dynamicFlows.DefaultErrorMessages.required',
5
- defaultMessage: 'Please fill out this field.',
6
- description: 'Customer has left the required field empty'
7
- }
8
- });
@@ -1,6 +0,0 @@
1
- export function isStatus2xx(status) {
2
- return status >= 200 && status < 300;
3
- }
4
- export function isStatus422(status) {
5
- return status === 422;
6
- }
@@ -1,22 +0,0 @@
1
- import { isNumber } from '../validators';
2
- // function taken from: https://stackoverflow.com/questions/23593052/format-javascript-date-as-yyyy-mm-dd
3
- function formatDate(date) {
4
- var d = new Date(date);
5
- var month = String(d.getMonth() + 1);
6
- var day = String(d.getDate());
7
- var year = d.getFullYear();
8
- var formattedMonth = month.length < 2 ? "0".concat(month) : month;
9
- var formattedDay = day.length < 2 ? "0".concat(day) : day;
10
- return [year, formattedMonth, formattedDay].join('-');
11
- }
12
- export var dateStringToDate = function (dateString) {
13
- if (!dateString) {
14
- return null;
15
- }
16
- var _a = dateString.split('-').map(function (number) { return parseInt(number, 10); }), year = _a[0], month = _a[1], date = _a[2];
17
- if (!isNumber(year) || !isNumber(month) || !isNumber(date)) {
18
- return null;
19
- }
20
- return new Date(year, month - 1, date);
21
- };
22
- export var dateToDateString = function (date) { return formatDate(date); };
@@ -1,38 +0,0 @@
1
- export var debounce = function (callback, waitMs) {
2
- var timeoutId;
3
- var lastArgs;
4
- var clearTimer = function () {
5
- if (timeoutId) {
6
- clearTimeout(timeoutId);
7
- timeoutId = null;
8
- }
9
- lastArgs = null;
10
- };
11
- var debouncedFn = function () {
12
- var args = [];
13
- for (var _i = 0; _i < arguments.length; _i++) {
14
- args[_i] = arguments[_i];
15
- }
16
- lastArgs = args;
17
- if (timeoutId !== null) {
18
- clearTimeout(timeoutId);
19
- }
20
- timeoutId = setTimeout(function () {
21
- callback.apply(void 0, lastArgs);
22
- timeoutId = null;
23
- lastArgs = null;
24
- }, waitMs);
25
- };
26
- debouncedFn.cancel = function () {
27
- if (timeoutId !== null) {
28
- clearTimer();
29
- }
30
- };
31
- debouncedFn.flush = function () {
32
- if (timeoutId !== null) {
33
- callback.apply(void 0, lastArgs);
34
- clearTimer();
35
- }
36
- };
37
- return debouncedFn;
38
- };
@@ -1,45 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- export function toKilobytes(sizeInBytes) {
13
- var ONE_KB_IN_BYTES = 1024;
14
- return Math.floor(sizeInBytes / ONE_KB_IN_BYTES);
15
- }
16
- // TODO: Refactor: This is duplicate logic as in CameraStep.tsx
17
- export var toBase64 = function (file) {
18
- return new Promise(function (resolve, reject) {
19
- // we can safely assume the type of reader.result is string
20
- // because we're calling reader.readAsDataURL
21
- // https://developer.mozilla.org/en-US/docs/Web/API/FileReader/result
22
- var reader = new FileReader();
23
- reader.readAsDataURL(file);
24
- reader.addEventListener('load', function () { return resolve(reader.result); });
25
- reader.addEventListener('error', function (error) { return reject(error); });
26
- });
27
- };
28
- export function areFilesSame(newFiles, files) {
29
- var fileIdToExistingFileMap = files.reduce(function (map, fileObject) {
30
- var _a;
31
- return (__assign(__assign({}, map), (_a = {}, _a[fileObject.id] = fileObject, _a)));
32
- }, {});
33
- for (var _i = 0, newFiles_1 = newFiles; _i < newFiles_1.length; _i++) {
34
- var newFile = newFiles_1[_i];
35
- var existingFileObject = fileIdToExistingFileMap[newFile.id];
36
- var fileDoesNotExistAlready = !existingFileObject;
37
- if (fileDoesNotExistAlready) {
38
- return false;
39
- }
40
- if (existingFileObject.status !== newFile.status) {
41
- return false;
42
- }
43
- }
44
- return true;
45
- }
@@ -1,5 +0,0 @@
1
- export var generateRandomId = function (prefix) {
2
- if (prefix === void 0) { prefix = ''; }
3
- var prefixString = prefix ? "".concat(prefix, "-") : '';
4
- return "".concat(prefixString).concat(Math.floor(100000000 * Math.random()));
5
- };
@@ -1,11 +0,0 @@
1
- export * from './api-utils';
2
- export * from './date-utils';
3
- export * from './debounce';
4
- export * from './is-equal';
5
- export * from './file-utils';
6
- export * from './id-utils';
7
- export * from './step-utils';
8
- export * from './model-utils';
9
- export * from './misc-utils';
10
- export * from './schema-utils';
11
- export * from './mobile-utils';
@@ -1,21 +0,0 @@
1
- export var isEqual = function (a, b) {
2
- if (a === b) {
3
- return true;
4
- }
5
- if (Array.isArray(a) && Array.isArray(b)) {
6
- return a.length === b.length && a.every(function (item, index) { return isEqual(item, b[index]); });
7
- }
8
- if (isNonNullObject(a) && isNonNullObject(b) && isObjectEquals(a, b)) {
9
- return true;
10
- }
11
- return false;
12
- };
13
- var isObjectEquals = function (a, b) {
14
- var keysA = Object.keys(a);
15
- var keysB = Object.keys(b);
16
- return (keysA.length === keysB.length &&
17
- keysA.every(function (key) { return Object.hasOwnProperty.call(b, key) && isEqual(a[key], b[key]); }));
18
- };
19
- var isNonNullObject = function (a) {
20
- return typeof a === 'object' && a !== null;
21
- };
@@ -1,4 +0,0 @@
1
- import { isNull, isString } from '../validators';
2
- export var isBasicError = function (error) {
3
- return isString(error) || isNull(error);
4
- };
@@ -1,23 +0,0 @@
1
- export var isMobile = function () { return isMobileScreenSize() && (isTouchScreen() || isMobileUA()); };
2
- export var isMobileUA = function (userAgent) {
3
- if (userAgent === void 0) { userAgent = window.navigator.userAgent; }
4
- // eslint-disable-next-line regexp/no-unused-capturing-group
5
- return /mobi|\b(iphone|android|blackberry|webos|windows phone)\b/i.test(userAgent);
6
- };
7
- export var isMobileScreenSize = function (width, height) {
8
- if (width === void 0) { width = window.screen.width; }
9
- if (height === void 0) { height = window.screen.height; }
10
- return width < 768 || height < 768;
11
- };
12
- export var isTouchScreen = function (navigator, matchMedia) {
13
- if (navigator === void 0) { navigator = window.navigator; }
14
- if (matchMedia === void 0) { matchMedia = window.matchMedia; }
15
- if ('maxTouchPoints' in navigator) {
16
- return navigator.maxTouchPoints > 0;
17
- }
18
- var mQ = matchMedia === null || matchMedia === void 0 ? void 0 : matchMedia('(pointer:coarse)');
19
- if ((mQ === null || mQ === void 0 ? void 0 : mQ.media) === '(pointer:coarse)') {
20
- return Boolean(mQ.matches);
21
- }
22
- return false;
23
- };
@@ -1,33 +0,0 @@
1
- import { isArray, isBoolean, isNull, isNumber, isString } from '../validators';
2
- export var isObjectModel = function (model) {
3
- return typeof model === 'object' && model !== null && model.constructor === Object;
4
- };
5
- export var isNullableObjectModel = function (model) {
6
- return isNull(model) || isObjectModel(model);
7
- };
8
- export var isNullableBasicModel = function (model) {
9
- return isBoolean(model) || isNumber(model) || isString(model) || isNull(model);
10
- };
11
- export var isNullableStringModel = function (model) {
12
- return isString(model) || isNull(model);
13
- };
14
- export var isArrayModel = function (model) {
15
- if (isArray(model)) {
16
- if (model.length === 0) {
17
- return true;
18
- }
19
- return model.every(function (item) {
20
- return typeof item === 'string' ||
21
- typeof item === 'number' ||
22
- typeof item === 'boolean' ||
23
- typeof item === 'object';
24
- });
25
- }
26
- return false;
27
- };
28
- export var isNullableArrayModel = function (model) {
29
- if (isNull(model)) {
30
- return true;
31
- }
32
- return isArrayModel(model);
33
- };