@wise/dynamic-flow-client 4.9.0 → 4.10.0-modal-renderer-exposed-b166873

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 CHANGED
@@ -2020,6 +2020,9 @@ var createRootDomainComponent = (updateComponent) => {
2020
2020
  async getSubmittableValue() {
2021
2021
  return this.stepComponent ? this.stepComponent.getSubmittableValue() : null;
2022
2022
  },
2023
+ getSubmittableValueSync() {
2024
+ return this.stepComponent ? this.stepComponent.getSubmittableValueSync() : null;
2025
+ },
2023
2026
  validate() {
2024
2027
  return this.stepComponent ? this.stepComponent.validate() : false;
2025
2028
  },
@@ -3121,36 +3124,51 @@ var createExternalConfirmation = (uid, url, updateComponent) => {
3121
3124
  };
3122
3125
  };
3123
3126
 
3124
- // src/revamp/utils/component-utils.ts
3125
- var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
3126
- (values) => values.reduce((acc, value) => mergeModels(acc, value), null)
3127
- );
3128
- var getSubmittableDataSync = (components) => components.map((component) => component.getSubmittableValueSync()).reduce((acc, value) => mergeModels(acc, value), null);
3129
- var getLocalValues = (components) => components.map((component) => component.getLocalValue()).reduce((acc, value) => mergeLocalValues(acc, value), null);
3130
- var mergeLocalValues = (valueA, valueB) => {
3127
+ // src/revamp/utils/recursiveMerge.ts
3128
+ function recursiveMerge(valueA, valueB) {
3131
3129
  if (valueA === null) {
3132
3130
  return valueB;
3133
3131
  }
3134
3132
  if (valueB === null) {
3135
3133
  return valueA;
3136
3134
  }
3137
- if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
3138
- return __spreadValues(__spreadValues({}, valueA), valueB);
3139
- }
3140
- return valueB;
3141
- };
3142
- var mergeModels = (valueA, valueB) => {
3143
- if (valueA === null) {
3144
- return valueB;
3145
- }
3146
- if (valueB === null) {
3147
- return valueA;
3135
+ if (isObject2(valueA) && isObject2(valueB)) {
3136
+ return mergeObjects(valueA, valueB);
3148
3137
  }
3149
- if (isObjectModel(valueA) && isObjectModel(valueB)) {
3150
- return __spreadValues(__spreadValues({}, valueA), valueB);
3138
+ if (Array.isArray(valueA) && Array.isArray(valueB)) {
3139
+ return mergeArrays(valueA, valueB);
3151
3140
  }
3152
3141
  return valueB;
3153
- };
3142
+ }
3143
+ function isObject2(value) {
3144
+ return value != null && typeof value === "object" && !Array.isArray(value) && !(value instanceof File);
3145
+ }
3146
+ function mergeObjects(valueA, valueB) {
3147
+ const allKeys = /* @__PURE__ */ new Set([...Object.keys(valueA), ...Object.keys(valueB)]);
3148
+ const entries = Array.from(allKeys).map((key) => {
3149
+ var _a, _b;
3150
+ const value = recursiveMerge((_a = valueA[key]) != null ? _a : null, (_b = valueB[key]) != null ? _b : null);
3151
+ return [key, value];
3152
+ });
3153
+ return Object.fromEntries(entries);
3154
+ }
3155
+ function mergeArrays(valueA, valueB) {
3156
+ const length = Math.max(valueA.length, valueB.length);
3157
+ return Array.from(
3158
+ { length },
3159
+ (_, index) => {
3160
+ var _a, _b;
3161
+ return recursiveMerge((_a = valueA[index]) != null ? _a : null, (_b = valueB[index]) != null ? _b : null);
3162
+ }
3163
+ );
3164
+ }
3165
+
3166
+ // src/revamp/utils/component-utils.ts
3167
+ var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
3168
+ (values) => values.reduce((acc, value) => recursiveMerge(acc, value), null)
3169
+ );
3170
+ var getSubmittableDataSync = (components) => components.map((component) => component.getSubmittableValueSync()).reduce((acc, value) => recursiveMerge(acc, value), null);
3171
+ var getLocalValues = (components) => components.map((component) => component.getLocalValue()).reduce((acc, value) => recursiveMerge(acc, value), null);
3154
3172
 
3155
3173
  // src/revamp/domain/components/step/StepDomainComponent.ts
3156
3174
  var createStepComponent = (stepProps) => {
@@ -3188,6 +3206,9 @@ var createStepComponent = (stepProps) => {
3188
3206
  async getSubmittableValue() {
3189
3207
  return getSubmittableData(this.schemaComponents);
3190
3208
  },
3209
+ getSubmittableValueSync() {
3210
+ return getSubmittableDataSync(this.schemaComponents);
3211
+ },
3191
3212
  getLocalValue() {
3192
3213
  return getLocalValues(this.schemaComponents);
3193
3214
  },
@@ -4292,12 +4313,13 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
4292
4313
  const update = getInputUpdateFunction(updateComponent);
4293
4314
  const getValidationErrors = getLocalValueValidator(checks);
4294
4315
  const getFileValidationErrors = getLocalValueValidator(fileChecks);
4316
+ const persist = performPersistAsync ? getComponentMultiPersistAsync(update, performPersistAsync) : void 0;
4295
4317
  const uploadComponent = __spreadValues({
4296
4318
  type: "multi-upload",
4297
4319
  kind: "input",
4298
4320
  uid,
4299
4321
  id,
4300
- format: "base64",
4322
+ format,
4301
4323
  files: [],
4302
4324
  _update(updateFn) {
4303
4325
  update(this, updateFn);
@@ -4309,28 +4331,44 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
4309
4331
  },
4310
4332
  // Noop
4311
4333
  async onRemoveFile(index) {
4334
+ var _a2;
4312
4335
  this._update((draft) => {
4313
4336
  draft.value.splice(index, 1);
4314
4337
  draft.files.splice(index, 1);
4315
4338
  });
4339
+ if (persist) {
4340
+ (_a2 = this.persistedState[index]) == null ? void 0 : _a2.abortController.abort();
4341
+ this._update((draft) => {
4342
+ draft.persistedState.splice(index, 1);
4343
+ });
4344
+ }
4316
4345
  },
4317
4346
  async onInsertFile(index, file) {
4318
4347
  const fileErrors = getFileValidationErrors(file);
4319
4348
  const fileId = getRandomId();
4349
+ const base64Value = format === "base64" ? await toBase64(file) : null;
4320
4350
  this._update((draft) => {
4321
4351
  draft.value.splice(index, 0, file);
4322
- draft.files.splice(index, 0, { file, id: fileId, errors: fileErrors });
4352
+ draft.files.splice(index, 0, { file, id: fileId, errors: fileErrors, base64Value });
4323
4353
  draft.errors = [];
4324
4354
  });
4355
+ if (persist) {
4356
+ await persist(this, index, format === "blob" ? file : base64Value);
4357
+ }
4325
4358
  onValueChange();
4326
4359
  return fileId;
4327
4360
  },
4328
4361
  async getSubmittableValue() {
4329
- const files = this.getLocalValue();
4330
- return files ? Promise.all(files.map(toBase64)) : null;
4362
+ if (persist) {
4363
+ return Promise.all(this.persistedState.map(async ({ submission }) => submission));
4364
+ }
4365
+ return this.files.map(({ base64Value }) => base64Value);
4331
4366
  },
4332
4367
  getSubmittableValueSync() {
4333
- return null;
4368
+ if (persist) {
4369
+ return this.persistedState.map(({ lastResponse }) => lastResponse);
4370
+ }
4371
+ return this.files.map(({ base64Value }) => base64Value);
4334
4372
  },
4335
4373
  getSummary() {
4336
4374
  return summariser(this.getLocalValue().map(({ name }) => name));
@@ -4346,34 +4384,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
4346
4384
  return errorMsgs.length === 0 && this.files.every(({ errors }) => errors.length === 0);
4347
4385
  }
4348
4386
  }, rest);
4349
- if (!performPersistAsync) {
4350
- return uploadComponent;
4351
- }
4352
- const persist = getComponentMultiPersistAsync(update, performPersistAsync);
4353
- return __spreadProps(__spreadValues({}, uploadComponent), {
4354
- format,
4355
- async onInsertFile(index, file) {
4356
- const fileId = await uploadComponent.onInsertFile.call(this, index, file);
4357
- const submission = format === "blob" ? file : await toBase64(file);
4358
- await persist(this, index, submission);
4359
- onValueChange();
4360
- return fileId;
4361
- },
4362
- async onRemoveFile(index) {
4363
- var _a2;
4364
- await uploadComponent.onRemoveFile.call(this, index);
4365
- (_a2 = this.persistedState[index]) == null ? void 0 : _a2.abortController.abort();
4366
- this._update((draft) => {
4367
- draft.persistedState = draft.persistedState.splice(index, 1);
4368
- });
4369
- },
4370
- async getSubmittableValue() {
4371
- return Promise.all(this.persistedState.map(async ({ submission }) => submission));
4372
- },
4373
- getSubmittableValueSync() {
4374
- return this.persistedState.map(({ lastResponse }) => lastResponse);
4375
- }
4376
- });
4387
+ return uploadComponent;
4377
4388
  };
4378
4389
 
4379
4390
  // src/revamp/domain/features/persistAsync/getInitialPersistedState.ts
@@ -4825,6 +4836,7 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
4825
4836
  id,
4826
4837
  format,
4827
4838
  value,
4839
+ base64Value: null,
4828
4840
  _update(updateFn) {
4829
4841
  update(this, updateFn);
4830
4842
  },
@@ -4835,9 +4847,11 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
4835
4847
  },
4836
4848
  // Noop
4837
4849
  async onUpload(updatedValue) {
4850
+ const base64Value = this.format === "base64" && updatedValue ? await toBase64(updatedValue) : null;
4838
4851
  this._update((draft) => {
4839
4852
  draft.errors = [];
4840
4853
  draft.value = updatedValue;
4854
+ draft.base64Value = base64Value;
4841
4855
  });
4842
4856
  schemaOnChange == null ? void 0 : schemaOnChange();
4843
4857
  onValueChange();
@@ -4856,7 +4870,7 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
4856
4870
  return null;
4857
4871
  },
4858
4872
  getSubmittableValueSync() {
4859
- return null;
4873
+ return this.base64Value;
4860
4874
  },
4861
4875
  getSummary() {
4862
4876
  var _a2, _b;
@@ -4873,8 +4887,20 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
4873
4887
  return errors.length === 0;
4874
4888
  }
4875
4889
  }, rest);
4890
+ if (format === "base64" && value && !onPersistAsync) {
4891
+ void initialiseBase64Value(uploadComponent);
4892
+ }
4876
4893
  return uploadComponent;
4877
4894
  };
4895
+ var initialiseBase64Value = async (uploadComponent) => {
4896
+ const { format, value } = uploadComponent;
4897
+ const base64Value = format === "base64" && value ? await toBase64(value) : null;
4898
+ if (base64Value) {
4899
+ uploadComponent._update((draft) => {
4900
+ draft.base64Value = base64Value;
4901
+ });
4902
+ }
4903
+ };
4878
4904
 
4879
4905
  // src/revamp/domain/mappers/schema/blobSchemaToComponent.ts
4880
4906
  var blobSchemaToComponent = (schemaMapperProps, mapperProps) => {
@@ -6213,7 +6239,7 @@ var executeSubmission = async (props) => {
6213
6239
  if (method === "GET") {
6214
6240
  return void 0;
6215
6241
  }
6216
- const payload = mergeModels(model, (_a = action.data) != null ? _a : null);
6242
+ const payload = recursiveMerge(model, (_a = action.data) != null ? _a : null);
6217
6243
  return payload !== null ? JSON.stringify(payload) : null;
6218
6244
  };
6219
6245
  const response = await getSafeHttpClient(httpClient)(url != null ? url : "", {
@@ -6234,7 +6260,7 @@ var executeSubmission = async (props) => {
6234
6260
  const responseType = await getResponseType(response);
6235
6261
  const body = await parseResponseBodyAsJsonElement(response);
6236
6262
  if (exit) {
6237
- return { type: "complete", result: mergeModels(body, result) };
6263
+ return { type: "complete", result: recursiveMerge(body, result) };
6238
6264
  }
6239
6265
  switch (responseType) {
6240
6266
  case "step": {
@@ -6245,7 +6271,7 @@ var executeSubmission = async (props) => {
6245
6271
  }
6246
6272
  case "exit": {
6247
6273
  trackSubmissionEvent("Action Succeeded", { actionId });
6248
- return { type: "complete", result: mergeModels(body, result) };
6274
+ return { type: "complete", result: recursiveMerge(body, result) };
6249
6275
  }
6250
6276
  case "action": {
6251
6277
  assertActionResponseBody(body);
@@ -6779,13 +6805,13 @@ function useDynamicFlowCore(props) {
6779
6805
  errorsOverride,
6780
6806
  analytics
6781
6807
  }) => {
6782
- var _a2, _b;
6808
+ var _a2;
6783
6809
  try {
6784
6810
  rootComponentRef.current.setLoadingState("refreshing");
6785
- const model = (_a2 = await rootComponentRef.current.getSubmittableValue()) != null ? _a2 : null;
6811
+ const model = rootComponentRef.current.getSubmittableValueSync();
6786
6812
  const command = await executeRefresh({
6787
6813
  abortSignal: abortCurrentAndGetNewAbortSignal(),
6788
- url: (_b = refreshUrl != null ? refreshUrl : rootComponentRef.current.getRefreshUrl()) != null ? _b : "",
6814
+ url: (_a2 = refreshUrl != null ? refreshUrl : rootComponentRef.current.getRefreshUrl()) != null ? _a2 : "",
6789
6815
  model,
6790
6816
  etag: etagRef.current,
6791
6817
  analytics,
@@ -7120,13 +7146,13 @@ var isInteger2 = (value) => {
7120
7146
  return isNumber2(value) && Math.floor(value) === value;
7121
7147
  };
7122
7148
  var isBoolean2 = (value) => typeof value === "boolean";
7123
- var isObject2 = (value) => !isNull2(value) && !isUndefined2(value) && (value == null ? void 0 : value.constructor) === Object;
7149
+ var isObject3 = (value) => !isNull2(value) && !isUndefined2(value) && (value == null ? void 0 : value.constructor) === Object;
7124
7150
  var isArray2 = (value) => Array.isArray(value);
7125
7151
  var isNull2 = (value) => value === null;
7126
7152
  var isUndefined2 = (value) => typeof value === "undefined";
7127
7153
 
7128
7154
  // src/legacy/common/validators/values/value-validators.ts
7129
- var isEmpty = (value) => isString2(value) && value.length === 0 || (isObject2(value) || isArray2(value)) && Object.keys(value).length === 0;
7155
+ var isEmpty = (value) => isString2(value) && value.length === 0 || (isObject3(value) || isArray2(value)) && Object.keys(value).length === 0;
7130
7156
 
7131
7157
  // src/legacy/common/validators/models/model-utils.ts
7132
7158
  function cleanBasicModelWithOneOfSchema(model, schema) {
@@ -7470,7 +7496,7 @@ function isValidConstSchema(value, schema) {
7470
7496
  return !getConstValidationFailures(value, schema).length;
7471
7497
  }
7472
7498
  function isValidObjectSchema(value, schema) {
7473
- if (!isObject2(value) || schema.type !== "object" || !isObject2(schema.properties)) {
7499
+ if (!isObject3(value) || schema.type !== "object" || !isObject3(schema.properties)) {
7474
7500
  return false;
7475
7501
  }
7476
7502
  return Object.keys(schema.properties).map(
@@ -7491,7 +7517,7 @@ function isObjectPropertyValid(propertyValue, propertySchema, isRequired) {
7491
7517
  return isValidSchema(propertyValue, propertySchema);
7492
7518
  }
7493
7519
  function isValidArraySchema(value, schema) {
7494
- if (schema.type !== "array" || !isObject2(schema.items)) {
7520
+ if (schema.type !== "array" || !isObject3(schema.items)) {
7495
7521
  return false;
7496
7522
  }
7497
7523
  if (getArrayValidationFailures(value, schema).length > 0) {
@@ -7659,7 +7685,7 @@ var isReadOnlySchema = (schema) => Boolean(schema.readOnly) && isBasicSchema(sch
7659
7685
  var isPromotedOneOfSchema = (schema) => Boolean(schema.oneOf) && Boolean(schema.promotion);
7660
7686
  var basicTypes = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean"]);
7661
7687
  function isBasicSchema(schema) {
7662
- return basicTypes.has(schema.type || "") || "const" in schema && schema.const !== void 0 && !isObject2(schema.const);
7688
+ return basicTypes.has(schema.type || "") || "const" in schema && schema.const !== void 0 && !isObject3(schema.const);
7663
7689
  }
7664
7690
  function isObjectSchema2(schema) {
7665
7691
  return schema.type === "object";
@@ -8585,7 +8611,7 @@ function constructUploadResponse(response) {
8585
8611
  }
8586
8612
  function constructUploadError(response) {
8587
8613
  const isError = response instanceof Error;
8588
- const hasValidData = isObject2(response) && "data" in response;
8614
+ const hasValidData = isObject3(response) && "data" in response;
8589
8615
  const isInvalidResponseData = !hasValidData && !isError;
8590
8616
  if (isInvalidResponseData) {
8591
8617
  return isString2(response) ? response : void 0;
@@ -9261,7 +9287,7 @@ function RepeatableSchema({
9261
9287
  const [openModalType, setOpenModalType] = (0, import_react19.useState)(null);
9262
9288
  const [changed, setChanged] = (0, import_react19.useState)(false);
9263
9289
  const [itemSummaries, setItemSummaries] = (0, import_react19.useState)(() => {
9264
- if (isObject2(model) && !isArray2(model)) {
9290
+ if (isObject3(model) && !isArray2(model)) {
9265
9291
  throw new Error(
9266
9292
  "RepeatableSchema does not support object models. Ensure your array schema is wrapped inside an object schema."
9267
9293
  );
@@ -9560,7 +9586,7 @@ var getSafeStringValue = (value, options = {}) => {
9560
9586
  if (isNull2(value)) {
9561
9587
  return void 0;
9562
9588
  }
9563
- if (isObject2(value)) {
9589
+ if (isObject3(value)) {
9564
9590
  logInvalidTypeFallbackWarning({ received: "object", expected: "string" });
9565
9591
  return void 0;
9566
9592
  }
@@ -9583,7 +9609,7 @@ var getSafeStringOrNumberValue = (value, options = {}) => {
9583
9609
  return value;
9584
9610
  }
9585
9611
  const logProps = { received: typeof value, expected: "string or number" };
9586
- if (isObject2(value)) {
9612
+ if (isObject3(value)) {
9587
9613
  logInvalidTypeFallbackWarning(logProps);
9588
9614
  return void 0;
9589
9615
  }
@@ -10636,7 +10662,7 @@ function PersistAsyncBlobSchema(props) {
10636
10662
  }
10637
10663
  var getResponseJsonObject = async (response) => {
10638
10664
  const json = await response.json().catch(() => ({}));
10639
- return isObject2(json) ? json : {};
10665
+ return isObject3(json) ? json : {};
10640
10666
  };
10641
10667
  var PersistAsyncBlobSchema_default = PersistAsyncBlobSchema;
10642
10668
 
@@ -10900,7 +10926,7 @@ function ValidationAsyncSchema(props) {
10900
10926
  });
10901
10927
  try {
10902
10928
  const jsonResponse = await response.json();
10903
- if (!isObject2(jsonResponse)) {
10929
+ if (!isObject3(jsonResponse)) {
10904
10930
  throw new Error("Response body is not an object");
10905
10931
  }
10906
10932
  onEvent("Dynamic Flow - ValidationAsync", { status: "success" });
@@ -11671,8 +11697,8 @@ var useSearch = (defaultSearchConfig) => {
11671
11697
  const results = state.status === "success" ? state.results : [];
11672
11698
  return { status: state.status, results, search };
11673
11699
  };
11674
- var isValidResponseBody2 = (body) => isObject2(body) && "results" in body && isArray2(body.results) && body.results.every(
11675
- (result) => isObject2(result) && "title" in result && "type" in result && "value" in result
11700
+ var isValidResponseBody2 = (body) => isObject3(body) && "results" in body && isArray2(body.results) && body.results.every(
11701
+ (result) => isObject3(result) && "title" in result && "type" in result && "value" in result
11676
11702
  );
11677
11703
  var isAbortError = (error) => error instanceof DOMException && error.name === "AbortError";
11678
11704
  var addQueryParameter2 = (url, key, value) => {
@@ -12011,7 +12037,7 @@ function PersistAsyncBasicSchema(props) {
12011
12037
  onPersistAsync(persistAsyncFetch);
12012
12038
  const response = await persistAsyncFetch;
12013
12039
  const responseBody = await response.json();
12014
- if (!isObject2(responseBody)) {
12040
+ if (!isObject3(responseBody)) {
12015
12041
  throw new Error("Response is not an object");
12016
12042
  }
12017
12043
  const { idProperty, param } = schema.persistAsync;
@@ -12020,7 +12046,7 @@ function PersistAsyncBasicSchema(props) {
12020
12046
  onChange({ model: id, triggerSchema: schema, triggerModel: id });
12021
12047
  } else if (!response.ok) {
12022
12048
  const { validation } = responseBody;
12023
- const error = isObject2(validation) && (validation == null ? void 0 : validation[param]) || null;
12049
+ const error = isObject3(validation) && (validation == null ? void 0 : validation[param]) || null;
12024
12050
  setPersistAsyncError(error);
12025
12051
  onChange({ model: null, triggerSchema: schema, triggerModel: null });
12026
12052
  } else {
@@ -12110,7 +12136,7 @@ var usePersistAsync = (persistAsync) => {
12110
12136
  return handleHTTPError(response);
12111
12137
  }
12112
12138
  const jsonResponse = await response.json();
12113
- if (isObject2(jsonResponse)) {
12139
+ if (isObject3(jsonResponse)) {
12114
12140
  const id = jsonResponse[persistAsync.idProperty];
12115
12141
  if (isString2(id) || isNumber2(id)) {
12116
12142
  return { data: id };
@@ -12123,7 +12149,7 @@ var usePersistAsync = (persistAsync) => {
12123
12149
  }
12124
12150
  async function handleHTTPError(response) {
12125
12151
  const jsonResponse = await response.json();
12126
- if (isObject2(jsonResponse)) {
12152
+ if (isObject3(jsonResponse)) {
12127
12153
  const error = getErrorFromResponse(persistAsync.param, jsonResponse);
12128
12154
  if (isString2(error)) {
12129
12155
  throw new Error(error);
@@ -12145,7 +12171,7 @@ function wrapInFormData2(key, value) {
12145
12171
  return formData;
12146
12172
  }
12147
12173
  function hasStringMessage(value) {
12148
- return isObject2(value) && "message" in value && typeof value.message === "string";
12174
+ return isObject3(value) && "message" in value && typeof value.message === "string";
12149
12175
  }
12150
12176
 
12151
12177
  // src/legacy/common/hooks/usePolling/usePolling.tsx
@@ -13584,7 +13610,7 @@ var parseFetchResponseByResponseType = async (response, type) => {
13584
13610
  };
13585
13611
  var parseStepResponse = async (response) => {
13586
13612
  const jsonBody = await parseResponseJson(response);
13587
- if (!isObject2(jsonBody)) {
13613
+ if (!isObject3(jsonBody)) {
13588
13614
  throw new Error("Incorrect response body in response. Expected an object.");
13589
13615
  }
13590
13616
  const etag = response.headers.get("etag") || void 0;
@@ -13592,16 +13618,16 @@ var parseStepResponse = async (response) => {
13592
13618
  };
13593
13619
  var parseActionResponse = async (response) => {
13594
13620
  const jsonBody = await parseResponseJson(response);
13595
- if (!isObject2(jsonBody)) {
13621
+ if (!isObject3(jsonBody)) {
13596
13622
  throw new Error("Incorrect response body in response. Expected an object.");
13597
13623
  }
13598
- if (!isObject2(jsonBody.action)) {
13624
+ if (!isObject3(jsonBody.action)) {
13599
13625
  throw new Error(
13600
13626
  "Incorrect response body in action response. Expected an object satisfying the type { action: Action }."
13601
13627
  );
13602
13628
  }
13603
13629
  const action = jsonBody.action;
13604
- if (action.exit === true && isObject2(action.result)) {
13630
+ if (action.exit === true && isObject3(action.result)) {
13605
13631
  return { type: "exit", result: action.result };
13606
13632
  }
13607
13633
  return { type: "action", action: jsonBody.action };
@@ -13618,7 +13644,7 @@ var parseFetchResponse = async (response) => {
13618
13644
  return parseExitResponse(response);
13619
13645
  }
13620
13646
  const jsonBody = await parseResponseJson(response.clone());
13621
- if (isObject2(jsonBody) && jsonBody.action) {
13647
+ if (isObject3(jsonBody) && jsonBody.action) {
13622
13648
  return parseActionResponse(response);
13623
13649
  }
13624
13650
  return parseStepResponse(response);
@@ -13626,7 +13652,7 @@ var parseFetchResponse = async (response) => {
13626
13652
  var parseErrorResponse = async (response) => {
13627
13653
  assertResponseIsValid2(response);
13628
13654
  const jsonBody = await parseResponseJson(response);
13629
- if (!isObject2(jsonBody)) {
13655
+ if (!isObject3(jsonBody)) {
13630
13656
  throw new Error("Incorrect response body in error response. Expected an object.");
13631
13657
  }
13632
13658
  if (!jsonBody.refreshFormUrl && !jsonBody.refreshUrl && !jsonBody.validation && !jsonBody.error) {
@@ -13637,7 +13663,7 @@ var parseErrorResponse = async (response) => {
13637
13663
  var getJsonObjectOrNull = async (response) => {
13638
13664
  assertResponseIsValid2(response);
13639
13665
  const result = await parseResponseJson(response);
13640
- return isObject2(result) ? result : null;
13666
+ return isObject3(result) ? result : null;
13641
13667
  };
13642
13668
  var parseResponseJson = async (response) => {
13643
13669
  try {
@@ -13826,7 +13852,7 @@ var DynamicFlowComponent = ({
13826
13852
  void performAction(result.action, result.action.data);
13827
13853
  } else if (result.type === "exit") {
13828
13854
  dispatchEventAndComplete(
13829
- isObject2(actionResult) ? __spreadValues(__spreadValues({}, result.result), actionResult) : result.result
13855
+ isObject3(actionResult) ? __spreadValues(__spreadValues({}, result.result), actionResult) : result.result
13830
13856
  );
13831
13857
  } else {
13832
13858
  updateStep(result.step, result.etag, fetchType);
package/build/main.mjs CHANGED
@@ -1977,6 +1977,9 @@ var createRootDomainComponent = (updateComponent) => {
1977
1977
  async getSubmittableValue() {
1978
1978
  return this.stepComponent ? this.stepComponent.getSubmittableValue() : null;
1979
1979
  },
1980
+ getSubmittableValueSync() {
1981
+ return this.stepComponent ? this.stepComponent.getSubmittableValueSync() : null;
1982
+ },
1980
1983
  validate() {
1981
1984
  return this.stepComponent ? this.stepComponent.validate() : false;
1982
1985
  },
@@ -3078,36 +3081,51 @@ var createExternalConfirmation = (uid, url, updateComponent) => {
3078
3081
  };
3079
3082
  };
3080
3083
 
3081
- // src/revamp/utils/component-utils.ts
3082
- var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
3083
- (values) => values.reduce((acc, value) => mergeModels(acc, value), null)
3084
- );
3085
- var getSubmittableDataSync = (components) => components.map((component) => component.getSubmittableValueSync()).reduce((acc, value) => mergeModels(acc, value), null);
3086
- var getLocalValues = (components) => components.map((component) => component.getLocalValue()).reduce((acc, value) => mergeLocalValues(acc, value), null);
3087
- var mergeLocalValues = (valueA, valueB) => {
3084
+ // src/revamp/utils/recursiveMerge.ts
3085
+ function recursiveMerge(valueA, valueB) {
3088
3086
  if (valueA === null) {
3089
3087
  return valueB;
3090
3088
  }
3091
3089
  if (valueB === null) {
3092
3090
  return valueA;
3093
3091
  }
3094
- if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
3095
- return __spreadValues(__spreadValues({}, valueA), valueB);
3096
- }
3097
- return valueB;
3098
- };
3099
- var mergeModels = (valueA, valueB) => {
3100
- if (valueA === null) {
3101
- return valueB;
3102
- }
3103
- if (valueB === null) {
3104
- return valueA;
3092
+ if (isObject2(valueA) && isObject2(valueB)) {
3093
+ return mergeObjects(valueA, valueB);
3105
3094
  }
3106
- if (isObjectModel(valueA) && isObjectModel(valueB)) {
3107
- return __spreadValues(__spreadValues({}, valueA), valueB);
3095
+ if (Array.isArray(valueA) && Array.isArray(valueB)) {
3096
+ return mergeArrays(valueA, valueB);
3108
3097
  }
3109
3098
  return valueB;
3110
- };
3099
+ }
3100
+ function isObject2(value) {
3101
+ return value != null && typeof value === "object" && !Array.isArray(value) && !(value instanceof File);
3102
+ }
3103
+ function mergeObjects(valueA, valueB) {
3104
+ const allKeys = /* @__PURE__ */ new Set([...Object.keys(valueA), ...Object.keys(valueB)]);
3105
+ const entries = Array.from(allKeys).map((key) => {
3106
+ var _a, _b;
3107
+ const value = recursiveMerge((_a = valueA[key]) != null ? _a : null, (_b = valueB[key]) != null ? _b : null);
3108
+ return [key, value];
3109
+ });
3110
+ return Object.fromEntries(entries);
3111
+ }
3112
+ function mergeArrays(valueA, valueB) {
3113
+ const length = Math.max(valueA.length, valueB.length);
3114
+ return Array.from(
3115
+ { length },
3116
+ (_, index) => {
3117
+ var _a, _b;
3118
+ return recursiveMerge((_a = valueA[index]) != null ? _a : null, (_b = valueB[index]) != null ? _b : null);
3119
+ }
3120
+ );
3121
+ }
3122
+
3123
+ // src/revamp/utils/component-utils.ts
3124
+ var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
3125
+ (values) => values.reduce((acc, value) => recursiveMerge(acc, value), null)
3126
+ );
3127
+ var getSubmittableDataSync = (components) => components.map((component) => component.getSubmittableValueSync()).reduce((acc, value) => recursiveMerge(acc, value), null);
3128
+ var getLocalValues = (components) => components.map((component) => component.getLocalValue()).reduce((acc, value) => recursiveMerge(acc, value), null);
3111
3129
 
3112
3130
  // src/revamp/domain/components/step/StepDomainComponent.ts
3113
3131
  var createStepComponent = (stepProps) => {
@@ -3145,6 +3163,9 @@ var createStepComponent = (stepProps) => {
3145
3163
  async getSubmittableValue() {
3146
3164
  return getSubmittableData(this.schemaComponents);
3147
3165
  },
3166
+ getSubmittableValueSync() {
3167
+ return getSubmittableDataSync(this.schemaComponents);
3168
+ },
3148
3169
  getLocalValue() {
3149
3170
  return getLocalValues(this.schemaComponents);
3150
3171
  },
@@ -4249,12 +4270,13 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
4249
4270
  const update = getInputUpdateFunction(updateComponent);
4250
4271
  const getValidationErrors = getLocalValueValidator(checks);
4251
4272
  const getFileValidationErrors = getLocalValueValidator(fileChecks);
4273
+ const persist = performPersistAsync ? getComponentMultiPersistAsync(update, performPersistAsync) : void 0;
4252
4274
  const uploadComponent = __spreadValues({
4253
4275
  type: "multi-upload",
4254
4276
  kind: "input",
4255
4277
  uid,
4256
4278
  id,
4257
- format: "base64",
4279
+ format,
4258
4280
  files: [],
4259
4281
  _update(updateFn) {
4260
4282
  update(this, updateFn);
@@ -4266,28 +4288,44 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
4266
4288
  },
4267
4289
  // Noop
4268
4290
  async onRemoveFile(index) {
4291
+ var _a2;
4269
4292
  this._update((draft) => {
4270
4293
  draft.value.splice(index, 1);
4271
4294
  draft.files.splice(index, 1);
4272
4295
  });
4296
+ if (persist) {
4297
+ (_a2 = this.persistedState[index]) == null ? void 0 : _a2.abortController.abort();
4298
+ this._update((draft) => {
4299
+ draft.persistedState.splice(index, 1);
4300
+ });
4301
+ }
4273
4302
  },
4274
4303
  async onInsertFile(index, file) {
4275
4304
  const fileErrors = getFileValidationErrors(file);
4276
4305
  const fileId = getRandomId();
4306
+ const base64Value = format === "base64" ? await toBase64(file) : null;
4277
4307
  this._update((draft) => {
4278
4308
  draft.value.splice(index, 0, file);
4279
- draft.files.splice(index, 0, { file, id: fileId, errors: fileErrors });
4309
+ draft.files.splice(index, 0, { file, id: fileId, errors: fileErrors, base64Value });
4280
4310
  draft.errors = [];
4281
4311
  });
4312
+ if (persist) {
4313
+ await persist(this, index, format === "blob" ? file : base64Value);
4314
+ }
4282
4315
  onValueChange();
4283
4316
  return fileId;
4284
4317
  },
4285
4318
  async getSubmittableValue() {
4286
- const files = this.getLocalValue();
4287
- return files ? Promise.all(files.map(toBase64)) : null;
4319
+ if (persist) {
4320
+ return Promise.all(this.persistedState.map(async ({ submission }) => submission));
4321
+ }
4322
+ return this.files.map(({ base64Value }) => base64Value);
4288
4323
  },
4289
4324
  getSubmittableValueSync() {
4290
- return null;
4325
+ if (persist) {
4326
+ return this.persistedState.map(({ lastResponse }) => lastResponse);
4327
+ }
4328
+ return this.files.map(({ base64Value }) => base64Value);
4291
4329
  },
4292
4330
  getSummary() {
4293
4331
  return summariser(this.getLocalValue().map(({ name }) => name));
@@ -4303,34 +4341,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
4303
4341
  return errorMsgs.length === 0 && this.files.every(({ errors }) => errors.length === 0);
4304
4342
  }
4305
4343
  }, rest);
4306
- if (!performPersistAsync) {
4307
- return uploadComponent;
4308
- }
4309
- const persist = getComponentMultiPersistAsync(update, performPersistAsync);
4310
- return __spreadProps(__spreadValues({}, uploadComponent), {
4311
- format,
4312
- async onInsertFile(index, file) {
4313
- const fileId = await uploadComponent.onInsertFile.call(this, index, file);
4314
- const submission = format === "blob" ? file : await toBase64(file);
4315
- await persist(this, index, submission);
4316
- onValueChange();
4317
- return fileId;
4318
- },
4319
- async onRemoveFile(index) {
4320
- var _a2;
4321
- await uploadComponent.onRemoveFile.call(this, index);
4322
- (_a2 = this.persistedState[index]) == null ? void 0 : _a2.abortController.abort();
4323
- this._update((draft) => {
4324
- draft.persistedState = draft.persistedState.splice(index, 1);
4325
- });
4326
- },
4327
- async getSubmittableValue() {
4328
- return Promise.all(this.persistedState.map(async ({ submission }) => submission));
4329
- },
4330
- getSubmittableValueSync() {
4331
- return this.persistedState.map(({ lastResponse }) => lastResponse);
4332
- }
4333
- });
4344
+ return uploadComponent;
4334
4345
  };
4335
4346
 
4336
4347
  // src/revamp/domain/features/persistAsync/getInitialPersistedState.ts
@@ -4782,6 +4793,7 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
4782
4793
  id,
4783
4794
  format,
4784
4795
  value,
4796
+ base64Value: null,
4785
4797
  _update(updateFn) {
4786
4798
  update(this, updateFn);
4787
4799
  },
@@ -4792,9 +4804,11 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
4792
4804
  },
4793
4805
  // Noop
4794
4806
  async onUpload(updatedValue) {
4807
+ const base64Value = this.format === "base64" && updatedValue ? await toBase64(updatedValue) : null;
4795
4808
  this._update((draft) => {
4796
4809
  draft.errors = [];
4797
4810
  draft.value = updatedValue;
4811
+ draft.base64Value = base64Value;
4798
4812
  });
4799
4813
  schemaOnChange == null ? void 0 : schemaOnChange();
4800
4814
  onValueChange();
@@ -4813,7 +4827,7 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
4813
4827
  return null;
4814
4828
  },
4815
4829
  getSubmittableValueSync() {
4816
- return null;
4830
+ return this.base64Value;
4817
4831
  },
4818
4832
  getSummary() {
4819
4833
  var _a2, _b;
@@ -4830,8 +4844,20 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
4830
4844
  return errors.length === 0;
4831
4845
  }
4832
4846
  }, rest);
4847
+ if (format === "base64" && value && !onPersistAsync) {
4848
+ void initialiseBase64Value(uploadComponent);
4849
+ }
4833
4850
  return uploadComponent;
4834
4851
  };
4852
+ var initialiseBase64Value = async (uploadComponent) => {
4853
+ const { format, value } = uploadComponent;
4854
+ const base64Value = format === "base64" && value ? await toBase64(value) : null;
4855
+ if (base64Value) {
4856
+ uploadComponent._update((draft) => {
4857
+ draft.base64Value = base64Value;
4858
+ });
4859
+ }
4860
+ };
4835
4861
 
4836
4862
  // src/revamp/domain/mappers/schema/blobSchemaToComponent.ts
4837
4863
  var blobSchemaToComponent = (schemaMapperProps, mapperProps) => {
@@ -6170,7 +6196,7 @@ var executeSubmission = async (props) => {
6170
6196
  if (method === "GET") {
6171
6197
  return void 0;
6172
6198
  }
6173
- const payload = mergeModels(model, (_a = action.data) != null ? _a : null);
6199
+ const payload = recursiveMerge(model, (_a = action.data) != null ? _a : null);
6174
6200
  return payload !== null ? JSON.stringify(payload) : null;
6175
6201
  };
6176
6202
  const response = await getSafeHttpClient(httpClient)(url != null ? url : "", {
@@ -6191,7 +6217,7 @@ var executeSubmission = async (props) => {
6191
6217
  const responseType = await getResponseType(response);
6192
6218
  const body = await parseResponseBodyAsJsonElement(response);
6193
6219
  if (exit) {
6194
- return { type: "complete", result: mergeModels(body, result) };
6220
+ return { type: "complete", result: recursiveMerge(body, result) };
6195
6221
  }
6196
6222
  switch (responseType) {
6197
6223
  case "step": {
@@ -6202,7 +6228,7 @@ var executeSubmission = async (props) => {
6202
6228
  }
6203
6229
  case "exit": {
6204
6230
  trackSubmissionEvent("Action Succeeded", { actionId });
6205
- return { type: "complete", result: mergeModels(body, result) };
6231
+ return { type: "complete", result: recursiveMerge(body, result) };
6206
6232
  }
6207
6233
  case "action": {
6208
6234
  assertActionResponseBody(body);
@@ -6736,13 +6762,13 @@ function useDynamicFlowCore(props) {
6736
6762
  errorsOverride,
6737
6763
  analytics
6738
6764
  }) => {
6739
- var _a2, _b;
6765
+ var _a2;
6740
6766
  try {
6741
6767
  rootComponentRef.current.setLoadingState("refreshing");
6742
- const model = (_a2 = await rootComponentRef.current.getSubmittableValue()) != null ? _a2 : null;
6768
+ const model = rootComponentRef.current.getSubmittableValueSync();
6743
6769
  const command = await executeRefresh({
6744
6770
  abortSignal: abortCurrentAndGetNewAbortSignal(),
6745
- url: (_b = refreshUrl != null ? refreshUrl : rootComponentRef.current.getRefreshUrl()) != null ? _b : "",
6771
+ url: (_a2 = refreshUrl != null ? refreshUrl : rootComponentRef.current.getRefreshUrl()) != null ? _a2 : "",
6746
6772
  model,
6747
6773
  etag: etagRef.current,
6748
6774
  analytics,
@@ -7077,13 +7103,13 @@ var isInteger2 = (value) => {
7077
7103
  return isNumber2(value) && Math.floor(value) === value;
7078
7104
  };
7079
7105
  var isBoolean2 = (value) => typeof value === "boolean";
7080
- var isObject2 = (value) => !isNull2(value) && !isUndefined2(value) && (value == null ? void 0 : value.constructor) === Object;
7106
+ var isObject3 = (value) => !isNull2(value) && !isUndefined2(value) && (value == null ? void 0 : value.constructor) === Object;
7081
7107
  var isArray2 = (value) => Array.isArray(value);
7082
7108
  var isNull2 = (value) => value === null;
7083
7109
  var isUndefined2 = (value) => typeof value === "undefined";
7084
7110
 
7085
7111
  // src/legacy/common/validators/values/value-validators.ts
7086
- var isEmpty = (value) => isString2(value) && value.length === 0 || (isObject2(value) || isArray2(value)) && Object.keys(value).length === 0;
7112
+ var isEmpty = (value) => isString2(value) && value.length === 0 || (isObject3(value) || isArray2(value)) && Object.keys(value).length === 0;
7087
7113
 
7088
7114
  // src/legacy/common/validators/models/model-utils.ts
7089
7115
  function cleanBasicModelWithOneOfSchema(model, schema) {
@@ -7427,7 +7453,7 @@ function isValidConstSchema(value, schema) {
7427
7453
  return !getConstValidationFailures(value, schema).length;
7428
7454
  }
7429
7455
  function isValidObjectSchema(value, schema) {
7430
- if (!isObject2(value) || schema.type !== "object" || !isObject2(schema.properties)) {
7456
+ if (!isObject3(value) || schema.type !== "object" || !isObject3(schema.properties)) {
7431
7457
  return false;
7432
7458
  }
7433
7459
  return Object.keys(schema.properties).map(
@@ -7448,7 +7474,7 @@ function isObjectPropertyValid(propertyValue, propertySchema, isRequired) {
7448
7474
  return isValidSchema(propertyValue, propertySchema);
7449
7475
  }
7450
7476
  function isValidArraySchema(value, schema) {
7451
- if (schema.type !== "array" || !isObject2(schema.items)) {
7477
+ if (schema.type !== "array" || !isObject3(schema.items)) {
7452
7478
  return false;
7453
7479
  }
7454
7480
  if (getArrayValidationFailures(value, schema).length > 0) {
@@ -7616,7 +7642,7 @@ var isReadOnlySchema = (schema) => Boolean(schema.readOnly) && isBasicSchema(sch
7616
7642
  var isPromotedOneOfSchema = (schema) => Boolean(schema.oneOf) && Boolean(schema.promotion);
7617
7643
  var basicTypes = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean"]);
7618
7644
  function isBasicSchema(schema) {
7619
- return basicTypes.has(schema.type || "") || "const" in schema && schema.const !== void 0 && !isObject2(schema.const);
7645
+ return basicTypes.has(schema.type || "") || "const" in schema && schema.const !== void 0 && !isObject3(schema.const);
7620
7646
  }
7621
7647
  function isObjectSchema2(schema) {
7622
7648
  return schema.type === "object";
@@ -8545,7 +8571,7 @@ function constructUploadResponse(response) {
8545
8571
  }
8546
8572
  function constructUploadError(response) {
8547
8573
  const isError = response instanceof Error;
8548
- const hasValidData = isObject2(response) && "data" in response;
8574
+ const hasValidData = isObject3(response) && "data" in response;
8549
8575
  const isInvalidResponseData = !hasValidData && !isError;
8550
8576
  if (isInvalidResponseData) {
8551
8577
  return isString2(response) ? response : void 0;
@@ -9221,7 +9247,7 @@ function RepeatableSchema({
9221
9247
  const [openModalType, setOpenModalType] = useState8(null);
9222
9248
  const [changed, setChanged] = useState8(false);
9223
9249
  const [itemSummaries, setItemSummaries] = useState8(() => {
9224
- if (isObject2(model) && !isArray2(model)) {
9250
+ if (isObject3(model) && !isArray2(model)) {
9225
9251
  throw new Error(
9226
9252
  "RepeatableSchema does not support object models. Ensure your array schema is wrapped inside an object schema."
9227
9253
  );
@@ -9532,7 +9558,7 @@ var getSafeStringValue = (value, options = {}) => {
9532
9558
  if (isNull2(value)) {
9533
9559
  return void 0;
9534
9560
  }
9535
- if (isObject2(value)) {
9561
+ if (isObject3(value)) {
9536
9562
  logInvalidTypeFallbackWarning({ received: "object", expected: "string" });
9537
9563
  return void 0;
9538
9564
  }
@@ -9555,7 +9581,7 @@ var getSafeStringOrNumberValue = (value, options = {}) => {
9555
9581
  return value;
9556
9582
  }
9557
9583
  const logProps = { received: typeof value, expected: "string or number" };
9558
- if (isObject2(value)) {
9584
+ if (isObject3(value)) {
9559
9585
  logInvalidTypeFallbackWarning(logProps);
9560
9586
  return void 0;
9561
9587
  }
@@ -10608,7 +10634,7 @@ function PersistAsyncBlobSchema(props) {
10608
10634
  }
10609
10635
  var getResponseJsonObject = async (response) => {
10610
10636
  const json = await response.json().catch(() => ({}));
10611
- return isObject2(json) ? json : {};
10637
+ return isObject3(json) ? json : {};
10612
10638
  };
10613
10639
  var PersistAsyncBlobSchema_default = PersistAsyncBlobSchema;
10614
10640
 
@@ -10872,7 +10898,7 @@ function ValidationAsyncSchema(props) {
10872
10898
  });
10873
10899
  try {
10874
10900
  const jsonResponse = await response.json();
10875
- if (!isObject2(jsonResponse)) {
10901
+ if (!isObject3(jsonResponse)) {
10876
10902
  throw new Error("Response body is not an object");
10877
10903
  }
10878
10904
  onEvent("Dynamic Flow - ValidationAsync", { status: "success" });
@@ -11643,8 +11669,8 @@ var useSearch = (defaultSearchConfig) => {
11643
11669
  const results = state.status === "success" ? state.results : [];
11644
11670
  return { status: state.status, results, search };
11645
11671
  };
11646
- var isValidResponseBody2 = (body) => isObject2(body) && "results" in body && isArray2(body.results) && body.results.every(
11647
- (result) => isObject2(result) && "title" in result && "type" in result && "value" in result
11672
+ var isValidResponseBody2 = (body) => isObject3(body) && "results" in body && isArray2(body.results) && body.results.every(
11673
+ (result) => isObject3(result) && "title" in result && "type" in result && "value" in result
11648
11674
  );
11649
11675
  var isAbortError = (error) => error instanceof DOMException && error.name === "AbortError";
11650
11676
  var addQueryParameter2 = (url, key, value) => {
@@ -11983,7 +12009,7 @@ function PersistAsyncBasicSchema(props) {
11983
12009
  onPersistAsync(persistAsyncFetch);
11984
12010
  const response = await persistAsyncFetch;
11985
12011
  const responseBody = await response.json();
11986
- if (!isObject2(responseBody)) {
12012
+ if (!isObject3(responseBody)) {
11987
12013
  throw new Error("Response is not an object");
11988
12014
  }
11989
12015
  const { idProperty, param } = schema.persistAsync;
@@ -11992,7 +12018,7 @@ function PersistAsyncBasicSchema(props) {
11992
12018
  onChange({ model: id, triggerSchema: schema, triggerModel: id });
11993
12019
  } else if (!response.ok) {
11994
12020
  const { validation } = responseBody;
11995
- const error = isObject2(validation) && (validation == null ? void 0 : validation[param]) || null;
12021
+ const error = isObject3(validation) && (validation == null ? void 0 : validation[param]) || null;
11996
12022
  setPersistAsyncError(error);
11997
12023
  onChange({ model: null, triggerSchema: schema, triggerModel: null });
11998
12024
  } else {
@@ -12082,7 +12108,7 @@ var usePersistAsync = (persistAsync) => {
12082
12108
  return handleHTTPError(response);
12083
12109
  }
12084
12110
  const jsonResponse = await response.json();
12085
- if (isObject2(jsonResponse)) {
12111
+ if (isObject3(jsonResponse)) {
12086
12112
  const id = jsonResponse[persistAsync.idProperty];
12087
12113
  if (isString2(id) || isNumber2(id)) {
12088
12114
  return { data: id };
@@ -12095,7 +12121,7 @@ var usePersistAsync = (persistAsync) => {
12095
12121
  }
12096
12122
  async function handleHTTPError(response) {
12097
12123
  const jsonResponse = await response.json();
12098
- if (isObject2(jsonResponse)) {
12124
+ if (isObject3(jsonResponse)) {
12099
12125
  const error = getErrorFromResponse(persistAsync.param, jsonResponse);
12100
12126
  if (isString2(error)) {
12101
12127
  throw new Error(error);
@@ -12117,7 +12143,7 @@ function wrapInFormData2(key, value) {
12117
12143
  return formData;
12118
12144
  }
12119
12145
  function hasStringMessage(value) {
12120
- return isObject2(value) && "message" in value && typeof value.message === "string";
12146
+ return isObject3(value) && "message" in value && typeof value.message === "string";
12121
12147
  }
12122
12148
 
12123
12149
  // src/legacy/common/hooks/usePolling/usePolling.tsx
@@ -13556,7 +13582,7 @@ var parseFetchResponseByResponseType = async (response, type) => {
13556
13582
  };
13557
13583
  var parseStepResponse = async (response) => {
13558
13584
  const jsonBody = await parseResponseJson(response);
13559
- if (!isObject2(jsonBody)) {
13585
+ if (!isObject3(jsonBody)) {
13560
13586
  throw new Error("Incorrect response body in response. Expected an object.");
13561
13587
  }
13562
13588
  const etag = response.headers.get("etag") || void 0;
@@ -13564,16 +13590,16 @@ var parseStepResponse = async (response) => {
13564
13590
  };
13565
13591
  var parseActionResponse = async (response) => {
13566
13592
  const jsonBody = await parseResponseJson(response);
13567
- if (!isObject2(jsonBody)) {
13593
+ if (!isObject3(jsonBody)) {
13568
13594
  throw new Error("Incorrect response body in response. Expected an object.");
13569
13595
  }
13570
- if (!isObject2(jsonBody.action)) {
13596
+ if (!isObject3(jsonBody.action)) {
13571
13597
  throw new Error(
13572
13598
  "Incorrect response body in action response. Expected an object satisfying the type { action: Action }."
13573
13599
  );
13574
13600
  }
13575
13601
  const action = jsonBody.action;
13576
- if (action.exit === true && isObject2(action.result)) {
13602
+ if (action.exit === true && isObject3(action.result)) {
13577
13603
  return { type: "exit", result: action.result };
13578
13604
  }
13579
13605
  return { type: "action", action: jsonBody.action };
@@ -13590,7 +13616,7 @@ var parseFetchResponse = async (response) => {
13590
13616
  return parseExitResponse(response);
13591
13617
  }
13592
13618
  const jsonBody = await parseResponseJson(response.clone());
13593
- if (isObject2(jsonBody) && jsonBody.action) {
13619
+ if (isObject3(jsonBody) && jsonBody.action) {
13594
13620
  return parseActionResponse(response);
13595
13621
  }
13596
13622
  return parseStepResponse(response);
@@ -13598,7 +13624,7 @@ var parseFetchResponse = async (response) => {
13598
13624
  var parseErrorResponse = async (response) => {
13599
13625
  assertResponseIsValid2(response);
13600
13626
  const jsonBody = await parseResponseJson(response);
13601
- if (!isObject2(jsonBody)) {
13627
+ if (!isObject3(jsonBody)) {
13602
13628
  throw new Error("Incorrect response body in error response. Expected an object.");
13603
13629
  }
13604
13630
  if (!jsonBody.refreshFormUrl && !jsonBody.refreshUrl && !jsonBody.validation && !jsonBody.error) {
@@ -13609,7 +13635,7 @@ var parseErrorResponse = async (response) => {
13609
13635
  var getJsonObjectOrNull = async (response) => {
13610
13636
  assertResponseIsValid2(response);
13611
13637
  const result = await parseResponseJson(response);
13612
- return isObject2(result) ? result : null;
13638
+ return isObject3(result) ? result : null;
13613
13639
  };
13614
13640
  var parseResponseJson = async (response) => {
13615
13641
  try {
@@ -13798,7 +13824,7 @@ var DynamicFlowComponent = ({
13798
13824
  void performAction(result.action, result.action.data);
13799
13825
  } else if (result.type === "exit") {
13800
13826
  dispatchEventAndComplete(
13801
- isObject2(actionResult) ? __spreadValues(__spreadValues({}, result.result), actionResult) : result.result
13827
+ isObject3(actionResult) ? __spreadValues(__spreadValues({}, result.result), actionResult) : result.result
13802
13828
  );
13803
13829
  } else {
13804
13830
  updateStep(result.step, result.etag, fetchType);
@@ -11,6 +11,7 @@ export type MultiUploadInputComponent = BaseInputComponent<File[]> & {
11
11
  file: File;
12
12
  errors: string[];
13
13
  id: string;
14
+ base64Value: string | null;
14
15
  }[];
15
16
  format: 'blob' | 'base64';
16
17
  maxItems?: number;
@@ -15,6 +15,7 @@ export type RootDomainComponent = BaseComponent & {
15
15
  getLoadingState: () => LoadingState;
16
16
  getSchemaComponents: () => SchemaComponent[];
17
17
  getSubmittableValue: () => Promise<Model>;
18
+ getSubmittableValueSync: () => Model;
18
19
  validate: () => boolean;
19
20
  getTrackEvent: () => AnalyticsEventDispatcher<string> | null;
20
21
  setLoadingState: (loadingState: LoadingState) => void;
@@ -11,6 +11,7 @@ export type UploadInputComponent = BaseInputComponent<File | null> & {
11
11
  accepts?: string[];
12
12
  source?: UploadSource;
13
13
  validationAsyncState?: undefined;
14
+ base64Value: string | null;
14
15
  onUpload: (value: File | null) => Promise<void>;
15
16
  };
16
17
  export declare const createUploadInputComponent: (uploadInputProps: Pick<UploadInputComponent, "uid" | "id" | "accepts" | "analyticsId" | "alert" | "autoComplete" | "cameraConfig" | "control" | "errors" | "description" | "disabled" | "format" | "help" | "hidden" | "icon" | "image" | "maxSize" | "placeholder" | "required" | "source" | "title" | "value"> & {
@@ -27,6 +27,7 @@ export type StepDomainComponent = BaseComponent & {
27
27
  getModals: () => ModalComponent[];
28
28
  getLocalValue: () => LocalValue;
29
29
  getSubmittableValue: () => Promise<Model>;
30
+ getSubmittableValueSync: () => Model;
30
31
  validate: () => boolean;
31
32
  setLoadingState: (loadingState: LoadingState) => void;
32
33
  onBehavior: OnBehavior;
@@ -256,6 +256,7 @@ export declare const oneOfSchemaToComponent: (schemaMapperProps: SchemaMapperPro
256
256
  file: File;
257
257
  errors: string[];
258
258
  id: string;
259
+ base64Value: string | null;
259
260
  }[];
260
261
  format: "blob" | "base64";
261
262
  maxItems?: number;
@@ -462,6 +463,7 @@ export declare const oneOfSchemaToComponent: (schemaMapperProps: SchemaMapperPro
462
463
  accepts?: string[];
463
464
  source?: import("../../../types").UploadSource;
464
465
  validationAsyncState?: undefined;
466
+ base64Value: string | null;
465
467
  onUpload: (value: File | null) => Promise<void>;
466
468
  } & {
467
469
  kind: "input";
@@ -230,6 +230,7 @@ export declare const persistAsyncSchemaToComponent: (schemaMapperProps: SchemaMa
230
230
  file: File;
231
231
  errors: string[];
232
232
  id: string;
233
+ base64Value: string | null;
233
234
  }[];
234
235
  format: "blob" | "base64";
235
236
  maxItems?: number;
@@ -475,6 +476,7 @@ export declare const persistAsyncSchemaToComponent: (schemaMapperProps: SchemaMa
475
476
  accepts?: string[];
476
477
  source?: import("../../types").UploadSource;
477
478
  validationAsyncState?: undefined;
479
+ base64Value: string | null;
478
480
  onUpload: (value: File | null) => Promise<void>;
479
481
  } & {
480
482
  kind: "input";
@@ -1,5 +1,5 @@
1
- import { DynamicFlowCorePropsWithInitialAction, DynamicFlowCorePropsWithInitialStep } from '../types';
2
1
  import { Theming } from '@wise/components-theming';
2
+ import { DynamicFlowCorePropsWithInitialAction, DynamicFlowCorePropsWithInitialStep } from '../types';
3
3
  type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
4
4
  export type DynamicFlowWisePropsWithInitialAction = MakeOptional<DynamicFlowCorePropsWithInitialAction, 'renderers' | 'onLink'>;
5
5
  export type DynamicFlowWisePropsWithInitialStep = MakeOptional<DynamicFlowCorePropsWithInitialStep, 'renderers' | 'onLink'>;
@@ -1,7 +1,5 @@
1
- import type { Model } from '@wise/dynamic-flow-types/build/next';
2
- import type { SchemaComponent, LocalValue } from '../domain/types';
3
- export declare const getSubmittableData: (components: SchemaComponent[]) => Promise<Model>;
4
- export declare const getSubmittableDataSync: (components: SchemaComponent[]) => Model;
1
+ import type { JsonElement } from '@wise/dynamic-flow-types/build/next';
2
+ import type { LocalValue, SchemaComponent } from '../domain/types';
3
+ export declare const getSubmittableData: (components: SchemaComponent[]) => Promise<JsonElement>;
4
+ export declare const getSubmittableDataSync: (components: SchemaComponent[]) => JsonElement;
5
5
  export declare const getLocalValues: (components: SchemaComponent[]) => LocalValue;
6
- export declare const mergeLocalValues: (valueA: LocalValue, valueB: LocalValue) => LocalValue;
7
- export declare const mergeModels: (valueA: Model, valueB: Model) => Model;
@@ -0,0 +1,11 @@
1
+ import { LocalValue } from '../domain/types';
2
+ /**
3
+ * Recursively merges two local values.
4
+ * If both values are objects, it merges their properties.
5
+ * If both values are arrays, it merges their elements.
6
+ * Otherwise, it returns the second value.
7
+ *
8
+ * This function works with both LocalValue and JsonElement types.
9
+ * But, only because JsonElement is assignable to LocalValue.
10
+ */
11
+ export declare function recursiveMerge<T extends LocalValue>(valueA: T, valueB: T): T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/dynamic-flow-client",
3
- "version": "4.9.0",
3
+ "version": "4.10.0-modal-renderer-exposed-b166873",
4
4
  "description": "Dynamic Flow web client",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./build/main.js",
@@ -30,38 +30,38 @@
30
30
  "url": "git+https://github.com/transferwise/dynamic-flow.git"
31
31
  },
32
32
  "devDependencies": {
33
- "@babel/core": "7.27.7",
33
+ "@babel/core": "7.28.0",
34
34
  "@babel/plugin-syntax-flow": "7.27.1",
35
35
  "@babel/plugin-transform-react-jsx": "7.27.1",
36
- "@babel/preset-env": "7.27.2",
36
+ "@babel/preset-env": "7.28.0",
37
37
  "@babel/preset-react": "7.27.1",
38
38
  "@babel/preset-typescript": "7.27.1",
39
39
  "@chromatic-com/storybook": "4.0.1",
40
40
  "@formatjs/cli": "^6.7.2",
41
- "@storybook/addon-a11y": "^9.0.15",
42
- "@storybook/addon-docs": "^9.0.15",
43
- "@storybook/addon-links": "^9.0.15",
44
- "@storybook/react-vite": "9.0.15",
41
+ "@storybook/addon-a11y": "^9.0.18",
42
+ "@storybook/addon-docs": "^9.0.18",
43
+ "@storybook/addon-links": "^9.0.18",
44
+ "@storybook/react-vite": "9.0.18",
45
45
  "@testing-library/dom": "10.4.0",
46
46
  "@testing-library/jest-dom": "6.6.3",
47
47
  "@testing-library/react": "16.3.0",
48
48
  "@testing-library/user-event": "14.6.1",
49
- "@transferwise/components": "46.100.0",
50
- "@transferwise/formatting": "^2.13.3",
49
+ "@transferwise/components": "46.100.1",
50
+ "@transferwise/formatting": "^2.13.4",
51
51
  "@transferwise/icons": "3.22.3",
52
- "@transferwise/neptune-css": "14.24.4",
53
- "@types/jest": "29.5.14",
54
- "@types/node": "22.15.34",
52
+ "@transferwise/neptune-css": "14.24.5",
53
+ "@types/jest": "30.0.0",
54
+ "@types/node": "22.16.5",
55
55
  "@types/react": "18.3.23",
56
56
  "@types/react-dom": "18.3.7",
57
57
  "@types/react-intl": "3.0.0",
58
- "@wise/art": "2.22.0",
59
- "@wise/components-theming": "^1.6.3",
60
- "babel-jest": "30.0.2",
61
- "esbuild": "0.25.5",
62
- "eslint-plugin-storybook": "9.0.15",
63
- "jest": "30.0.3",
64
- "jest-environment-jsdom": "30.0.2",
58
+ "@wise/art": "2.23.0",
59
+ "@wise/components-theming": "^1.6.4",
60
+ "babel-jest": "30.0.5",
61
+ "esbuild": "0.25.8",
62
+ "eslint-plugin-storybook": "9.0.18",
63
+ "jest": "30.0.5",
64
+ "jest-environment-jsdom": "30.0.5",
65
65
  "jest-fetch-mock": "^3.0.3",
66
66
  "jest-watch-typeahead": "^3.0.1",
67
67
  "npm-run-all2": "7.0.2",
@@ -71,8 +71,8 @@
71
71
  "react": "18.3.1",
72
72
  "react-dom": "18.3.1",
73
73
  "react-intl": "6.8.9",
74
- "storybook": "^9.0.15",
75
- "stylelint": "16.21.0",
74
+ "storybook": "^9.0.18",
75
+ "stylelint": "16.22.0",
76
76
  "stylelint-config-standard": "36.0.1",
77
77
  "stylelint-no-unsupported-browser-features": "8.0.4",
78
78
  "stylelint-value-no-unknown-custom-properties": "6.0.1",
@@ -95,7 +95,7 @@
95
95
  "classnames": "2.5.1",
96
96
  "react-webcam": "^7.2.0",
97
97
  "screenfull": "^5.2.0",
98
- "@wise/dynamic-flow-types": "3.8.0"
98
+ "@wise/dynamic-flow-types": "3.8.1"
99
99
  },
100
100
  "scripts": {
101
101
  "dev": "pnpm build:visual-tests && storybook dev -p 3003",