@wise/dynamic-flow-client 3.30.1 → 3.31.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 +47 -22
- package/build/main.min.js +1 -1
- package/build/main.mjs +47 -22
- package/build/types/legacy/common/utils/api-utils.d.ts +0 -1
- package/build/types/revamp/domain/features/validation/validateStringPattern.d.ts +2 -0
- package/build/types/revamp/domain/features/validation/value-checks.d.ts +5 -2
- package/package.json +4 -4
package/build/main.mjs
CHANGED
|
@@ -7655,6 +7655,29 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
|
|
|
7655
7655
|
return numberComponent;
|
|
7656
7656
|
};
|
|
7657
7657
|
|
|
7658
|
+
// src/revamp/domain/features/validation/validateStringPattern.ts
|
|
7659
|
+
var validateStringPattern = (pattern, logEvent) => {
|
|
7660
|
+
if (!pattern) {
|
|
7661
|
+
return;
|
|
7662
|
+
}
|
|
7663
|
+
try {
|
|
7664
|
+
new RegExp(pattern, "u");
|
|
7665
|
+
} catch (error) {
|
|
7666
|
+
const message = `Invalid schema pattern. Failed to instantiate RegExp with Unicode support.`;
|
|
7667
|
+
if (logEvent) {
|
|
7668
|
+
logEvent("warning", message, {
|
|
7669
|
+
pattern,
|
|
7670
|
+
error: error == null ? void 0 : error.toString()
|
|
7671
|
+
});
|
|
7672
|
+
} else {
|
|
7673
|
+
console.warn(`DynamicFlow - warning - ${message}`, {
|
|
7674
|
+
pattern,
|
|
7675
|
+
error: error == null ? void 0 : error.toString()
|
|
7676
|
+
});
|
|
7677
|
+
}
|
|
7678
|
+
}
|
|
7679
|
+
};
|
|
7680
|
+
|
|
7658
7681
|
// src/revamp/domain/features/validation/value-checks.ts
|
|
7659
7682
|
var getAboveMaxItemsCheck = ({ maxItems }, messageFunctions) => (value) => {
|
|
7660
7683
|
if (isNumber(maxItems) && isArray(value) && value.length > maxItems) {
|
|
@@ -7730,11 +7753,14 @@ var getBelowMinimumDateCheck = ({ minimum }, messageFunctions) => (value) => {
|
|
|
7730
7753
|
}
|
|
7731
7754
|
return null;
|
|
7732
7755
|
};
|
|
7733
|
-
var getNotAdheringToPatternCheck = ({ pattern }, messageFunctions
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7756
|
+
var getNotAdheringToPatternCheck = ({ pattern }, messageFunctions, options) => {
|
|
7757
|
+
validateStringPattern(pattern, options == null ? void 0 : options.logEvent);
|
|
7758
|
+
return (value) => {
|
|
7759
|
+
if (isString(pattern) && isString(value)) {
|
|
7760
|
+
return new RegExp(pattern).test(value) ? null : messageFunctions.pattern();
|
|
7761
|
+
}
|
|
7762
|
+
return null;
|
|
7763
|
+
};
|
|
7738
7764
|
};
|
|
7739
7765
|
var getRequiredCheck = (required, messageFunctions) => (value) => {
|
|
7740
7766
|
if (!required) {
|
|
@@ -7912,7 +7938,7 @@ var getPerformPersistAsync = ({
|
|
|
7912
7938
|
trackFailure();
|
|
7913
7939
|
throw new Error(genericErrorMessage);
|
|
7914
7940
|
}
|
|
7915
|
-
const validationError = response.
|
|
7941
|
+
const validationError = !response.ok && isObject(json) ? getValidationError(param, json) : null;
|
|
7916
7942
|
trackFailure(json);
|
|
7917
7943
|
throw new Error(validationError != null ? validationError : genericErrorMessage);
|
|
7918
7944
|
};
|
|
@@ -9037,7 +9063,7 @@ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
|
|
|
9037
9063
|
minLength,
|
|
9038
9064
|
validationMessages
|
|
9039
9065
|
} = schema;
|
|
9040
|
-
const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
|
|
9066
|
+
const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange, logEvent } = mapperProps;
|
|
9041
9067
|
const controlForLegacyFormat = getControlForLegacyFormat(format);
|
|
9042
9068
|
const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
|
|
9043
9069
|
const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
|
|
@@ -9058,7 +9084,7 @@ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
|
|
|
9058
9084
|
getRequiredCheck(required, errorMessageFunctions),
|
|
9059
9085
|
getAboveMaxLengthCheck(schema, errorMessageFunctions),
|
|
9060
9086
|
getBelowMinLengthCheck(schema, errorMessageFunctions),
|
|
9061
|
-
getNotAdheringToPatternCheck(schema, errorMessageFunctions)
|
|
9087
|
+
getNotAdheringToPatternCheck(schema, errorMessageFunctions, { logEvent })
|
|
9062
9088
|
],
|
|
9063
9089
|
control: control != null ? control : controlForLegacyFormat,
|
|
9064
9090
|
displayFormat,
|
|
@@ -14432,9 +14458,6 @@ var debounce2 = (callback, waitMs) => {
|
|
|
14432
14458
|
function isStatus2xx(status) {
|
|
14433
14459
|
return status >= 200 && status < 300;
|
|
14434
14460
|
}
|
|
14435
|
-
function isStatus422(status) {
|
|
14436
|
-
return status === 422;
|
|
14437
|
-
}
|
|
14438
14461
|
|
|
14439
14462
|
// src/legacy/common/validators/types/type-validators.ts
|
|
14440
14463
|
var isString2 = (value) => typeof value === "string";
|
|
@@ -17885,7 +17908,7 @@ function PersistAsyncBlobSchema(props) {
|
|
|
17885
17908
|
}
|
|
17886
17909
|
}, [model, schema, submitted, required]);
|
|
17887
17910
|
const onSuccess = async (httpResponse, _fileName) => {
|
|
17888
|
-
const jsonResponse = await httpResponse
|
|
17911
|
+
const jsonResponse = await getResponseJsonObject(httpResponse);
|
|
17889
17912
|
const id2 = getIdFromResponse(schema.persistAsync.idProperty, jsonResponse);
|
|
17890
17913
|
onChange({ model: id2, triggerSchema: schema, triggerModel: id2 });
|
|
17891
17914
|
setChanged(true);
|
|
@@ -17893,8 +17916,8 @@ function PersistAsyncBlobSchema(props) {
|
|
|
17893
17916
|
};
|
|
17894
17917
|
const onFailure = async (error) => {
|
|
17895
17918
|
const errorResponse = error;
|
|
17896
|
-
if (errorResponse.response
|
|
17897
|
-
const jsonResponse = await errorResponse.response
|
|
17919
|
+
if (errorResponse.response) {
|
|
17920
|
+
const jsonResponse = await getResponseJsonObject(errorResponse.response);
|
|
17898
17921
|
setPersistAsyncValidationMessages(jsonResponse.validation || {});
|
|
17899
17922
|
setPersistAsyncValidations([schema.persistAsync.param]);
|
|
17900
17923
|
}
|
|
@@ -17953,6 +17976,10 @@ function PersistAsyncBlobSchema(props) {
|
|
|
17953
17976
|
)
|
|
17954
17977
|
] });
|
|
17955
17978
|
}
|
|
17979
|
+
var getResponseJsonObject = async (response) => {
|
|
17980
|
+
const json = await response.json().catch(() => ({}));
|
|
17981
|
+
return isObject2(json) ? json : {};
|
|
17982
|
+
};
|
|
17956
17983
|
var PersistAsyncBlobSchema_default = PersistAsyncBlobSchema;
|
|
17957
17984
|
|
|
17958
17985
|
// src/legacy/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.tsx
|
|
@@ -19319,7 +19346,7 @@ function PersistAsyncBasicSchema(props) {
|
|
|
19319
19346
|
if (isStatus2xx(response.status)) {
|
|
19320
19347
|
const id = getIdFromResponse(idProperty, responseBody);
|
|
19321
19348
|
onChange({ model: id, triggerSchema: schema, triggerModel: id });
|
|
19322
|
-
} else if (
|
|
19349
|
+
} else if (!response.ok) {
|
|
19323
19350
|
const { validation } = responseBody;
|
|
19324
19351
|
const error = isObject2(validation) && (validation == null ? void 0 : validation[param]) || null;
|
|
19325
19352
|
setPersistAsyncError(error);
|
|
@@ -19423,13 +19450,11 @@ var usePersistAsync = (persistAsync) => {
|
|
|
19423
19450
|
}
|
|
19424
19451
|
}
|
|
19425
19452
|
async function handleHTTPError(response) {
|
|
19426
|
-
|
|
19427
|
-
|
|
19428
|
-
|
|
19429
|
-
|
|
19430
|
-
|
|
19431
|
-
throw new Error(error);
|
|
19432
|
-
}
|
|
19453
|
+
const jsonResponse = await response.json();
|
|
19454
|
+
if (isObject2(jsonResponse)) {
|
|
19455
|
+
const error = getErrorFromResponse(persistAsync.param, jsonResponse);
|
|
19456
|
+
if (isString2(error)) {
|
|
19457
|
+
throw new Error(error);
|
|
19433
19458
|
}
|
|
19434
19459
|
}
|
|
19435
19460
|
throw new Error(intl.formatMessage(generic_error_messages_default.genericErrorRetryHint));
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { ArraySchemaList, IntegerSchema, NumberSchema, Schema, StringSchema } from '@wise/dynamic-flow-types/build/next';
|
|
2
|
+
import { PersistAsyncWithUploadSchema, StringSchemaWithUpload } from '../../../utils/type-utils';
|
|
2
3
|
import type { ErrorMessageFunctions } from '../../mappers/types';
|
|
3
4
|
import type { LocalValue, LocalValueArray } from '../../types';
|
|
4
|
-
import {
|
|
5
|
+
import { LoggingEventDispatcher } from '../events';
|
|
5
6
|
export type IsInvalidCheck<V extends LocalValue> = (value: V | null) => string | null;
|
|
6
|
-
type GetIsInvalidCheck<S extends Schema, V extends LocalValue> = (schema: S, messageFunctions: ErrorMessageFunctions
|
|
7
|
+
type GetIsInvalidCheck<S extends Schema, V extends LocalValue> = (schema: S, messageFunctions: ErrorMessageFunctions, options?: {
|
|
8
|
+
logEvent?: LoggingEventDispatcher;
|
|
9
|
+
}) => IsInvalidCheck<V>;
|
|
7
10
|
export declare const getAboveMaxItemsCheck: GetIsInvalidCheck<ArraySchemaList, LocalValueArray | null>;
|
|
8
11
|
export declare const getBelowMinFilesCheck: GetIsInvalidCheck<ArraySchemaList, LocalValueArray | null>;
|
|
9
12
|
export declare const getAboveMaxFilesCheck: GetIsInvalidCheck<ArraySchemaList, LocalValueArray | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wise/dynamic-flow-client",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.31.0",
|
|
4
4
|
"description": "Dynamic Flow web client",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./build/main.min.js",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@testing-library/jest-dom": "6.6.3",
|
|
54
54
|
"@testing-library/react": "16.1.0",
|
|
55
55
|
"@testing-library/user-event": "14.5.2",
|
|
56
|
-
"@transferwise/components": "46.
|
|
56
|
+
"@transferwise/components": "46.86.1",
|
|
57
57
|
"@transferwise/formatting": "^2.13.0",
|
|
58
58
|
"@transferwise/icons": "3.18.0",
|
|
59
59
|
"@transferwise/neptune-css": "14.20.1",
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"tsx": "4.19.2",
|
|
86
86
|
"typescript": "5.7.3",
|
|
87
87
|
"webpack": "5.97.1",
|
|
88
|
-
"@wise/dynamic-flow-
|
|
89
|
-
"@wise/dynamic-flow-
|
|
88
|
+
"@wise/dynamic-flow-renderers": "0.0.0",
|
|
89
|
+
"@wise/dynamic-flow-fixtures": "0.0.1"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
92
|
"@transferwise/components": "^46.31",
|