@resistdesign/voltra 3.0.0-alpha.33 → 3.0.0-alpha.35
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/README.md +72 -2
- package/api/index.js +49 -36
- package/app/forms/Engine.d.ts +3 -0
- package/app/forms/UI.d.ts +12 -2
- package/app/forms/core/createAutoField.d.ts +11 -3
- package/app/forms/core/createFormRenderer.d.ts +3 -2
- package/app/forms/core/mergeSuites.d.ts +3 -2
- package/app/forms/core/resolveSuite.d.ts +2 -1
- package/app/forms/core/types.d.ts +20 -9
- package/app/forms/types.d.ts +34 -7
- package/app/index.js +21 -12
- package/app/utils/ApplicationState.d.ts +1 -1
- package/build/index.js +2 -2
- package/{chunk-FQMZMCXU.js → chunk-BKRJZXWX.js} +1 -1
- package/chunk-TJFTWPXQ.js +39 -0
- package/{chunk-LGM75I6P.js → chunk-WTD5BBJP.js} +223 -38
- package/chunk-X3NHBZUT.js +1143 -0
- package/common/Logging/Utils.d.ts +0 -9
- package/common/TypeParsing/TypeInfo.d.ts +20 -0
- package/common/TypeParsing/Validation.d.ts +152 -22
- package/common/index.js +6 -7
- package/iac/packs/auth.d.ts +10 -4
- package/iac-packs/index.d.ts +1 -0
- package/native/forms/UI.d.ts +8 -2
- package/native/forms/createNativeFormRenderer.d.ts +1 -1
- package/native/forms/index.d.ts +16 -0
- package/native/forms/suite.d.ts +1 -1
- package/native/index.js +71 -40
- package/native/testing/react-native.d.ts +33 -15
- package/native/utils/index.d.ts +13 -1
- package/package.json +1 -1
- package/web/forms/UI.d.ts +8 -2
- package/web/forms/createWebFormRenderer.d.ts +1 -1
- package/web/forms/suite.d.ts +1 -1
- package/web/index.js +234 -113
- package/web/utils/Route.d.ts +9 -3
- package/web/utils/index.d.ts +1 -0
- package/chunk-G5CLUK4Y.js +0 -621
- package/chunk-IWRHGGGH.js +0 -10
- package/chunk-WELZGQDJ.js +0 -456
|
@@ -7,13 +7,4 @@ export declare enum LOGGING_MESSAGES {
|
|
|
7
7
|
OUTPUT = "OUTPUT",
|
|
8
8
|
ERROR = "ERROR"
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
11
|
-
* Make a function call and log input/output/errors when enabled.
|
|
12
|
-
*
|
|
13
|
-
* @param label - Label to include in logs.
|
|
14
|
-
* @param args - Arguments passed to the function.
|
|
15
|
-
* @param functionRef - Function to execute.
|
|
16
|
-
* @param enabled - Whether to emit logs.
|
|
17
|
-
* @returns The function result.
|
|
18
|
-
*/
|
|
19
10
|
export declare const logFunctionCall: (label: string, args: any[], functionRef: (...args: any[]) => Promise<any> | any, enabled: boolean) => Promise<any>;
|
|
@@ -112,6 +112,26 @@ export type SupportedFieldTags = Partial<{
|
|
|
112
112
|
* Operations that will be denied at the field level.
|
|
113
113
|
* */
|
|
114
114
|
deniedOperations: DeniedOperations;
|
|
115
|
+
/**
|
|
116
|
+
* Validation behavior overrides for field processing.
|
|
117
|
+
* */
|
|
118
|
+
validation: Partial<{
|
|
119
|
+
/**
|
|
120
|
+
* Whether hidden fields should be validated.
|
|
121
|
+
* Defaults to false for data-item validation flows that opt into field-level behavior.
|
|
122
|
+
*/
|
|
123
|
+
validateHidden: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Whether readonly fields should enforce required-value checks.
|
|
126
|
+
* Defaults to false for data-item validation flows that opt into field-level behavior.
|
|
127
|
+
*/
|
|
128
|
+
validateReadonly: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Whether empty arrays are accepted for required array fields.
|
|
131
|
+
* Defaults to false.
|
|
132
|
+
*/
|
|
133
|
+
emptyArrayIsValid: boolean;
|
|
134
|
+
}>;
|
|
115
135
|
}>;
|
|
116
136
|
/**
|
|
117
137
|
* The set of acceptable literal value types.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Validation helpers for TypeInfo values, including relationship rules and
|
|
5
5
|
* custom type validators.
|
|
6
6
|
*/
|
|
7
|
-
import { TypeInfo, TypeInfoField, TypeInfoMap, TypeKeyword, TypeOperation } from "./TypeInfo";
|
|
7
|
+
import { TypeInfo, TypeInfoDataItem, TypeInfoField, TypeInfoMap, TypeKeyword, TypeOperation } from "./TypeInfo";
|
|
8
8
|
/**
|
|
9
9
|
* Relationship validation behavior for TypeInfo checks.
|
|
10
10
|
*/
|
|
@@ -30,11 +30,96 @@ export type CustomTypeInfoFieldValidator = (value: any) => boolean;
|
|
|
30
30
|
* A map of custom type info field validators.
|
|
31
31
|
* */
|
|
32
32
|
export type CustomTypeInfoFieldValidatorMap = Record<string, CustomTypeInfoFieldValidator>;
|
|
33
|
+
/**
|
|
34
|
+
* A custom field validator that can return a domain-specific error descriptor.
|
|
35
|
+
*/
|
|
36
|
+
export type FieldValueValidator = (value: any, typeInfoField: TypeInfoField) => ErrorDescriptor;
|
|
37
|
+
/**
|
|
38
|
+
* A map of custom field validators by field key.
|
|
39
|
+
*/
|
|
40
|
+
export type FieldValueValidatorMap = Record<string, FieldValueValidator>;
|
|
41
|
+
/**
|
|
42
|
+
* Error code for custom type validation failures.
|
|
43
|
+
*/
|
|
44
|
+
export declare const INVALID_CUSTOM_TYPE = "INVALID_CUSTOM_TYPE";
|
|
45
|
+
/**
|
|
46
|
+
* Error codes for primitive type validation failures.
|
|
47
|
+
*
|
|
48
|
+
* Keys intentionally match `typeof value` results.
|
|
49
|
+
*/
|
|
50
|
+
export declare const PRIMITIVE_ERROR_MESSAGE_CONSTANTS: {
|
|
51
|
+
readonly string: "NOT_A_STRING";
|
|
52
|
+
readonly number: "NOT_A_NUMBER";
|
|
53
|
+
readonly boolean: "NOT_A_BOOLEAN";
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Error codes for denied type operations.
|
|
57
|
+
*
|
|
58
|
+
* Keys intentionally match `TypeOperation` names.
|
|
59
|
+
*/
|
|
60
|
+
export declare const DENIED_TYPE_OPERATIONS: {
|
|
61
|
+
readonly CREATE: "DENIED_TYPE_OPERATION_CREATE";
|
|
62
|
+
readonly READ: "DENIED_TYPE_OPERATION_READ";
|
|
63
|
+
readonly UPDATE: "DENIED_TYPE_OPERATION_UPDATE";
|
|
64
|
+
readonly DELETE: "DENIED_TYPE_OPERATION_DELETE";
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Error codes for TypeInfo validation failures.
|
|
68
|
+
*
|
|
69
|
+
* Uses canonical string-valued keys (for example `NOT_A_STRING` and
|
|
70
|
+
* `DENIED_TYPE_OPERATION_CREATE`) so consumers can key by code values.
|
|
71
|
+
*/
|
|
72
|
+
export declare const ERROR_MESSAGE_CONSTANTS: {
|
|
73
|
+
readonly NONE: "NONE";
|
|
74
|
+
readonly INVALID_CUSTOM_TYPE: "INVALID_CUSTOM_TYPE";
|
|
75
|
+
readonly NOT_A_STRING: "NOT_A_STRING";
|
|
76
|
+
readonly NOT_A_NUMBER: "NOT_A_NUMBER";
|
|
77
|
+
readonly NOT_A_BOOLEAN: "NOT_A_BOOLEAN";
|
|
78
|
+
readonly DENIED_TYPE_OPERATION_CREATE: "DENIED_TYPE_OPERATION_CREATE";
|
|
79
|
+
readonly DENIED_TYPE_OPERATION_READ: "DENIED_TYPE_OPERATION_READ";
|
|
80
|
+
readonly DENIED_TYPE_OPERATION_UPDATE: "DENIED_TYPE_OPERATION_UPDATE";
|
|
81
|
+
readonly DENIED_TYPE_OPERATION_DELETE: "DENIED_TYPE_OPERATION_DELETE";
|
|
82
|
+
readonly MISSING_FIELD_VALUE: "MISSING_FIELD_VALUE";
|
|
83
|
+
readonly INVALID_OPTION: "INVALID_OPTION";
|
|
84
|
+
readonly INVALID_FIELD: "INVALID_FIELD";
|
|
85
|
+
readonly RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED: "RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED";
|
|
86
|
+
readonly INVALID_TYPE: "INVALID_TYPE";
|
|
87
|
+
readonly NO_UNION_TYPE_MATCHED: "NO_UNION_TYPE_MATCHED";
|
|
88
|
+
readonly TYPE_DOES_NOT_EXIST: "TYPE_DOES_NOT_EXIST";
|
|
89
|
+
readonly INVALID_PATTERN: "INVALID_PATTERN";
|
|
90
|
+
readonly VALUE_DOES_NOT_MATCH_PATTERN: "VALUE_DOES_NOT_MATCH_PATTERN";
|
|
91
|
+
readonly VALUE_BELOW_MINIMUM: "VALUE_BELOW_MINIMUM";
|
|
92
|
+
readonly VALUE_ABOVE_MAXIMUM: "VALUE_ABOVE_MAXIMUM";
|
|
93
|
+
};
|
|
94
|
+
export type ErrorCode = (typeof ERROR_MESSAGE_CONSTANTS)[keyof typeof ERROR_MESSAGE_CONSTANTS];
|
|
95
|
+
/**
|
|
96
|
+
* Primitive type keyword to error code mapping used during validation.
|
|
97
|
+
*/
|
|
98
|
+
export declare const TYPE_KEYWORD_ERROR_MESSAGE_CONSTANTS: Record<TypeKeyword, ErrorCode>;
|
|
99
|
+
/**
|
|
100
|
+
* A descriptor for a validation error.
|
|
101
|
+
*/
|
|
102
|
+
export type ErrorDescriptor = {
|
|
103
|
+
code: ErrorCode | string;
|
|
104
|
+
values?: string[];
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* A map of errors for an array of items.
|
|
108
|
+
*/
|
|
109
|
+
export type ArrayItemErrorMap = {
|
|
110
|
+
[index: number]: ErrorDescriptor[];
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* A descriptor for an array of errors.
|
|
114
|
+
*/
|
|
115
|
+
export type ArrayErrorDescriptorCollection = {
|
|
116
|
+
itemErrorMap: ArrayItemErrorMap;
|
|
117
|
+
};
|
|
33
118
|
/**
|
|
34
119
|
* A map of errors.
|
|
35
|
-
|
|
120
|
+
*/
|
|
36
121
|
export type ErrorMap = {
|
|
37
|
-
[key: string]:
|
|
122
|
+
[key: string]: (ErrorDescriptor | ArrayErrorDescriptorCollection)[];
|
|
38
123
|
};
|
|
39
124
|
/**
|
|
40
125
|
* The validation results for type info fields.
|
|
@@ -51,38 +136,32 @@ export type TypeInfoValidationResults = {
|
|
|
51
136
|
/**
|
|
52
137
|
* Primary error code when validation fails.
|
|
53
138
|
*/
|
|
54
|
-
error:
|
|
139
|
+
error: ErrorDescriptor;
|
|
55
140
|
/**
|
|
56
141
|
* Field-level error mapping.
|
|
57
142
|
*/
|
|
58
143
|
errorMap: ErrorMap;
|
|
59
144
|
};
|
|
60
145
|
/**
|
|
61
|
-
*
|
|
146
|
+
* Creates an error descriptor from a code and optional values.
|
|
62
147
|
*/
|
|
63
|
-
export declare const
|
|
148
|
+
export declare const getErrorDescriptor: (code?: ErrorCode | string, values?: string[]) => ErrorDescriptor;
|
|
64
149
|
/**
|
|
65
|
-
*
|
|
150
|
+
* Creates a descriptor representing the absence of an error.
|
|
66
151
|
*/
|
|
67
|
-
export declare const
|
|
152
|
+
export declare const getNoErrorDescriptor: () => ErrorDescriptor;
|
|
68
153
|
/**
|
|
69
|
-
*
|
|
154
|
+
* Type guard for array-item error collection entries.
|
|
70
155
|
*/
|
|
71
|
-
export declare const
|
|
72
|
-
MISSING: string;
|
|
73
|
-
INVALID_OPTION: string;
|
|
74
|
-
INVALID_FIELD: string;
|
|
75
|
-
RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED: string;
|
|
76
|
-
INVALID_TYPE: string;
|
|
77
|
-
NO_UNION_TYPE_MATCHED: string;
|
|
78
|
-
TYPE_DOES_NOT_EXIST: string;
|
|
79
|
-
INVALID_PATTERN: string;
|
|
80
|
-
VALUE_DOES_NOT_MATCH_PATTERN: string;
|
|
81
|
-
};
|
|
156
|
+
export declare const isArrayErrorDescriptorCollection: (value: ErrorDescriptor | ArrayErrorDescriptorCollection) => value is ArrayErrorDescriptorCollection;
|
|
82
157
|
/**
|
|
83
|
-
*
|
|
158
|
+
* Returns only descriptor entries from a mixed error entry list.
|
|
84
159
|
*/
|
|
85
|
-
export declare const
|
|
160
|
+
export declare const getErrorDescriptors: (values?: (ErrorDescriptor | ArrayErrorDescriptorCollection)[]) => ErrorDescriptor[];
|
|
161
|
+
/**
|
|
162
|
+
* Merges all array-item error maps from a mixed entry list.
|
|
163
|
+
*/
|
|
164
|
+
export declare const getArrayItemErrorMap: (values?: (ErrorDescriptor | ArrayErrorDescriptorCollection)[]) => ArrayItemErrorMap;
|
|
86
165
|
/**
|
|
87
166
|
* Validates a value against a pattern.
|
|
88
167
|
*
|
|
@@ -181,6 +260,57 @@ export declare const validateTypeInfoFieldOperationAllowed: (fieldName: string,
|
|
|
181
260
|
* @returns Validation results for the type operation.
|
|
182
261
|
* */
|
|
183
262
|
export declare const validateTypeOperationAllowed: (typeName: string, valueFields: string[], typeOperation: TypeOperation, typeInfo: TypeInfo) => TypeInfoValidationResults;
|
|
263
|
+
/**
|
|
264
|
+
* Options for validating a data item against a single TypeInfo definition.
|
|
265
|
+
*/
|
|
266
|
+
export type ValidateTypeInfoDataItemOptions = {
|
|
267
|
+
/**
|
|
268
|
+
* Type name used for result metadata and nested lookups.
|
|
269
|
+
*/
|
|
270
|
+
typeName?: string;
|
|
271
|
+
/**
|
|
272
|
+
* Additional types used for nested type references.
|
|
273
|
+
*/
|
|
274
|
+
typeInfoMap?: TypeInfoMap;
|
|
275
|
+
/**
|
|
276
|
+
* Whether unknown fields should fail validation.
|
|
277
|
+
*/
|
|
278
|
+
strict?: boolean;
|
|
279
|
+
/**
|
|
280
|
+
* Custom validators for `tags.customType` handling.
|
|
281
|
+
*/
|
|
282
|
+
customTypeValidators?: CustomTypeInfoFieldValidatorMap;
|
|
283
|
+
/**
|
|
284
|
+
* Operation context for denied operation checks.
|
|
285
|
+
*/
|
|
286
|
+
typeOperation?: TypeOperation;
|
|
287
|
+
/**
|
|
288
|
+
* Relationship validation behavior.
|
|
289
|
+
*/
|
|
290
|
+
relationshipValidationType?: RelationshipValidationType;
|
|
291
|
+
/**
|
|
292
|
+
* Whether this is a partial payload.
|
|
293
|
+
*/
|
|
294
|
+
itemIsPartial?: boolean;
|
|
295
|
+
/**
|
|
296
|
+
* Default hidden-field validation behavior.
|
|
297
|
+
*/
|
|
298
|
+
validateHidden?: boolean;
|
|
299
|
+
/**
|
|
300
|
+
* Default readonly-field required-value behavior.
|
|
301
|
+
*/
|
|
302
|
+
validateReadonly?: boolean;
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* Validates a data item against a TypeInfo definition.
|
|
306
|
+
*
|
|
307
|
+
* @param value - Data item to validate.
|
|
308
|
+
* @param typeInfo - TypeInfo definition used for validation.
|
|
309
|
+
* @param customValidatorMap - Optional custom validators keyed by field.
|
|
310
|
+
* @param options - Validation behavior options.
|
|
311
|
+
* @returns Validation result for the entire item.
|
|
312
|
+
*/
|
|
313
|
+
export declare const validateTypeInfoDataItem: (value: Partial<TypeInfoDataItem> | undefined, typeInfo: TypeInfo, customValidatorMap?: FieldValueValidatorMap, options?: ValidateTypeInfoDataItemOptions) => TypeInfoValidationResults;
|
|
184
314
|
/**
|
|
185
315
|
* Validates a type info value.
|
|
186
316
|
*
|
package/common/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { DENIED_TYPE_OPERATIONS, ERROR_MESSAGE_CONSTANTS, INVALID_CUSTOM_TYPE, PRIMITIVE_ERROR_MESSAGE_CONSTANTS, RelationshipValidationType, TYPE_KEYWORD_VALIDATORS, getValidityValue, hasValue, validateArrayOfTypeInfoFieldValues, validateCustomType, validateKeywordType, validateTypeInfoFieldOperationAllowed, validateTypeInfoFieldValue, validateTypeInfoValue, validateTypeOperationAllowed, validateValueMatchesPattern } from '../chunk-LGM75I6P.js';
|
|
2
1
|
export { ComparisonOperators, ITEM_RELATIONSHIP_DAC_RESOURCE_NAME, LogicalOperators, OperationGroup, RelationshipOperation, TypeInfoORMAPIRoutePaths, TypeInfoORMServiceError } from '../chunk-7AMEFPPP.js';
|
|
3
|
-
export { TypeOperation } from '../chunk-
|
|
2
|
+
export { DENIED_TYPE_OPERATIONS, ERROR_MESSAGE_CONSTANTS, INVALID_CUSTOM_TYPE, PRIMITIVE_ERROR_MESSAGE_CONSTANTS, RelationshipValidationType, TYPE_KEYWORD_ERROR_MESSAGE_CONSTANTS, TYPE_KEYWORD_VALIDATORS, TypeOperation, getArrayItemErrorMap, getErrorDescriptor, getErrorDescriptors, getNoErrorDescriptor, getValidityValue, hasValue, isArrayErrorDescriptorCollection, validateArrayOfTypeInfoFieldValues, validateCustomType, validateKeywordType, validateTypeInfoDataItem, validateTypeInfoFieldOperationAllowed, validateTypeInfoFieldValue, validateTypeInfoValue, validateTypeOperationAllowed, validateValueMatchesPattern } from '../chunk-WTD5BBJP.js';
|
|
4
3
|
import '../chunk-GYWRAW3Y.js';
|
|
5
4
|
import '../chunk-I2KLQ2HA.js';
|
|
6
5
|
|
|
@@ -8,12 +7,12 @@ import '../chunk-I2KLQ2HA.js';
|
|
|
8
7
|
var collectRequiredEnvironmentVariables = (varNames) => {
|
|
9
8
|
const result = {};
|
|
10
9
|
const missingEnvVars = [];
|
|
11
|
-
for (const
|
|
12
|
-
const value = process.env[
|
|
10
|
+
for (const varName of varNames) {
|
|
11
|
+
const value = process.env[varName];
|
|
13
12
|
if (!value) {
|
|
14
|
-
missingEnvVars.push(
|
|
13
|
+
missingEnvVars.push(varName);
|
|
15
14
|
} else {
|
|
16
|
-
result[
|
|
15
|
+
result[varName] = value;
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
if (missingEnvVars.length > 0) {
|
|
@@ -25,7 +24,7 @@ var collectRequiredEnvironmentVariables = (varNames) => {
|
|
|
25
24
|
|
|
26
25
|
Missing Required Environment Variables:
|
|
27
26
|
|
|
28
|
-
${missingEnvVars.map((
|
|
27
|
+
${missingEnvVars.map((varName) => `- ${varName}`).join(`
|
|
29
28
|
`)}
|
|
30
29
|
`
|
|
31
30
|
);
|
package/iac/packs/auth.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Configuration for the auth pack.
|
|
3
3
|
*/
|
|
4
|
-
type AddAuthConfigBase = {
|
|
4
|
+
export type AddAuthConfigBase = {
|
|
5
5
|
/**
|
|
6
6
|
* Cognito user pool resource id.
|
|
7
7
|
*/
|
|
@@ -31,7 +31,11 @@ type AddAuthConfigBase = {
|
|
|
31
31
|
*/
|
|
32
32
|
userManagementAdminGroupName: string;
|
|
33
33
|
};
|
|
34
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Configuration for adding auth resources including a user pool domain with
|
|
36
|
+
* callback and logout URLs.
|
|
37
|
+
* */
|
|
38
|
+
export type AddAuthConfigWithUserPoolDomain = AddAuthConfigBase & {
|
|
35
39
|
/**
|
|
36
40
|
* Enable Cognito Hosted UI/OAuth redirect mode by creating a custom user pool
|
|
37
41
|
* domain plus Route53 records.
|
|
@@ -94,7 +98,10 @@ type AddAuthConfigWithUserPoolDomain = AddAuthConfigBase & {
|
|
|
94
98
|
*/
|
|
95
99
|
supportedIdentityProviders?: any[];
|
|
96
100
|
};
|
|
97
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Configuration for adding auth resources without a user pool domain.
|
|
103
|
+
* */
|
|
104
|
+
export type AddAuthConfigWithoutUserPoolDomain = AddAuthConfigBase & {
|
|
98
105
|
/**
|
|
99
106
|
* Disable Cognito Hosted UI/OAuth redirect configuration.
|
|
100
107
|
*
|
|
@@ -121,4 +128,3 @@ export type AddAuthConfig = AddAuthConfigWithUserPoolDomain | AddAuthConfigWitho
|
|
|
121
128
|
* @group Resource Packs
|
|
122
129
|
*/
|
|
123
130
|
export declare const addAuth: import("..").ResourcePackApplier<AddAuthConfig>;
|
|
124
|
-
export {};
|
package/iac-packs/index.d.ts
CHANGED
package/native/forms/UI.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Native AutoForm wrappers backed by the default native renderer.
|
|
5
5
|
*/
|
|
6
|
-
import type
|
|
7
|
-
import type { AutoFieldProps, CustomTypeActionPayload, FormController, FormValues, RelationActionPayload } from "../../app/forms/types";
|
|
6
|
+
import { type FC } from "react";
|
|
7
|
+
import type { AutoFieldProps, CustomValidatorMap, CustomTypeActionPayload, FormController, FormValues, RelationActionPayload, TranslateValidationErrorCode } from "../../app/forms/types";
|
|
8
8
|
import type { TypeInfo, TypeOperation } from "../../common/TypeParsing/TypeInfo";
|
|
9
9
|
/**
|
|
10
10
|
* Render a form field based on TypeInfo metadata.
|
|
@@ -29,6 +29,8 @@ export interface AutoFormViewProps {
|
|
|
29
29
|
onRelationAction?: (payload: RelationActionPayload) => void;
|
|
30
30
|
/** Optional custom type action handler. */
|
|
31
31
|
onCustomTypeAction?: (payload: CustomTypeActionPayload) => void;
|
|
32
|
+
/** Optional translator for validation error descriptors. */
|
|
33
|
+
translateValidationErrorCode?: TranslateValidationErrorCode;
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
34
36
|
* Render a native form UI from a prepared form controller.
|
|
@@ -57,6 +59,10 @@ export interface AutoFormProps {
|
|
|
57
59
|
operation?: TypeOperation;
|
|
58
60
|
/** Disable the submit button when true. */
|
|
59
61
|
submitDisabled?: boolean;
|
|
62
|
+
/** Optional translator for validation error descriptors. */
|
|
63
|
+
translateValidationErrorCode?: TranslateValidationErrorCode;
|
|
64
|
+
/** Optional custom validators keyed by field name. */
|
|
65
|
+
customValidatorMap?: CustomValidatorMap;
|
|
60
66
|
}
|
|
61
67
|
/**
|
|
62
68
|
* Build a controller from type metadata and render a native auto form.
|
|
@@ -16,6 +16,6 @@ import type { ComponentSuite } from "../../app/forms/core/types";
|
|
|
16
16
|
export declare const createNativeFormRenderer: (options?: {
|
|
17
17
|
suite?: ComponentSuite<ReactElement>;
|
|
18
18
|
}) => {
|
|
19
|
-
AutoField:
|
|
19
|
+
AutoField: import("react").FC<import("../../app").AutoFieldInput>;
|
|
20
20
|
suite: import("../../app").ResolvedSuite<ReactElement<any, string | import("react").JSXElementConstructor<any>>>;
|
|
21
21
|
};
|
package/native/forms/index.d.ts
CHANGED
|
@@ -3,7 +3,23 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Native form rendering exports.
|
|
5
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* @category native
|
|
8
|
+
* @group Forms
|
|
9
|
+
*/
|
|
6
10
|
export * from "./suite";
|
|
11
|
+
/**
|
|
12
|
+
* @category native
|
|
13
|
+
* @group Forms
|
|
14
|
+
*/
|
|
7
15
|
export * from "./UI";
|
|
16
|
+
/**
|
|
17
|
+
* @category native
|
|
18
|
+
* @group Forms
|
|
19
|
+
*/
|
|
8
20
|
export * from "./primitives";
|
|
21
|
+
/**
|
|
22
|
+
* @category native
|
|
23
|
+
* @group Forms
|
|
24
|
+
*/
|
|
9
25
|
export * from "./createNativeFormRenderer";
|
package/native/forms/suite.d.ts
CHANGED
|
@@ -12,4 +12,4 @@ export declare const nativeSuite: ComponentSuite<ReactElement>;
|
|
|
12
12
|
/**
|
|
13
13
|
* AutoField renderer backed by the default native suite.
|
|
14
14
|
*/
|
|
15
|
-
export declare const nativeAutoField:
|
|
15
|
+
export declare const nativeAutoField: import("react").FC<import("../../app").AutoFieldInput>;
|
package/native/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createFormRenderer, AutoFormView, AutoForm, parseTemplate, validateAreas, computeAreaBounds } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
import { computeTrackPixels } from '../chunk-TJFTWPXQ.js';
|
|
2
|
+
import { createFormRenderer, createHistoryBackHandler, buildHistoryPath, AutoFormView, AutoForm, parseTemplate, validateAreas, computeAreaBounds, parseHistoryPath, createMemoryHistory, Route, buildRoutePath } from '../chunk-X3NHBZUT.js';
|
|
3
|
+
import { ERROR_MESSAGE_CONSTANTS } from '../chunk-WTD5BBJP.js';
|
|
4
4
|
import { getPathArray } from '../chunk-GYWRAW3Y.js';
|
|
5
5
|
import '../chunk-I2KLQ2HA.js';
|
|
6
6
|
import { createElement, useMemo } from 'react';
|
|
@@ -51,8 +51,31 @@ var formatCustomValue = (val) => {
|
|
|
51
51
|
if (typeof val === "string" || typeof val === "number") return String(val);
|
|
52
52
|
return JSON.stringify(val, null, 2);
|
|
53
53
|
};
|
|
54
|
-
var
|
|
55
|
-
const {
|
|
54
|
+
var renderErrorMessage = (context) => {
|
|
55
|
+
const { error, errors = [], translateValidationErrorCode } = context;
|
|
56
|
+
const descriptors = (errors.length ? errors : error ? [error] : []).filter(
|
|
57
|
+
(descriptor) => descriptor.code !== ERROR_MESSAGE_CONSTANTS.NONE
|
|
58
|
+
);
|
|
59
|
+
if (!descriptors.length) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return createElement(
|
|
63
|
+
View,
|
|
64
|
+
{ style: { gap: 4 } },
|
|
65
|
+
descriptors.map((descriptor, index) => {
|
|
66
|
+
const message = translateValidationErrorCode(descriptor);
|
|
67
|
+
if (!message) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return createElement(
|
|
71
|
+
ErrorMessage,
|
|
72
|
+
{ key: `${descriptor.code}-${index}`, children: message }
|
|
73
|
+
);
|
|
74
|
+
})
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
var RelationSingleField = (context) => {
|
|
78
|
+
const { field, fieldKey, label, required, disabled, onRelationAction } = context;
|
|
56
79
|
return createElement(
|
|
57
80
|
FieldWrapper,
|
|
58
81
|
null,
|
|
@@ -72,11 +95,11 @@ var renderRelationSingle = (context) => {
|
|
|
72
95
|
},
|
|
73
96
|
"Manage"
|
|
74
97
|
) : null,
|
|
75
|
-
|
|
98
|
+
renderErrorMessage(context)
|
|
76
99
|
);
|
|
77
100
|
};
|
|
78
|
-
var
|
|
79
|
-
const { field, fieldKey, label, required, disabled,
|
|
101
|
+
var RelationArrayField = (context) => {
|
|
102
|
+
const { field, fieldKey, label, required, disabled, onRelationAction } = context;
|
|
80
103
|
return createElement(
|
|
81
104
|
FieldWrapper,
|
|
82
105
|
null,
|
|
@@ -96,11 +119,11 @@ var renderRelationArray = (context) => {
|
|
|
96
119
|
},
|
|
97
120
|
"Manage"
|
|
98
121
|
) : null,
|
|
99
|
-
|
|
122
|
+
renderErrorMessage(context)
|
|
100
123
|
);
|
|
101
124
|
};
|
|
102
|
-
var
|
|
103
|
-
const { field, fieldKey, label, required, disabled
|
|
125
|
+
var CustomSingleField = (context) => {
|
|
126
|
+
const { field, fieldKey, label, required, disabled } = context;
|
|
104
127
|
const customType = field.tags?.customType;
|
|
105
128
|
const onCustomTypeAction = context.onCustomTypeAction;
|
|
106
129
|
return createElement(
|
|
@@ -123,11 +146,11 @@ var renderCustomSingle = (context) => {
|
|
|
123
146
|
},
|
|
124
147
|
"Manage"
|
|
125
148
|
) : null,
|
|
126
|
-
|
|
149
|
+
renderErrorMessage(context)
|
|
127
150
|
);
|
|
128
151
|
};
|
|
129
|
-
var
|
|
130
|
-
const { field, fieldKey, label, required, disabled
|
|
152
|
+
var CustomArrayField = (context) => {
|
|
153
|
+
const { field, fieldKey, label, required, disabled } = context;
|
|
131
154
|
const customType = field.tags?.customType;
|
|
132
155
|
const onCustomTypeAction = context.onCustomTypeAction;
|
|
133
156
|
const arrayValue = Array.isArray(context.value) ? context.value : [];
|
|
@@ -197,11 +220,11 @@ var renderCustomArray = (context) => {
|
|
|
197
220
|
},
|
|
198
221
|
"Add Item"
|
|
199
222
|
) : null,
|
|
200
|
-
|
|
223
|
+
renderErrorMessage(context)
|
|
201
224
|
);
|
|
202
225
|
};
|
|
203
|
-
var
|
|
204
|
-
const { field, fieldKey, label, required, disabled
|
|
226
|
+
var ArrayField = (context) => {
|
|
227
|
+
const { field, fieldKey, label, required, disabled } = context;
|
|
205
228
|
const itemField = createArrayItemField(field);
|
|
206
229
|
const arrayValue = Array.isArray(context.value) ? [...context.value] : [];
|
|
207
230
|
return createElement(
|
|
@@ -227,6 +250,11 @@ var renderArray = (context) => {
|
|
|
227
250
|
newValue[index] = newItem;
|
|
228
251
|
context.onChange(newValue);
|
|
229
252
|
},
|
|
253
|
+
errors: context.arrayItemErrorMap?.[index] ?? [],
|
|
254
|
+
error: context.arrayItemErrorMap?.[index]?.find(
|
|
255
|
+
(descriptor) => descriptor.code !== ERROR_MESSAGE_CONSTANTS.NONE
|
|
256
|
+
) ?? void 0,
|
|
257
|
+
translateValidationErrorCode: context.translateValidationErrorCode,
|
|
230
258
|
disabled
|
|
231
259
|
})
|
|
232
260
|
),
|
|
@@ -259,11 +287,11 @@ var renderArray = (context) => {
|
|
|
259
287
|
"Add Item"
|
|
260
288
|
)
|
|
261
289
|
),
|
|
262
|
-
|
|
290
|
+
renderErrorMessage(context)
|
|
263
291
|
);
|
|
264
292
|
};
|
|
265
|
-
var
|
|
266
|
-
const { label, required, disabled
|
|
293
|
+
var StringField = (context) => {
|
|
294
|
+
const { label, required, disabled } = context;
|
|
267
295
|
return createElement(
|
|
268
296
|
FieldWrapper,
|
|
269
297
|
null,
|
|
@@ -274,11 +302,11 @@ var renderString = (context) => {
|
|
|
274
302
|
editable: !disabled,
|
|
275
303
|
placeholder: label
|
|
276
304
|
}),
|
|
277
|
-
|
|
305
|
+
renderErrorMessage(context)
|
|
278
306
|
);
|
|
279
307
|
};
|
|
280
|
-
var
|
|
281
|
-
const { label, required, disabled
|
|
308
|
+
var NumberField = (context) => {
|
|
309
|
+
const { label, required, disabled } = context;
|
|
282
310
|
return createElement(
|
|
283
311
|
FieldWrapper,
|
|
284
312
|
null,
|
|
@@ -290,11 +318,11 @@ var renderNumber = (context) => {
|
|
|
290
318
|
keyboardType: "numeric",
|
|
291
319
|
placeholder: label
|
|
292
320
|
}),
|
|
293
|
-
|
|
321
|
+
renderErrorMessage(context)
|
|
294
322
|
);
|
|
295
323
|
};
|
|
296
|
-
var
|
|
297
|
-
const { label, disabled
|
|
324
|
+
var BooleanField = (context) => {
|
|
325
|
+
const { label, disabled } = context;
|
|
298
326
|
return createElement(
|
|
299
327
|
FieldWrapper,
|
|
300
328
|
null,
|
|
@@ -308,11 +336,11 @@ var renderBoolean = (context) => {
|
|
|
308
336
|
}),
|
|
309
337
|
createElement(Text, null, label)
|
|
310
338
|
),
|
|
311
|
-
|
|
339
|
+
renderErrorMessage(context)
|
|
312
340
|
);
|
|
313
341
|
};
|
|
314
|
-
var
|
|
315
|
-
const { field, label, required, disabled
|
|
342
|
+
var EnumSelectField = (context) => {
|
|
343
|
+
const { field, label, required, disabled } = context;
|
|
316
344
|
const selectableValues = getSelectableValues(context.possibleValues) ?? [];
|
|
317
345
|
return createElement(
|
|
318
346
|
FieldWrapper,
|
|
@@ -335,7 +363,7 @@ var renderEnumSelect = (context) => {
|
|
|
335
363
|
)
|
|
336
364
|
)
|
|
337
365
|
),
|
|
338
|
-
|
|
366
|
+
renderErrorMessage(context)
|
|
339
367
|
);
|
|
340
368
|
};
|
|
341
369
|
var FormRoot = ({
|
|
@@ -365,15 +393,15 @@ var SuiteButton = ({
|
|
|
365
393
|
};
|
|
366
394
|
var nativeSuite = {
|
|
367
395
|
renderers: {
|
|
368
|
-
string:
|
|
369
|
-
number:
|
|
370
|
-
boolean:
|
|
371
|
-
enum_select:
|
|
372
|
-
array:
|
|
373
|
-
relation_single:
|
|
374
|
-
relation_array:
|
|
375
|
-
custom_single:
|
|
376
|
-
custom_array:
|
|
396
|
+
string: StringField,
|
|
397
|
+
number: NumberField,
|
|
398
|
+
boolean: BooleanField,
|
|
399
|
+
enum_select: EnumSelectField,
|
|
400
|
+
array: ArrayField,
|
|
401
|
+
relation_single: RelationSingleField,
|
|
402
|
+
relation_array: RelationArrayField,
|
|
403
|
+
custom_single: CustomSingleField,
|
|
404
|
+
custom_array: CustomArrayField
|
|
377
405
|
},
|
|
378
406
|
primitives: {
|
|
379
407
|
FormRoot,
|
|
@@ -396,12 +424,15 @@ var createNativeFormRenderer = (options) => {
|
|
|
396
424
|
};
|
|
397
425
|
var defaultNativeRenderer = createNativeFormRenderer();
|
|
398
426
|
var AutoField = (props) => {
|
|
399
|
-
return nativeAutoField
|
|
427
|
+
return createElement(nativeAutoField, {
|
|
400
428
|
field: props.field,
|
|
401
429
|
fieldKey: props.fieldKey,
|
|
402
430
|
value: props.value,
|
|
403
431
|
onChange: props.onChange,
|
|
404
432
|
error: props.error,
|
|
433
|
+
errors: props.errors,
|
|
434
|
+
arrayItemErrorMap: props.arrayItemErrorMap,
|
|
435
|
+
translateValidationErrorCode: props.translateValidationErrorCode,
|
|
405
436
|
disabled: props.disabled,
|
|
406
437
|
onRelationAction: props.onRelationAction,
|
|
407
438
|
onCustomTypeAction: props.onCustomTypeAction
|