@ram_28/kf-ai-sdk 1.0.8 → 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.
Files changed (28) hide show
  1. package/dist/components/hooks/index.d.ts +2 -1
  2. package/dist/components/hooks/index.d.ts.map +1 -1
  3. package/dist/components/hooks/useForm/apiClient.d.ts +4 -4
  4. package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
  5. package/dist/components/hooks/useForm/expressionValidator.utils.d.ts +3 -3
  6. package/dist/components/hooks/useForm/expressionValidator.utils.d.ts.map +1 -1
  7. package/dist/components/hooks/useForm/index.d.ts +7 -4
  8. package/dist/components/hooks/useForm/index.d.ts.map +1 -1
  9. package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts +5 -5
  10. package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts.map +1 -1
  11. package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts +7 -6
  12. package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts.map +1 -1
  13. package/dist/components/hooks/useForm/schemaParser.utils.d.ts +8 -8
  14. package/dist/components/hooks/useForm/schemaParser.utils.d.ts.map +1 -1
  15. package/dist/components/hooks/useForm/types.d.ts +86 -93
  16. package/dist/components/hooks/useForm/types.d.ts.map +1 -1
  17. package/dist/index.cjs +11 -11
  18. package/dist/index.mjs +1003 -1009
  19. package/package.json +1 -1
  20. package/sdk/components/hooks/index.ts +24 -4
  21. package/sdk/components/hooks/useForm/apiClient.ts +5 -5
  22. package/sdk/components/hooks/useForm/expressionValidator.utils.ts +11 -11
  23. package/sdk/components/hooks/useForm/index.ts +41 -45
  24. package/sdk/components/hooks/useForm/optimizedExpressionValidator.utils.ts +7 -7
  25. package/sdk/components/hooks/useForm/ruleClassifier.utils.ts +21 -20
  26. package/sdk/components/hooks/useForm/schemaParser.utils.ts +36 -41
  27. package/sdk/components/hooks/useForm/types.ts +107 -113
  28. package/sdk/components/hooks/useForm/useForm.ts +54 -54
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ram_28/kf-ai-sdk",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Type-safe, AI-driven SDK for building modern web applications with role-based access control",
5
5
  "author": "Ramprasad",
6
6
  "license": "MIT",
@@ -9,15 +9,35 @@ export type {
9
9
  // Form hook
10
10
  export { useForm } from "./useForm";
11
11
  export type {
12
+ // Core types
12
13
  UseFormOptions,
13
14
  UseFormReturn,
14
- BackendFieldDefinition,
15
- ProcessedField,
16
- ProcessedSchema,
17
15
  FormOperation,
18
16
  FormMode,
19
- ValidationResult,
17
+
18
+ // Form field configuration
19
+ FormFieldConfig,
20
+ FormSchemaConfig,
21
+ FormFieldType,
22
+ SelectOption,
23
+ FieldPermission,
24
+
25
+ // Result types
26
+ FieldValidationResult,
20
27
  SubmissionResult,
28
+
29
+ // BDO Schema types (advanced)
30
+ BDOSchema,
31
+ BDOFieldDefinition,
32
+ SchemaValidationRule,
33
+ } from "./useForm";
34
+
35
+ // Error utilities
36
+ export {
37
+ parseApiError,
38
+ isNetworkError,
39
+ isValidationError,
40
+ clearFormCache,
21
41
  } from "./useForm";
22
42
 
23
43
  // Kanban hook
@@ -4,7 +4,7 @@
4
4
  // Handles schema fetching and form submissions
5
5
 
6
6
  import { api, getBdoSchema } from "../../../api";
7
- import type { BackendSchema, FormOperation, SubmissionResult } from "./types";
7
+ import type { BDOSchema, FormOperation, SubmissionResult } from "./types";
8
8
 
9
9
  // ============================================================
10
10
  // SCHEMA FETCHING
@@ -13,7 +13,7 @@ import type { BackendSchema, FormOperation, SubmissionResult } from "./types";
13
13
  /**
14
14
  * Fetch BDO schema from backend metadata endpoint
15
15
  */
16
- export async function fetchFormSchema(source: string): Promise<BackendSchema> {
16
+ export async function fetchFormSchema(source: string): Promise<BDOSchema> {
17
17
  try {
18
18
  // Use the new metadata API client to fetch BDO schema
19
19
  const bdoResp = await getBdoSchema(source);
@@ -25,7 +25,7 @@ export async function fetchFormSchema(source: string): Promise<BackendSchema> {
25
25
  }
26
26
 
27
27
  // Return the full BDO schema - the form processor will extract what it needs
28
- return bdoSchema as BackendSchema;
28
+ return bdoSchema as BDOSchema;
29
29
  } catch (error) {
30
30
  console.error(`Schema fetch error for ${source}:`, error);
31
31
  throw new Error(
@@ -40,7 +40,7 @@ export async function fetchFormSchema(source: string): Promise<BackendSchema> {
40
40
  export async function fetchFormSchemaWithRetry(
41
41
  source: string,
42
42
  maxRetries: number = 3
43
- ): Promise<BackendSchema> {
43
+ ): Promise<BDOSchema> {
44
44
  let lastError: Error;
45
45
 
46
46
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
@@ -404,7 +404,7 @@ export function clearCache(keyPrefix?: string): void {
404
404
  */
405
405
  export async function fetchFormSchemaWithCache(
406
406
  source: string
407
- ): Promise<BackendSchema> {
407
+ ): Promise<BDOSchema> {
408
408
  const cacheKey = `schema:${source}`;
409
409
  const cached = getCacheData(cacheKey);
410
410
 
@@ -5,9 +5,9 @@
5
5
 
6
6
  import type {
7
7
  ExpressionTree,
8
- EvaluationContext,
9
- ValidationResult,
10
- ValidationRule,
8
+ ExpressionContext,
9
+ FieldValidationResult,
10
+ SchemaValidationRule,
11
11
  } from "./types";
12
12
 
13
13
  // ============================================================
@@ -137,7 +137,7 @@ const FUNCTIONS = {
137
137
  /**
138
138
  * Evaluate an expression tree node
139
139
  */
140
- function evaluateNode(node: ExpressionTree, context: EvaluationContext): any {
140
+ function evaluateNode(node: ExpressionTree, context: ExpressionContext): any {
141
141
  switch (node.Type) {
142
142
  case "Literal":
143
143
  return node.Value;
@@ -218,7 +218,7 @@ function evaluateNode(node: ExpressionTree, context: EvaluationContext): any {
218
218
  */
219
219
  function getIdentifierValue(
220
220
  node: ExpressionTree,
221
- context: EvaluationContext
221
+ context: ExpressionContext
222
222
  ): any {
223
223
  const { Name, Source } = node;
224
224
 
@@ -293,7 +293,7 @@ function evaluateBinaryOperation(operator: string, left: any, right: any): any {
293
293
  function evaluateLogicalOperation(
294
294
  operator: string,
295
295
  args: ExpressionTree[],
296
- context: EvaluationContext
296
+ context: ExpressionContext
297
297
  ): boolean {
298
298
  switch (operator) {
299
299
  case "AND":
@@ -317,7 +317,7 @@ export function evaluateExpression(
317
317
  formValues: Record<string, any>,
318
318
  referenceData: Record<string, any> = {}
319
319
  ): any {
320
- const context: EvaluationContext = {
320
+ const context: ExpressionContext = {
321
321
  formValues,
322
322
  systemValues: getSystemValues(),
323
323
  referenceData,
@@ -337,10 +337,10 @@ export function evaluateExpression(
337
337
  export function validateField<T = Record<string, any>>(
338
338
  fieldName: string,
339
339
  fieldValue: any,
340
- validationRules: ValidationRule[],
340
+ validationRules: SchemaValidationRule[],
341
341
  formValues: T,
342
342
  referenceData: Record<string, any> = {}
343
- ): ValidationResult<T> {
343
+ ): FieldValidationResult<T> {
344
344
  // If no validation rules, field is valid
345
345
  if (!validationRules || validationRules.length === 0) {
346
346
  return { isValid: true };
@@ -385,8 +385,8 @@ export function validateCrossField<T = Record<string, any>>(
385
385
  }>,
386
386
  formValues: T,
387
387
  referenceData: Record<string, any> = {}
388
- ): ValidationResult<T>[] {
389
- const results: ValidationResult<T>[] = [];
388
+ ): FieldValidationResult<T>[] {
389
+ const results: FieldValidationResult<T>[] = [];
390
390
 
391
391
  for (const rule of validationRules) {
392
392
  try {
@@ -1,64 +1,60 @@
1
1
  // ============================================================
2
- // USE FORM HOOK - MAIN EXPORT
2
+ // useForm Hook - Public API
3
3
  // ============================================================
4
4
 
5
- // Main hook
5
+ // === MAIN HOOK ===
6
6
  export { useForm } from './useForm';
7
7
 
8
- // Types
8
+ // === TYPES: Core (Always needed) ===
9
9
  export type {
10
10
  UseFormOptions,
11
11
  UseFormReturn,
12
- BackendSchema,
13
- BackendFieldDefinition,
14
- ProcessedField,
15
- ProcessedSchema,
16
12
  FormOperation,
17
13
  FormMode,
18
- ValidationResult,
14
+ } from './types';
15
+
16
+ // === TYPES: Form Field Configuration (For dynamic form rendering) ===
17
+ export type {
18
+ FormFieldConfig,
19
+ FormSchemaConfig,
20
+ FormFieldType,
21
+ SelectOption,
22
+ FieldPermission,
23
+ FieldRuleIds,
24
+ } from './types';
25
+
26
+ // === TYPES: Result Types ===
27
+ export type {
28
+ FieldValidationResult,
19
29
  SubmissionResult,
20
- ExpressionTree,
21
- ValidationRule,
22
- Formula,
23
- DefaultValue,
24
- ReferenceField,
25
- FieldValues,
26
- EvaluationContext
27
30
  } from './types';
28
31
 
29
- // Utilities
30
- export {
31
- processSchema,
32
- updateComputedFields,
33
- buildDependencyMap,
34
- extractReferenceFields,
35
- validateSchema,
36
- buildReferenceFieldConfig
37
- } from './schemaParser.utils';
32
+ // === TYPES: BDO Schema (For advanced schema manipulation) ===
33
+ export type {
34
+ BDOSchema,
35
+ BDOFieldDefinition,
36
+ SchemaValidationRule,
37
+ ComputedFieldFormula,
38
+ DefaultValueExpression,
39
+ ReferenceFieldConfig,
40
+ FieldOptionsConfig,
41
+ ExpressionTree,
42
+ BusinessObjectRules,
43
+ RolePermission,
44
+ RuleType,
45
+ } from './types';
38
46
 
39
- export {
40
- evaluateExpression,
41
- validateField,
42
- validateCrossField,
43
- calculateComputedValue,
44
- calculateDefaultValue
45
- } from './expressionValidator.utils';
47
+ // === TYPES: Expression Evaluation (For custom expression handling) ===
48
+ export type {
49
+ ExpressionContext,
50
+ } from './types';
46
51
 
52
+ // === UTILITIES: Error Handling ===
47
53
  export {
48
- fetchFormSchema,
49
- fetchFormSchemaWithRetry,
50
- fetchRecord,
51
- submitFormData,
52
- fetchReferenceData,
53
- fetchAllReferenceData,
54
- validateFormData,
55
- cleanFormData,
56
54
  parseApiError,
57
55
  isNetworkError,
58
56
  isValidationError,
59
- setCacheData,
60
- getCacheData,
61
- clearCache,
62
- fetchFormSchemaWithCache,
63
- fetchReferenceDataWithCache
64
- } from './apiClient';
57
+ } from './apiClient';
58
+
59
+ // === UTILITIES: Cache Control ===
60
+ export { clearCache as clearFormCache } from './apiClient';
@@ -5,8 +5,8 @@
5
5
 
6
6
  import type {
7
7
  ExpressionTree,
8
- ValidationResult,
9
- ValidationRule,
8
+ FieldValidationResult,
9
+ SchemaValidationRule,
10
10
  } from "./types";
11
11
 
12
12
  // ============================================================
@@ -94,7 +94,7 @@ export function analyzeExpressionDependencies(
94
94
  * Build dependency graph for multiple expressions
95
95
  */
96
96
  export function buildDependencyGraph(
97
- rules: Record<string, ValidationRule>
97
+ rules: Record<string, SchemaValidationRule>
98
98
  ): Map<string, Set<string>> {
99
99
  const graph = new Map<string, Set<string>>();
100
100
 
@@ -398,10 +398,10 @@ const globalEvaluator = new OptimizedExpressionEvaluator();
398
398
  export function validateFieldOptimized<T = Record<string, any>>(
399
399
  fieldName: string,
400
400
  fieldValue: any,
401
- validationRules: ValidationRule[],
401
+ validationRules: SchemaValidationRule[],
402
402
  formValues: T,
403
403
  lastFormValues?: T
404
- ): ValidationResult<T> {
404
+ ): FieldValidationResult<T> {
405
405
  if (!validationRules || validationRules.length === 0) {
406
406
  return { isValid: true };
407
407
  }
@@ -461,11 +461,11 @@ export function batchValidateFields<T = Record<string, any>>(
461
461
  validations: Array<{
462
462
  fieldName: string;
463
463
  fieldValue: any;
464
- rules: ValidationRule[];
464
+ rules: SchemaValidationRule[];
465
465
  }>,
466
466
  formValues: T,
467
467
  lastFormValues?: T
468
- ): Array<ValidationResult<T>> {
468
+ ): Array<FieldValidationResult<T>> {
469
469
  return validations.map(({ fieldName, fieldValue, rules }) =>
470
470
  validateFieldOptimized(fieldName, fieldValue, rules, formValues, lastFormValues)
471
471
  );
@@ -5,9 +5,9 @@
5
5
 
6
6
  import type {
7
7
  BDOSchema,
8
- BackendSchema,
9
- ProcessedSchema,
10
- ValidationRule,
8
+ BDOFieldDefinition,
9
+ FormSchemaConfig,
10
+ SchemaValidationRule,
11
11
  RuleType,
12
12
  FieldPermission,
13
13
  } from "./types";
@@ -20,7 +20,7 @@ import type {
20
20
  * Check if a validation rule represents a "required" validation
21
21
  * Detects patterns like: field != null, TRIM(field) != '', etc.
22
22
  */
23
- function isRequiredValidationRule(rule: ValidationRule, fieldName: string): boolean {
23
+ function isRequiredSchemaValidationRule(rule: SchemaValidationRule, fieldName: string): boolean {
24
24
  const expression = rule.Expression?.toLowerCase() || '';
25
25
  const ruleName = rule.Name?.toLowerCase() || '';
26
26
  const ruleId = rule.Id?.toLowerCase() || '';
@@ -84,13 +84,13 @@ export function normalizeBDOSchema(schema: BDOSchema): BDOSchema {
84
84
  // Extract inline validation rules
85
85
  const ruleIds: string[] = [];
86
86
 
87
- (field.Validation as ValidationRule[]).forEach((rule) => {
87
+ (field.Validation as SchemaValidationRule[]).forEach((rule) => {
88
88
  // Add rule to centralized Rules.Validation
89
89
  normalizedSchema.Rules.Validation![rule.Id] = rule;
90
90
  ruleIds.push(rule.Id);
91
91
 
92
92
  // Check if this is a required validation rule
93
- if (isRequiredValidationRule(rule, fieldName)) {
93
+ if (isRequiredSchemaValidationRule(rule, fieldName)) {
94
94
  isRequired = true;
95
95
  }
96
96
  });
@@ -106,7 +106,7 @@ export function normalizeBDOSchema(schema: BDOSchema): BDOSchema {
106
106
  const validationRuleIds = field.Validation as string[];
107
107
  validationRuleIds.forEach((ruleId) => {
108
108
  const rule = normalizedSchema.Rules.Validation?.[ruleId];
109
- if (rule && isRequiredValidationRule(rule, fieldName)) {
109
+ if (rule && isRequiredSchemaValidationRule(rule, fieldName)) {
110
110
  isRequired = true;
111
111
  }
112
112
  });
@@ -146,11 +146,11 @@ export function normalizeBDOSchema(schema: BDOSchema): BDOSchema {
146
146
  /**
147
147
  * Classify rules by type from BDO schema
148
148
  */
149
- export function classifyRules(schema: BDOSchema): ProcessedSchema["rules"] {
149
+ export function classifyRules(schema: BDOSchema): FormSchemaConfig["rules"] {
150
150
  const rules = {
151
- validation: {} as Record<string, ValidationRule>,
152
- computation: {} as Record<string, ValidationRule>,
153
- businessLogic: {} as Record<string, ValidationRule>,
151
+ validation: {} as Record<string, SchemaValidationRule>,
152
+ computation: {} as Record<string, SchemaValidationRule>,
153
+ businessLogic: {} as Record<string, SchemaValidationRule>,
154
154
  };
155
155
 
156
156
  // Extract rules from BDO Rules section
@@ -223,9 +223,9 @@ function inferComputationRuleTargets(
223
223
 
224
224
  export function createFieldRuleMapping(
225
225
  schema: BDOSchema,
226
- classifiedRules: ProcessedSchema["rules"]
227
- ): ProcessedSchema["fieldRules"] {
228
- const fieldRules: ProcessedSchema["fieldRules"] = {};
226
+ classifiedRules: FormSchemaConfig["rules"]
227
+ ): FormSchemaConfig["fieldRules"] {
228
+ const fieldRules: FormSchemaConfig["fieldRules"] = {};
229
229
 
230
230
  // Initialize all fields
231
231
  Object.keys(schema.Fields).forEach((fieldName) => {
@@ -356,11 +356,11 @@ export function getRuleExecutionStrategy(
356
356
  */
357
357
  export function getRulesForField(
358
358
  fieldName: string,
359
- fieldRules: ProcessedSchema["fieldRules"],
360
- classifiedRules: ProcessedSchema["rules"],
359
+ fieldRules: FormSchemaConfig["fieldRules"],
360
+ classifiedRules: FormSchemaConfig["rules"],
361
361
  executionType: "client" | "server"
362
- ): ValidationRule[] {
363
- const rules: ValidationRule[] = [];
362
+ ): SchemaValidationRule[] {
363
+ const rules: SchemaValidationRule[] = [];
364
364
  const fieldRuleMap = fieldRules[fieldName];
365
365
 
366
366
  if (!fieldRuleMap) return rules;
@@ -394,9 +394,10 @@ export function getRulesForField(
394
394
  // ============================================================
395
395
 
396
396
  /**
397
- * Convert legacy BackendSchema to BDO format
397
+ * Convert legacy schema format to BDO format
398
+ * @deprecated Legacy schema format is no longer supported
398
399
  */
399
- export function convertLegacySchema(legacySchema: BackendSchema): BDOSchema {
400
+ export function convertLegacySchema(legacySchema: Record<string, BDOFieldDefinition>): BDOSchema {
400
401
  return {
401
402
  Id: "legacy_schema",
402
403
  Name: "Legacy Schema",
@@ -4,12 +4,11 @@
4
4
  // Converts backend field schemas to react-hook-form validation rules
5
5
 
6
6
  import type {
7
- BackendSchema,
8
7
  BDOSchema,
9
- BackendFieldDefinition,
10
- ProcessedField,
11
- ProcessedSchema,
12
- ValidationRule,
8
+ BDOFieldDefinition,
9
+ FormFieldConfig,
10
+ FormSchemaConfig,
11
+ SchemaValidationRule,
13
12
  FieldPermission,
14
13
  } from "./types";
15
14
  import {
@@ -20,7 +19,6 @@ import {
20
19
  classifyRules,
21
20
  createFieldRuleMapping,
22
21
  calculateFieldPermissions,
23
- convertLegacySchema,
24
22
  normalizeBDOSchema,
25
23
  } from "./ruleClassifier.utils";
26
24
 
@@ -85,10 +83,10 @@ function generateLabel(fieldName: string): string {
85
83
  /**
86
84
  * Convert backend validation rules to react-hook-form validation
87
85
  */
88
- function convertValidationRules(
86
+ function convertSchemaValidationRules(
89
87
  fieldName: string,
90
- fieldDef: BackendFieldDefinition,
91
- _allFields: Record<string, BackendFieldDefinition>
88
+ fieldDef: BDOFieldDefinition,
89
+ _allFields: Record<string, BDOFieldDefinition>
92
90
  ): any {
93
91
  const validation: any = {};
94
92
 
@@ -113,7 +111,7 @@ function convertValidationRules(
113
111
  }
114
112
 
115
113
  // Custom validation using expression trees
116
- // Note: fieldDef.Validation contains rule IDs (string[]), not ValidationRule[]
114
+ // Note: fieldDef.Validation contains rule IDs (string[]), not SchemaValidationRule[]
117
115
  // Validation is handled by the form hook which has access to the full schema rules
118
116
  if (fieldDef.Validation && fieldDef.Validation.length > 0) {
119
117
  // Validation rules will be applied by the form hook
@@ -132,7 +130,7 @@ function convertValidationRules(
132
130
  * Process field options for select/reference fields
133
131
  */
134
132
  function processFieldOptions(
135
- fieldDef: BackendFieldDefinition
133
+ fieldDef: BDOFieldDefinition
136
134
  ): Array<{ value: any; label: string }> {
137
135
  if (!fieldDef.Values) {
138
136
  return [];
@@ -163,7 +161,7 @@ function processFieldOptions(
163
161
  * Calculate default value for a field
164
162
  */
165
163
  function processDefaultValue(
166
- fieldDef: BackendFieldDefinition,
164
+ fieldDef: BDOFieldDefinition,
167
165
  formValues: Record<string, any> = {}
168
166
  ): any {
169
167
  if (!fieldDef.DefaultValue) {
@@ -199,8 +197,8 @@ function processDefaultValue(
199
197
  */
200
198
  function processField(
201
199
  fieldName: string,
202
- fieldDef: BackendFieldDefinition,
203
- allFields: Record<string, BackendFieldDefinition>,
200
+ fieldDef: BDOFieldDefinition,
201
+ allFields: Record<string, BDOFieldDefinition>,
204
202
  formValues: Record<string, any> = {},
205
203
  permission?: FieldPermission,
206
204
  rules?: {
@@ -208,7 +206,7 @@ function processField(
208
206
  computation: string[];
209
207
  businessLogic: string[];
210
208
  }
211
- ): ProcessedField {
209
+ ): FormFieldConfig {
212
210
  const defaultPermission: FieldPermission = {
213
211
  editable: true,
214
212
  readable: true,
@@ -227,7 +225,7 @@ function processField(
227
225
  !!fieldDef.Formula ||
228
226
  fieldRules.computation.length > 0;
229
227
 
230
- const validation = convertValidationRules(fieldName, fieldDef, allFields);
228
+ const validation = convertSchemaValidationRules(fieldName, fieldDef, allFields);
231
229
 
232
230
  // Mark computed fields as disabled so they cannot be manually edited
233
231
  if (isComputed) {
@@ -244,7 +242,7 @@ function processField(
244
242
  options: processFieldOptions(fieldDef),
245
243
  validation,
246
244
  description: fieldDef.Description,
247
- backendField: fieldDef,
245
+ _bdoField: fieldDef,
248
246
  permission: permission || defaultPermission,
249
247
  rules: fieldRules,
250
248
  };
@@ -255,27 +253,24 @@ function processField(
255
253
  // ============================================================
256
254
 
257
255
  /**
258
- * Process complete backend schema
256
+ * Process complete BDO schema
259
257
  */
260
258
  export function processSchema(
261
- schema: BackendSchema | BDOSchema,
259
+ schema: BDOSchema,
262
260
  formValues: Record<string, any> = {},
263
261
  userRole?: string
264
- ): ProcessedSchema {
265
- // Convert legacy schema to BDO format if needed
266
- let bdoSchema =
267
- "Kind" in schema && schema.Kind === "BusinessObject"
268
- ? (schema as BDOSchema)
269
- : convertLegacySchema(schema as BackendSchema);
262
+ ): FormSchemaConfig {
263
+ // Ensure schema is in BDO format
264
+ let bdoSchema = schema;
270
265
 
271
266
  // Normalize BDO schema to ensure inline validation rules are centralized
272
267
  bdoSchema = normalizeBDOSchema(bdoSchema);
273
268
 
274
- const fields: Record<string, ProcessedField> = {};
269
+ const fields: Record<string, FormFieldConfig> = {};
275
270
  const fieldOrder: string[] = [];
276
271
  const computedFields: string[] = [];
277
272
  const requiredFields: string[] = [];
278
- const crossFieldValidation: ValidationRule[] = [];
273
+ const crossFieldValidation: SchemaValidationRule[] = [];
279
274
 
280
275
  // Classify rules by type
281
276
  const classifiedRules = classifyRules(bdoSchema);
@@ -344,14 +339,14 @@ export function processSchema(
344
339
  * Update computed field values based on current form values
345
340
  */
346
341
  export function updateComputedFields(
347
- processedSchema: ProcessedSchema,
342
+ processedSchema: FormSchemaConfig,
348
343
  currentValues: Record<string, any>
349
344
  ): Record<string, any> {
350
345
  const computedValues: Record<string, any> = {};
351
346
 
352
347
  for (const fieldName of processedSchema.computedFields) {
353
348
  const field = processedSchema.fields[fieldName];
354
- const backendField = field.backendField;
349
+ const backendField = field._bdoField;
355
350
 
356
351
  if (backendField.Formula) {
357
352
  try {
@@ -406,7 +401,7 @@ function extractFieldDependencies(expressionTree: any): string[] {
406
401
  * Build field dependency map
407
402
  */
408
403
  export function buildDependencyMap(
409
- processedSchema: ProcessedSchema
404
+ processedSchema: FormSchemaConfig
410
405
  ): Record<string, string[]> {
411
406
  const dependencyMap: Record<string, string[]> = {};
412
407
 
@@ -414,25 +409,25 @@ export function buildDependencyMap(
414
409
  const dependencies: Set<string> = new Set();
415
410
 
416
411
  // Check formula dependencies
417
- if (field.backendField.Formula) {
412
+ if (field._bdoField.Formula) {
418
413
  const formulaDeps = extractFieldDependencies(
419
- field.backendField.Formula.ExpressionTree
414
+ field._bdoField.Formula.ExpressionTree
420
415
  );
421
416
  formulaDeps.forEach((dep) => dependencies.add(dep));
422
417
  }
423
418
 
424
419
  // Check validation dependencies
425
- // Note: field.backendField.Validation contains rule IDs (string[])
420
+ // Note: field._bdoField.Validation contains rule IDs (string[])
426
421
  // To extract validation dependencies, we would need access to the full schema rules
427
422
  // This is skipped for now as validation dependencies are tracked separately
428
- if (field.backendField.Validation) {
423
+ if (field._bdoField.Validation) {
429
424
  // Validation rule dependencies would be extracted here if we had access to the rules
430
425
  }
431
426
 
432
427
  // Check default value dependencies
433
- if (field.backendField.DefaultValue) {
428
+ if (field._bdoField.DefaultValue) {
434
429
  const defaultDeps = extractFieldDependencies(
435
- field.backendField.DefaultValue.ExpressionTree
430
+ field._bdoField.DefaultValue.ExpressionTree
436
431
  );
437
432
  defaultDeps.forEach((dep) => dependencies.add(dep));
438
433
  }
@@ -450,7 +445,7 @@ export function buildDependencyMap(
450
445
  /**
451
446
  * Validate processed schema
452
447
  */
453
- export function validateSchema(processedSchema: ProcessedSchema): {
448
+ export function validateSchema(processedSchema: FormSchemaConfig): {
454
449
  isValid: boolean;
455
450
  errors: string[];
456
451
  } {
@@ -483,12 +478,12 @@ export function validateSchema(processedSchema: ProcessedSchema): {
483
478
  /**
484
479
  * Build reference field configuration for API calls
485
480
  */
486
- export function buildReferenceFieldConfig(field: ProcessedField): any {
487
- if (field.type !== "reference" || !field.backendField.Values?.Reference) {
481
+ export function buildReferenceFieldConfig(field: FormFieldConfig): any {
482
+ if (field.type !== "reference" || !field._bdoField.Values?.Reference) {
488
483
  return null;
489
484
  }
490
485
 
491
- const ref = field.backendField.Values.Reference;
486
+ const ref = field._bdoField.Values.Reference;
492
487
 
493
488
  return {
494
489
  businessObject: ref.BusinessObject,
@@ -502,7 +497,7 @@ export function buildReferenceFieldConfig(field: ProcessedField): any {
502
497
  * Extract all reference field configurations from schema
503
498
  */
504
499
  export function extractReferenceFields(
505
- processedSchema: ProcessedSchema
500
+ processedSchema: FormSchemaConfig
506
501
  ): Record<string, any> {
507
502
  const referenceFields: Record<string, any> = {};
508
503