@wise/dynamic-flow-client 4.9.1 → 4.10.0
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 +88 -83
- package/build/main.mjs +88 -83
- package/build/types/revamp/domain/components/MultiUploadInputComponent.d.ts +1 -0
- package/build/types/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.d.ts +1 -0
- package/build/types/revamp/domain/mappers/schema/persistAsyncSchemaToComponent.d.ts +1 -0
- package/build/types/revamp/test-utils/DynamicFlowWise.d.ts +1 -1
- package/build/types/revamp/utils/component-utils.d.ts +4 -6
- package/build/types/revamp/utils/recursiveMerge.d.ts +11 -0
- package/package.json +20 -20
package/build/main.js
CHANGED
|
@@ -3124,36 +3124,51 @@ var createExternalConfirmation = (uid, url, updateComponent) => {
|
|
|
3124
3124
|
};
|
|
3125
3125
|
};
|
|
3126
3126
|
|
|
3127
|
-
// src/revamp/utils/
|
|
3128
|
-
|
|
3129
|
-
(values) => values.reduce((acc, value) => mergeModels(acc, value), null)
|
|
3130
|
-
);
|
|
3131
|
-
var getSubmittableDataSync = (components) => components.map((component) => component.getSubmittableValueSync()).reduce((acc, value) => mergeModels(acc, value), null);
|
|
3132
|
-
var getLocalValues = (components) => components.map((component) => component.getLocalValue()).reduce((acc, value) => mergeLocalValues(acc, value), null);
|
|
3133
|
-
var mergeLocalValues = (valueA, valueB) => {
|
|
3127
|
+
// src/revamp/utils/recursiveMerge.ts
|
|
3128
|
+
function recursiveMerge(valueA, valueB) {
|
|
3134
3129
|
if (valueA === null) {
|
|
3135
3130
|
return valueB;
|
|
3136
3131
|
}
|
|
3137
3132
|
if (valueB === null) {
|
|
3138
3133
|
return valueA;
|
|
3139
3134
|
}
|
|
3140
|
-
if (
|
|
3141
|
-
return
|
|
3135
|
+
if (isObject2(valueA) && isObject2(valueB)) {
|
|
3136
|
+
return mergeObjects(valueA, valueB);
|
|
3142
3137
|
}
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
var mergeModels = (valueA, valueB) => {
|
|
3146
|
-
if (valueA === null) {
|
|
3147
|
-
return valueB;
|
|
3148
|
-
}
|
|
3149
|
-
if (valueB === null) {
|
|
3150
|
-
return valueA;
|
|
3151
|
-
}
|
|
3152
|
-
if (isObjectModel(valueA) && isObjectModel(valueB)) {
|
|
3153
|
-
return __spreadValues(__spreadValues({}, valueA), valueB);
|
|
3138
|
+
if (Array.isArray(valueA) && Array.isArray(valueB)) {
|
|
3139
|
+
return mergeArrays(valueA, valueB);
|
|
3154
3140
|
}
|
|
3155
3141
|
return valueB;
|
|
3156
|
-
}
|
|
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);
|
|
3157
3172
|
|
|
3158
3173
|
// src/revamp/domain/components/step/StepDomainComponent.ts
|
|
3159
3174
|
var createStepComponent = (stepProps) => {
|
|
@@ -4298,12 +4313,13 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4298
4313
|
const update = getInputUpdateFunction(updateComponent);
|
|
4299
4314
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4300
4315
|
const getFileValidationErrors = getLocalValueValidator(fileChecks);
|
|
4316
|
+
const persist = performPersistAsync ? getComponentMultiPersistAsync(update, performPersistAsync) : void 0;
|
|
4301
4317
|
const uploadComponent = __spreadValues({
|
|
4302
4318
|
type: "multi-upload",
|
|
4303
4319
|
kind: "input",
|
|
4304
4320
|
uid,
|
|
4305
4321
|
id,
|
|
4306
|
-
format
|
|
4322
|
+
format,
|
|
4307
4323
|
files: [],
|
|
4308
4324
|
_update(updateFn) {
|
|
4309
4325
|
update(this, updateFn);
|
|
@@ -4315,28 +4331,44 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4315
4331
|
},
|
|
4316
4332
|
// Noop
|
|
4317
4333
|
async onRemoveFile(index) {
|
|
4334
|
+
var _a2;
|
|
4318
4335
|
this._update((draft) => {
|
|
4319
4336
|
draft.value.splice(index, 1);
|
|
4320
4337
|
draft.files.splice(index, 1);
|
|
4321
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
|
+
}
|
|
4322
4345
|
},
|
|
4323
4346
|
async onInsertFile(index, file) {
|
|
4324
4347
|
const fileErrors = getFileValidationErrors(file);
|
|
4325
4348
|
const fileId = getRandomId();
|
|
4349
|
+
const base64Value = format === "base64" ? await toBase64(file) : null;
|
|
4326
4350
|
this._update((draft) => {
|
|
4327
4351
|
draft.value.splice(index, 0, file);
|
|
4328
|
-
draft.files.splice(index, 0, { file, id: fileId, errors: fileErrors });
|
|
4352
|
+
draft.files.splice(index, 0, { file, id: fileId, errors: fileErrors, base64Value });
|
|
4329
4353
|
draft.errors = [];
|
|
4330
4354
|
});
|
|
4355
|
+
if (persist) {
|
|
4356
|
+
await persist(this, index, format === "blob" ? file : base64Value);
|
|
4357
|
+
}
|
|
4331
4358
|
onValueChange();
|
|
4332
4359
|
return fileId;
|
|
4333
4360
|
},
|
|
4334
4361
|
async getSubmittableValue() {
|
|
4335
|
-
|
|
4336
|
-
|
|
4362
|
+
if (persist) {
|
|
4363
|
+
return Promise.all(this.persistedState.map(async ({ submission }) => submission));
|
|
4364
|
+
}
|
|
4365
|
+
return this.files.map(({ base64Value }) => base64Value);
|
|
4337
4366
|
},
|
|
4338
4367
|
getSubmittableValueSync() {
|
|
4339
|
-
|
|
4368
|
+
if (persist) {
|
|
4369
|
+
return this.persistedState.map(({ lastResponse }) => lastResponse);
|
|
4370
|
+
}
|
|
4371
|
+
return this.files.map(({ base64Value }) => base64Value);
|
|
4340
4372
|
},
|
|
4341
4373
|
getSummary() {
|
|
4342
4374
|
return summariser(this.getLocalValue().map(({ name }) => name));
|
|
@@ -4352,34 +4384,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4352
4384
|
return errorMsgs.length === 0 && this.files.every(({ errors }) => errors.length === 0);
|
|
4353
4385
|
}
|
|
4354
4386
|
}, rest);
|
|
4355
|
-
|
|
4356
|
-
return uploadComponent;
|
|
4357
|
-
}
|
|
4358
|
-
const persist = getComponentMultiPersistAsync(update, performPersistAsync);
|
|
4359
|
-
return __spreadProps(__spreadValues({}, uploadComponent), {
|
|
4360
|
-
format,
|
|
4361
|
-
async onInsertFile(index, file) {
|
|
4362
|
-
const fileId = await uploadComponent.onInsertFile.call(this, index, file);
|
|
4363
|
-
const submission = format === "blob" ? file : await toBase64(file);
|
|
4364
|
-
await persist(this, index, submission);
|
|
4365
|
-
onValueChange();
|
|
4366
|
-
return fileId;
|
|
4367
|
-
},
|
|
4368
|
-
async onRemoveFile(index) {
|
|
4369
|
-
var _a2;
|
|
4370
|
-
await uploadComponent.onRemoveFile.call(this, index);
|
|
4371
|
-
(_a2 = this.persistedState[index]) == null ? void 0 : _a2.abortController.abort();
|
|
4372
|
-
this._update((draft) => {
|
|
4373
|
-
draft.persistedState = draft.persistedState.splice(index, 1);
|
|
4374
|
-
});
|
|
4375
|
-
},
|
|
4376
|
-
async getSubmittableValue() {
|
|
4377
|
-
return Promise.all(this.persistedState.map(async ({ submission }) => submission));
|
|
4378
|
-
},
|
|
4379
|
-
getSubmittableValueSync() {
|
|
4380
|
-
return this.persistedState.map(({ lastResponse }) => lastResponse);
|
|
4381
|
-
}
|
|
4382
|
-
});
|
|
4387
|
+
return uploadComponent;
|
|
4383
4388
|
};
|
|
4384
4389
|
|
|
4385
4390
|
// src/revamp/domain/features/persistAsync/getInitialPersistedState.ts
|
|
@@ -6234,7 +6239,7 @@ var executeSubmission = async (props) => {
|
|
|
6234
6239
|
if (method === "GET") {
|
|
6235
6240
|
return void 0;
|
|
6236
6241
|
}
|
|
6237
|
-
const payload =
|
|
6242
|
+
const payload = recursiveMerge(model, (_a = action.data) != null ? _a : null);
|
|
6238
6243
|
return payload !== null ? JSON.stringify(payload) : null;
|
|
6239
6244
|
};
|
|
6240
6245
|
const response = await getSafeHttpClient(httpClient)(url != null ? url : "", {
|
|
@@ -6255,7 +6260,7 @@ var executeSubmission = async (props) => {
|
|
|
6255
6260
|
const responseType = await getResponseType(response);
|
|
6256
6261
|
const body = await parseResponseBodyAsJsonElement(response);
|
|
6257
6262
|
if (exit) {
|
|
6258
|
-
return { type: "complete", result:
|
|
6263
|
+
return { type: "complete", result: recursiveMerge(body, result) };
|
|
6259
6264
|
}
|
|
6260
6265
|
switch (responseType) {
|
|
6261
6266
|
case "step": {
|
|
@@ -6266,7 +6271,7 @@ var executeSubmission = async (props) => {
|
|
|
6266
6271
|
}
|
|
6267
6272
|
case "exit": {
|
|
6268
6273
|
trackSubmissionEvent("Action Succeeded", { actionId });
|
|
6269
|
-
return { type: "complete", result:
|
|
6274
|
+
return { type: "complete", result: recursiveMerge(body, result) };
|
|
6270
6275
|
}
|
|
6271
6276
|
case "action": {
|
|
6272
6277
|
assertActionResponseBody(body);
|
|
@@ -7141,13 +7146,13 @@ var isInteger2 = (value) => {
|
|
|
7141
7146
|
return isNumber2(value) && Math.floor(value) === value;
|
|
7142
7147
|
};
|
|
7143
7148
|
var isBoolean2 = (value) => typeof value === "boolean";
|
|
7144
|
-
var
|
|
7149
|
+
var isObject3 = (value) => !isNull2(value) && !isUndefined2(value) && (value == null ? void 0 : value.constructor) === Object;
|
|
7145
7150
|
var isArray2 = (value) => Array.isArray(value);
|
|
7146
7151
|
var isNull2 = (value) => value === null;
|
|
7147
7152
|
var isUndefined2 = (value) => typeof value === "undefined";
|
|
7148
7153
|
|
|
7149
7154
|
// src/legacy/common/validators/values/value-validators.ts
|
|
7150
|
-
var isEmpty = (value) => isString2(value) && value.length === 0 || (
|
|
7155
|
+
var isEmpty = (value) => isString2(value) && value.length === 0 || (isObject3(value) || isArray2(value)) && Object.keys(value).length === 0;
|
|
7151
7156
|
|
|
7152
7157
|
// src/legacy/common/validators/models/model-utils.ts
|
|
7153
7158
|
function cleanBasicModelWithOneOfSchema(model, schema) {
|
|
@@ -7491,7 +7496,7 @@ function isValidConstSchema(value, schema) {
|
|
|
7491
7496
|
return !getConstValidationFailures(value, schema).length;
|
|
7492
7497
|
}
|
|
7493
7498
|
function isValidObjectSchema(value, schema) {
|
|
7494
|
-
if (!
|
|
7499
|
+
if (!isObject3(value) || schema.type !== "object" || !isObject3(schema.properties)) {
|
|
7495
7500
|
return false;
|
|
7496
7501
|
}
|
|
7497
7502
|
return Object.keys(schema.properties).map(
|
|
@@ -7512,7 +7517,7 @@ function isObjectPropertyValid(propertyValue, propertySchema, isRequired) {
|
|
|
7512
7517
|
return isValidSchema(propertyValue, propertySchema);
|
|
7513
7518
|
}
|
|
7514
7519
|
function isValidArraySchema(value, schema) {
|
|
7515
|
-
if (schema.type !== "array" || !
|
|
7520
|
+
if (schema.type !== "array" || !isObject3(schema.items)) {
|
|
7516
7521
|
return false;
|
|
7517
7522
|
}
|
|
7518
7523
|
if (getArrayValidationFailures(value, schema).length > 0) {
|
|
@@ -7680,7 +7685,7 @@ var isReadOnlySchema = (schema) => Boolean(schema.readOnly) && isBasicSchema(sch
|
|
|
7680
7685
|
var isPromotedOneOfSchema = (schema) => Boolean(schema.oneOf) && Boolean(schema.promotion);
|
|
7681
7686
|
var basicTypes = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean"]);
|
|
7682
7687
|
function isBasicSchema(schema) {
|
|
7683
|
-
return basicTypes.has(schema.type || "") || "const" in schema && schema.const !== void 0 && !
|
|
7688
|
+
return basicTypes.has(schema.type || "") || "const" in schema && schema.const !== void 0 && !isObject3(schema.const);
|
|
7684
7689
|
}
|
|
7685
7690
|
function isObjectSchema2(schema) {
|
|
7686
7691
|
return schema.type === "object";
|
|
@@ -8606,7 +8611,7 @@ function constructUploadResponse(response) {
|
|
|
8606
8611
|
}
|
|
8607
8612
|
function constructUploadError(response) {
|
|
8608
8613
|
const isError = response instanceof Error;
|
|
8609
|
-
const hasValidData =
|
|
8614
|
+
const hasValidData = isObject3(response) && "data" in response;
|
|
8610
8615
|
const isInvalidResponseData = !hasValidData && !isError;
|
|
8611
8616
|
if (isInvalidResponseData) {
|
|
8612
8617
|
return isString2(response) ? response : void 0;
|
|
@@ -9282,7 +9287,7 @@ function RepeatableSchema({
|
|
|
9282
9287
|
const [openModalType, setOpenModalType] = (0, import_react19.useState)(null);
|
|
9283
9288
|
const [changed, setChanged] = (0, import_react19.useState)(false);
|
|
9284
9289
|
const [itemSummaries, setItemSummaries] = (0, import_react19.useState)(() => {
|
|
9285
|
-
if (
|
|
9290
|
+
if (isObject3(model) && !isArray2(model)) {
|
|
9286
9291
|
throw new Error(
|
|
9287
9292
|
"RepeatableSchema does not support object models. Ensure your array schema is wrapped inside an object schema."
|
|
9288
9293
|
);
|
|
@@ -9581,7 +9586,7 @@ var getSafeStringValue = (value, options = {}) => {
|
|
|
9581
9586
|
if (isNull2(value)) {
|
|
9582
9587
|
return void 0;
|
|
9583
9588
|
}
|
|
9584
|
-
if (
|
|
9589
|
+
if (isObject3(value)) {
|
|
9585
9590
|
logInvalidTypeFallbackWarning({ received: "object", expected: "string" });
|
|
9586
9591
|
return void 0;
|
|
9587
9592
|
}
|
|
@@ -9604,7 +9609,7 @@ var getSafeStringOrNumberValue = (value, options = {}) => {
|
|
|
9604
9609
|
return value;
|
|
9605
9610
|
}
|
|
9606
9611
|
const logProps = { received: typeof value, expected: "string or number" };
|
|
9607
|
-
if (
|
|
9612
|
+
if (isObject3(value)) {
|
|
9608
9613
|
logInvalidTypeFallbackWarning(logProps);
|
|
9609
9614
|
return void 0;
|
|
9610
9615
|
}
|
|
@@ -10657,7 +10662,7 @@ function PersistAsyncBlobSchema(props) {
|
|
|
10657
10662
|
}
|
|
10658
10663
|
var getResponseJsonObject = async (response) => {
|
|
10659
10664
|
const json = await response.json().catch(() => ({}));
|
|
10660
|
-
return
|
|
10665
|
+
return isObject3(json) ? json : {};
|
|
10661
10666
|
};
|
|
10662
10667
|
var PersistAsyncBlobSchema_default = PersistAsyncBlobSchema;
|
|
10663
10668
|
|
|
@@ -10921,7 +10926,7 @@ function ValidationAsyncSchema(props) {
|
|
|
10921
10926
|
});
|
|
10922
10927
|
try {
|
|
10923
10928
|
const jsonResponse = await response.json();
|
|
10924
|
-
if (!
|
|
10929
|
+
if (!isObject3(jsonResponse)) {
|
|
10925
10930
|
throw new Error("Response body is not an object");
|
|
10926
10931
|
}
|
|
10927
10932
|
onEvent("Dynamic Flow - ValidationAsync", { status: "success" });
|
|
@@ -11692,8 +11697,8 @@ var useSearch = (defaultSearchConfig) => {
|
|
|
11692
11697
|
const results = state.status === "success" ? state.results : [];
|
|
11693
11698
|
return { status: state.status, results, search };
|
|
11694
11699
|
};
|
|
11695
|
-
var isValidResponseBody2 = (body) =>
|
|
11696
|
-
(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
|
|
11697
11702
|
);
|
|
11698
11703
|
var isAbortError = (error) => error instanceof DOMException && error.name === "AbortError";
|
|
11699
11704
|
var addQueryParameter2 = (url, key, value) => {
|
|
@@ -12032,7 +12037,7 @@ function PersistAsyncBasicSchema(props) {
|
|
|
12032
12037
|
onPersistAsync(persistAsyncFetch);
|
|
12033
12038
|
const response = await persistAsyncFetch;
|
|
12034
12039
|
const responseBody = await response.json();
|
|
12035
|
-
if (!
|
|
12040
|
+
if (!isObject3(responseBody)) {
|
|
12036
12041
|
throw new Error("Response is not an object");
|
|
12037
12042
|
}
|
|
12038
12043
|
const { idProperty, param } = schema.persistAsync;
|
|
@@ -12041,7 +12046,7 @@ function PersistAsyncBasicSchema(props) {
|
|
|
12041
12046
|
onChange({ model: id, triggerSchema: schema, triggerModel: id });
|
|
12042
12047
|
} else if (!response.ok) {
|
|
12043
12048
|
const { validation } = responseBody;
|
|
12044
|
-
const error =
|
|
12049
|
+
const error = isObject3(validation) && (validation == null ? void 0 : validation[param]) || null;
|
|
12045
12050
|
setPersistAsyncError(error);
|
|
12046
12051
|
onChange({ model: null, triggerSchema: schema, triggerModel: null });
|
|
12047
12052
|
} else {
|
|
@@ -12131,7 +12136,7 @@ var usePersistAsync = (persistAsync) => {
|
|
|
12131
12136
|
return handleHTTPError(response);
|
|
12132
12137
|
}
|
|
12133
12138
|
const jsonResponse = await response.json();
|
|
12134
|
-
if (
|
|
12139
|
+
if (isObject3(jsonResponse)) {
|
|
12135
12140
|
const id = jsonResponse[persistAsync.idProperty];
|
|
12136
12141
|
if (isString2(id) || isNumber2(id)) {
|
|
12137
12142
|
return { data: id };
|
|
@@ -12144,7 +12149,7 @@ var usePersistAsync = (persistAsync) => {
|
|
|
12144
12149
|
}
|
|
12145
12150
|
async function handleHTTPError(response) {
|
|
12146
12151
|
const jsonResponse = await response.json();
|
|
12147
|
-
if (
|
|
12152
|
+
if (isObject3(jsonResponse)) {
|
|
12148
12153
|
const error = getErrorFromResponse(persistAsync.param, jsonResponse);
|
|
12149
12154
|
if (isString2(error)) {
|
|
12150
12155
|
throw new Error(error);
|
|
@@ -12166,7 +12171,7 @@ function wrapInFormData2(key, value) {
|
|
|
12166
12171
|
return formData;
|
|
12167
12172
|
}
|
|
12168
12173
|
function hasStringMessage(value) {
|
|
12169
|
-
return
|
|
12174
|
+
return isObject3(value) && "message" in value && typeof value.message === "string";
|
|
12170
12175
|
}
|
|
12171
12176
|
|
|
12172
12177
|
// src/legacy/common/hooks/usePolling/usePolling.tsx
|
|
@@ -13605,7 +13610,7 @@ var parseFetchResponseByResponseType = async (response, type) => {
|
|
|
13605
13610
|
};
|
|
13606
13611
|
var parseStepResponse = async (response) => {
|
|
13607
13612
|
const jsonBody = await parseResponseJson(response);
|
|
13608
|
-
if (!
|
|
13613
|
+
if (!isObject3(jsonBody)) {
|
|
13609
13614
|
throw new Error("Incorrect response body in response. Expected an object.");
|
|
13610
13615
|
}
|
|
13611
13616
|
const etag = response.headers.get("etag") || void 0;
|
|
@@ -13613,16 +13618,16 @@ var parseStepResponse = async (response) => {
|
|
|
13613
13618
|
};
|
|
13614
13619
|
var parseActionResponse = async (response) => {
|
|
13615
13620
|
const jsonBody = await parseResponseJson(response);
|
|
13616
|
-
if (!
|
|
13621
|
+
if (!isObject3(jsonBody)) {
|
|
13617
13622
|
throw new Error("Incorrect response body in response. Expected an object.");
|
|
13618
13623
|
}
|
|
13619
|
-
if (!
|
|
13624
|
+
if (!isObject3(jsonBody.action)) {
|
|
13620
13625
|
throw new Error(
|
|
13621
13626
|
"Incorrect response body in action response. Expected an object satisfying the type { action: Action }."
|
|
13622
13627
|
);
|
|
13623
13628
|
}
|
|
13624
13629
|
const action = jsonBody.action;
|
|
13625
|
-
if (action.exit === true &&
|
|
13630
|
+
if (action.exit === true && isObject3(action.result)) {
|
|
13626
13631
|
return { type: "exit", result: action.result };
|
|
13627
13632
|
}
|
|
13628
13633
|
return { type: "action", action: jsonBody.action };
|
|
@@ -13639,7 +13644,7 @@ var parseFetchResponse = async (response) => {
|
|
|
13639
13644
|
return parseExitResponse(response);
|
|
13640
13645
|
}
|
|
13641
13646
|
const jsonBody = await parseResponseJson(response.clone());
|
|
13642
|
-
if (
|
|
13647
|
+
if (isObject3(jsonBody) && jsonBody.action) {
|
|
13643
13648
|
return parseActionResponse(response);
|
|
13644
13649
|
}
|
|
13645
13650
|
return parseStepResponse(response);
|
|
@@ -13647,7 +13652,7 @@ var parseFetchResponse = async (response) => {
|
|
|
13647
13652
|
var parseErrorResponse = async (response) => {
|
|
13648
13653
|
assertResponseIsValid2(response);
|
|
13649
13654
|
const jsonBody = await parseResponseJson(response);
|
|
13650
|
-
if (!
|
|
13655
|
+
if (!isObject3(jsonBody)) {
|
|
13651
13656
|
throw new Error("Incorrect response body in error response. Expected an object.");
|
|
13652
13657
|
}
|
|
13653
13658
|
if (!jsonBody.refreshFormUrl && !jsonBody.refreshUrl && !jsonBody.validation && !jsonBody.error) {
|
|
@@ -13658,7 +13663,7 @@ var parseErrorResponse = async (response) => {
|
|
|
13658
13663
|
var getJsonObjectOrNull = async (response) => {
|
|
13659
13664
|
assertResponseIsValid2(response);
|
|
13660
13665
|
const result = await parseResponseJson(response);
|
|
13661
|
-
return
|
|
13666
|
+
return isObject3(result) ? result : null;
|
|
13662
13667
|
};
|
|
13663
13668
|
var parseResponseJson = async (response) => {
|
|
13664
13669
|
try {
|
|
@@ -13847,7 +13852,7 @@ var DynamicFlowComponent = ({
|
|
|
13847
13852
|
void performAction(result.action, result.action.data);
|
|
13848
13853
|
} else if (result.type === "exit") {
|
|
13849
13854
|
dispatchEventAndComplete(
|
|
13850
|
-
|
|
13855
|
+
isObject3(actionResult) ? __spreadValues(__spreadValues({}, result.result), actionResult) : result.result
|
|
13851
13856
|
);
|
|
13852
13857
|
} else {
|
|
13853
13858
|
updateStep(result.step, result.etag, fetchType);
|
package/build/main.mjs
CHANGED
|
@@ -3081,36 +3081,51 @@ var createExternalConfirmation = (uid, url, updateComponent) => {
|
|
|
3081
3081
|
};
|
|
3082
3082
|
};
|
|
3083
3083
|
|
|
3084
|
-
// src/revamp/utils/
|
|
3085
|
-
|
|
3086
|
-
(values) => values.reduce((acc, value) => mergeModels(acc, value), null)
|
|
3087
|
-
);
|
|
3088
|
-
var getSubmittableDataSync = (components) => components.map((component) => component.getSubmittableValueSync()).reduce((acc, value) => mergeModels(acc, value), null);
|
|
3089
|
-
var getLocalValues = (components) => components.map((component) => component.getLocalValue()).reduce((acc, value) => mergeLocalValues(acc, value), null);
|
|
3090
|
-
var mergeLocalValues = (valueA, valueB) => {
|
|
3084
|
+
// src/revamp/utils/recursiveMerge.ts
|
|
3085
|
+
function recursiveMerge(valueA, valueB) {
|
|
3091
3086
|
if (valueA === null) {
|
|
3092
3087
|
return valueB;
|
|
3093
3088
|
}
|
|
3094
3089
|
if (valueB === null) {
|
|
3095
3090
|
return valueA;
|
|
3096
3091
|
}
|
|
3097
|
-
if (
|
|
3098
|
-
return
|
|
3092
|
+
if (isObject2(valueA) && isObject2(valueB)) {
|
|
3093
|
+
return mergeObjects(valueA, valueB);
|
|
3099
3094
|
}
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
var mergeModels = (valueA, valueB) => {
|
|
3103
|
-
if (valueA === null) {
|
|
3104
|
-
return valueB;
|
|
3105
|
-
}
|
|
3106
|
-
if (valueB === null) {
|
|
3107
|
-
return valueA;
|
|
3108
|
-
}
|
|
3109
|
-
if (isObjectModel(valueA) && isObjectModel(valueB)) {
|
|
3110
|
-
return __spreadValues(__spreadValues({}, valueA), valueB);
|
|
3095
|
+
if (Array.isArray(valueA) && Array.isArray(valueB)) {
|
|
3096
|
+
return mergeArrays(valueA, valueB);
|
|
3111
3097
|
}
|
|
3112
3098
|
return valueB;
|
|
3113
|
-
}
|
|
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);
|
|
3114
3129
|
|
|
3115
3130
|
// src/revamp/domain/components/step/StepDomainComponent.ts
|
|
3116
3131
|
var createStepComponent = (stepProps) => {
|
|
@@ -4255,12 +4270,13 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4255
4270
|
const update = getInputUpdateFunction(updateComponent);
|
|
4256
4271
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4257
4272
|
const getFileValidationErrors = getLocalValueValidator(fileChecks);
|
|
4273
|
+
const persist = performPersistAsync ? getComponentMultiPersistAsync(update, performPersistAsync) : void 0;
|
|
4258
4274
|
const uploadComponent = __spreadValues({
|
|
4259
4275
|
type: "multi-upload",
|
|
4260
4276
|
kind: "input",
|
|
4261
4277
|
uid,
|
|
4262
4278
|
id,
|
|
4263
|
-
format
|
|
4279
|
+
format,
|
|
4264
4280
|
files: [],
|
|
4265
4281
|
_update(updateFn) {
|
|
4266
4282
|
update(this, updateFn);
|
|
@@ -4272,28 +4288,44 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4272
4288
|
},
|
|
4273
4289
|
// Noop
|
|
4274
4290
|
async onRemoveFile(index) {
|
|
4291
|
+
var _a2;
|
|
4275
4292
|
this._update((draft) => {
|
|
4276
4293
|
draft.value.splice(index, 1);
|
|
4277
4294
|
draft.files.splice(index, 1);
|
|
4278
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
|
+
}
|
|
4279
4302
|
},
|
|
4280
4303
|
async onInsertFile(index, file) {
|
|
4281
4304
|
const fileErrors = getFileValidationErrors(file);
|
|
4282
4305
|
const fileId = getRandomId();
|
|
4306
|
+
const base64Value = format === "base64" ? await toBase64(file) : null;
|
|
4283
4307
|
this._update((draft) => {
|
|
4284
4308
|
draft.value.splice(index, 0, file);
|
|
4285
|
-
draft.files.splice(index, 0, { file, id: fileId, errors: fileErrors });
|
|
4309
|
+
draft.files.splice(index, 0, { file, id: fileId, errors: fileErrors, base64Value });
|
|
4286
4310
|
draft.errors = [];
|
|
4287
4311
|
});
|
|
4312
|
+
if (persist) {
|
|
4313
|
+
await persist(this, index, format === "blob" ? file : base64Value);
|
|
4314
|
+
}
|
|
4288
4315
|
onValueChange();
|
|
4289
4316
|
return fileId;
|
|
4290
4317
|
},
|
|
4291
4318
|
async getSubmittableValue() {
|
|
4292
|
-
|
|
4293
|
-
|
|
4319
|
+
if (persist) {
|
|
4320
|
+
return Promise.all(this.persistedState.map(async ({ submission }) => submission));
|
|
4321
|
+
}
|
|
4322
|
+
return this.files.map(({ base64Value }) => base64Value);
|
|
4294
4323
|
},
|
|
4295
4324
|
getSubmittableValueSync() {
|
|
4296
|
-
|
|
4325
|
+
if (persist) {
|
|
4326
|
+
return this.persistedState.map(({ lastResponse }) => lastResponse);
|
|
4327
|
+
}
|
|
4328
|
+
return this.files.map(({ base64Value }) => base64Value);
|
|
4297
4329
|
},
|
|
4298
4330
|
getSummary() {
|
|
4299
4331
|
return summariser(this.getLocalValue().map(({ name }) => name));
|
|
@@ -4309,34 +4341,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4309
4341
|
return errorMsgs.length === 0 && this.files.every(({ errors }) => errors.length === 0);
|
|
4310
4342
|
}
|
|
4311
4343
|
}, rest);
|
|
4312
|
-
|
|
4313
|
-
return uploadComponent;
|
|
4314
|
-
}
|
|
4315
|
-
const persist = getComponentMultiPersistAsync(update, performPersistAsync);
|
|
4316
|
-
return __spreadProps(__spreadValues({}, uploadComponent), {
|
|
4317
|
-
format,
|
|
4318
|
-
async onInsertFile(index, file) {
|
|
4319
|
-
const fileId = await uploadComponent.onInsertFile.call(this, index, file);
|
|
4320
|
-
const submission = format === "blob" ? file : await toBase64(file);
|
|
4321
|
-
await persist(this, index, submission);
|
|
4322
|
-
onValueChange();
|
|
4323
|
-
return fileId;
|
|
4324
|
-
},
|
|
4325
|
-
async onRemoveFile(index) {
|
|
4326
|
-
var _a2;
|
|
4327
|
-
await uploadComponent.onRemoveFile.call(this, index);
|
|
4328
|
-
(_a2 = this.persistedState[index]) == null ? void 0 : _a2.abortController.abort();
|
|
4329
|
-
this._update((draft) => {
|
|
4330
|
-
draft.persistedState = draft.persistedState.splice(index, 1);
|
|
4331
|
-
});
|
|
4332
|
-
},
|
|
4333
|
-
async getSubmittableValue() {
|
|
4334
|
-
return Promise.all(this.persistedState.map(async ({ submission }) => submission));
|
|
4335
|
-
},
|
|
4336
|
-
getSubmittableValueSync() {
|
|
4337
|
-
return this.persistedState.map(({ lastResponse }) => lastResponse);
|
|
4338
|
-
}
|
|
4339
|
-
});
|
|
4344
|
+
return uploadComponent;
|
|
4340
4345
|
};
|
|
4341
4346
|
|
|
4342
4347
|
// src/revamp/domain/features/persistAsync/getInitialPersistedState.ts
|
|
@@ -6191,7 +6196,7 @@ var executeSubmission = async (props) => {
|
|
|
6191
6196
|
if (method === "GET") {
|
|
6192
6197
|
return void 0;
|
|
6193
6198
|
}
|
|
6194
|
-
const payload =
|
|
6199
|
+
const payload = recursiveMerge(model, (_a = action.data) != null ? _a : null);
|
|
6195
6200
|
return payload !== null ? JSON.stringify(payload) : null;
|
|
6196
6201
|
};
|
|
6197
6202
|
const response = await getSafeHttpClient(httpClient)(url != null ? url : "", {
|
|
@@ -6212,7 +6217,7 @@ var executeSubmission = async (props) => {
|
|
|
6212
6217
|
const responseType = await getResponseType(response);
|
|
6213
6218
|
const body = await parseResponseBodyAsJsonElement(response);
|
|
6214
6219
|
if (exit) {
|
|
6215
|
-
return { type: "complete", result:
|
|
6220
|
+
return { type: "complete", result: recursiveMerge(body, result) };
|
|
6216
6221
|
}
|
|
6217
6222
|
switch (responseType) {
|
|
6218
6223
|
case "step": {
|
|
@@ -6223,7 +6228,7 @@ var executeSubmission = async (props) => {
|
|
|
6223
6228
|
}
|
|
6224
6229
|
case "exit": {
|
|
6225
6230
|
trackSubmissionEvent("Action Succeeded", { actionId });
|
|
6226
|
-
return { type: "complete", result:
|
|
6231
|
+
return { type: "complete", result: recursiveMerge(body, result) };
|
|
6227
6232
|
}
|
|
6228
6233
|
case "action": {
|
|
6229
6234
|
assertActionResponseBody(body);
|
|
@@ -7098,13 +7103,13 @@ var isInteger2 = (value) => {
|
|
|
7098
7103
|
return isNumber2(value) && Math.floor(value) === value;
|
|
7099
7104
|
};
|
|
7100
7105
|
var isBoolean2 = (value) => typeof value === "boolean";
|
|
7101
|
-
var
|
|
7106
|
+
var isObject3 = (value) => !isNull2(value) && !isUndefined2(value) && (value == null ? void 0 : value.constructor) === Object;
|
|
7102
7107
|
var isArray2 = (value) => Array.isArray(value);
|
|
7103
7108
|
var isNull2 = (value) => value === null;
|
|
7104
7109
|
var isUndefined2 = (value) => typeof value === "undefined";
|
|
7105
7110
|
|
|
7106
7111
|
// src/legacy/common/validators/values/value-validators.ts
|
|
7107
|
-
var isEmpty = (value) => isString2(value) && value.length === 0 || (
|
|
7112
|
+
var isEmpty = (value) => isString2(value) && value.length === 0 || (isObject3(value) || isArray2(value)) && Object.keys(value).length === 0;
|
|
7108
7113
|
|
|
7109
7114
|
// src/legacy/common/validators/models/model-utils.ts
|
|
7110
7115
|
function cleanBasicModelWithOneOfSchema(model, schema) {
|
|
@@ -7448,7 +7453,7 @@ function isValidConstSchema(value, schema) {
|
|
|
7448
7453
|
return !getConstValidationFailures(value, schema).length;
|
|
7449
7454
|
}
|
|
7450
7455
|
function isValidObjectSchema(value, schema) {
|
|
7451
|
-
if (!
|
|
7456
|
+
if (!isObject3(value) || schema.type !== "object" || !isObject3(schema.properties)) {
|
|
7452
7457
|
return false;
|
|
7453
7458
|
}
|
|
7454
7459
|
return Object.keys(schema.properties).map(
|
|
@@ -7469,7 +7474,7 @@ function isObjectPropertyValid(propertyValue, propertySchema, isRequired) {
|
|
|
7469
7474
|
return isValidSchema(propertyValue, propertySchema);
|
|
7470
7475
|
}
|
|
7471
7476
|
function isValidArraySchema(value, schema) {
|
|
7472
|
-
if (schema.type !== "array" || !
|
|
7477
|
+
if (schema.type !== "array" || !isObject3(schema.items)) {
|
|
7473
7478
|
return false;
|
|
7474
7479
|
}
|
|
7475
7480
|
if (getArrayValidationFailures(value, schema).length > 0) {
|
|
@@ -7637,7 +7642,7 @@ var isReadOnlySchema = (schema) => Boolean(schema.readOnly) && isBasicSchema(sch
|
|
|
7637
7642
|
var isPromotedOneOfSchema = (schema) => Boolean(schema.oneOf) && Boolean(schema.promotion);
|
|
7638
7643
|
var basicTypes = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean"]);
|
|
7639
7644
|
function isBasicSchema(schema) {
|
|
7640
|
-
return basicTypes.has(schema.type || "") || "const" in schema && schema.const !== void 0 && !
|
|
7645
|
+
return basicTypes.has(schema.type || "") || "const" in schema && schema.const !== void 0 && !isObject3(schema.const);
|
|
7641
7646
|
}
|
|
7642
7647
|
function isObjectSchema2(schema) {
|
|
7643
7648
|
return schema.type === "object";
|
|
@@ -8566,7 +8571,7 @@ function constructUploadResponse(response) {
|
|
|
8566
8571
|
}
|
|
8567
8572
|
function constructUploadError(response) {
|
|
8568
8573
|
const isError = response instanceof Error;
|
|
8569
|
-
const hasValidData =
|
|
8574
|
+
const hasValidData = isObject3(response) && "data" in response;
|
|
8570
8575
|
const isInvalidResponseData = !hasValidData && !isError;
|
|
8571
8576
|
if (isInvalidResponseData) {
|
|
8572
8577
|
return isString2(response) ? response : void 0;
|
|
@@ -9242,7 +9247,7 @@ function RepeatableSchema({
|
|
|
9242
9247
|
const [openModalType, setOpenModalType] = useState8(null);
|
|
9243
9248
|
const [changed, setChanged] = useState8(false);
|
|
9244
9249
|
const [itemSummaries, setItemSummaries] = useState8(() => {
|
|
9245
|
-
if (
|
|
9250
|
+
if (isObject3(model) && !isArray2(model)) {
|
|
9246
9251
|
throw new Error(
|
|
9247
9252
|
"RepeatableSchema does not support object models. Ensure your array schema is wrapped inside an object schema."
|
|
9248
9253
|
);
|
|
@@ -9553,7 +9558,7 @@ var getSafeStringValue = (value, options = {}) => {
|
|
|
9553
9558
|
if (isNull2(value)) {
|
|
9554
9559
|
return void 0;
|
|
9555
9560
|
}
|
|
9556
|
-
if (
|
|
9561
|
+
if (isObject3(value)) {
|
|
9557
9562
|
logInvalidTypeFallbackWarning({ received: "object", expected: "string" });
|
|
9558
9563
|
return void 0;
|
|
9559
9564
|
}
|
|
@@ -9576,7 +9581,7 @@ var getSafeStringOrNumberValue = (value, options = {}) => {
|
|
|
9576
9581
|
return value;
|
|
9577
9582
|
}
|
|
9578
9583
|
const logProps = { received: typeof value, expected: "string or number" };
|
|
9579
|
-
if (
|
|
9584
|
+
if (isObject3(value)) {
|
|
9580
9585
|
logInvalidTypeFallbackWarning(logProps);
|
|
9581
9586
|
return void 0;
|
|
9582
9587
|
}
|
|
@@ -10629,7 +10634,7 @@ function PersistAsyncBlobSchema(props) {
|
|
|
10629
10634
|
}
|
|
10630
10635
|
var getResponseJsonObject = async (response) => {
|
|
10631
10636
|
const json = await response.json().catch(() => ({}));
|
|
10632
|
-
return
|
|
10637
|
+
return isObject3(json) ? json : {};
|
|
10633
10638
|
};
|
|
10634
10639
|
var PersistAsyncBlobSchema_default = PersistAsyncBlobSchema;
|
|
10635
10640
|
|
|
@@ -10893,7 +10898,7 @@ function ValidationAsyncSchema(props) {
|
|
|
10893
10898
|
});
|
|
10894
10899
|
try {
|
|
10895
10900
|
const jsonResponse = await response.json();
|
|
10896
|
-
if (!
|
|
10901
|
+
if (!isObject3(jsonResponse)) {
|
|
10897
10902
|
throw new Error("Response body is not an object");
|
|
10898
10903
|
}
|
|
10899
10904
|
onEvent("Dynamic Flow - ValidationAsync", { status: "success" });
|
|
@@ -11664,8 +11669,8 @@ var useSearch = (defaultSearchConfig) => {
|
|
|
11664
11669
|
const results = state.status === "success" ? state.results : [];
|
|
11665
11670
|
return { status: state.status, results, search };
|
|
11666
11671
|
};
|
|
11667
|
-
var isValidResponseBody2 = (body) =>
|
|
11668
|
-
(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
|
|
11669
11674
|
);
|
|
11670
11675
|
var isAbortError = (error) => error instanceof DOMException && error.name === "AbortError";
|
|
11671
11676
|
var addQueryParameter2 = (url, key, value) => {
|
|
@@ -12004,7 +12009,7 @@ function PersistAsyncBasicSchema(props) {
|
|
|
12004
12009
|
onPersistAsync(persistAsyncFetch);
|
|
12005
12010
|
const response = await persistAsyncFetch;
|
|
12006
12011
|
const responseBody = await response.json();
|
|
12007
|
-
if (!
|
|
12012
|
+
if (!isObject3(responseBody)) {
|
|
12008
12013
|
throw new Error("Response is not an object");
|
|
12009
12014
|
}
|
|
12010
12015
|
const { idProperty, param } = schema.persistAsync;
|
|
@@ -12013,7 +12018,7 @@ function PersistAsyncBasicSchema(props) {
|
|
|
12013
12018
|
onChange({ model: id, triggerSchema: schema, triggerModel: id });
|
|
12014
12019
|
} else if (!response.ok) {
|
|
12015
12020
|
const { validation } = responseBody;
|
|
12016
|
-
const error =
|
|
12021
|
+
const error = isObject3(validation) && (validation == null ? void 0 : validation[param]) || null;
|
|
12017
12022
|
setPersistAsyncError(error);
|
|
12018
12023
|
onChange({ model: null, triggerSchema: schema, triggerModel: null });
|
|
12019
12024
|
} else {
|
|
@@ -12103,7 +12108,7 @@ var usePersistAsync = (persistAsync) => {
|
|
|
12103
12108
|
return handleHTTPError(response);
|
|
12104
12109
|
}
|
|
12105
12110
|
const jsonResponse = await response.json();
|
|
12106
|
-
if (
|
|
12111
|
+
if (isObject3(jsonResponse)) {
|
|
12107
12112
|
const id = jsonResponse[persistAsync.idProperty];
|
|
12108
12113
|
if (isString2(id) || isNumber2(id)) {
|
|
12109
12114
|
return { data: id };
|
|
@@ -12116,7 +12121,7 @@ var usePersistAsync = (persistAsync) => {
|
|
|
12116
12121
|
}
|
|
12117
12122
|
async function handleHTTPError(response) {
|
|
12118
12123
|
const jsonResponse = await response.json();
|
|
12119
|
-
if (
|
|
12124
|
+
if (isObject3(jsonResponse)) {
|
|
12120
12125
|
const error = getErrorFromResponse(persistAsync.param, jsonResponse);
|
|
12121
12126
|
if (isString2(error)) {
|
|
12122
12127
|
throw new Error(error);
|
|
@@ -12138,7 +12143,7 @@ function wrapInFormData2(key, value) {
|
|
|
12138
12143
|
return formData;
|
|
12139
12144
|
}
|
|
12140
12145
|
function hasStringMessage(value) {
|
|
12141
|
-
return
|
|
12146
|
+
return isObject3(value) && "message" in value && typeof value.message === "string";
|
|
12142
12147
|
}
|
|
12143
12148
|
|
|
12144
12149
|
// src/legacy/common/hooks/usePolling/usePolling.tsx
|
|
@@ -13577,7 +13582,7 @@ var parseFetchResponseByResponseType = async (response, type) => {
|
|
|
13577
13582
|
};
|
|
13578
13583
|
var parseStepResponse = async (response) => {
|
|
13579
13584
|
const jsonBody = await parseResponseJson(response);
|
|
13580
|
-
if (!
|
|
13585
|
+
if (!isObject3(jsonBody)) {
|
|
13581
13586
|
throw new Error("Incorrect response body in response. Expected an object.");
|
|
13582
13587
|
}
|
|
13583
13588
|
const etag = response.headers.get("etag") || void 0;
|
|
@@ -13585,16 +13590,16 @@ var parseStepResponse = async (response) => {
|
|
|
13585
13590
|
};
|
|
13586
13591
|
var parseActionResponse = async (response) => {
|
|
13587
13592
|
const jsonBody = await parseResponseJson(response);
|
|
13588
|
-
if (!
|
|
13593
|
+
if (!isObject3(jsonBody)) {
|
|
13589
13594
|
throw new Error("Incorrect response body in response. Expected an object.");
|
|
13590
13595
|
}
|
|
13591
|
-
if (!
|
|
13596
|
+
if (!isObject3(jsonBody.action)) {
|
|
13592
13597
|
throw new Error(
|
|
13593
13598
|
"Incorrect response body in action response. Expected an object satisfying the type { action: Action }."
|
|
13594
13599
|
);
|
|
13595
13600
|
}
|
|
13596
13601
|
const action = jsonBody.action;
|
|
13597
|
-
if (action.exit === true &&
|
|
13602
|
+
if (action.exit === true && isObject3(action.result)) {
|
|
13598
13603
|
return { type: "exit", result: action.result };
|
|
13599
13604
|
}
|
|
13600
13605
|
return { type: "action", action: jsonBody.action };
|
|
@@ -13611,7 +13616,7 @@ var parseFetchResponse = async (response) => {
|
|
|
13611
13616
|
return parseExitResponse(response);
|
|
13612
13617
|
}
|
|
13613
13618
|
const jsonBody = await parseResponseJson(response.clone());
|
|
13614
|
-
if (
|
|
13619
|
+
if (isObject3(jsonBody) && jsonBody.action) {
|
|
13615
13620
|
return parseActionResponse(response);
|
|
13616
13621
|
}
|
|
13617
13622
|
return parseStepResponse(response);
|
|
@@ -13619,7 +13624,7 @@ var parseFetchResponse = async (response) => {
|
|
|
13619
13624
|
var parseErrorResponse = async (response) => {
|
|
13620
13625
|
assertResponseIsValid2(response);
|
|
13621
13626
|
const jsonBody = await parseResponseJson(response);
|
|
13622
|
-
if (!
|
|
13627
|
+
if (!isObject3(jsonBody)) {
|
|
13623
13628
|
throw new Error("Incorrect response body in error response. Expected an object.");
|
|
13624
13629
|
}
|
|
13625
13630
|
if (!jsonBody.refreshFormUrl && !jsonBody.refreshUrl && !jsonBody.validation && !jsonBody.error) {
|
|
@@ -13630,7 +13635,7 @@ var parseErrorResponse = async (response) => {
|
|
|
13630
13635
|
var getJsonObjectOrNull = async (response) => {
|
|
13631
13636
|
assertResponseIsValid2(response);
|
|
13632
13637
|
const result = await parseResponseJson(response);
|
|
13633
|
-
return
|
|
13638
|
+
return isObject3(result) ? result : null;
|
|
13634
13639
|
};
|
|
13635
13640
|
var parseResponseJson = async (response) => {
|
|
13636
13641
|
try {
|
|
@@ -13819,7 +13824,7 @@ var DynamicFlowComponent = ({
|
|
|
13819
13824
|
void performAction(result.action, result.action.data);
|
|
13820
13825
|
} else if (result.type === "exit") {
|
|
13821
13826
|
dispatchEventAndComplete(
|
|
13822
|
-
|
|
13827
|
+
isObject3(actionResult) ? __spreadValues(__spreadValues({}, result.result), actionResult) : result.result
|
|
13823
13828
|
);
|
|
13824
13829
|
} else {
|
|
13825
13830
|
updateStep(result.step, result.etag, fetchType);
|
|
@@ -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 {
|
|
2
|
-
import type {
|
|
3
|
-
export declare const getSubmittableData: (components: SchemaComponent[]) => Promise<
|
|
4
|
-
export declare const getSubmittableDataSync: (components: SchemaComponent[]) =>
|
|
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.
|
|
3
|
+
"version": "4.10.0",
|
|
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.
|
|
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.
|
|
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.
|
|
42
|
-
"@storybook/addon-docs": "^9.0.
|
|
43
|
-
"@storybook/addon-links": "^9.0.
|
|
44
|
-
"@storybook/react-vite": "9.0.
|
|
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
49
|
"@transferwise/components": "46.100.1",
|
|
50
|
-
"@transferwise/formatting": "^2.13.
|
|
50
|
+
"@transferwise/formatting": "^2.13.4",
|
|
51
51
|
"@transferwise/icons": "3.22.3",
|
|
52
52
|
"@transferwise/neptune-css": "14.24.5",
|
|
53
|
-
"@types/jest": "
|
|
54
|
-
"@types/node": "22.
|
|
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
58
|
"@wise/art": "2.23.0",
|
|
59
59
|
"@wise/components-theming": "^1.6.4",
|
|
60
|
-
"babel-jest": "30.0.
|
|
61
|
-
"esbuild": "0.25.
|
|
62
|
-
"eslint-plugin-storybook": "9.0.
|
|
63
|
-
"jest": "30.0.
|
|
64
|
-
"jest-environment-jsdom": "30.0.
|
|
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,15 +71,15 @@
|
|
|
71
71
|
"react": "18.3.1",
|
|
72
72
|
"react-dom": "18.3.1",
|
|
73
73
|
"react-intl": "6.8.9",
|
|
74
|
-
"storybook": "^9.0.
|
|
75
|
-
"stylelint": "16.
|
|
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",
|
|
79
79
|
"tsx": "4.20.3",
|
|
80
80
|
"typescript": "5.8.3",
|
|
81
|
-
"@wise/dynamic-flow-
|
|
82
|
-
"@wise/dynamic-flow-
|
|
81
|
+
"@wise/dynamic-flow-renderers": "0.0.0",
|
|
82
|
+
"@wise/dynamic-flow-fixtures": "0.0.1"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"@transferwise/components": "^46.92.0",
|
|
@@ -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.
|
|
98
|
+
"@wise/dynamic-flow-types": "3.8.1"
|
|
99
99
|
},
|
|
100
100
|
"scripts": {
|
|
101
101
|
"dev": "pnpm build:visual-tests && storybook dev -p 3003",
|