@ram_28/kf-ai-sdk 1.0.7 → 1.0.9
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/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/components/hooks/index.d.ts +2 -1
- package/dist/components/hooks/index.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/index.d.ts +3 -3
- package/dist/components/hooks/useFilter/index.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/types.d.ts +83 -109
- package/dist/components/hooks/useFilter/types.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/useFilter.d.ts +1 -1
- package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -1
- package/dist/components/hooks/useForm/apiClient.d.ts +4 -4
- package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
- package/dist/components/hooks/useForm/expressionValidator.utils.d.ts +3 -3
- package/dist/components/hooks/useForm/expressionValidator.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/index.d.ts +7 -4
- package/dist/components/hooks/useForm/index.d.ts.map +1 -1
- package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts +5 -5
- package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts +7 -6
- package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/schemaParser.utils.d.ts +8 -8
- package/dist/components/hooks/useForm/schemaParser.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/types.d.ts +86 -93
- package/dist/components/hooks/useForm/types.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 +6 -46
- package/dist/components/hooks/useKanban/types.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -1
- package/dist/components/hooks/useTable/types.d.ts +5 -33
- package/dist/components/hooks/useTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useTable/useTable.d.ts +0 -5
- package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
- package/dist/index.cjs +13 -13
- package/dist/index.mjs +1990 -2234
- package/dist/types/common.d.ts +35 -26
- package/dist/types/common.d.ts.map +1 -1
- package/package.json +1 -1
- package/sdk/api/index.ts +7 -3
- package/sdk/components/hooks/index.ts +24 -4
- package/sdk/components/hooks/useFilter/index.ts +19 -18
- package/sdk/components/hooks/useFilter/types.ts +157 -123
- package/sdk/components/hooks/useFilter/useFilter.ts +259 -393
- package/sdk/components/hooks/useForm/apiClient.ts +5 -5
- package/sdk/components/hooks/useForm/expressionValidator.utils.ts +11 -11
- package/sdk/components/hooks/useForm/index.ts +41 -45
- package/sdk/components/hooks/useForm/optimizedExpressionValidator.utils.ts +7 -7
- package/sdk/components/hooks/useForm/ruleClassifier.utils.ts +21 -20
- package/sdk/components/hooks/useForm/schemaParser.utils.ts +36 -41
- package/sdk/components/hooks/useForm/types.ts +107 -113
- package/sdk/components/hooks/useForm/useForm.ts +54 -54
- package/sdk/components/hooks/useKanban/index.ts +0 -1
- package/sdk/components/hooks/useKanban/types.ts +8 -66
- package/sdk/components/hooks/useKanban/useKanban.ts +14 -75
- package/sdk/components/hooks/useTable/types.ts +7 -60
- package/sdk/components/hooks/useTable/useTable.ts +13 -121
- package/sdk/types/common.ts +42 -26
- package/dist/components/hooks/useFilter/payloadBuilder.utils.d.ts +0 -33
- package/dist/components/hooks/useFilter/payloadBuilder.utils.d.ts.map +0 -1
- package/sdk/components/hooks/useFilter/payloadBuilder.utils.ts +0 -298
|
@@ -32,11 +32,12 @@ export type ExtendedHandleSubmit<T extends RHFFieldValues> = {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
// ============================================================
|
|
35
|
-
//
|
|
35
|
+
// EXPRESSION TREE TYPES
|
|
36
36
|
// ============================================================
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Expression tree node types from backend validation system
|
|
40
|
+
* Used for evaluating validation rules, computed fields, and default values
|
|
40
41
|
*/
|
|
41
42
|
export interface ExpressionTree {
|
|
42
43
|
Type:
|
|
@@ -62,10 +63,15 @@ export interface ExpressionTree {
|
|
|
62
63
|
Value?: any;
|
|
63
64
|
}
|
|
64
65
|
|
|
66
|
+
// ============================================================
|
|
67
|
+
// SCHEMA DEFINITION TYPES (BDO - Business Data Object)
|
|
68
|
+
// ============================================================
|
|
69
|
+
|
|
65
70
|
/**
|
|
66
|
-
*
|
|
71
|
+
* Validation rule from BDO schema
|
|
72
|
+
* Defines a validation, computation, or business logic rule
|
|
67
73
|
*/
|
|
68
|
-
export interface
|
|
74
|
+
export interface SchemaValidationRule {
|
|
69
75
|
Id: string;
|
|
70
76
|
Name: string;
|
|
71
77
|
Description: string;
|
|
@@ -76,9 +82,9 @@ export interface ValidationRule {
|
|
|
76
82
|
}
|
|
77
83
|
|
|
78
84
|
/**
|
|
79
|
-
*
|
|
85
|
+
* Formula definition for computed fields
|
|
80
86
|
*/
|
|
81
|
-
export interface
|
|
87
|
+
export interface ComputedFieldFormula {
|
|
82
88
|
Id?: string;
|
|
83
89
|
Name?: string;
|
|
84
90
|
Description?: string;
|
|
@@ -88,17 +94,17 @@ export interface Formula {
|
|
|
88
94
|
}
|
|
89
95
|
|
|
90
96
|
/**
|
|
91
|
-
*
|
|
97
|
+
* Default value expression for a field
|
|
92
98
|
*/
|
|
93
|
-
export interface
|
|
99
|
+
export interface DefaultValueExpression {
|
|
94
100
|
Expression: string;
|
|
95
101
|
ExpressionTree: ExpressionTree;
|
|
96
102
|
}
|
|
97
103
|
|
|
98
104
|
/**
|
|
99
|
-
*
|
|
105
|
+
* Reference field configuration for dynamic lookups
|
|
100
106
|
*/
|
|
101
|
-
export interface
|
|
107
|
+
export interface ReferenceFieldConfig {
|
|
102
108
|
Mode: "Dynamic" | "Static";
|
|
103
109
|
Reference?: {
|
|
104
110
|
BusinessObject: string;
|
|
@@ -108,7 +114,7 @@ export interface ReferenceField {
|
|
|
108
114
|
LhsField: string;
|
|
109
115
|
Operator: string;
|
|
110
116
|
RhsType: string;
|
|
111
|
-
RhsValue?:
|
|
117
|
+
RhsValue?: DefaultValueExpression;
|
|
112
118
|
}>;
|
|
113
119
|
};
|
|
114
120
|
Sort?: Array<{
|
|
@@ -119,21 +125,21 @@ export interface ReferenceField {
|
|
|
119
125
|
}
|
|
120
126
|
|
|
121
127
|
/**
|
|
122
|
-
*
|
|
128
|
+
* Field options configuration for select/dropdown fields
|
|
123
129
|
*/
|
|
124
|
-
export interface
|
|
130
|
+
export interface FieldOptionsConfig {
|
|
125
131
|
Mode: "Static" | "Dynamic";
|
|
126
132
|
Items?: Array<{
|
|
127
133
|
Value: string | number | boolean;
|
|
128
134
|
Label: string;
|
|
129
135
|
}>;
|
|
130
|
-
Reference?:
|
|
136
|
+
Reference?: ReferenceFieldConfig["Reference"];
|
|
131
137
|
}
|
|
132
138
|
|
|
133
139
|
/**
|
|
134
|
-
*
|
|
140
|
+
* BDO field definition structure
|
|
135
141
|
*/
|
|
136
|
-
export interface
|
|
142
|
+
export interface BDOFieldDefinition {
|
|
137
143
|
Id: string;
|
|
138
144
|
Name: string;
|
|
139
145
|
Type:
|
|
@@ -148,16 +154,16 @@ export interface BackendFieldDefinition {
|
|
|
148
154
|
| "ActivityFlow";
|
|
149
155
|
Required?: boolean;
|
|
150
156
|
Unique?: boolean;
|
|
151
|
-
DefaultValue?:
|
|
152
|
-
Formula?:
|
|
157
|
+
DefaultValue?: DefaultValueExpression;
|
|
158
|
+
Formula?: ComputedFieldFormula;
|
|
153
159
|
Computed?: boolean;
|
|
154
|
-
Validation?: string[] |
|
|
155
|
-
Values?:
|
|
160
|
+
Validation?: string[] | SchemaValidationRule[]; // Array of rule IDs OR inline validation rule objects
|
|
161
|
+
Values?: FieldOptionsConfig;
|
|
156
162
|
Items?: {
|
|
157
163
|
Type: string;
|
|
158
|
-
Property?: Record<string,
|
|
164
|
+
Property?: Record<string, BDOFieldDefinition>;
|
|
159
165
|
};
|
|
160
|
-
Property?: Record<string,
|
|
166
|
+
Property?: Record<string, BDOFieldDefinition>;
|
|
161
167
|
Description?: string;
|
|
162
168
|
}
|
|
163
169
|
|
|
@@ -165,9 +171,9 @@ export interface BackendFieldDefinition {
|
|
|
165
171
|
* Business Object Rule definitions from BDO schema
|
|
166
172
|
*/
|
|
167
173
|
export interface BusinessObjectRules {
|
|
168
|
-
Computation?: Record<string,
|
|
169
|
-
Validation?: Record<string,
|
|
170
|
-
BusinessLogic?: Record<string,
|
|
174
|
+
Computation?: Record<string, SchemaValidationRule>;
|
|
175
|
+
Validation?: Record<string, SchemaValidationRule>;
|
|
176
|
+
BusinessLogic?: Record<string, SchemaValidationRule>;
|
|
171
177
|
}
|
|
172
178
|
|
|
173
179
|
/**
|
|
@@ -189,7 +195,7 @@ export interface RolePermission {
|
|
|
189
195
|
}
|
|
190
196
|
|
|
191
197
|
/**
|
|
192
|
-
* Complete BDO
|
|
198
|
+
* Complete BDO (Business Data Object) schema structure
|
|
193
199
|
*/
|
|
194
200
|
export interface BDOSchema {
|
|
195
201
|
Id: string;
|
|
@@ -197,7 +203,7 @@ export interface BDOSchema {
|
|
|
197
203
|
Kind: "BusinessObject";
|
|
198
204
|
Description: string;
|
|
199
205
|
Rules: BusinessObjectRules;
|
|
200
|
-
Fields: Record<string,
|
|
206
|
+
Fields: Record<string, BDOFieldDefinition>;
|
|
201
207
|
RolePermission: Record<string, RolePermission>;
|
|
202
208
|
Roles: Record<
|
|
203
209
|
string,
|
|
@@ -208,13 +214,6 @@ export interface BDOSchema {
|
|
|
208
214
|
>;
|
|
209
215
|
}
|
|
210
216
|
|
|
211
|
-
/**
|
|
212
|
-
* Complete backend schema response structure (legacy support)
|
|
213
|
-
*/
|
|
214
|
-
export interface BackendSchema {
|
|
215
|
-
[fieldName: string]: BackendFieldDefinition;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
217
|
// ============================================================
|
|
219
218
|
// FORM CONFIGURATION TYPES
|
|
220
219
|
// ============================================================
|
|
@@ -234,18 +233,6 @@ export type FormMode = Mode;
|
|
|
234
233
|
*/
|
|
235
234
|
export type RuleType = "Validation" | "Computation" | "BusinessLogic";
|
|
236
235
|
|
|
237
|
-
/**
|
|
238
|
-
* Rule execution context
|
|
239
|
-
*/
|
|
240
|
-
export interface RuleExecutionContext<T> {
|
|
241
|
-
ruleType: RuleType;
|
|
242
|
-
ruleId: string;
|
|
243
|
-
fieldName: keyof T;
|
|
244
|
-
fieldValue: any;
|
|
245
|
-
formValues: Partial<T>;
|
|
246
|
-
rule: ValidationRule;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
236
|
/**
|
|
250
237
|
* useForm hook options with strict typing
|
|
251
238
|
*/
|
|
@@ -301,14 +288,11 @@ export interface UseFormOptions<
|
|
|
301
288
|
/** Submit error callback */
|
|
302
289
|
onSubmitError?: (error: Error) => void;
|
|
303
290
|
|
|
304
|
-
/** Computation rule callback (called when computation rules are triggered) */
|
|
305
|
-
onComputationRule?: (context: RuleExecutionContext<T>) => Promise<Partial<T>>;
|
|
306
|
-
|
|
307
291
|
/** Skip schema fetching (use for testing) */
|
|
308
292
|
skipSchemaFetch?: boolean;
|
|
309
293
|
|
|
310
294
|
/** Manual schema (use instead of fetching) */
|
|
311
|
-
schema?:
|
|
295
|
+
schema?: BDOSchema;
|
|
312
296
|
|
|
313
297
|
/**
|
|
314
298
|
* Trigger draft API call on every field change (after validation passes)
|
|
@@ -319,7 +303,7 @@ export interface UseFormOptions<
|
|
|
319
303
|
}
|
|
320
304
|
|
|
321
305
|
// ============================================================
|
|
322
|
-
//
|
|
306
|
+
// FORM FIELD CONFIGURATION TYPES
|
|
323
307
|
// ============================================================
|
|
324
308
|
|
|
325
309
|
/**
|
|
@@ -337,98 +321,108 @@ export interface FieldPermission {
|
|
|
337
321
|
}
|
|
338
322
|
|
|
339
323
|
/**
|
|
340
|
-
*
|
|
324
|
+
* Field input types for form rendering
|
|
341
325
|
*/
|
|
342
|
-
export
|
|
343
|
-
|
|
326
|
+
export type FormFieldType =
|
|
327
|
+
| "text"
|
|
328
|
+
| "number"
|
|
329
|
+
| "email"
|
|
330
|
+
| "password"
|
|
331
|
+
| "date"
|
|
332
|
+
| "datetime-local"
|
|
333
|
+
| "checkbox"
|
|
334
|
+
| "select"
|
|
335
|
+
| "textarea"
|
|
336
|
+
| "reference";
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Select option for dropdown fields
|
|
340
|
+
*/
|
|
341
|
+
export interface SelectOption {
|
|
342
|
+
value: any;
|
|
343
|
+
label: string;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Field rule IDs by category
|
|
348
|
+
*/
|
|
349
|
+
export interface FieldRuleIds {
|
|
350
|
+
validation: string[];
|
|
351
|
+
computation: string[];
|
|
352
|
+
businessLogic: string[];
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Form field configuration for rendering
|
|
357
|
+
* Contains all metadata needed to render and validate a form field
|
|
358
|
+
*/
|
|
359
|
+
export interface FormFieldConfig {
|
|
360
|
+
/** Field name/identifier */
|
|
344
361
|
name: string;
|
|
345
362
|
|
|
346
|
-
/** Field type */
|
|
347
|
-
type:
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
| "email"
|
|
351
|
-
| "password"
|
|
352
|
-
| "date"
|
|
353
|
-
| "datetime-local"
|
|
354
|
-
| "checkbox"
|
|
355
|
-
| "select"
|
|
356
|
-
| "textarea"
|
|
357
|
-
| "reference";
|
|
358
|
-
|
|
359
|
-
/** Field label (derived from name or schema) */
|
|
363
|
+
/** Field input type */
|
|
364
|
+
type: FormFieldType;
|
|
365
|
+
|
|
366
|
+
/** Display label */
|
|
360
367
|
label: string;
|
|
361
368
|
|
|
362
369
|
/** Whether field is required */
|
|
363
370
|
required: boolean;
|
|
364
371
|
|
|
365
|
-
/** Whether field is computed (read-only) */
|
|
372
|
+
/** Whether field is computed (read-only, auto-calculated) */
|
|
366
373
|
computed: boolean;
|
|
367
374
|
|
|
368
375
|
/** Default value */
|
|
369
376
|
defaultValue?: any;
|
|
370
377
|
|
|
371
378
|
/** Select options (for select/reference fields) */
|
|
372
|
-
options?:
|
|
373
|
-
value: any;
|
|
374
|
-
label: string;
|
|
375
|
-
}>;
|
|
379
|
+
options?: SelectOption[];
|
|
376
380
|
|
|
377
|
-
/** Validation
|
|
381
|
+
/** Validation configuration */
|
|
378
382
|
validation: any;
|
|
379
383
|
|
|
380
384
|
/** Field description/help text */
|
|
381
385
|
description?: string;
|
|
382
386
|
|
|
383
|
-
/**
|
|
384
|
-
|
|
387
|
+
/** Original BDO field definition (for advanced use) */
|
|
388
|
+
_bdoField: BDOFieldDefinition;
|
|
385
389
|
|
|
386
390
|
/** Field permissions for current user */
|
|
387
391
|
permission: FieldPermission;
|
|
388
392
|
|
|
389
|
-
/**
|
|
390
|
-
rules:
|
|
391
|
-
validation: string[];
|
|
392
|
-
computation: string[];
|
|
393
|
-
businessLogic: string[];
|
|
394
|
-
};
|
|
393
|
+
/** Associated rule IDs by category */
|
|
394
|
+
rules: FieldRuleIds;
|
|
395
395
|
}
|
|
396
396
|
|
|
397
397
|
/**
|
|
398
|
-
* Form schema after processing
|
|
398
|
+
* Form schema configuration after processing
|
|
399
|
+
* Contains all fields and rules ready for form rendering
|
|
399
400
|
*/
|
|
400
|
-
export interface
|
|
401
|
-
/** All fields */
|
|
402
|
-
fields: Record<string,
|
|
401
|
+
export interface FormSchemaConfig {
|
|
402
|
+
/** All fields by name */
|
|
403
|
+
fields: Record<string, FormFieldConfig>;
|
|
403
404
|
|
|
404
|
-
/** Field names in order */
|
|
405
|
+
/** Field names in display order */
|
|
405
406
|
fieldOrder: string[];
|
|
406
407
|
|
|
407
|
-
/**
|
|
408
|
+
/** Names of computed fields */
|
|
408
409
|
computedFields: string[];
|
|
409
410
|
|
|
410
|
-
/**
|
|
411
|
+
/** Names of required fields */
|
|
411
412
|
requiredFields: string[];
|
|
412
413
|
|
|
413
414
|
/** Cross-field validation rules */
|
|
414
|
-
crossFieldValidation:
|
|
415
|
+
crossFieldValidation: SchemaValidationRule[];
|
|
415
416
|
|
|
416
417
|
/** Classified rules by type */
|
|
417
418
|
rules: {
|
|
418
|
-
validation: Record<string,
|
|
419
|
-
computation: Record<string,
|
|
420
|
-
businessLogic: Record<string,
|
|
419
|
+
validation: Record<string, SchemaValidationRule>;
|
|
420
|
+
computation: Record<string, SchemaValidationRule>;
|
|
421
|
+
businessLogic: Record<string, SchemaValidationRule>;
|
|
421
422
|
};
|
|
422
423
|
|
|
423
424
|
/** Field-to-rule mapping for quick lookup */
|
|
424
|
-
fieldRules: Record<
|
|
425
|
-
string,
|
|
426
|
-
{
|
|
427
|
-
validation: string[];
|
|
428
|
-
computation: string[];
|
|
429
|
-
businessLogic: string[];
|
|
430
|
-
}
|
|
431
|
-
>;
|
|
425
|
+
fieldRules: Record<string, FieldRuleIds>;
|
|
432
426
|
|
|
433
427
|
/** Role permissions */
|
|
434
428
|
rolePermissions?: Record<string, RolePermission>;
|
|
@@ -532,11 +526,11 @@ export interface UseFormReturn<
|
|
|
532
526
|
// SCHEMA INFORMATION WITH STRICT TYPING
|
|
533
527
|
// ============================================================
|
|
534
528
|
|
|
535
|
-
/** Raw
|
|
536
|
-
schema:
|
|
529
|
+
/** Raw BDO schema */
|
|
530
|
+
schema: BDOSchema | null;
|
|
537
531
|
|
|
538
|
-
/** Processed schema for rendering */
|
|
539
|
-
|
|
532
|
+
/** Processed schema configuration for rendering */
|
|
533
|
+
schemaConfig: FormSchemaConfig | null;
|
|
540
534
|
|
|
541
535
|
/** Computed field names as typed array */
|
|
542
536
|
computedFields: Array<keyof T>;
|
|
@@ -548,11 +542,11 @@ export interface UseFormReturn<
|
|
|
548
542
|
// FIELD HELPERS WITH STRICT TYPING
|
|
549
543
|
// ============================================================
|
|
550
544
|
|
|
551
|
-
/** Get field
|
|
552
|
-
getField: <K extends keyof T>(fieldName: K) =>
|
|
545
|
+
/** Get field configuration with strict typing */
|
|
546
|
+
getField: <K extends keyof T>(fieldName: K) => FormFieldConfig | null;
|
|
553
547
|
|
|
554
|
-
/** Get all
|
|
555
|
-
getFields: () => Record<keyof T,
|
|
548
|
+
/** Get all field configurations with strict typing */
|
|
549
|
+
getFields: () => Record<keyof T, FormFieldConfig>;
|
|
556
550
|
|
|
557
551
|
/** Check if field exists with strict typing */
|
|
558
552
|
hasField: <K extends keyof T>(fieldName: K) => boolean;
|
|
@@ -581,13 +575,13 @@ export interface UseFormReturn<
|
|
|
581
575
|
}
|
|
582
576
|
|
|
583
577
|
// ============================================================
|
|
584
|
-
//
|
|
578
|
+
// RESULT TYPES
|
|
585
579
|
// ============================================================
|
|
586
580
|
|
|
587
581
|
/**
|
|
588
|
-
* Expression evaluation context
|
|
582
|
+
* Expression evaluation context
|
|
589
583
|
*/
|
|
590
|
-
export interface
|
|
584
|
+
export interface ExpressionContext<T = Record<string, any>> {
|
|
591
585
|
/** Current form values */
|
|
592
586
|
formValues: Partial<T>;
|
|
593
587
|
|
|
@@ -599,9 +593,9 @@ export interface EvaluationContext<T = Record<string, any>> {
|
|
|
599
593
|
}
|
|
600
594
|
|
|
601
595
|
/**
|
|
602
|
-
*
|
|
596
|
+
* Field validation result
|
|
603
597
|
*/
|
|
604
|
-
export interface
|
|
598
|
+
export interface FieldValidationResult<T = Record<string, any>> {
|
|
605
599
|
/** Is validation passing */
|
|
606
600
|
isValid: boolean;
|
|
607
601
|
|