@ram_28/kf-ai-sdk 1.0.11 → 1.0.12
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 +55 -48
- package/dist/api/client.d.ts +14 -14
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/datetime.d.ts +5 -5
- package/dist/api/datetime.d.ts.map +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/metadata.d.ts +2 -2
- package/dist/api/metadata.d.ts.map +1 -1
- package/dist/api.cjs +1 -0
- package/dist/api.d.ts +4 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.mjs +27 -0
- package/dist/api.types.cjs +1 -0
- package/dist/api.types.d.ts +4 -0
- package/dist/api.types.d.ts.map +1 -0
- package/dist/api.types.mjs +1 -0
- package/dist/auth/AuthProvider.d.ts +3 -3
- package/dist/auth/AuthProvider.d.ts.map +1 -1
- package/dist/auth/authClient.d.ts +4 -4
- package/dist/auth/authClient.d.ts.map +1 -1
- package/dist/auth/authConfig.d.ts +5 -5
- package/dist/auth/authConfig.d.ts.map +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/types.d.ts +21 -21
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/useAuth.d.ts +2 -2
- package/dist/auth/useAuth.d.ts.map +1 -1
- package/dist/auth.cjs +1 -0
- package/dist/auth.d.ts +5 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.mjs +280 -0
- package/dist/auth.types.cjs +1 -0
- package/dist/auth.types.d.ts +2 -0
- package/dist/auth.types.d.ts.map +1 -0
- package/dist/auth.types.mjs +1 -0
- package/dist/base-types.d.ts +2 -0
- package/dist/base-types.d.ts.map +1 -0
- package/dist/client-C15j4O5B.cjs +1 -0
- package/dist/client-CfvLiGfP.js +233 -0
- package/dist/cn-Dr87sK3i.js +2775 -0
- package/dist/cn-mXUIg4vp.cjs +1 -0
- package/dist/components/hooks/index.d.ts +3 -3
- package/dist/components/hooks/index.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/index.d.ts +2 -2
- package/dist/components/hooks/useFilter/index.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/types.d.ts +19 -31
- package/dist/components/hooks/useFilter/types.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/useFilter.d.ts +2 -2
- package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -1
- package/dist/components/hooks/useForm/apiClient.d.ts +6 -6
- package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
- package/dist/components/hooks/useForm/expressionValidator.utils.d.ts +7 -7
- package/dist/components/hooks/useForm/expressionValidator.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/index.d.ts +5 -5
- package/dist/components/hooks/useForm/index.d.ts.map +1 -1
- package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts +10 -10
- package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts +7 -12
- package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/schemaParser.utils.d.ts +7 -7
- package/dist/components/hooks/useForm/schemaParser.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/types.d.ts +67 -76
- package/dist/components/hooks/useForm/types.d.ts.map +1 -1
- package/dist/components/hooks/useForm/useForm.d.ts +2 -2
- package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/apiClient.d.ts +16 -16
- package/dist/components/hooks/useKanban/apiClient.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/context.d.ts +3 -3
- package/dist/components/hooks/useKanban/context.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/dragDropManager.d.ts +7 -7
- package/dist/components/hooks/useKanban/dragDropManager.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/index.d.ts +1 -1
- package/dist/components/hooks/useKanban/index.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/types.d.ts +65 -67
- package/dist/components/hooks/useKanban/types.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/useKanban.d.ts +2 -2
- package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -1
- package/dist/components/hooks/useTable/index.d.ts +1 -1
- package/dist/components/hooks/useTable/index.d.ts.map +1 -1
- package/dist/components/hooks/useTable/types.d.ts +10 -10
- package/dist/components/hooks/useTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useTable/useTable.d.ts +2 -2
- package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
- package/dist/filter.cjs +1 -0
- package/dist/filter.d.ts +3 -0
- package/dist/filter.d.ts.map +1 -0
- package/dist/filter.mjs +6 -0
- package/dist/filter.types.cjs +1 -0
- package/dist/filter.types.d.ts +2 -0
- package/dist/filter.types.d.ts.map +1 -0
- package/dist/filter.types.mjs +1 -0
- package/dist/form.cjs +1 -0
- package/dist/form.d.ts +3 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.mjs +1346 -0
- package/dist/form.types.cjs +1 -0
- package/dist/form.types.d.ts +2 -0
- package/dist/form.types.d.ts.map +1 -0
- package/dist/form.types.mjs +1 -0
- package/dist/jsx-runtime-BYECrxsp.cjs +30 -0
- package/dist/jsx-runtime-DGlMoOmv.js +630 -0
- package/dist/kanban.cjs +13 -0
- package/dist/kanban.d.ts +5 -0
- package/dist/kanban.d.ts.map +1 -0
- package/dist/kanban.mjs +694 -0
- package/dist/kanban.types.cjs +1 -0
- package/dist/kanban.types.d.ts +2 -0
- package/dist/kanban.types.d.ts.map +1 -0
- package/dist/kanban.types.mjs +1 -0
- package/dist/kanban.ui.cjs +1 -0
- package/dist/kanban.ui.d.ts +2 -0
- package/dist/kanban.ui.d.ts.map +1 -0
- package/dist/kanban.ui.mjs +104 -0
- package/dist/metadata-2FLBsFcf.cjs +1 -0
- package/dist/metadata-DBcoDth-.js +43 -0
- package/dist/table.cjs +1 -0
- package/dist/table.d.ts +2 -0
- package/dist/table.d.ts.map +1 -0
- package/dist/table.mjs +148 -0
- package/dist/table.types.cjs +1 -0
- package/dist/table.types.d.ts +2 -0
- package/dist/table.types.d.ts.map +1 -0
- package/dist/table.types.mjs +1 -0
- package/dist/types/base-fields.d.ts +45 -45
- package/dist/types/base-fields.d.ts.map +1 -1
- package/dist/types/common.d.ts +45 -61
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types.cjs +1 -0
- package/dist/types.mjs +1 -0
- package/dist/useFilter-CXFqEHyI.js +129 -0
- package/dist/useFilter-D-bCDo6Z.cjs +1 -0
- package/dist/utils/formatting.d.ts +4 -4
- package/dist/utils/formatting.d.ts.map +1 -1
- package/dist/utils.cjs +4 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.mjs +105 -0
- package/package.json +147 -9
- package/sdk/api/client.ts +51 -51
- package/sdk/api/datetime.ts +5 -5
- package/sdk/api/index.ts +28 -33
- package/sdk/api/metadata.ts +4 -4
- package/sdk/api.ts +24 -0
- package/sdk/api.types.ts +58 -0
- package/sdk/auth/AuthProvider.tsx +18 -18
- package/sdk/auth/authClient.ts +9 -9
- package/sdk/auth/authConfig.ts +9 -9
- package/sdk/auth/index.ts +5 -5
- package/sdk/auth/types.ts +21 -21
- package/sdk/auth/useAuth.ts +2 -2
- package/sdk/auth.ts +22 -0
- package/sdk/auth.types.ts +28 -0
- package/sdk/base-types.ts +45 -0
- package/sdk/components/hooks/index.ts +22 -22
- package/sdk/components/hooks/useFilter/index.ts +8 -14
- package/sdk/components/hooks/useFilter/types.ts +29 -58
- package/sdk/components/hooks/useFilter/useFilter.ts +41 -44
- package/sdk/components/hooks/useForm/apiClient.ts +8 -8
- package/sdk/components/hooks/useForm/expressionValidator.utils.ts +18 -18
- package/sdk/components/hooks/useForm/index.ts +24 -24
- package/sdk/components/hooks/useForm/optimizedExpressionValidator.utils.ts +22 -22
- package/sdk/components/hooks/useForm/ruleClassifier.utils.ts +26 -62
- package/sdk/components/hooks/useForm/schemaParser.utils.ts +24 -24
- package/sdk/components/hooks/useForm/types.ts +66 -82
- package/sdk/components/hooks/useForm/useForm.ts +15 -21
- package/sdk/components/hooks/useKanban/apiClient.ts +54 -54
- package/sdk/components/hooks/useKanban/context.ts +3 -3
- package/sdk/components/hooks/useKanban/dragDropManager.ts +19 -19
- package/sdk/components/hooks/useKanban/index.ts +26 -26
- package/sdk/components/hooks/useKanban/types.ts +69 -71
- package/sdk/components/hooks/useKanban/useKanban.ts +43 -51
- package/sdk/components/hooks/useKanban/useKanbanSimple.ts +4 -4
- package/sdk/components/hooks/useTable/index.ts +5 -1
- package/sdk/components/hooks/useTable/types.ts +10 -10
- package/sdk/components/hooks/useTable/useTable.ts +10 -10
- package/sdk/filter.ts +13 -0
- package/sdk/filter.types.ts +17 -0
- package/sdk/form.ts +15 -0
- package/sdk/form.types.ts +46 -0
- package/sdk/kanban.ts +23 -0
- package/sdk/kanban.types.ts +50 -0
- package/sdk/kanban.ui.ts +16 -0
- package/sdk/table.ts +7 -0
- package/sdk/table.types.ts +13 -0
- package/sdk/types/base-fields.ts +47 -47
- package/sdk/types/common.ts +47 -71
- package/sdk/types/index.ts +1 -1
- package/sdk/utils/formatting.ts +4 -4
- package/sdk/utils.ts +10 -0
- package/dist/index.cjs +0 -45
- package/dist/index.mjs +0 -6387
|
@@ -11,7 +11,6 @@ import type {
|
|
|
11
11
|
PathValue,
|
|
12
12
|
RegisterOptions,
|
|
13
13
|
SetValueConfig,
|
|
14
|
-
FormState,
|
|
15
14
|
} from "react-hook-form";
|
|
16
15
|
|
|
17
16
|
// ============================================================
|
|
@@ -29,7 +28,7 @@ import type {
|
|
|
29
28
|
* 2. Clean data & call API → FAILS → onError(apiError)
|
|
30
29
|
* 3. SUCCESS → onSuccess(responseData)
|
|
31
30
|
*/
|
|
32
|
-
export type
|
|
31
|
+
export type HandleSubmitType<T extends RHFFieldValues> = (
|
|
33
32
|
onSuccess?: (data: T, e?: React.BaseSyntheticEvent) => void | Promise<void>,
|
|
34
33
|
onError?: (
|
|
35
34
|
error: FieldErrors<T> | Error,
|
|
@@ -45,7 +44,7 @@ export type HandleSubmit<T extends RHFFieldValues> = (
|
|
|
45
44
|
* Expression tree node types from backend validation system
|
|
46
45
|
* Used for evaluating validation rules, computed fields, and default values
|
|
47
46
|
*/
|
|
48
|
-
export interface
|
|
47
|
+
export interface ExpressionTreeType {
|
|
49
48
|
Type:
|
|
50
49
|
| "BinaryExpression"
|
|
51
50
|
| "LogicalExpression"
|
|
@@ -57,7 +56,7 @@ export interface ExpressionTree {
|
|
|
57
56
|
| "Literal";
|
|
58
57
|
Operator?: string;
|
|
59
58
|
Callee?: string;
|
|
60
|
-
Arguments?:
|
|
59
|
+
Arguments?: ExpressionTreeType[];
|
|
61
60
|
Name?: string;
|
|
62
61
|
Source?: string;
|
|
63
62
|
Property?: {
|
|
@@ -77,12 +76,12 @@ export interface ExpressionTree {
|
|
|
77
76
|
* Validation rule from BDO schema
|
|
78
77
|
* Defines a validation, computation, or business logic rule
|
|
79
78
|
*/
|
|
80
|
-
export interface
|
|
79
|
+
export interface SchemaValidationRuleType {
|
|
81
80
|
Id: string;
|
|
82
81
|
Name: string;
|
|
83
82
|
Description: string;
|
|
84
83
|
Expression: string;
|
|
85
|
-
ExpressionTree:
|
|
84
|
+
ExpressionTree: ExpressionTreeType;
|
|
86
85
|
ResultType: string;
|
|
87
86
|
Message?: string;
|
|
88
87
|
}
|
|
@@ -90,27 +89,27 @@ export interface SchemaValidationRule {
|
|
|
90
89
|
/**
|
|
91
90
|
* Formula definition for computed fields
|
|
92
91
|
*/
|
|
93
|
-
export interface
|
|
92
|
+
export interface ComputedFieldFormulaType {
|
|
94
93
|
Id?: string;
|
|
95
94
|
Name?: string;
|
|
96
95
|
Description?: string;
|
|
97
96
|
Expression: string;
|
|
98
|
-
ExpressionTree:
|
|
97
|
+
ExpressionTree: ExpressionTreeType;
|
|
99
98
|
ResultType?: string;
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
/**
|
|
103
102
|
* Default value expression for a field
|
|
104
103
|
*/
|
|
105
|
-
export interface
|
|
104
|
+
export interface DefaultValueExpressionType {
|
|
106
105
|
Expression: string;
|
|
107
|
-
ExpressionTree:
|
|
106
|
+
ExpressionTree: ExpressionTreeType;
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
/**
|
|
111
110
|
* Reference field configuration for dynamic lookups
|
|
112
111
|
*/
|
|
113
|
-
export interface
|
|
112
|
+
export interface ReferenceFieldConfigType {
|
|
114
113
|
Mode: "Dynamic" | "Static";
|
|
115
114
|
Reference?: {
|
|
116
115
|
BusinessObject: string;
|
|
@@ -120,7 +119,7 @@ export interface ReferenceFieldConfig {
|
|
|
120
119
|
LhsField: string;
|
|
121
120
|
Operator: string;
|
|
122
121
|
RhsType: string;
|
|
123
|
-
RhsValue?:
|
|
122
|
+
RhsValue?: DefaultValueExpressionType;
|
|
124
123
|
}>;
|
|
125
124
|
};
|
|
126
125
|
Sort?: Array<{
|
|
@@ -133,19 +132,19 @@ export interface ReferenceFieldConfig {
|
|
|
133
132
|
/**
|
|
134
133
|
* Field options configuration for select/dropdown fields
|
|
135
134
|
*/
|
|
136
|
-
export interface
|
|
135
|
+
export interface FieldOptionsConfigType {
|
|
137
136
|
Mode: "Static" | "Dynamic";
|
|
138
137
|
Items?: Array<{
|
|
139
138
|
Value: string | number | boolean;
|
|
140
139
|
Label: string;
|
|
141
140
|
}>;
|
|
142
|
-
Reference?:
|
|
141
|
+
Reference?: ReferenceFieldConfigType["Reference"];
|
|
143
142
|
}
|
|
144
143
|
|
|
145
144
|
/**
|
|
146
145
|
* BDO field definition structure
|
|
147
146
|
*/
|
|
148
|
-
export interface
|
|
147
|
+
export interface BDOFieldDefinitionType {
|
|
149
148
|
Id: string;
|
|
150
149
|
Name: string;
|
|
151
150
|
Type:
|
|
@@ -160,32 +159,32 @@ export interface BDOFieldDefinition {
|
|
|
160
159
|
| "ActivityFlow";
|
|
161
160
|
Required?: boolean;
|
|
162
161
|
Unique?: boolean;
|
|
163
|
-
DefaultValue?:
|
|
164
|
-
Formula?:
|
|
162
|
+
DefaultValue?: DefaultValueExpressionType;
|
|
163
|
+
Formula?: ComputedFieldFormulaType;
|
|
165
164
|
Computed?: boolean;
|
|
166
|
-
Validation?: string[] |
|
|
167
|
-
Values?:
|
|
165
|
+
Validation?: string[] | SchemaValidationRuleType[]; // Array of rule IDs OR inline validation rule objects
|
|
166
|
+
Values?: FieldOptionsConfigType;
|
|
168
167
|
Items?: {
|
|
169
168
|
Type: string;
|
|
170
|
-
Property?: Record<string,
|
|
169
|
+
Property?: Record<string, BDOFieldDefinitionType>;
|
|
171
170
|
};
|
|
172
|
-
Property?: Record<string,
|
|
171
|
+
Property?: Record<string, BDOFieldDefinitionType>;
|
|
173
172
|
Description?: string;
|
|
174
173
|
}
|
|
175
174
|
|
|
176
175
|
/**
|
|
177
176
|
* Business Object Rule definitions from BDO schema
|
|
178
177
|
*/
|
|
179
|
-
export interface
|
|
180
|
-
Computation?: Record<string,
|
|
181
|
-
Validation?: Record<string,
|
|
182
|
-
BusinessLogic?: Record<string,
|
|
178
|
+
export interface BusinessObjectRulesType {
|
|
179
|
+
Computation?: Record<string, SchemaValidationRuleType>;
|
|
180
|
+
Validation?: Record<string, SchemaValidationRuleType>;
|
|
181
|
+
BusinessLogic?: Record<string, SchemaValidationRuleType>;
|
|
183
182
|
}
|
|
184
183
|
|
|
185
184
|
/**
|
|
186
185
|
* Role permission definition from BDO schema
|
|
187
186
|
*/
|
|
188
|
-
export interface
|
|
187
|
+
export interface RolePermissionType {
|
|
189
188
|
Editable?: string[];
|
|
190
189
|
ReadOnly?: string[];
|
|
191
190
|
Methods?: string[];
|
|
@@ -203,14 +202,14 @@ export interface RolePermission {
|
|
|
203
202
|
/**
|
|
204
203
|
* Complete BDO (Business Data Object) schema structure
|
|
205
204
|
*/
|
|
206
|
-
export interface
|
|
205
|
+
export interface BDOSchemaType {
|
|
207
206
|
Id: string;
|
|
208
207
|
Name: string;
|
|
209
208
|
Kind: "BusinessObject";
|
|
210
209
|
Description: string;
|
|
211
|
-
Rules:
|
|
212
|
-
Fields: Record<string,
|
|
213
|
-
RolePermission: Record<string,
|
|
210
|
+
Rules: BusinessObjectRulesType;
|
|
211
|
+
Fields: Record<string, BDOFieldDefinitionType>;
|
|
212
|
+
RolePermission: Record<string, RolePermissionType>;
|
|
214
213
|
Roles: Record<
|
|
215
214
|
string,
|
|
216
215
|
{
|
|
@@ -227,36 +226,36 @@ export interface BDOSchema {
|
|
|
227
226
|
/**
|
|
228
227
|
* Form operation mode
|
|
229
228
|
*/
|
|
230
|
-
export type
|
|
229
|
+
export type FormOperationType = "create" | "update";
|
|
231
230
|
|
|
232
231
|
/**
|
|
233
232
|
* Form interaction mode
|
|
234
233
|
* - "interactive" (default): Real-time server-side validation and computation on every field blur
|
|
235
234
|
* - "non-interactive": Draft only for computed field dependencies (legacy behavior)
|
|
236
235
|
*/
|
|
237
|
-
export type
|
|
236
|
+
export type InteractionModeType = "interactive" | "non-interactive";
|
|
238
237
|
|
|
239
238
|
/**
|
|
240
239
|
* Form validation mode (from react-hook-form)
|
|
241
240
|
*/
|
|
242
|
-
export type
|
|
241
|
+
export type FormModeType = Mode;
|
|
243
242
|
|
|
244
243
|
/**
|
|
245
244
|
* Rule classification types
|
|
246
245
|
*/
|
|
247
|
-
export type
|
|
246
|
+
export type RuleTypeType = "Validation" | "Computation" | "BusinessLogic";
|
|
248
247
|
|
|
249
248
|
/**
|
|
250
249
|
* useForm hook options with strict typing
|
|
251
250
|
*/
|
|
252
|
-
export interface
|
|
251
|
+
export interface UseFormOptionsType<
|
|
253
252
|
T extends Record<string, any> = Record<string, any>,
|
|
254
253
|
> {
|
|
255
254
|
/** Data source identifier (Business Object name) */
|
|
256
255
|
source: string;
|
|
257
256
|
|
|
258
257
|
/** Form operation type */
|
|
259
|
-
operation:
|
|
258
|
+
operation: FormOperationType;
|
|
260
259
|
|
|
261
260
|
/** Record ID for update operations */
|
|
262
261
|
recordId?: string;
|
|
@@ -281,7 +280,7 @@ export interface UseFormOptions<
|
|
|
281
280
|
* @default "onBlur"
|
|
282
281
|
* @see https://react-hook-form.com/docs/useform for more details on validation modes
|
|
283
282
|
*/
|
|
284
|
-
mode?:
|
|
283
|
+
mode?: FormModeType;
|
|
285
284
|
|
|
286
285
|
/** Whether to enable schema fetching and form initialization (default: true) */
|
|
287
286
|
enabled?: boolean;
|
|
@@ -296,23 +295,15 @@ export interface UseFormOptions<
|
|
|
296
295
|
skipSchemaFetch?: boolean;
|
|
297
296
|
|
|
298
297
|
/** Manual schema (use instead of fetching) */
|
|
299
|
-
schema?:
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Trigger draft API call on every field change (after validation passes)
|
|
303
|
-
* If true: draft API is called for any field change
|
|
304
|
-
* If false (default): draft API is called only when computed field dependencies change
|
|
305
|
-
* @deprecated Use interactionMode: "interactive" instead
|
|
306
|
-
*/
|
|
307
|
-
draftOnEveryChange?: boolean;
|
|
298
|
+
schema?: BDOSchemaType;
|
|
308
299
|
|
|
309
300
|
/**
|
|
310
301
|
* Form interaction mode
|
|
311
302
|
* - "interactive" (default): Real-time server-side validation and computation on every field blur
|
|
312
|
-
* - "non-interactive": Draft only for computed field dependencies
|
|
303
|
+
* - "non-interactive": Draft only for computed field dependencies
|
|
313
304
|
* @default "interactive"
|
|
314
305
|
*/
|
|
315
|
-
interactionMode?:
|
|
306
|
+
interactionMode?: InteractionModeType;
|
|
316
307
|
}
|
|
317
308
|
|
|
318
309
|
// ============================================================
|
|
@@ -322,7 +313,7 @@ export interface UseFormOptions<
|
|
|
322
313
|
/**
|
|
323
314
|
* Field permission for current user
|
|
324
315
|
*/
|
|
325
|
-
export interface
|
|
316
|
+
export interface FieldPermissionType {
|
|
326
317
|
/** Can user edit this field */
|
|
327
318
|
editable: boolean;
|
|
328
319
|
|
|
@@ -336,7 +327,7 @@ export interface FieldPermission {
|
|
|
336
327
|
/**
|
|
337
328
|
* Field input types for form rendering
|
|
338
329
|
*/
|
|
339
|
-
export type
|
|
330
|
+
export type FormFieldTypeType =
|
|
340
331
|
| "text"
|
|
341
332
|
| "number"
|
|
342
333
|
| "email"
|
|
@@ -351,7 +342,7 @@ export type FormFieldType =
|
|
|
351
342
|
/**
|
|
352
343
|
* Select option for dropdown fields
|
|
353
344
|
*/
|
|
354
|
-
export interface
|
|
345
|
+
export interface SelectOptionType {
|
|
355
346
|
value: any;
|
|
356
347
|
label: string;
|
|
357
348
|
}
|
|
@@ -359,7 +350,7 @@ export interface SelectOption {
|
|
|
359
350
|
/**
|
|
360
351
|
* Field rule IDs by category
|
|
361
352
|
*/
|
|
362
|
-
export interface
|
|
353
|
+
export interface FieldRuleIdsType {
|
|
363
354
|
validation: string[];
|
|
364
355
|
computation: string[];
|
|
365
356
|
businessLogic: string[];
|
|
@@ -369,12 +360,12 @@ export interface FieldRuleIds {
|
|
|
369
360
|
* Form field configuration for rendering
|
|
370
361
|
* Contains all metadata needed to render and validate a form field
|
|
371
362
|
*/
|
|
372
|
-
export interface
|
|
363
|
+
export interface FormFieldConfigType {
|
|
373
364
|
/** Field name/identifier */
|
|
374
365
|
name: string;
|
|
375
366
|
|
|
376
367
|
/** Field input type */
|
|
377
|
-
type:
|
|
368
|
+
type: FormFieldTypeType;
|
|
378
369
|
|
|
379
370
|
/** Display label */
|
|
380
371
|
label: string;
|
|
@@ -389,7 +380,7 @@ export interface FormFieldConfig {
|
|
|
389
380
|
defaultValue?: any;
|
|
390
381
|
|
|
391
382
|
/** Select options (for select/reference fields) */
|
|
392
|
-
options?:
|
|
383
|
+
options?: SelectOptionType[];
|
|
393
384
|
|
|
394
385
|
/** Validation configuration */
|
|
395
386
|
validation: any;
|
|
@@ -398,22 +389,22 @@ export interface FormFieldConfig {
|
|
|
398
389
|
description?: string;
|
|
399
390
|
|
|
400
391
|
/** Original BDO field definition (for advanced use) */
|
|
401
|
-
_bdoField:
|
|
392
|
+
_bdoField: BDOFieldDefinitionType;
|
|
402
393
|
|
|
403
394
|
/** Field permissions for current user */
|
|
404
|
-
permission:
|
|
395
|
+
permission: FieldPermissionType;
|
|
405
396
|
|
|
406
397
|
/** Associated rule IDs by category */
|
|
407
|
-
rules:
|
|
398
|
+
rules: FieldRuleIdsType;
|
|
408
399
|
}
|
|
409
400
|
|
|
410
401
|
/**
|
|
411
402
|
* Form schema configuration after processing
|
|
412
403
|
* Contains all fields and rules ready for form rendering
|
|
413
404
|
*/
|
|
414
|
-
export interface
|
|
405
|
+
export interface FormSchemaConfigType {
|
|
415
406
|
/** All fields by name */
|
|
416
|
-
fields: Record<string,
|
|
407
|
+
fields: Record<string, FormFieldConfigType>;
|
|
417
408
|
|
|
418
409
|
/** Field names in display order */
|
|
419
410
|
fieldOrder: string[];
|
|
@@ -425,20 +416,20 @@ export interface FormSchemaConfig {
|
|
|
425
416
|
requiredFields: string[];
|
|
426
417
|
|
|
427
418
|
/** Cross-field validation rules */
|
|
428
|
-
crossFieldValidation:
|
|
419
|
+
crossFieldValidation: SchemaValidationRuleType[];
|
|
429
420
|
|
|
430
421
|
/** Classified rules by type */
|
|
431
422
|
rules: {
|
|
432
|
-
validation: Record<string,
|
|
433
|
-
computation: Record<string,
|
|
434
|
-
businessLogic: Record<string,
|
|
423
|
+
validation: Record<string, SchemaValidationRuleType>;
|
|
424
|
+
computation: Record<string, SchemaValidationRuleType>;
|
|
425
|
+
businessLogic: Record<string, SchemaValidationRuleType>;
|
|
435
426
|
};
|
|
436
427
|
|
|
437
428
|
/** Field-to-rule mapping for quick lookup */
|
|
438
|
-
fieldRules: Record<string,
|
|
429
|
+
fieldRules: Record<string, FieldRuleIdsType>;
|
|
439
430
|
|
|
440
431
|
/** Role permissions */
|
|
441
|
-
rolePermissions?: Record<string,
|
|
432
|
+
rolePermissions?: Record<string, RolePermissionType>;
|
|
442
433
|
}
|
|
443
434
|
|
|
444
435
|
// ============================================================
|
|
@@ -448,7 +439,7 @@ export interface FormSchemaConfig {
|
|
|
448
439
|
/**
|
|
449
440
|
* useForm hook return type with flattened state access and strict typing
|
|
450
441
|
*/
|
|
451
|
-
export interface
|
|
442
|
+
export interface UseFormReturnType<
|
|
452
443
|
T extends Record<string, any> = Record<string, any>,
|
|
453
444
|
> {
|
|
454
445
|
// ============================================================
|
|
@@ -492,7 +483,7 @@ export interface UseFormReturn<
|
|
|
492
483
|
* // Programmatic submission
|
|
493
484
|
* await form.handleSubmit(onSuccess, onError)();
|
|
494
485
|
*/
|
|
495
|
-
handleSubmit:
|
|
486
|
+
handleSubmit: HandleSubmitType<T>;
|
|
496
487
|
|
|
497
488
|
/** Watch field values with strict typing */
|
|
498
489
|
watch: <K extends Path<T> | readonly Path<T>[]>(
|
|
@@ -532,13 +523,6 @@ export interface UseFormReturn<
|
|
|
532
523
|
/** Form submission was successful - direct access */
|
|
533
524
|
isSubmitSuccessful: boolean;
|
|
534
525
|
|
|
535
|
-
// ============================================================
|
|
536
|
-
// BACKWARD COMPATIBILITY
|
|
537
|
-
// ============================================================
|
|
538
|
-
|
|
539
|
-
/** Form state object (for backward compatibility with existing components) */
|
|
540
|
-
formState: FormState<T>;
|
|
541
|
-
|
|
542
526
|
// ============================================================
|
|
543
527
|
// LOADING STATES
|
|
544
528
|
// ============================================================
|
|
@@ -577,10 +561,10 @@ export interface UseFormReturn<
|
|
|
577
561
|
// ============================================================
|
|
578
562
|
|
|
579
563
|
/** Raw BDO schema */
|
|
580
|
-
schema:
|
|
564
|
+
schema: BDOSchemaType | null;
|
|
581
565
|
|
|
582
566
|
/** Processed schema configuration for rendering */
|
|
583
|
-
schemaConfig:
|
|
567
|
+
schemaConfig: FormSchemaConfigType | null;
|
|
584
568
|
|
|
585
569
|
/** Computed field names as typed array */
|
|
586
570
|
computedFields: Array<keyof T>;
|
|
@@ -593,10 +577,10 @@ export interface UseFormReturn<
|
|
|
593
577
|
// ============================================================
|
|
594
578
|
|
|
595
579
|
/** Get field configuration with strict typing */
|
|
596
|
-
getField: <K extends keyof T>(fieldName: K) =>
|
|
580
|
+
getField: <K extends keyof T>(fieldName: K) => FormFieldConfigType | null;
|
|
597
581
|
|
|
598
582
|
/** Get all field configurations with strict typing */
|
|
599
|
-
getFields: () => Record<keyof T,
|
|
583
|
+
getFields: () => Record<keyof T, FormFieldConfigType>;
|
|
600
584
|
|
|
601
585
|
/** Check if field exists with strict typing */
|
|
602
586
|
hasField: <K extends keyof T>(fieldName: K) => boolean;
|
|
@@ -628,7 +612,7 @@ export interface UseFormReturn<
|
|
|
628
612
|
/**
|
|
629
613
|
* Expression evaluation context
|
|
630
614
|
*/
|
|
631
|
-
export interface
|
|
615
|
+
export interface ExpressionContextType<T = Record<string, any>> {
|
|
632
616
|
/** Current form values */
|
|
633
617
|
formValues: Partial<T>;
|
|
634
618
|
|
|
@@ -642,7 +626,7 @@ export interface ExpressionContext<T = Record<string, any>> {
|
|
|
642
626
|
/**
|
|
643
627
|
* Field validation result
|
|
644
628
|
*/
|
|
645
|
-
export interface
|
|
629
|
+
export interface FieldValidationResultType<T = Record<string, any>> {
|
|
646
630
|
/** Is validation passing */
|
|
647
631
|
isValid: boolean;
|
|
648
632
|
|
|
@@ -656,7 +640,7 @@ export interface FieldValidationResult<T = Record<string, any>> {
|
|
|
656
640
|
/**
|
|
657
641
|
* Form submission result
|
|
658
642
|
*/
|
|
659
|
-
export interface
|
|
643
|
+
export interface SubmissionResultType {
|
|
660
644
|
/** Was submission successful */
|
|
661
645
|
success: boolean;
|
|
662
646
|
|
|
@@ -9,11 +9,11 @@ import { useQuery } from "@tanstack/react-query";
|
|
|
9
9
|
import type { Path } from "react-hook-form";
|
|
10
10
|
|
|
11
11
|
import type {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
UseFormOptionsType,
|
|
13
|
+
UseFormReturnType,
|
|
14
|
+
BDOSchemaType,
|
|
15
|
+
FormSchemaConfigType,
|
|
16
|
+
FormFieldConfigType,
|
|
17
17
|
} from "./types";
|
|
18
18
|
|
|
19
19
|
import { processSchema, extractReferenceFields } from "./schemaParser.utils";
|
|
@@ -39,8 +39,8 @@ import {
|
|
|
39
39
|
// ============================================================
|
|
40
40
|
|
|
41
41
|
export function useForm<T extends Record<string, any> = Record<string, any>>(
|
|
42
|
-
options:
|
|
43
|
-
):
|
|
42
|
+
options: UseFormOptionsType<T>
|
|
43
|
+
): UseFormReturnType<T> {
|
|
44
44
|
const {
|
|
45
45
|
source,
|
|
46
46
|
operation,
|
|
@@ -52,7 +52,6 @@ export function useForm<T extends Record<string, any> = Record<string, any>>(
|
|
|
52
52
|
onSchemaError,
|
|
53
53
|
skipSchemaFetch = false,
|
|
54
54
|
schema: manualSchema,
|
|
55
|
-
draftOnEveryChange = false,
|
|
56
55
|
interactionMode = "interactive",
|
|
57
56
|
} = options;
|
|
58
57
|
|
|
@@ -64,7 +63,7 @@ export function useForm<T extends Record<string, any> = Record<string, any>>(
|
|
|
64
63
|
// ============================================================
|
|
65
64
|
|
|
66
65
|
const [schemaConfig, setSchemaConfig] =
|
|
67
|
-
useState<
|
|
66
|
+
useState<FormSchemaConfigType | null>(null);
|
|
68
67
|
const [referenceData, setReferenceData] = useState<Record<string, any[]>>({});
|
|
69
68
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
70
69
|
const [lastFormValues] = useState<Partial<T>>({});
|
|
@@ -323,12 +322,11 @@ export function useForm<T extends Record<string, any> = Record<string, any>>(
|
|
|
323
322
|
|
|
324
323
|
// Determine if draft should be triggered based on interaction mode
|
|
325
324
|
// Interactive mode: Always trigger draft API on blur
|
|
326
|
-
// Non-interactive mode: Only trigger for computed field dependencies
|
|
325
|
+
// Non-interactive mode: Only trigger for computed field dependencies
|
|
327
326
|
const shouldTrigger = isInteractiveMode
|
|
328
327
|
? true // Interactive mode: always trigger
|
|
329
328
|
: (computedFieldDependencies.length > 0 &&
|
|
330
|
-
|
|
331
|
-
computedFieldDependencies.includes(fieldName as Path<T>)));
|
|
329
|
+
computedFieldDependencies.includes(fieldName as Path<T>));
|
|
332
330
|
|
|
333
331
|
if (!shouldTrigger) {
|
|
334
332
|
return;
|
|
@@ -497,7 +495,6 @@ export function useForm<T extends Record<string, any> = Record<string, any>>(
|
|
|
497
495
|
source,
|
|
498
496
|
rhfForm,
|
|
499
497
|
computedFieldDependencies,
|
|
500
|
-
draftOnEveryChange,
|
|
501
498
|
isInteractiveMode,
|
|
502
499
|
draftId,
|
|
503
500
|
]
|
|
@@ -706,16 +703,16 @@ export function useForm<T extends Record<string, any> = Record<string, any>>(
|
|
|
706
703
|
// ============================================================
|
|
707
704
|
|
|
708
705
|
const getField = useCallback(
|
|
709
|
-
<K extends keyof T>(fieldName: K):
|
|
706
|
+
<K extends keyof T>(fieldName: K): FormFieldConfigType | null => {
|
|
710
707
|
return schemaConfig?.fields[fieldName as string] || null;
|
|
711
708
|
},
|
|
712
709
|
[schemaConfig]
|
|
713
710
|
);
|
|
714
711
|
|
|
715
|
-
const getFields = useCallback((): Record<keyof T,
|
|
716
|
-
if (!schemaConfig) return {} as Record<keyof T,
|
|
712
|
+
const getFields = useCallback((): Record<keyof T, FormFieldConfigType> => {
|
|
713
|
+
if (!schemaConfig) return {} as Record<keyof T, FormFieldConfigType>;
|
|
717
714
|
|
|
718
|
-
const typedFields: Record<keyof T,
|
|
715
|
+
const typedFields: Record<keyof T, FormFieldConfigType> = {} as any;
|
|
719
716
|
Object.entries(schemaConfig.fields).forEach(([key, field]) => {
|
|
720
717
|
(typedFields as any)[key] = field;
|
|
721
718
|
});
|
|
@@ -923,9 +920,6 @@ export function useForm<T extends Record<string, any> = Record<string, any>>(
|
|
|
923
920
|
isSubmitting: rhfForm.formState.isSubmitting || isSubmitting,
|
|
924
921
|
isSubmitSuccessful: rhfForm.formState.isSubmitSuccessful,
|
|
925
922
|
|
|
926
|
-
// BACKWARD COMPATIBILITY - Keep formState for existing components
|
|
927
|
-
formState: rhfForm.formState,
|
|
928
|
-
|
|
929
923
|
// Loading states
|
|
930
924
|
isLoadingInitialData,
|
|
931
925
|
isLoadingRecord,
|
|
@@ -940,7 +934,7 @@ export function useForm<T extends Record<string, any> = Record<string, any>>(
|
|
|
940
934
|
hasError,
|
|
941
935
|
|
|
942
936
|
// Schema information
|
|
943
|
-
schema: schema as
|
|
937
|
+
schema: schema as BDOSchemaType | null,
|
|
944
938
|
schemaConfig,
|
|
945
939
|
computedFields,
|
|
946
940
|
requiredFields,
|