@ram_28/kf-ai-sdk 1.0.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.
Files changed (126) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +840 -0
  3. package/dist/api/client.d.ts +78 -0
  4. package/dist/api/client.d.ts.map +1 -0
  5. package/dist/api/datetime.d.ts +21 -0
  6. package/dist/api/datetime.d.ts.map +1 -0
  7. package/dist/api/index.d.ts +7 -0
  8. package/dist/api/index.d.ts.map +1 -0
  9. package/dist/api/metadata.d.ts +75 -0
  10. package/dist/api/metadata.d.ts.map +1 -0
  11. package/dist/components/hooks/index.d.ts +8 -0
  12. package/dist/components/hooks/index.d.ts.map +1 -0
  13. package/dist/components/hooks/useFilter/index.d.ts +5 -0
  14. package/dist/components/hooks/useFilter/index.d.ts.map +1 -0
  15. package/dist/components/hooks/useFilter/payloadBuilder.utils.d.ts +33 -0
  16. package/dist/components/hooks/useFilter/payloadBuilder.utils.d.ts.map +1 -0
  17. package/dist/components/hooks/useFilter/types.d.ts +137 -0
  18. package/dist/components/hooks/useFilter/types.d.ts.map +1 -0
  19. package/dist/components/hooks/useFilter/useFilter.d.ts +3 -0
  20. package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -0
  21. package/dist/components/hooks/useFilter/validation.utils.d.ts +38 -0
  22. package/dist/components/hooks/useFilter/validation.utils.d.ts.map +1 -0
  23. package/dist/components/hooks/useForm/apiClient.d.ts +71 -0
  24. package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -0
  25. package/dist/components/hooks/useForm/expressionValidator.utils.d.ts +28 -0
  26. package/dist/components/hooks/useForm/expressionValidator.utils.d.ts.map +1 -0
  27. package/dist/components/hooks/useForm/index.d.ts +6 -0
  28. package/dist/components/hooks/useForm/index.d.ts.map +1 -0
  29. package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts +88 -0
  30. package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts.map +1 -0
  31. package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts +28 -0
  32. package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts.map +1 -0
  33. package/dist/components/hooks/useForm/schemaParser.utils.d.ts +29 -0
  34. package/dist/components/hooks/useForm/schemaParser.utils.d.ts.map +1 -0
  35. package/dist/components/hooks/useForm/types.d.ts +412 -0
  36. package/dist/components/hooks/useForm/types.d.ts.map +1 -0
  37. package/dist/components/hooks/useForm/useForm.d.ts +3 -0
  38. package/dist/components/hooks/useForm/useForm.d.ts.map +1 -0
  39. package/dist/components/hooks/useKanban/apiClient.d.ts +99 -0
  40. package/dist/components/hooks/useKanban/apiClient.d.ts.map +1 -0
  41. package/dist/components/hooks/useKanban/context.d.ts +4 -0
  42. package/dist/components/hooks/useKanban/context.d.ts.map +1 -0
  43. package/dist/components/hooks/useKanban/dragDropManager.d.ts +27 -0
  44. package/dist/components/hooks/useKanban/dragDropManager.d.ts.map +1 -0
  45. package/dist/components/hooks/useKanban/index.d.ts +6 -0
  46. package/dist/components/hooks/useKanban/index.d.ts.map +1 -0
  47. package/dist/components/hooks/useKanban/types.d.ts +438 -0
  48. package/dist/components/hooks/useKanban/types.d.ts.map +1 -0
  49. package/dist/components/hooks/useKanban/useKanban.d.ts +3 -0
  50. package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -0
  51. package/dist/components/hooks/useKanban/useKanbanSimple.d.ts +62 -0
  52. package/dist/components/hooks/useKanban/useKanbanSimple.d.ts.map +1 -0
  53. package/dist/components/hooks/useTable/index.d.ts +3 -0
  54. package/dist/components/hooks/useTable/index.d.ts.map +1 -0
  55. package/dist/components/hooks/useTable/types.d.ts +107 -0
  56. package/dist/components/hooks/useTable/types.d.ts.map +1 -0
  57. package/dist/components/hooks/useTable/useTable.d.ts +8 -0
  58. package/dist/components/hooks/useTable/useTable.d.ts.map +1 -0
  59. package/dist/components/index.d.ts +3 -0
  60. package/dist/components/index.d.ts.map +1 -0
  61. package/dist/components/ui/index.d.ts +2 -0
  62. package/dist/components/ui/index.d.ts.map +1 -0
  63. package/dist/components/ui/kanban/Kanban.d.ts +12 -0
  64. package/dist/components/ui/kanban/Kanban.d.ts.map +1 -0
  65. package/dist/components/ui/kanban/index.d.ts +2 -0
  66. package/dist/components/ui/kanban/index.d.ts.map +1 -0
  67. package/dist/index.cjs +45 -0
  68. package/dist/index.d.ts +5 -0
  69. package/dist/index.d.ts.map +1 -0
  70. package/dist/index.mjs +6522 -0
  71. package/dist/types/base-fields.d.ts +182 -0
  72. package/dist/types/base-fields.d.ts.map +1 -0
  73. package/dist/types/common.d.ts +238 -0
  74. package/dist/types/common.d.ts.map +1 -0
  75. package/dist/types/index.d.ts +3 -0
  76. package/dist/types/index.d.ts.map +1 -0
  77. package/dist/utils/cn.d.ts +7 -0
  78. package/dist/utils/cn.d.ts.map +1 -0
  79. package/dist/utils/formatting.d.ts +52 -0
  80. package/dist/utils/formatting.d.ts.map +1 -0
  81. package/dist/utils/index.d.ts +3 -0
  82. package/dist/utils/index.d.ts.map +1 -0
  83. package/package.json +98 -0
  84. package/sdk/api/client.ts +447 -0
  85. package/sdk/api/datetime.ts +33 -0
  86. package/sdk/api/index.ts +61 -0
  87. package/sdk/api/metadata.ts +148 -0
  88. package/sdk/components/hooks/index.ts +34 -0
  89. package/sdk/components/hooks/useFilter/index.ts +37 -0
  90. package/sdk/components/hooks/useFilter/payloadBuilder.utils.ts +298 -0
  91. package/sdk/components/hooks/useFilter/types.ts +158 -0
  92. package/sdk/components/hooks/useFilter/useFilter.llm.txt +497 -0
  93. package/sdk/components/hooks/useFilter/useFilter.ts +494 -0
  94. package/sdk/components/hooks/useFilter/validation.utils.ts +401 -0
  95. package/sdk/components/hooks/useForm/apiClient.ts +441 -0
  96. package/sdk/components/hooks/useForm/expressionValidator.utils.ts +444 -0
  97. package/sdk/components/hooks/useForm/index.ts +64 -0
  98. package/sdk/components/hooks/useForm/optimizedExpressionValidator.utils.ts +482 -0
  99. package/sdk/components/hooks/useForm/ruleClassifier.utils.ts +424 -0
  100. package/sdk/components/hooks/useForm/schemaParser.utils.ts +519 -0
  101. package/sdk/components/hooks/useForm/types.ts +630 -0
  102. package/sdk/components/hooks/useForm/useForm.llm.txt +340 -0
  103. package/sdk/components/hooks/useForm/useForm.ts +821 -0
  104. package/sdk/components/hooks/useKanban/apiClient.ts +494 -0
  105. package/sdk/components/hooks/useKanban/context.ts +14 -0
  106. package/sdk/components/hooks/useKanban/dragDropManager.ts +529 -0
  107. package/sdk/components/hooks/useKanban/index.ts +63 -0
  108. package/sdk/components/hooks/useKanban/types.ts +606 -0
  109. package/sdk/components/hooks/useKanban/useKanban.llm.txt +482 -0
  110. package/sdk/components/hooks/useKanban/useKanban.ts +725 -0
  111. package/sdk/components/hooks/useKanban/useKanbanSimple.ts +389 -0
  112. package/sdk/components/hooks/useTable/index.ts +5 -0
  113. package/sdk/components/hooks/useTable/types.ts +154 -0
  114. package/sdk/components/hooks/useTable/useTable.llm.txt +344 -0
  115. package/sdk/components/hooks/useTable/useTable.ts +413 -0
  116. package/sdk/components/index.ts +15 -0
  117. package/sdk/components/ui/index.ts +2 -0
  118. package/sdk/components/ui/kanban/Kanban.tsx +134 -0
  119. package/sdk/components/ui/kanban/index.ts +11 -0
  120. package/sdk/index.ts +13 -0
  121. package/sdk/types/base-fields.ts +221 -0
  122. package/sdk/types/common.ts +306 -0
  123. package/sdk/types/index.ts +5 -0
  124. package/sdk/utils/cn.ts +10 -0
  125. package/sdk/utils/formatting.ts +212 -0
  126. package/sdk/utils/index.ts +5 -0
@@ -0,0 +1,630 @@
1
+ // ============================================================
2
+ // TYPE DEFINITIONS FOR useForm HOOK
3
+ // ============================================================
4
+
5
+ import type {
6
+ UseFormRegister,
7
+ Mode,
8
+ FieldValues as RHFFieldValues,
9
+ SubmitHandler,
10
+ SubmitErrorHandler,
11
+ FieldErrors,
12
+ Path,
13
+ PathValue,
14
+ RegisterOptions,
15
+ SetValueConfig,
16
+ FormState,
17
+ } from "react-hook-form";
18
+
19
+ // ============================================================
20
+ // CUSTOM HANDLE SUBMIT TYPE
21
+ // ============================================================
22
+
23
+ /**
24
+ * Extended handleSubmit that allows optional callbacks
25
+ * When no callback is provided, uses the SDK's built-in submit function
26
+ */
27
+ export type ExtendedHandleSubmit<T extends RHFFieldValues> = {
28
+ (
29
+ onValid?: SubmitHandler<T>,
30
+ onInvalid?: SubmitErrorHandler<T>
31
+ ): (e?: React.BaseSyntheticEvent) => Promise<void>;
32
+ };
33
+
34
+ // ============================================================
35
+ // BACKEND SCHEMA TYPES
36
+ // ============================================================
37
+
38
+ /**
39
+ * Expression tree node types from backend validation system
40
+ */
41
+ export interface ExpressionTree {
42
+ Type:
43
+ | "BinaryExpression"
44
+ | "LogicalExpression"
45
+ | "CallExpression"
46
+ | "MemberExpression"
47
+ | "AssignmentExpression"
48
+ | "SystemIdentifier"
49
+ | "Identifier"
50
+ | "Literal";
51
+ Operator?: string;
52
+ Callee?: string;
53
+ Arguments?: ExpressionTree[];
54
+ Name?: string;
55
+ Source?: string;
56
+ Property?: {
57
+ Name: string;
58
+ Property?: {
59
+ Name: string;
60
+ };
61
+ };
62
+ Value?: any;
63
+ }
64
+
65
+ /**
66
+ * Backend validation rule structure
67
+ */
68
+ export interface ValidationRule {
69
+ Id: string;
70
+ Name: string;
71
+ Description: string;
72
+ Expression: string;
73
+ ExpressionTree: ExpressionTree;
74
+ ResultType: string;
75
+ Message?: string;
76
+ }
77
+
78
+ /**
79
+ * Backend formula structure for computed fields
80
+ */
81
+ export interface Formula {
82
+ Id?: string;
83
+ Name?: string;
84
+ Description?: string;
85
+ Expression: string;
86
+ ExpressionTree: ExpressionTree;
87
+ ResultType?: string;
88
+ }
89
+
90
+ /**
91
+ * Backend default value structure
92
+ */
93
+ export interface DefaultValue {
94
+ Expression: string;
95
+ ExpressionTree: ExpressionTree;
96
+ }
97
+
98
+ /**
99
+ * Backend reference field configuration
100
+ */
101
+ export interface ReferenceField {
102
+ Mode: "Dynamic" | "Static";
103
+ Reference?: {
104
+ BusinessObject: string;
105
+ Fields: string[];
106
+ Filters?: {
107
+ Condition: Array<{
108
+ LhsField: string;
109
+ Operator: string;
110
+ RhsType: string;
111
+ RhsValue?: DefaultValue;
112
+ }>;
113
+ };
114
+ Sort?: Array<{
115
+ Field: string;
116
+ Order: "ASC" | "DESC";
117
+ }>;
118
+ };
119
+ }
120
+
121
+ /**
122
+ * Backend values configuration for select fields
123
+ */
124
+ export interface FieldValues {
125
+ Mode: "Static" | "Dynamic";
126
+ Items?: Array<{
127
+ Value: string | number | boolean;
128
+ Label: string;
129
+ }>;
130
+ Reference?: ReferenceField["Reference"];
131
+ }
132
+
133
+ /**
134
+ * Backend field definition structure
135
+ */
136
+ export interface BackendFieldDefinition {
137
+ Id: string;
138
+ Name: string;
139
+ Type:
140
+ | "String"
141
+ | "Number"
142
+ | "Boolean"
143
+ | "Date"
144
+ | "DateTime"
145
+ | "Reference"
146
+ | "Array"
147
+ | "Object"
148
+ | "ActivityFlow";
149
+ Required?: boolean;
150
+ Unique?: boolean;
151
+ DefaultValue?: DefaultValue;
152
+ Formula?: Formula;
153
+ Computed?: boolean;
154
+ Validation?: string[] | ValidationRule[]; // Array of rule IDs OR inline validation rule objects
155
+ Values?: FieldValues;
156
+ Items?: {
157
+ Type: string;
158
+ Property?: Record<string, BackendFieldDefinition>;
159
+ };
160
+ Property?: Record<string, BackendFieldDefinition>;
161
+ Description?: string;
162
+ }
163
+
164
+ /**
165
+ * Business Object Rule definitions from BDO schema
166
+ */
167
+ export interface BusinessObjectRules {
168
+ Computation?: Record<string, ValidationRule>;
169
+ Validation?: Record<string, ValidationRule>;
170
+ BusinessLogic?: Record<string, ValidationRule>;
171
+ }
172
+
173
+ /**
174
+ * Role permission definition from BDO schema
175
+ */
176
+ export interface RolePermission {
177
+ Editable?: string[];
178
+ ReadOnly?: string[];
179
+ Methods?: string[];
180
+ Filters?: {
181
+ Operator: "AND" | "OR";
182
+ Condition: Array<{
183
+ LhsField: string;
184
+ Operator: string;
185
+ RhsType: "Literal" | "Field";
186
+ RhsValue: any;
187
+ }>;
188
+ };
189
+ }
190
+
191
+ /**
192
+ * Complete BDO schema structure matching your JSON
193
+ */
194
+ export interface BDOSchema {
195
+ Id: string;
196
+ Name: string;
197
+ Kind: "BusinessObject";
198
+ Description: string;
199
+ Rules: BusinessObjectRules;
200
+ Fields: Record<string, BackendFieldDefinition>;
201
+ RolePermission: Record<string, RolePermission>;
202
+ Roles: Record<
203
+ string,
204
+ {
205
+ Name: string;
206
+ Description: string;
207
+ }
208
+ >;
209
+ }
210
+
211
+ /**
212
+ * Complete backend schema response structure (legacy support)
213
+ */
214
+ export interface BackendSchema {
215
+ [fieldName: string]: BackendFieldDefinition;
216
+ }
217
+
218
+ // ============================================================
219
+ // FORM CONFIGURATION TYPES
220
+ // ============================================================
221
+
222
+ /**
223
+ * Form operation mode
224
+ */
225
+ export type FormOperation = "create" | "update";
226
+
227
+ /**
228
+ * Form validation mode (from react-hook-form)
229
+ */
230
+ export type FormMode = Mode;
231
+
232
+ /**
233
+ * Rule classification types
234
+ */
235
+ export type RuleType = "Validation" | "Computation" | "BusinessLogic";
236
+
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
+ /**
250
+ * useForm hook options with strict typing
251
+ */
252
+ export interface UseFormOptions<
253
+ T extends Record<string, any> = Record<string, any>,
254
+ > {
255
+ /** Data source identifier (Business Object name) */
256
+ source: string;
257
+
258
+ /** Form operation type */
259
+ operation: FormOperation;
260
+
261
+ /** Record ID for update operations */
262
+ recordId?: string;
263
+
264
+ /** Default form values */
265
+ defaultValues?: Partial<T>;
266
+
267
+ /**
268
+ * Validation mode - controls when validation runs and errors are displayed
269
+ *
270
+ * Available modes:
271
+ * - "onSubmit" (default in react-hook-form): Validate only when form is submitted
272
+ * - "onBlur" (default in useForm): Validate when field loses focus
273
+ * - "onChange": Validate on every keystroke/change
274
+ * - "onTouched": Validate on first blur, then on every change after
275
+ * - "all": Validate on both blur and change
276
+ *
277
+ * **Important:** Computation (draft API calls) ALWAYS fires on blur regardless of mode,
278
+ * but only if the field value is valid. In "onSubmit" mode, computation will fire
279
+ * on blur since no validation has occurred yet (validation happens at submit time).
280
+ *
281
+ * @default "onBlur"
282
+ * @see https://react-hook-form.com/docs/useform for more details on validation modes
283
+ */
284
+ mode?: FormMode;
285
+
286
+ /** Whether to enable schema fetching and form initialization (default: true) */
287
+ enabled?: boolean;
288
+
289
+ /** User role for permission enforcement */
290
+ userRole?: string;
291
+
292
+ /** Success callback */
293
+ onSuccess?: (data: T) => void;
294
+
295
+ /** Error callback */
296
+ onError?: (error: Error) => void;
297
+
298
+ /** Schema load error callback */
299
+ onSchemaError?: (error: Error) => void;
300
+
301
+ /** Submit error callback */
302
+ onSubmitError?: (error: Error) => void;
303
+
304
+ /** Computation rule callback (called when computation rules are triggered) */
305
+ onComputationRule?: (context: RuleExecutionContext<T>) => Promise<Partial<T>>;
306
+
307
+ /** Skip schema fetching (use for testing) */
308
+ skipSchemaFetch?: boolean;
309
+
310
+ /** Manual schema (use instead of fetching) */
311
+ schema?: BackendSchema | BDOSchema;
312
+
313
+ /**
314
+ * Trigger draft API call on every field change (after validation passes)
315
+ * If true: draft API is called for any field change
316
+ * If false (default): draft API is called only when computed field dependencies change
317
+ */
318
+ draftOnEveryChange?: boolean;
319
+ }
320
+
321
+ // ============================================================
322
+ // PROCESSED FORM TYPES
323
+ // ============================================================
324
+
325
+ /**
326
+ * Field permission for current user
327
+ */
328
+ export interface FieldPermission {
329
+ /** Can user edit this field */
330
+ editable: boolean;
331
+
332
+ /** Can user see this field */
333
+ readable: boolean;
334
+
335
+ /** Is field completely hidden */
336
+ hidden: boolean;
337
+ }
338
+
339
+ /**
340
+ * Processed field metadata for form rendering
341
+ */
342
+ export interface ProcessedField {
343
+ /** Field name */
344
+ name: string;
345
+
346
+ /** Field type */
347
+ type:
348
+ | "text"
349
+ | "number"
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) */
360
+ label: string;
361
+
362
+ /** Whether field is required */
363
+ required: boolean;
364
+
365
+ /** Whether field is computed (read-only) */
366
+ computed: boolean;
367
+
368
+ /** Default value */
369
+ defaultValue?: any;
370
+
371
+ /** Select options (for select/reference fields) */
372
+ options?: Array<{
373
+ value: any;
374
+ label: string;
375
+ }>;
376
+
377
+ /** Validation rules */
378
+ validation: any;
379
+
380
+ /** Field description/help text */
381
+ description?: string;
382
+
383
+ /** Backend field definition */
384
+ backendField: BackendFieldDefinition;
385
+
386
+ /** Field permissions for current user */
387
+ permission: FieldPermission;
388
+
389
+ /** Rule classifications for this field */
390
+ rules: {
391
+ validation: string[];
392
+ computation: string[];
393
+ businessLogic: string[];
394
+ };
395
+ }
396
+
397
+ /**
398
+ * Form schema after processing
399
+ */
400
+ export interface ProcessedSchema {
401
+ /** All fields */
402
+ fields: Record<string, ProcessedField>;
403
+
404
+ /** Field names in order */
405
+ fieldOrder: string[];
406
+
407
+ /** Computed field names */
408
+ computedFields: string[];
409
+
410
+ /** Required field names */
411
+ requiredFields: string[];
412
+
413
+ /** Cross-field validation rules */
414
+ crossFieldValidation: ValidationRule[];
415
+
416
+ /** Classified rules by type */
417
+ rules: {
418
+ validation: Record<string, ValidationRule>;
419
+ computation: Record<string, ValidationRule>;
420
+ businessLogic: Record<string, ValidationRule>;
421
+ };
422
+
423
+ /** Field-to-rule mapping for quick lookup */
424
+ fieldRules: Record<
425
+ string,
426
+ {
427
+ validation: string[];
428
+ computation: string[];
429
+ businessLogic: string[];
430
+ }
431
+ >;
432
+
433
+ /** Role permissions */
434
+ rolePermissions?: Record<string, RolePermission>;
435
+ }
436
+
437
+ // ============================================================
438
+ // HOOK RETURN TYPES
439
+ // ============================================================
440
+
441
+ /**
442
+ * useForm hook return type with flattened state access and strict typing
443
+ */
444
+ export interface UseFormReturn<
445
+ T extends Record<string, any> = Record<string, any>,
446
+ > {
447
+ // ============================================================
448
+ // FORM METHODS WITH STRICT TYPING
449
+ // ============================================================
450
+
451
+ /** Register field for validation and form handling with strict typing */
452
+ register: <K extends Path<T>>(
453
+ name: K,
454
+ options?: RegisterOptions<T, K>
455
+ ) => ReturnType<UseFormRegister<T>>;
456
+
457
+ /** Handle form submission - automatically uses SDK's submit logic */
458
+ handleSubmit: () => (e?: React.BaseSyntheticEvent) => Promise<void>;
459
+
460
+ /** Watch field values with strict typing */
461
+ watch: <K extends Path<T> | readonly Path<T>[]>(
462
+ name?: K
463
+ ) => K extends Path<T>
464
+ ? PathValue<T, K>
465
+ : K extends readonly Path<T>[]
466
+ ? PathValue<T, K[number]>[]
467
+ : T;
468
+
469
+ /** Set field value programmatically with strict typing */
470
+ setValue: <K extends Path<T>>(
471
+ name: K,
472
+ value: PathValue<T, K>,
473
+ options?: SetValueConfig
474
+ ) => void;
475
+
476
+ /** Reset form to default values */
477
+ reset: (values?: T) => void;
478
+
479
+ // ============================================================
480
+ // FLATTENED FORM STATE (NO NESTED formState)
481
+ // ============================================================
482
+
483
+ /** Form validation errors - direct access */
484
+ errors: FieldErrors<T>;
485
+
486
+ /** Form is valid - direct access */
487
+ isValid: boolean;
488
+
489
+ /** Form has been modified - direct access */
490
+ isDirty: boolean;
491
+
492
+ /** Form is currently submitting - direct access */
493
+ isSubmitting: boolean;
494
+
495
+ /** Form submission was successful - direct access */
496
+ isSubmitSuccessful: boolean;
497
+
498
+ // ============================================================
499
+ // BACKWARD COMPATIBILITY
500
+ // ============================================================
501
+
502
+ /** Form state object (for backward compatibility with existing components) */
503
+ formState: FormState<T>;
504
+
505
+ // ============================================================
506
+ // LOADING STATES
507
+ // ============================================================
508
+
509
+ /** Loading initial schema/data */
510
+ isLoadingInitialData: boolean;
511
+
512
+ /** Loading record data for update */
513
+ isLoadingRecord: boolean;
514
+
515
+ /** Any loading state active */
516
+ isLoading: boolean;
517
+
518
+ // ============================================================
519
+ // ERROR HANDLING
520
+ // ============================================================
521
+
522
+ /** Schema fetch error */
523
+ loadError: Error | null;
524
+
525
+ /** Form submission error */
526
+ submitError: Error | null;
527
+
528
+ /** Any error active */
529
+ hasError: boolean;
530
+
531
+ // ============================================================
532
+ // SCHEMA INFORMATION WITH STRICT TYPING
533
+ // ============================================================
534
+
535
+ /** Raw backend schema */
536
+ schema: BackendSchema | null;
537
+
538
+ /** Processed schema for rendering */
539
+ processedSchema: ProcessedSchema | null;
540
+
541
+ /** Computed field names as typed array */
542
+ computedFields: Array<keyof T>;
543
+
544
+ /** Required field names as typed array */
545
+ requiredFields: Array<keyof T>;
546
+
547
+ // ============================================================
548
+ // FIELD HELPERS WITH STRICT TYPING
549
+ // ============================================================
550
+
551
+ /** Get field metadata with strict typing */
552
+ getField: <K extends keyof T>(fieldName: K) => ProcessedField | null;
553
+
554
+ /** Get all fields with strict typing */
555
+ getFields: () => Record<keyof T, ProcessedField>;
556
+
557
+ /** Check if field exists with strict typing */
558
+ hasField: <K extends keyof T>(fieldName: K) => boolean;
559
+
560
+ /** Check if field is required with strict typing */
561
+ isFieldRequired: <K extends keyof T>(fieldName: K) => boolean;
562
+
563
+ /** Check if field is computed with strict typing */
564
+ isFieldComputed: <K extends keyof T>(fieldName: K) => boolean;
565
+
566
+ // ============================================================
567
+ // OPERATIONS
568
+ // ============================================================
569
+
570
+ /** Submit form manually */
571
+ submit: () => Promise<void>;
572
+
573
+ /** Refresh schema */
574
+ refreshSchema: () => Promise<void>;
575
+
576
+ /** Validate form manually */
577
+ validateForm: () => Promise<boolean>;
578
+
579
+ /** Clear all errors */
580
+ clearErrors: () => void;
581
+ }
582
+
583
+ // ============================================================
584
+ // UTILITY TYPES
585
+ // ============================================================
586
+
587
+ /**
588
+ * Expression evaluation context with strict typing
589
+ */
590
+ export interface EvaluationContext<T = Record<string, any>> {
591
+ /** Current form values */
592
+ formValues: Partial<T>;
593
+
594
+ /** System values (NOW, TODAY, CURRENT_USER, etc.) */
595
+ systemValues: Record<string, any>;
596
+
597
+ /** Reference data cache */
598
+ referenceData: Record<string, any[]>;
599
+ }
600
+
601
+ /**
602
+ * Validation result with strict typing
603
+ */
604
+ export interface ValidationResult<T = Record<string, any>> {
605
+ /** Is validation passing */
606
+ isValid: boolean;
607
+
608
+ /** Error message if validation fails */
609
+ message?: string;
610
+
611
+ /** Field name that caused error */
612
+ fieldName?: keyof T;
613
+ }
614
+
615
+ /**
616
+ * Form submission result
617
+ */
618
+ export interface SubmissionResult {
619
+ /** Was submission successful */
620
+ success: boolean;
621
+
622
+ /** Response data */
623
+ data?: any;
624
+
625
+ /** Error if submission failed */
626
+ error?: Error;
627
+
628
+ /** Created/updated record ID */
629
+ recordId?: string;
630
+ }