@ram_28/kf-ai-sdk 1.0.5 → 1.0.8

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 (38) hide show
  1. package/dist/api/index.d.ts +1 -1
  2. package/dist/api/index.d.ts.map +1 -1
  3. package/dist/components/hooks/useFilter/index.d.ts +3 -4
  4. package/dist/components/hooks/useFilter/index.d.ts.map +1 -1
  5. package/dist/components/hooks/useFilter/types.d.ts +84 -127
  6. package/dist/components/hooks/useFilter/types.d.ts.map +1 -1
  7. package/dist/components/hooks/useFilter/useFilter.d.ts +1 -1
  8. package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -1
  9. package/dist/components/hooks/useKanban/index.d.ts +1 -1
  10. package/dist/components/hooks/useKanban/index.d.ts.map +1 -1
  11. package/dist/components/hooks/useKanban/types.d.ts +6 -49
  12. package/dist/components/hooks/useKanban/types.d.ts.map +1 -1
  13. package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -1
  14. package/dist/components/hooks/useTable/types.d.ts +5 -35
  15. package/dist/components/hooks/useTable/types.d.ts.map +1 -1
  16. package/dist/components/hooks/useTable/useTable.d.ts +0 -5
  17. package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
  18. package/dist/index.cjs +13 -13
  19. package/dist/index.mjs +2395 -2865
  20. package/dist/types/common.d.ts +35 -26
  21. package/dist/types/common.d.ts.map +1 -1
  22. package/package.json +1 -1
  23. package/sdk/api/index.ts +7 -3
  24. package/sdk/components/hooks/useFilter/index.ts +19 -31
  25. package/sdk/components/hooks/useFilter/types.ts +157 -138
  26. package/sdk/components/hooks/useFilter/useFilter.ts +259 -414
  27. package/sdk/components/hooks/useKanban/index.ts +0 -1
  28. package/sdk/components/hooks/useKanban/types.ts +8 -71
  29. package/sdk/components/hooks/useKanban/useKanban.ts +14 -77
  30. package/sdk/components/hooks/useTable/types.ts +7 -63
  31. package/sdk/components/hooks/useTable/useTable.ts +13 -122
  32. package/sdk/types/common.ts +42 -26
  33. package/dist/components/hooks/useFilter/payloadBuilder.utils.d.ts +0 -33
  34. package/dist/components/hooks/useFilter/payloadBuilder.utils.d.ts.map +0 -1
  35. package/dist/components/hooks/useFilter/validation.utils.d.ts +0 -38
  36. package/dist/components/hooks/useFilter/validation.utils.d.ts.map +0 -1
  37. package/sdk/components/hooks/useFilter/payloadBuilder.utils.ts +0 -298
  38. package/sdk/components/hooks/useFilter/validation.utils.ts +0 -401
@@ -12,30 +12,27 @@ export type SortOption = Record<string, SortDirection>;
12
12
  */
13
13
  export type Sort = SortOption[];
14
14
  /**
15
- * Filter operators for individual conditions (leaf nodes)
15
+ * Condition operators for individual conditions (leaf nodes)
16
+ * Used in Condition.Operator
16
17
  */
17
- export type FilterOperator = "EQ" | "NE" | "GT" | "GTE" | "LT" | "LTE" | "Between" | "NotBetween" | "IN" | "NIN" | "Empty" | "NotEmpty" | "Contains" | "NotContains" | "MinLength" | "MaxLength";
18
+ export type ConditionOperator = "EQ" | "NE" | "GT" | "GTE" | "LT" | "LTE" | "Between" | "NotBetween" | "IN" | "NIN" | "Empty" | "NotEmpty" | "Contains" | "NotContains" | "MinLength" | "MaxLength";
18
19
  /**
19
- * Logical operators for combining filter conditions (tree nodes)
20
+ * Operators for combining conditions in a group (tree nodes)
21
+ * Used in ConditionGroup.Operator
20
22
  */
21
- export type LogicalOperator = "And" | "Or" | "Not";
23
+ export type ConditionGroupOperator = "And" | "Or" | "Not";
22
24
  /**
23
25
  * RHS value type for filter conditions
24
26
  */
25
27
  export type FilterRHSType = "Constant" | "BOField" | "AppVariable";
26
28
  /**
27
- * Base interface for all filter nodes
29
+ * Leaf condition (actual field comparison)
28
30
  */
29
- interface FilterNodeBase {
30
- /** Operator type */
31
- Operator: FilterOperator | LogicalOperator;
32
- }
33
- /**
34
- * Leaf filter condition (actual field comparison)
35
- */
36
- export interface FilterCondition extends FilterNodeBase {
31
+ export interface Condition {
32
+ /** Optional ID for hook state management (omitted in API payload) */
33
+ id?: string;
37
34
  /** Condition operator */
38
- Operator: FilterOperator;
35
+ Operator: ConditionOperator;
39
36
  /** Left-hand side field name */
40
37
  LHSField: string;
41
38
  /** Right-hand side value */
@@ -44,23 +41,36 @@ export interface FilterCondition extends FilterNodeBase {
44
41
  RHSType?: FilterRHSType;
45
42
  }
46
43
  /**
47
- * Logical filter node (combines multiple conditions)
44
+ * Group combining conditions (recursive structure)
48
45
  */
49
- export interface FilterLogical extends FilterNodeBase {
50
- /** Logical operator */
51
- Operator: LogicalOperator;
52
- /** Nested conditions (can be FilterCondition or FilterLogical) */
53
- Condition: Array<FilterCondition | FilterLogical>;
46
+ export interface ConditionGroup {
47
+ /** Optional ID for hook state management (omitted in API payload) */
48
+ id?: string;
49
+ /** Group operator (And, Or, Not) */
50
+ Operator: ConditionGroupOperator;
51
+ /** Nested conditions (can be Condition or ConditionGroup) */
52
+ Condition: Array<Condition | ConditionGroup>;
54
53
  }
55
54
  /**
56
- * Filter structure matching API specification (root level)
57
- * This is a discriminated union - a filter is either a logical node or a condition
55
+ * Root filter type (alias for ConditionGroup)
56
+ */
57
+ export type Filter = ConditionGroup;
58
+ /**
59
+ * @deprecated Use `Condition` instead
60
+ */
61
+ export type FilterCondition = Condition;
62
+ /**
63
+ * @deprecated Use `ConditionGroup` instead
64
+ */
65
+ export type FilterLogical = ConditionGroup;
66
+ /**
67
+ * @deprecated Use `ConditionGroupOperator` instead
58
68
  */
59
- export type Filter = FilterLogical;
69
+ export type FilterOperator = ConditionGroupOperator;
60
70
  /**
61
- * Convenience type for any filter node (leaf or logical)
71
+ * @deprecated Use `Condition | ConditionGroup` instead
62
72
  */
63
- export type FilterNode = FilterCondition | FilterLogical;
73
+ export type FilterNode = Condition | ConditionGroup;
64
74
  /**
65
75
  * DateTime encoding format used by the API
66
76
  */
@@ -234,5 +244,4 @@ export interface FetchFieldResponse {
234
244
  /** Array of field options */
235
245
  Data: FetchFieldOption[];
236
246
  }
237
- export {};
238
247
  //# sourceMappingURL=common.d.ts.map
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CAAC;CAC1B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ram_28/kf-ai-sdk",
3
- "version": "1.0.5",
3
+ "version": "1.0.8",
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",
package/sdk/api/index.ts CHANGED
@@ -26,12 +26,16 @@ export type {
26
26
  SortDirection,
27
27
  SortOption,
28
28
  Sort,
29
- // Filter types
29
+ // Filter types (new names)
30
+ Condition,
31
+ ConditionGroup,
32
+ ConditionGroupOperator,
30
33
  Filter,
34
+ FilterRHSType,
35
+ ConditionOperator,
36
+ // Filter types (legacy - deprecated)
31
37
  FilterCondition,
32
38
  FilterOperator,
33
- FilterRHSType,
34
- LogicalOperator,
35
39
  FilterLogical,
36
40
  FilterNode,
37
41
  // List types
@@ -1,37 +1,25 @@
1
1
  // Main hook export
2
- export { useFilter } from './useFilter';
2
+ export { useFilter } from "./useFilter";
3
3
 
4
- // Type exports
4
+ // Type exports (new names)
5
5
  export type {
6
- FilterConditionWithId,
7
- TypedFilterConditionInput,
8
- FilterState,
9
- FieldDefinition,
10
- ValidationResult,
11
- ValidationError,
6
+ Condition,
7
+ ConditionGroup,
8
+ ConditionGroupOperator,
9
+ Filter,
10
+ FilterRHSType,
12
11
  UseFilterOptions,
13
- UseFilterReturn
14
- } from './types';
12
+ UseFilterReturn,
13
+ // Legacy type exports
14
+ FilterCondition,
15
+ FilterOperator,
16
+ } from "./types";
15
17
 
16
- // Validation utilities
18
+ // Type guard exports
17
19
  export {
18
- validateNumberValue,
19
- validateDateValue,
20
- validateCurrencyValue,
21
- validateStringValue,
22
- validateBooleanValue,
23
- validateSelectValue,
24
- getDefaultFieldDefinition,
25
- createFieldDefinitionsFromSample
26
- } from './validation.utils';
27
-
28
- // Payload building utilities
29
- export {
30
- buildFilterPayload,
31
- buildFilterPayloadFromState,
32
- validateFilterPayload,
33
- cloneFilterPayload,
34
- mergeFilterPayloads,
35
- filterPayloadToString,
36
- areFilterPayloadsEqual
37
- } from './payloadBuilder.utils';
20
+ isCondition,
21
+ isConditionGroup,
22
+ // Legacy type guard exports
23
+ isFilterCondition,
24
+ isFilterLogical,
25
+ } from "./types";
@@ -1,158 +1,177 @@
1
- import type { Filter, FilterOperator, FilterRHSType, LogicalOperator } from "../../../types/common";
1
+ import type {
2
+ Condition,
3
+ ConditionGroup,
4
+ ConditionGroupOperator,
5
+ Filter,
6
+ FilterRHSType,
7
+ // Legacy types for backwards compatibility
8
+ FilterCondition,
9
+ FilterOperator,
10
+ } from "../../../types/common";
11
+
12
+ // Re-export from common types for convenience
13
+ export type {
14
+ Condition,
15
+ ConditionGroup,
16
+ ConditionGroupOperator,
17
+ Filter,
18
+ FilterRHSType,
19
+ // Legacy re-exports
20
+ FilterCondition,
21
+ FilterOperator,
22
+ };
2
23
 
3
24
  // ============================================================
4
- // TYPE DEFINITIONS
25
+ // TYPE GUARDS
5
26
  // ============================================================
6
27
 
7
28
  /**
8
- * Internal filter condition with ID for management
9
- * Supports both simple conditions and nested logical groups
29
+ * Type guard to check if an item is a ConditionGroup (has nested Condition array)
10
30
  */
11
- export interface FilterConditionWithId {
12
- /** Unique identifier for internal management */
13
- id: string;
14
- /** Filter operator (can be condition or logical operator) */
15
- operator: FilterOperator | LogicalOperator;
16
- /** Left-hand side field name (required for condition operators) */
17
- lhsField?: string;
18
- /** Right-hand side value (required for condition operators) */
19
- rhsValue?: any;
20
- /** Right-hand side type (defaults to Constant) */
21
- rhsType?: FilterRHSType;
22
- /** Nested conditions (for logical operators: And, Or, Not) */
23
- children?: FilterConditionWithId[];
24
- /** Validation state */
25
- isValid: boolean;
26
- /** Specific validation errors */
27
- validationErrors?: string[];
28
- }
31
+ export const isConditionGroup = (
32
+ item: Condition | ConditionGroup
33
+ ): item is ConditionGroup => {
34
+ return "Condition" in item;
35
+ };
29
36
 
30
37
  /**
31
- * Type-safe filter condition input (for addCondition)
32
- * Constrains lhsField to keys of T for compile-time type checking
38
+ * Type guard to check if an item is a leaf Condition (has LHSField)
33
39
  */
34
- export interface TypedFilterConditionInput<T> {
35
- /** Filter operator (can be condition or logical operator) */
36
- operator: FilterOperator | LogicalOperator;
37
- /** Left-hand side field name - constrained to keyof T */
38
- lhsField?: keyof T & string;
39
- /** Right-hand side value */
40
- rhsValue?: T[keyof T] | T[keyof T][] | any;
41
- /** Right-hand side type (defaults to Constant) */
42
- rhsType?: FilterRHSType;
43
- /** Nested conditions (for logical operators: And, Or, Not) */
44
- children?: TypedFilterConditionInput<T>[];
45
- }
40
+ export const isCondition = (
41
+ item: Condition | ConditionGroup
42
+ ): item is Condition => {
43
+ return "LHSField" in item;
44
+ };
46
45
 
47
- export interface FilterState {
48
- /** Logical operator for combining conditions */
49
- logicalOperator: LogicalOperator;
50
- /** Array of filter conditions with IDs */
51
- conditions: FilterConditionWithId[];
52
- }
46
+ // ============================================================
47
+ // LEGACY TYPE GUARDS (for backwards compatibility)
48
+ // ============================================================
53
49
 
54
- export interface FieldDefinition {
55
- /** Field data type */
56
- type: 'string' | 'number' | 'date' | 'boolean' | 'currency' | 'select';
57
- /** Operators allowed for this field type */
58
- allowedOperators: FilterOperator[];
59
- /** Custom value validation function */
60
- validateValue?: (value: any, operator: FilterOperator) => ValidationResult;
61
- /** Value transformation function */
62
- transformValue?: (value: any) => any;
63
- /** Options for select fields */
64
- selectOptions?: Array<{ label: string; value: any }>;
65
- }
50
+ /**
51
+ * @deprecated Use `isConditionGroup` instead
52
+ */
53
+ export const isFilterLogical = isConditionGroup;
66
54
 
67
- export interface ValidationResult {
68
- /** Whether the validation passed */
69
- isValid: boolean;
70
- /** Array of error messages */
71
- errors: string[];
72
- }
55
+ /**
56
+ * @deprecated Use `isCondition` instead
57
+ */
58
+ export const isFilterCondition = isCondition;
73
59
 
74
- export interface ValidationError {
75
- /** ID of the condition with errors */
76
- conditionId: string;
77
- /** Field name */
78
- field: string;
79
- /** Error message */
80
- message: string;
81
- }
60
+ // ============================================================
61
+ // HOOK-SPECIFIC TYPE DEFINITIONS
62
+ // ============================================================
82
63
 
83
- export interface UseFilterOptions<T = any> {
64
+ /**
65
+ * Hook options (minimal configuration)
66
+ */
67
+ export interface UseFilterOptions {
84
68
  /** Initial filter conditions */
85
- initialConditions?: FilterConditionWithId[];
86
- /** Initial logical operator */
87
- initialLogicalOperator?: LogicalOperator;
88
- /** Field definitions for validation */
89
- fieldDefinitions?: Record<keyof T, FieldDefinition>;
90
- /** Whether to validate conditions on change */
91
- validateOnChange?: boolean;
92
- /** Callback when condition is added */
93
- onConditionAdd?: (condition: FilterConditionWithId) => void;
94
- /** Callback when condition is updated */
95
- onConditionUpdate?: (condition: FilterConditionWithId) => void;
96
- /** Callback when condition is removed */
97
- onConditionRemove?: (conditionId: string) => void;
98
- /** Callback when validation errors occur */
99
- onValidationError?: (errors: ValidationError[]) => void;
69
+ initialConditions?: Array<Condition | ConditionGroup>;
70
+ /** Initial operator for combining conditions (defaults to "And") */
71
+ initialOperator?: ConditionGroupOperator;
100
72
  }
101
73
 
102
- export interface UseFilterReturn<T = any> {
103
- // Current state
104
- /** Array of current filter conditions */
105
- conditions: FilterConditionWithId[];
106
- /** Current logical operator */
107
- logicalOperator: LogicalOperator;
108
- /** SDK-formatted filter payload for API calls */
109
- filterPayload: Filter | undefined;
110
- /** Overall validation state */
111
- isValid: boolean;
112
- /** Array of validation errors */
113
- validationErrors: ValidationError[];
114
-
115
- // Condition management
116
- /** Add a new filter condition (type-safe: lhsField constrained to keyof T) */
117
- addCondition: (condition: TypedFilterConditionInput<T>) => string;
118
- /** Update an existing condition */
119
- updateCondition: (id: string, updates: Partial<TypedFilterConditionInput<T>>) => boolean;
120
- /** Remove a condition by ID */
121
- removeCondition: (id: string) => boolean;
122
- /** Clear all conditions */
123
- clearConditions: () => void;
124
- /** Get a specific condition by ID */
125
- getCondition: (id: string) => FilterConditionWithId | undefined;
126
-
127
- // Logical operator management
128
- /** Set the root logical operator */
129
- setLogicalOperator: (operator: LogicalOperator) => void;
130
-
131
- // Bulk operations
132
- /** Replace all conditions */
133
- setConditions: (conditions: FilterConditionWithId[]) => void;
134
- /** Replace a specific condition */
135
- replaceCondition: (id: string, newCondition: TypedFilterConditionInput<T>) => boolean;
136
-
137
- // Validation
138
- /** Validate a single condition */
139
- validateCondition: (condition: Partial<FilterConditionWithId>) => ValidationResult;
140
- /** Validate all current conditions */
141
- validateAllConditions: () => ValidationResult;
142
-
143
- // State management
144
- /** Export current filter state */
145
- exportState: () => FilterState;
146
- /** Import a filter state */
147
- importState: (state: FilterState) => void;
148
- /** Reset to initial state */
149
- resetToInitial: () => void;
150
-
151
- // Utilities
152
- /** Get total number of conditions */
153
- getConditionCount: () => number;
74
+ /**
75
+ * Hook return interface with nested filter support
76
+ */
77
+ export interface UseFilterReturn {
78
+ // ============================================================
79
+ // STATE (read-only)
80
+ // ============================================================
81
+
82
+ /** Current operator for combining root-level conditions ("And" | "Or" | "Not") */
83
+ operator: ConditionGroupOperator;
84
+
85
+ /** Current filter items (with id populated) */
86
+ items: Array<Condition | ConditionGroup>;
87
+
88
+ /** Ready-to-use API payload (id stripped, undefined if no conditions) */
89
+ payload: Filter | undefined;
90
+
154
91
  /** Whether any conditions exist */
155
92
  hasConditions: boolean;
156
- /** Whether more conditions can be added */
157
- canAddCondition: boolean;
93
+
94
+ // ============================================================
95
+ // ADD OPERATIONS (return id of created item)
96
+ // ============================================================
97
+
98
+ /**
99
+ * Add a leaf condition at root level
100
+ * @returns The id of the created condition
101
+ */
102
+ add: (condition: Omit<Condition, "id">) => string;
103
+
104
+ /**
105
+ * Add a condition group at root level
106
+ * @returns The id of the created group
107
+ */
108
+ addGroup: (operator: ConditionGroupOperator) => string;
109
+
110
+ /**
111
+ * Add a leaf condition to a specific parent group
112
+ * @param parentId - The id of the parent ConditionGroup
113
+ * @returns The id of the created condition
114
+ */
115
+ addTo: (parentId: string, condition: Omit<Condition, "id">) => string;
116
+
117
+ /**
118
+ * Add a condition group to a specific parent group
119
+ * @param parentId - The id of the parent ConditionGroup
120
+ * @returns The id of the created group
121
+ */
122
+ addGroupTo: (parentId: string, operator: ConditionGroupOperator) => string;
123
+
124
+ // ============================================================
125
+ // UPDATE OPERATIONS
126
+ // ============================================================
127
+
128
+ /**
129
+ * Update a leaf condition by id
130
+ * @param id - The id of the condition to update
131
+ * @param updates - Partial updates to apply
132
+ */
133
+ update: (id: string, updates: Partial<Omit<Condition, "id">>) => void;
134
+
135
+ /**
136
+ * Update a condition group's operator by id
137
+ * @param id - The id of the group to update
138
+ * @param operator - The new operator
139
+ */
140
+ updateOperator: (id: string, operator: ConditionGroupOperator) => void;
141
+
142
+ // ============================================================
143
+ // REMOVE & ACCESS
144
+ // ============================================================
145
+
146
+ /**
147
+ * Remove a condition or group by id
148
+ * @param id - The id of the item to remove
149
+ */
150
+ remove: (id: string) => void;
151
+
152
+ /**
153
+ * Get a condition or group by id
154
+ * @param id - The id to look up
155
+ * @returns The item or undefined if not found
156
+ */
157
+ get: (id: string) => Condition | ConditionGroup | undefined;
158
+
159
+ // ============================================================
160
+ // UTILITY
161
+ // ============================================================
162
+
163
+ /** Clear all conditions */
164
+ clear: () => void;
165
+
166
+ /** Set the root operator for combining conditions */
167
+ setOperator: (op: ConditionGroupOperator) => void;
168
+
169
+ // ============================================================
170
+ // LEGACY API (for backwards compatibility)
171
+ // ============================================================
172
+
173
+ /**
174
+ * @deprecated Use `items` instead
175
+ */
176
+ conditions: Array<Condition | ConditionGroup>;
158
177
  }