@wise/dynamic-flow-client 0.4.0 → 0.4.2

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 (233) hide show
  1. package/build/common/constants/DateMode.js +2 -2
  2. package/build/common/constants/FormControlType.js +2 -2
  3. package/build/common/constants/MonthFormat.js +2 -2
  4. package/build/common/constants/SchemaType.js +2 -2
  5. package/build/common/constants/Size.js +2 -2
  6. package/build/common/constants/index.js +1 -1
  7. package/build/common/contexts/dynamicFlowContexts/DynamicFlowContexts.js +15 -27
  8. package/build/common/contexts/dynamicFlowContexts/usePendingPromiseCounter.js +11 -9
  9. package/build/common/contexts/eventsContext/EventsContext.js +11 -28
  10. package/build/common/contexts/fetcherContexts/FetcherContexts.js +14 -27
  11. package/build/common/contexts/index.js +1 -1
  12. package/build/common/contexts/logContext/LogContext.js +12 -30
  13. package/build/common/hooks/index.js +1 -1
  14. package/build/common/hooks/useDebouncedFunction/useDebouncedFunction.js +3 -3
  15. package/build/common/hooks/useExternal/useExternal.js +8 -8
  16. package/build/common/hooks/useExternalStepPolling/useExternalStepPolling.js +20 -31
  17. package/build/common/hooks/usePersistAsync/usePersistAsync.js +60 -139
  18. package/build/common/hooks/usePolling/usePolling.js +20 -21
  19. package/build/common/hooks/usePrevious/usePrevious.js +5 -5
  20. package/build/common/hooks/useStepPolling/useStepPolling.js +15 -14
  21. package/build/common/makeFetcher/index.js +1 -1
  22. package/build/common/makeFetcher/makeFetcher.js +10 -24
  23. package/build/common/messages.js +5 -5
  24. package/build/common/utils/api-utils.js +3 -4
  25. package/build/common/utils/date-utils.js +11 -11
  26. package/build/common/utils/debounce.js +11 -15
  27. package/build/common/utils/file-utils.js +12 -25
  28. package/build/common/utils/id-utils.js +4 -5
  29. package/build/common/utils/index.js +1 -1
  30. package/build/common/utils/is-equal.js +8 -8
  31. package/build/common/utils/schema-utils.js +6 -6
  32. package/build/common/utils/step-utils.js +14 -14
  33. package/build/common/validators/index.js +7 -7
  34. package/build/common/validators/models/model-validators.js +8 -8
  35. package/build/common/validators/models/models.utils.js +29 -42
  36. package/build/common/validators/schemas/schema-validators.js +11 -13
  37. package/build/common/validators/types/type-validators.js +9 -13
  38. package/build/common/validators/validationFailures/validation-failures.js +14 -14
  39. package/build/common/validators/validationFailures/validation-failures.utils.js +5 -7
  40. package/build/common/validators/values/value-validators.js +4 -6
  41. package/build/dynamicFlow/DynamicFlow.js +185 -307
  42. package/build/dynamicFlow/DynamicFlowStep.js +12 -23
  43. package/build/dynamicFlow/DynamicFlowTypes.js +1 -1
  44. package/build/dynamicFlow/index.js +6 -14
  45. package/build/dynamicFlow/stories/DynamicFlow.story.js +20 -20
  46. package/build/dynamicFlow/stories/EditableDynamicFlow.js +20 -33
  47. package/build/dynamicFlow/stories/fixtureFetcher.js +46 -104
  48. package/build/dynamicFlow/utils/errorBoundary/ErrorBoundary.js +22 -40
  49. package/build/dynamicFlow/utils/errorBoundary/ErrorBoundary.messages.js +6 -6
  50. package/build/dynamicFlow/utils/errorBoundary/ErrorBoundaryAlert.js +10 -11
  51. package/build/dynamicFlow/utils/index.js +5 -2
  52. package/build/dynamicFlow/utils/responseParsers/response-parsers.js +53 -118
  53. package/build/dynamicFlow/utils/useDebouncedRefresh/useDebouncedRefresh.js +9 -9
  54. package/build/dynamicFlow/utils/useDynamicFlowState.js +51 -74
  55. package/build/dynamicFlow/utils/useLoader.js +9 -20
  56. package/build/fixtures/components/alert.js +8 -8
  57. package/build/fixtures/components/box.js +7 -7
  58. package/build/fixtures/components/button.js +25 -36
  59. package/build/fixtures/components/columns.js +10 -10
  60. package/build/fixtures/components/copyable.js +6 -6
  61. package/build/fixtures/components/decision.js +15 -15
  62. package/build/fixtures/components/heading.js +7 -7
  63. package/build/fixtures/components/image.js +10 -10
  64. package/build/fixtures/components/index.js +17 -25
  65. package/build/fixtures/components/info.js +22 -6
  66. package/build/fixtures/components/list.js +8 -8
  67. package/build/fixtures/components/loading-indicator.js +5 -5
  68. package/build/fixtures/components/paragraph.js +9 -9
  69. package/build/fixtures/components/review.js +11 -11
  70. package/build/fixtures/examples/camera-capture.js +29 -29
  71. package/build/fixtures/examples/index.js +9 -17
  72. package/build/fixtures/examples/recipient-update.js +69 -69
  73. package/build/fixtures/examples/recipient.js +63 -63
  74. package/build/fixtures/examples/single-file-upload.js +21 -21
  75. package/build/fixtures/examples/step-validation-errors.js +21 -21
  76. package/build/fixtures/features/action-response.js +8 -8
  77. package/build/fixtures/features/external.js +8 -8
  78. package/build/fixtures/features/index.js +9 -17
  79. package/build/fixtures/features/persist-async.js +11 -11
  80. package/build/fixtures/features/polling.js +9 -9
  81. package/build/fixtures/features/validation-async.js +10 -10
  82. package/build/fixtures/index.js +11 -22
  83. package/build/fixtures/jsonSchemaForm/allOf.js +30 -30
  84. package/build/fixtures/jsonSchemaForm/audRecipient.js +271 -271
  85. package/build/fixtures/jsonSchemaForm/currency.js +12 -12
  86. package/build/fixtures/jsonSchemaForm/multipleFileUploadBase64.js +11 -11
  87. package/build/fixtures/jsonSchemaForm/multipleFileUploadBlob.js +11 -11
  88. package/build/fixtures/jsonSchemaForm/oneOf.js +27 -27
  89. package/build/fixtures/jsonSchemaForm/oneOfTabs.js +16 -16
  90. package/build/fixtures/jsonSchemaForm/promotedOneOf.js +17 -17
  91. package/build/fixtures/jsonSchemaForm/promotedOneOfCheckbox.js +30 -30
  92. package/build/fixtures/jsonSchemaForm/simple.js +16 -16
  93. package/build/fixtures/jsonSchemaForm/uploadPersistAsync.js +19 -19
  94. package/build/fixtures/jsonSchemaForm/validationAsync.js +8 -8
  95. package/build/fixtures/layouts/all.js +37 -37
  96. package/build/fixtures/layouts/final-step-layout.js +9 -9
  97. package/build/fixtures/layouts/index.js +10 -18
  98. package/build/fixtures/layouts/list.js +10 -10
  99. package/build/fixtures/layouts/pay-in.js +23 -23
  100. package/build/fixtures/layouts/review.js +38 -38
  101. package/build/fixtures/layouts/success.js +15 -15
  102. package/build/fixtures/responses/action-response-final.js +8 -8
  103. package/build/fixtures/responses/action.js +3 -3
  104. package/build/fixtures/responses/exit.js +3 -3
  105. package/build/fixtures/responses/index.js +8 -16
  106. package/build/fixtures/responses/recipient-update-final.js +8 -8
  107. package/build/fixtures/schemas/basic-form.js +11 -11
  108. package/build/fixtures/schemas/index.js +8 -16
  109. package/build/fixtures/schemas/number-and-integer.js +11 -11
  110. package/build/fixtures/schemas/one-of.js +43 -46
  111. package/build/fixtures/schemas/string-formats.js +15 -15
  112. package/build/fixtures/utils/image-util.js +8 -8
  113. package/build/formControl/FormControl.js +118 -148
  114. package/build/formControl/index.js +6 -14
  115. package/build/formControl/utils/index.js +1 -1
  116. package/build/formControl/utils/value-utils.js +18 -23
  117. package/build/i18n/index.js +31 -31
  118. package/build/index.js +13 -10
  119. package/build/jsonSchemaForm/JsonSchemaForm.js +12 -24
  120. package/build/jsonSchemaForm/allOfSchema/AllOfSchema.js +24 -37
  121. package/build/jsonSchemaForm/allOfSchema/index.js +6 -14
  122. package/build/jsonSchemaForm/arrayTypeSchema/ArraySchema.js +9 -20
  123. package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.js +9 -20
  124. package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/index.js +6 -14
  125. package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.js +56 -115
  126. package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.messages.js +7 -7
  127. package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/index.js +6 -14
  128. package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/index.js +1 -1
  129. package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/upload-utils.js +19 -71
  130. package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/useFormattedDefaultErrorMessages.js +10 -11
  131. package/build/jsonSchemaForm/arrayTypeSchema/index.js +6 -14
  132. package/build/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.js +45 -62
  133. package/build/jsonSchemaForm/basicTypeSchema/index.js +6 -14
  134. package/build/jsonSchemaForm/controlFeedback/ControlFeedback.js +39 -50
  135. package/build/jsonSchemaForm/controlFeedback/ControlFeedback.messages.js +18 -18
  136. package/build/jsonSchemaForm/controlFeedback/index.js +6 -14
  137. package/build/jsonSchemaForm/genericSchema/GenericSchema.js +52 -61
  138. package/build/jsonSchemaForm/genericSchema/index.js +6 -14
  139. package/build/jsonSchemaForm/help/Help.js +9 -9
  140. package/build/jsonSchemaForm/help/Help.messages.js +5 -5
  141. package/build/jsonSchemaForm/help/index.js +6 -14
  142. package/build/jsonSchemaForm/index.js +6 -14
  143. package/build/jsonSchemaForm/objectSchema/ObjectSchema.js +28 -49
  144. package/build/jsonSchemaForm/objectSchema/index.js +6 -14
  145. package/build/jsonSchemaForm/oneOfSchema/OneOfSchema.js +54 -74
  146. package/build/jsonSchemaForm/oneOfSchema/index.js +6 -14
  147. package/build/jsonSchemaForm/oneOfSchema/utils/const-schema-utils.js +3 -3
  148. package/build/jsonSchemaForm/oneOfSchema/utils/index.js +1 -1
  149. package/build/jsonSchemaForm/oneOfSchema/utils/one-of-utils.js +19 -20
  150. package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.js +11 -22
  151. package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.messages.js +5 -5
  152. package/build/jsonSchemaForm/persistAsyncSchema/index.js +6 -14
  153. package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.js +73 -127
  154. package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/index.js +6 -14
  155. package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.js +45 -110
  156. package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.js +17 -17
  157. package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/index.js +6 -14
  158. package/build/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.js +28 -47
  159. package/build/jsonSchemaForm/promotedOneOfSchema/index.js +6 -14
  160. package/build/jsonSchemaForm/promotedOneOfSchema/promoted-one-of-utils.js +4 -4
  161. package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfCheckboxControl.js +13 -24
  162. package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfControl.js +11 -22
  163. package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfRadioControl.js +12 -23
  164. package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.js +24 -26
  165. package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.js +6 -6
  166. package/build/jsonSchemaForm/readOnlySchema/index.js +6 -14
  167. package/build/jsonSchemaForm/schemaFormControl/SchemaFormControl.js +26 -39
  168. package/build/jsonSchemaForm/schemaFormControl/index.js +6 -14
  169. package/build/jsonSchemaForm/schemaFormControl/utils/currency-utils.js +5 -5
  170. package/build/jsonSchemaForm/schemaFormControl/utils/index.js +1 -1
  171. package/build/jsonSchemaForm/schemaFormControl/utils/mapping-utils.js +30 -47
  172. package/build/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.js +57 -119
  173. package/build/jsonSchemaForm/validationAsyncSchema/index.js +6 -14
  174. package/build/layout/DynamicLayout.js +10 -21
  175. package/build/layout/alert/DynamicAlert.js +9 -9
  176. package/build/layout/box/DynamicBox.js +12 -23
  177. package/build/layout/button/DynamicButton.js +16 -27
  178. package/build/layout/columns/DynamicColumns.js +13 -24
  179. package/build/layout/decision/DynamicDecision.js +16 -27
  180. package/build/layout/divider/DynamicDivider.js +7 -8
  181. package/build/layout/external/DynamicExternal.js +16 -28
  182. package/build/layout/external/DynamicExternal.messages.js +5 -5
  183. package/build/layout/form/DynamicForm.js +10 -21
  184. package/build/layout/heading/DynamicHeading.js +12 -23
  185. package/build/layout/icon/DynamicIcon.js +9 -10
  186. package/build/layout/image/DynamicImage.js +43 -93
  187. package/build/layout/index.js +21 -29
  188. package/build/layout/info/DynamicInfo.js +7 -19
  189. package/build/layout/list/DynamicList.js +14 -26
  190. package/build/layout/loadingIndicator/DynamicLoadingIndicator.js +8 -9
  191. package/build/layout/paragraph/DynamicParagraph.js +19 -37
  192. package/build/layout/paragraph/DynamicParagraph.messages.js +6 -6
  193. package/build/layout/paragraph/useSnackBarIfAvailable.js +4 -4
  194. package/build/layout/review/DynamicReview.js +14 -26
  195. package/build/layout/utils.js +4 -6
  196. package/build/step/cameraStep/CameraStep.js +42 -88
  197. package/build/step/cameraStep/cameraCapture/CameraCapture.js +48 -105
  198. package/build/step/cameraStep/cameraCapture/CameraCapture.messages.js +7 -7
  199. package/build/step/cameraStep/cameraCapture/components/index.js +10 -28
  200. package/build/step/cameraStep/cameraCapture/hooks/index.js +17 -72
  201. package/build/step/cameraStep/cameraCapture/index.js +6 -14
  202. package/build/step/cameraStep/cameraCapture/overlay/Overlay.js +33 -45
  203. package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.js +8 -19
  204. package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.messages.js +6 -6
  205. package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.js +9 -21
  206. package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.messages.js +7 -7
  207. package/build/step/cameraStep/cameraCapture/screens/index.js +6 -14
  208. package/build/step/cameraStep/cameraCapture/tracking/index.js +17 -99
  209. package/build/step/cameraStep/cameraCapture/utils/index.js +33 -96
  210. package/build/step/cameraStep/index.js +6 -14
  211. package/build/step/externalConfirmationStep/ExternalConfirmationStep.js +20 -21
  212. package/build/step/externalConfirmationStep/ExternalConfirmationStep.messages.js +8 -8
  213. package/build/step/externalConfirmationStep/index.js +6 -14
  214. package/build/step/index.js +7 -15
  215. package/build/step/layoutStep/LayoutStep.js +19 -19
  216. package/build/step/layoutStep/index.js +6 -14
  217. package/build/step/layoutStep/utils/index.js +3 -14
  218. package/build/step/layoutStep/utils/inline-reference-utils.js +29 -46
  219. package/build/step/layoutStep/utils/layout-utils.js +34 -53
  220. package/build/types/common/FormControl.js +1 -1
  221. package/build/types/index.js +13 -13
  222. package/build/types/specification/Action.js +1 -1
  223. package/build/types/specification/FileUploadSchema.js +1 -1
  224. package/build/types/specification/LayoutComponent.js +1 -1
  225. package/build/types/specification/Model.js +9 -17
  226. package/build/types/specification/PersistAsync.js +1 -1
  227. package/build/types/specification/Polling.js +1 -1
  228. package/build/types/specification/Promotion.js +1 -1
  229. package/build/types/specification/Schema.js +8 -8
  230. package/build/types/specification/Step.js +3 -5
  231. package/build/types/specification/ValidationAsync.js +1 -1
  232. package/build/types/specification/core.js +1 -1
  233. package/package.json +1 -1
@@ -1,172 +1,93 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- 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;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
50
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
4
  };
52
- exports.__esModule = true;
5
+ Object.defineProperty(exports, "__esModule", { value: true });
53
6
  exports.usePersistAsync = void 0;
54
- var react_1 = require("react");
55
- var react_intl_1 = require("react-intl");
56
- var validators_1 = require("../../../common/validators");
57
- var PersistAsyncSchema_messages_1 = __importDefault(require("../../../jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.messages"));
58
- var PersistAsyncBasicSchema_1 = require("../../../jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema"); // FIXME: extract these functions form that schema component to either here or their own module
59
- var types_1 = require("../../../types");
60
- var contexts_1 = require("../../contexts");
61
- var validators_2 = require("../../validators");
62
- var usePersistAsync = function (persistAsync) {
63
- var _a = (0, react_1.useState)(null), abortController = _a[0], setAbortController = _a[1];
64
- var fetcher = (0, contexts_1.useFetcher)();
65
- var intl = (0, react_intl_1.useIntl)();
66
- var schema = persistAsync.schema;
67
- function handlePersistAsync(model) {
68
- return __awaiter(this, void 0, void 0, function () {
69
- var isInvalidSchema;
70
- return __generator(this, function (_a) {
71
- switch (_a.label) {
72
- case 0:
73
- isInvalidSchema = model instanceof Blob ? !(0, types_1.isBlobSchema)(schema) : !(0, validators_2.isValidSchema)(model, schema);
74
- if ((0, validators_1.isNull)(model) || isInvalidSchema) {
75
- handleError();
76
- }
77
- return [4 /*yield*/, performPersistAsync(model)];
78
- case 1: return [2 /*return*/, _a.sent()];
79
- }
80
- });
81
- });
7
+ const react_1 = require("react");
8
+ const react_intl_1 = require("react-intl");
9
+ const validators_1 = require("../../../common/validators");
10
+ const PersistAsyncSchema_messages_1 = __importDefault(require("../../../jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.messages"));
11
+ const PersistAsyncBasicSchema_1 = require("../../../jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema"); // FIXME: extract these functions form that schema component to either here or their own module
12
+ const types_1 = require("../../../types");
13
+ const contexts_1 = require("../../contexts");
14
+ const validators_2 = require("../../validators");
15
+ const usePersistAsync = (persistAsync) => {
16
+ const [abortController, setAbortController] = (0, react_1.useState)(null);
17
+ const fetcher = (0, contexts_1.useFetcher)();
18
+ const intl = (0, react_intl_1.useIntl)();
19
+ const { schema } = persistAsync;
20
+ async function handlePersistAsync(model) {
21
+ const isInvalidSchema = model instanceof Blob ? !(0, types_1.isBlobSchema)(schema) : !(0, validators_2.isValidSchema)(model, schema);
22
+ if ((0, validators_1.isNull)(model) || isInvalidSchema) {
23
+ handleError();
24
+ }
25
+ return await performPersistAsync(model);
82
26
  }
83
- var abortCurrentRequestAndGetNewAbortSignal = function () {
27
+ const abortCurrentRequestAndGetNewAbortSignal = () => {
84
28
  if (abortController) {
85
29
  abortController.abort();
86
30
  }
87
- var newAbortController = new AbortController();
31
+ const newAbortController = new AbortController();
88
32
  setAbortController(newAbortController);
89
33
  return newAbortController.signal;
90
34
  };
91
35
  function constructFetchInit(model) {
92
- var _a;
93
- var isBlob = (0, types_1.isBlobSchema)(schema);
94
- var signal = abortCurrentRequestAndGetNewAbortSignal();
95
- var requestKey = persistAsync.param;
96
- var requestBody = isBlob
36
+ const isBlob = (0, types_1.isBlobSchema)(schema);
37
+ const signal = abortCurrentRequestAndGetNewAbortSignal();
38
+ const requestKey = persistAsync.param;
39
+ const requestBody = isBlob
97
40
  ? wrapInFormData(requestKey, model)
98
- : JSON.stringify((_a = {}, _a[requestKey] = model, _a));
41
+ : JSON.stringify({ [requestKey]: model });
99
42
  return {
100
43
  method: persistAsync.method,
101
- headers: __assign({}, (!isBlob && { 'Content-Type': 'application/json' })),
44
+ headers: Object.assign({}, (!isBlob && { 'Content-Type': 'application/json' })),
102
45
  body: requestBody,
103
- signal: signal
46
+ signal,
104
47
  };
105
48
  }
106
- function performPersistAsync(payload) {
107
- return __awaiter(this, void 0, void 0, function () {
108
- var response, jsonResponse, id, error_1;
109
- return __generator(this, function (_a) {
110
- switch (_a.label) {
111
- case 0:
112
- _a.trys.push([0, 3, , 4]);
113
- return [4 /*yield*/, fetcher(persistAsync.url, constructFetchInit(payload))];
114
- case 1:
115
- response = _a.sent();
116
- if (!response.ok) {
117
- return [2 /*return*/, handleHTTPError(response)];
118
- }
119
- return [4 /*yield*/, response.json()];
120
- case 2:
121
- jsonResponse = _a.sent();
122
- if ((0, validators_1.isObject)(jsonResponse)) {
123
- id = jsonResponse[persistAsync.idProperty];
124
- if ((0, validators_1.isString)(id) || (0, validators_1.isNumber)(id)) {
125
- return [2 /*return*/, { data: id }];
126
- }
127
- }
128
- return [2 /*return*/, handleError()];
129
- case 3:
130
- error_1 = _a.sent();
131
- return [2 /*return*/, handleError(error_1)];
132
- case 4: return [2 /*return*/];
49
+ async function performPersistAsync(payload) {
50
+ try {
51
+ const response = await fetcher(persistAsync.url, constructFetchInit(payload));
52
+ if (!response.ok) {
53
+ return handleHTTPError(response);
54
+ }
55
+ const jsonResponse = await response.json();
56
+ if ((0, validators_1.isObject)(jsonResponse)) {
57
+ const id = jsonResponse[persistAsync.idProperty];
58
+ if ((0, validators_1.isString)(id) || (0, validators_1.isNumber)(id)) {
59
+ return { data: id };
133
60
  }
134
- });
135
- });
61
+ }
62
+ return handleError();
63
+ }
64
+ catch (error) {
65
+ return handleError(error);
66
+ }
136
67
  }
137
- function handleHTTPError(response) {
138
- return __awaiter(this, void 0, void 0, function () {
139
- var jsonResponse, error;
140
- return __generator(this, function (_a) {
141
- switch (_a.label) {
142
- case 0:
143
- if (!(response.status === 422)) return [3 /*break*/, 2];
144
- return [4 /*yield*/, response.json()];
145
- case 1:
146
- jsonResponse = _a.sent();
147
- if ((0, validators_1.isObject)(jsonResponse)) {
148
- error = (0, PersistAsyncBasicSchema_1.getErrorFromResponse)(persistAsync.param, jsonResponse);
149
- if ((0, validators_1.isString)(error)) {
150
- throw new Error(error);
151
- }
152
- }
153
- _a.label = 2;
154
- case 2: throw new Error(intl.formatMessage(PersistAsyncSchema_messages_1["default"].genericError));
68
+ async function handleHTTPError(response) {
69
+ if (response.status === 422) {
70
+ const jsonResponse = await response.json();
71
+ if ((0, validators_1.isObject)(jsonResponse)) {
72
+ const error = (0, PersistAsyncBasicSchema_1.getErrorFromResponse)(persistAsync.param, jsonResponse);
73
+ if ((0, validators_1.isString)(error)) {
74
+ throw new Error(error);
155
75
  }
156
- });
157
- });
76
+ }
77
+ }
78
+ throw new Error(intl.formatMessage(PersistAsyncSchema_messages_1.default.genericError));
158
79
  }
159
- var handleError = function (error) {
160
- var message = hasStringMessage(error)
80
+ const handleError = (error) => {
81
+ const message = hasStringMessage(error)
161
82
  ? error.message
162
- : intl.formatMessage(PersistAsyncSchema_messages_1["default"].genericError);
83
+ : intl.formatMessage(PersistAsyncSchema_messages_1.default.genericError);
163
84
  throw new Error(message);
164
85
  };
165
86
  return handlePersistAsync;
166
87
  };
167
88
  exports.usePersistAsync = usePersistAsync;
168
89
  function wrapInFormData(key, value) {
169
- var formData = new FormData();
90
+ const formData = new FormData();
170
91
  if (value !== null) {
171
92
  formData.append(key, value);
172
93
  }
@@ -1,44 +1,43 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createPollingClosure = exports.usePolling = void 0;
4
4
  /* eslint-disable fp/no-mutation */
5
- var react_1 = require("react");
6
- function usePolling(_a) {
7
- var asyncFn = _a.asyncFn, interval = _a.interval, maxAttempts = _a.maxAttempts, maxConsecutiveFails = _a.maxConsecutiveFails, onPollingResponse = _a.onPollingResponse, onFailure = _a.onFailure;
8
- var onPollingResponseReference = (0, react_1.useRef)(onPollingResponse);
9
- var onFailureReference = (0, react_1.useRef)(onFailure);
10
- var poll = (0, react_1.useMemo)(function () {
11
- return createPollingClosure(asyncFn, maxAttempts, maxConsecutiveFails, function (pollingResponse) { return onPollingResponseReference.current(pollingResponse); }, function () { return onFailureReference.current(); });
12
- }, [asyncFn, maxAttempts, maxConsecutiveFails]);
13
- (0, react_1.useEffect)(function () {
5
+ const react_1 = require("react");
6
+ function usePolling({ asyncFn, interval, maxAttempts, maxConsecutiveFails, onPollingResponse, onFailure, }) {
7
+ const onPollingResponseReference = (0, react_1.useRef)(onPollingResponse);
8
+ const onFailureReference = (0, react_1.useRef)(onFailure);
9
+ const poll = (0, react_1.useMemo)(() => createPollingClosure(asyncFn, maxAttempts, maxConsecutiveFails, (pollingResponse) => onPollingResponseReference.current(pollingResponse), () => onFailureReference.current()), [asyncFn, maxAttempts, maxConsecutiveFails]);
10
+ (0, react_1.useEffect)(() => {
14
11
  if (interval > 0) {
15
- var intervalReference_1 = setInterval(function () {
12
+ const intervalReference = setInterval(() => {
16
13
  poll();
17
14
  }, interval);
18
- return function () { return clearInterval(intervalReference_1); };
15
+ return () => clearInterval(intervalReference);
19
16
  }
20
17
  }, [poll, interval]);
21
- (0, react_1.useEffect)(function () {
18
+ (0, react_1.useEffect)(() => {
22
19
  onPollingResponseReference.current = onPollingResponse;
23
20
  onFailureReference.current = onFailure;
24
21
  }, [onPollingResponse, onFailure]);
25
22
  }
26
23
  exports.usePolling = usePolling;
27
24
  function createPollingClosure(asyncFn, maxAttempts, maxConsecutiveFails, onPollingResponse, onFailure) {
28
- var isPolling = true;
29
- var consecutiveFailures = 0;
30
- var attemptCount = 0;
25
+ let isPolling = true;
26
+ let consecutiveFailures = 0;
27
+ let attemptCount = 0;
31
28
  return asyncFn
32
- ? function () {
29
+ ? () => {
33
30
  if (isPolling) {
34
31
  attemptCount++;
35
32
  asyncFn()
36
- .then(function (pollingResponse) {
33
+ .then((pollingResponse) => {
37
34
  consecutiveFailures = 0;
38
35
  isPolling = onPollingResponse(pollingResponse);
39
- })["catch"](function () {
36
+ })
37
+ .catch(() => {
40
38
  consecutiveFailures++;
41
- })["finally"](function () {
39
+ })
40
+ .finally(() => {
42
41
  if (consecutiveFailures >= maxConsecutiveFails || attemptCount >= maxAttempts) {
43
42
  onFailure();
44
43
  isPolling = false;
@@ -46,7 +45,7 @@ function createPollingClosure(asyncFn, maxAttempts, maxConsecutiveFails, onPolli
46
45
  });
47
46
  }
48
47
  }
49
- : function () {
48
+ : () => {
50
49
  //
51
50
  };
52
51
  }
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.usePrevious = void 0;
4
- var react_1 = require("react");
5
- var usePrevious = function (value) {
6
- var reference = (0, react_1.useRef)();
7
- (0, react_1.useEffect)(function () {
4
+ const react_1 = require("react");
5
+ const usePrevious = (value) => {
6
+ const reference = (0, react_1.useRef)();
7
+ (0, react_1.useEffect)(() => {
8
8
  reference.current = value;
9
9
  }, [value]);
10
10
  return reference.current;
@@ -1,19 +1,20 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useStepPolling = void 0;
4
- var react_1 = require("react");
5
- var __1 = require("..");
6
- var contexts_1 = require("../../contexts");
4
+ const react_1 = require("react");
5
+ const __1 = require("..");
6
+ const contexts_1 = require("../../contexts");
7
7
  function useStepPolling(polling, onAction) {
8
- var fetcher = (0, contexts_1.useFetcher)();
9
- var asyncFn = (0, react_1.useMemo)(function () {
8
+ const fetcher = (0, contexts_1.useFetcher)();
9
+ const asyncFn = (0, react_1.useMemo)(() => {
10
10
  if (polling) {
11
- return function () {
12
- return fetcher(polling.url).then(function (response) {
11
+ return () => {
12
+ return fetcher(polling.url).then((response) => {
13
13
  if (response.ok) {
14
14
  return response
15
15
  .json()
16
- .then(function (pollingResponse) { return pollingResponse; })["catch"](function (error) { return null; });
16
+ .then((pollingResponse) => pollingResponse)
17
+ .catch((error) => null);
17
18
  }
18
19
  else {
19
20
  throw new Error('failed');
@@ -25,7 +26,7 @@ function useStepPolling(polling, onAction) {
25
26
  return undefined;
26
27
  }
27
28
  }, [polling, fetcher]);
28
- var onPollingResponse = (0, react_1.useCallback)(function (pollingResponse) {
29
+ const onPollingResponse = (0, react_1.useCallback)((pollingResponse) => {
29
30
  if (pollingResponse === null || pollingResponse === void 0 ? void 0 : pollingResponse.action) {
30
31
  onAction(pollingResponse.action);
31
32
  return false; // stop polling
@@ -33,16 +34,16 @@ function useStepPolling(polling, onAction) {
33
34
  return true; // continue polling
34
35
  }, [onAction]);
35
36
  (0, __1.usePolling)({
36
- asyncFn: asyncFn,
37
+ asyncFn,
37
38
  interval: 1000 * ((polling === null || polling === void 0 ? void 0 : polling.interval) || 0),
38
39
  maxAttempts: (polling === null || polling === void 0 ? void 0 : polling.maxAttempts) || 0,
39
40
  maxConsecutiveFails: 1,
40
- onPollingResponse: onPollingResponse,
41
- onFailure: (0, react_1.useCallback)(function () {
41
+ onPollingResponse,
42
+ onFailure: (0, react_1.useCallback)(() => {
42
43
  if (polling) {
43
44
  onAction(polling.onError.action);
44
45
  }
45
- }, [onAction, polling])
46
+ }, [onAction, polling]),
46
47
  });
47
48
  }
48
49
  exports.useStepPolling = useStepPolling;
@@ -13,5 +13,5 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
13
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
- exports.__esModule = true;
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./makeFetcher"), exports);
@@ -1,36 +1,22 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.makeFetcher = void 0;
15
- var api_utils_1 = require("../utils/api-utils");
16
- var makeFetcher = function (baseUrl, additionalHeaders) {
17
- return function (input, init) {
18
- var resource = applyBaseUrl(input, baseUrl || '');
19
- var headers = mergeHeaders(init === null || init === void 0 ? void 0 : init.headers, additionalHeaders);
20
- return fetch(resource, __assign(__assign({}, (init || {})), { headers: headers }));
21
- };
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 }));
22
9
  };
23
10
  exports.makeFetcher = makeFetcher;
24
- var applyBaseUrl = function (input, baseUrl) {
11
+ const applyBaseUrl = (input, baseUrl) => {
25
12
  return typeof input === 'string' && (0, api_utils_1.isRelativePath)(input) ? baseUrl + input : input;
26
13
  };
27
- var mergeHeaders = function (initHeaders, additionalHeaders) {
14
+ const mergeHeaders = (initHeaders, additionalHeaders) => {
28
15
  if (!initHeaders && !additionalHeaders) {
29
16
  return {};
30
17
  }
31
- var headers = new Headers(initHeaders);
32
- for (var _i = 0, _a = Object.entries(additionalHeaders || {}); _i < _a.length; _i++) {
33
- var _b = _a[_i], key = _b[0], value = _b[1];
18
+ const headers = new Headers(initHeaders);
19
+ for (const [key, value] of Object.entries(additionalHeaders || {})) {
34
20
  headers.set(key, value);
35
21
  }
36
22
  return headers;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
- exports.__esModule = true;
3
- var react_intl_1 = require("react-intl");
4
- exports["default"] = (0, react_intl_1.defineMessages)({
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_intl_1 = require("react-intl");
4
+ exports.default = (0, react_intl_1.defineMessages)({
5
5
  required: {
6
6
  id: 'dynamicFlows.DefaultErrorMessages.required',
7
7
  defaultMessage: 'Please fill out this field.',
8
- description: 'Customer has left the required field empty'
9
- }
8
+ description: 'Customer has left the required field empty',
9
+ },
10
10
  });
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isRelativePath = exports.getJson = exports.isStatus422 = exports.isStatus2xx = void 0;
4
4
  function isStatus2xx(status) {
5
5
  return status >= 200 && status < 300;
@@ -13,8 +13,7 @@ function getJson(response) {
13
13
  return response.json();
14
14
  }
15
15
  exports.getJson = getJson;
16
- function isRelativePath(url) {
17
- if (url === void 0) { url = ''; }
18
- return (['https://', 'http://', 'data:'].some(function (prefix) { return url.slice(0, prefix.length) === prefix && url.length > prefix.length; }) === false);
16
+ function isRelativePath(url = '') {
17
+ return (['https://', 'http://', 'data:'].some((prefix) => url.slice(0, prefix.length) === prefix && url.length > prefix.length) === false);
19
18
  }
20
19
  exports.isRelativePath = isRelativePath;
@@ -1,27 +1,27 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.dateToDateString = exports.dateStringToDate = void 0;
4
- var validators_1 = require("../validators");
4
+ const validators_1 = require("../validators");
5
5
  // function taken from: https://stackoverflow.com/questions/23593052/format-javascript-date-as-yyyy-mm-dd
6
6
  function formatDate(date) {
7
- var d = new Date(date);
8
- var month = "".concat(d.getMonth() + 1);
9
- var day = "".concat(d.getDate());
10
- var year = d.getFullYear();
11
- var formattedMonth = month.length < 2 ? "0".concat(month) : month;
12
- var formattedDay = day.length < 2 ? "0".concat(day) : day;
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
13
  return [year, formattedMonth, formattedDay].join('-');
14
14
  }
15
- var dateStringToDate = function (dateString) {
15
+ const dateStringToDate = (dateString) => {
16
16
  if (!dateString) {
17
17
  return null;
18
18
  }
19
- var _a = dateString.split('-').map(function (number) { return parseInt(number, 10); }), year = _a[0], month = _a[1], date = _a[2];
19
+ const [year, month, date] = dateString.split('-').map((number) => parseInt(number, 10));
20
20
  if (!(0, validators_1.isNumber)(year) || !(0, validators_1.isNumber)(month) || !(0, validators_1.isNumber)(date)) {
21
21
  return null;
22
22
  }
23
23
  return new Date(year, month - 1, date);
24
24
  };
25
25
  exports.dateStringToDate = dateStringToDate;
26
- var dateToDateString = function (date) { return formatDate(date); };
26
+ const dateToDateString = (date) => formatDate(date);
27
27
  exports.dateToDateString = dateToDateString;
@@ -1,39 +1,35 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.debounce = void 0;
4
- var debounce = function (callback, waitMs) {
5
- var timeoutId;
6
- var lastArgs;
7
- var clearTimer = function () {
4
+ const debounce = (callback, waitMs) => {
5
+ let timeoutId;
6
+ let lastArgs;
7
+ const clearTimer = () => {
8
8
  if (timeoutId) {
9
9
  clearTimeout(timeoutId);
10
10
  timeoutId = null;
11
11
  }
12
12
  lastArgs = null;
13
13
  };
14
- var debouncedFn = function () {
15
- var args = [];
16
- for (var _i = 0; _i < arguments.length; _i++) {
17
- args[_i] = arguments[_i];
18
- }
14
+ const debouncedFn = (...args) => {
19
15
  lastArgs = args;
20
16
  if (timeoutId !== null) {
21
17
  clearTimeout(timeoutId);
22
18
  }
23
- timeoutId = setTimeout(function () {
24
- callback.apply(void 0, lastArgs);
19
+ timeoutId = setTimeout(() => {
20
+ callback(...lastArgs);
25
21
  timeoutId = null;
26
22
  lastArgs = null;
27
23
  }, waitMs);
28
24
  };
29
- debouncedFn.cancel = function () {
25
+ debouncedFn.cancel = () => {
30
26
  if (timeoutId !== null) {
31
27
  clearTimer();
32
28
  }
33
29
  };
34
- debouncedFn.flush = function () {
30
+ debouncedFn.flush = () => {
35
31
  if (timeoutId !== null) {
36
- callback.apply(void 0, lastArgs);
32
+ callback(...lastArgs);
37
33
  clearTimer();
38
34
  }
39
35
  };
@@ -1,44 +1,31 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.areFilesSame = exports.toBase64 = exports.toKilobytes = void 0;
15
4
  function toKilobytes(sizeInBytes) {
16
- var ONE_KB_IN_BYTES = 1024;
5
+ const ONE_KB_IN_BYTES = 1024;
17
6
  return Math.floor(sizeInBytes / ONE_KB_IN_BYTES);
18
7
  }
19
8
  exports.toKilobytes = toKilobytes;
20
9
  //TODO: Refactor: This is duplicate logic as in CameraStep.tsx
21
- var toBase64 = function (file) {
22
- return new Promise(function (resolve, reject) {
10
+ const toBase64 = (file) => {
11
+ return new Promise((resolve, reject) => {
23
12
  // we can safely assume the type of reader.result is string
24
13
  // because we're calling reader.readAsDataURL
25
14
  // https://developer.mozilla.org/en-US/docs/Web/API/FileReader/result
26
- var reader = new FileReader();
15
+ const reader = new FileReader();
27
16
  reader.readAsDataURL(file);
28
- reader.addEventListener('load', function () { return resolve(reader.result); });
29
- reader.addEventListener('error', function (error) { return reject(error); });
17
+ reader.addEventListener('load', () => resolve(reader.result));
18
+ reader.addEventListener('error', (error) => reject(error));
30
19
  });
31
20
  };
32
21
  exports.toBase64 = toBase64;
33
22
  function areFilesSame(newFiles, files) {
34
- var fileIdToExistingFileMap = files.reduce(function (map, fileObject) {
35
- var _a;
36
- return __assign(__assign({}, map), (_a = {}, _a[fileObject.id] = fileObject, _a));
23
+ const fileIdToExistingFileMap = files.reduce((map, fileObject) => {
24
+ return Object.assign(Object.assign({}, map), { [fileObject.id]: fileObject });
37
25
  }, {});
38
- for (var _i = 0, newFiles_1 = newFiles; _i < newFiles_1.length; _i++) {
39
- var newFile = newFiles_1[_i];
40
- var existingFileObject = fileIdToExistingFileMap[newFile.id];
41
- var fileDoesNotExistAlready = !existingFileObject;
26
+ for (const newFile of newFiles) {
27
+ const existingFileObject = fileIdToExistingFileMap[newFile.id];
28
+ const fileDoesNotExistAlready = !existingFileObject;
42
29
  if (fileDoesNotExistAlready) {
43
30
  return false;
44
31
  }
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateRandomId = void 0;
4
- var generateRandomId = function (prefix) {
5
- if (prefix === void 0) { prefix = ''; }
6
- var prefixString = prefix ? "".concat(prefix, "-") : '';
7
- return "".concat(prefixString).concat(Math.floor(100000000 * Math.random()));
4
+ const generateRandomId = (prefix = '') => {
5
+ const prefixString = prefix ? `${prefix}-` : '';
6
+ return `${prefixString}${Math.floor(100000000 * Math.random())}`;
8
7
  };
9
8
  exports.generateRandomId = generateRandomId;