@ram_28/kf-ai-sdk 1.0.7 → 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 (35) 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 -3
  4. package/dist/components/hooks/useFilter/index.d.ts.map +1 -1
  5. package/dist/components/hooks/useFilter/types.d.ts +83 -109
  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 -46
  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 -33
  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 +12 -12
  19. package/dist/index.mjs +2130 -2368
  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 -18
  25. package/sdk/components/hooks/useFilter/types.ts +157 -123
  26. package/sdk/components/hooks/useFilter/useFilter.ts +259 -393
  27. package/sdk/components/hooks/useKanban/index.ts +0 -1
  28. package/sdk/components/hooks/useKanban/types.ts +8 -66
  29. package/sdk/components/hooks/useKanban/useKanban.ts +14 -75
  30. package/sdk/components/hooks/useTable/types.ts +7 -60
  31. package/sdk/components/hooks/useTable/useTable.ts +13 -121
  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/sdk/components/hooks/useFilter/payloadBuilder.utils.ts +0 -298
@@ -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
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../sdk/types/common.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,K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  "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,24 +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
- ValidationResult,
10
- ValidationError,
6
+ Condition,
7
+ ConditionGroup,
8
+ ConditionGroupOperator,
9
+ Filter,
10
+ FilterRHSType,
11
11
  UseFilterOptions,
12
- UseFilterReturn
13
- } from './types';
12
+ UseFilterReturn,
13
+ // Legacy type exports
14
+ FilterCondition,
15
+ FilterOperator,
16
+ } from "./types";
14
17
 
15
- // Payload building utilities
18
+ // Type guard exports
16
19
  export {
17
- buildFilterPayload,
18
- buildFilterPayloadFromState,
19
- validateFilterPayload,
20
- cloneFilterPayload,
21
- mergeFilterPayloads,
22
- filterPayloadToString,
23
- areFilterPayloadsEqual
24
- } from './payloadBuilder.utils';
20
+ isCondition,
21
+ isConditionGroup,
22
+ // Legacy type guard exports
23
+ isFilterCondition,
24
+ isFilterLogical,
25
+ } from "./types";
@@ -1,143 +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 ValidationResult {
55
- /** Whether the validation passed */
56
- isValid: boolean;
57
- /** Array of error messages */
58
- errors: string[];
59
- }
50
+ /**
51
+ * @deprecated Use `isConditionGroup` instead
52
+ */
53
+ export const isFilterLogical = isConditionGroup;
60
54
 
61
- export interface ValidationError {
62
- /** ID of the condition with errors */
63
- conditionId: string;
64
- /** Field name */
65
- field: string;
66
- /** Error message */
67
- message: string;
68
- }
55
+ /**
56
+ * @deprecated Use `isCondition` instead
57
+ */
58
+ export const isFilterCondition = isCondition;
69
59
 
60
+ // ============================================================
61
+ // HOOK-SPECIFIC TYPE DEFINITIONS
62
+ // ============================================================
63
+
64
+ /**
65
+ * Hook options (minimal configuration)
66
+ */
70
67
  export interface UseFilterOptions {
71
68
  /** Initial filter conditions */
72
- initialConditions?: FilterConditionWithId[];
73
- /** Initial logical operator */
74
- initialLogicalOperator?: LogicalOperator;
75
- /** Whether to validate conditions on change */
76
- validateOnChange?: boolean;
77
- /** Callback when condition is added */
78
- onConditionAdd?: (condition: FilterConditionWithId) => void;
79
- /** Callback when condition is updated */
80
- onConditionUpdate?: (condition: FilterConditionWithId) => void;
81
- /** Callback when condition is removed */
82
- onConditionRemove?: (conditionId: string) => void;
83
- /** Callback when validation errors occur */
84
- onValidationError?: (errors: ValidationError[]) => void;
69
+ initialConditions?: Array<Condition | ConditionGroup>;
70
+ /** Initial operator for combining conditions (defaults to "And") */
71
+ initialOperator?: ConditionGroupOperator;
85
72
  }
86
73
 
87
- export interface UseFilterReturn<T = any> {
88
- // Current state
89
- /** Array of current filter conditions */
90
- conditions: FilterConditionWithId[];
91
- /** Current logical operator */
92
- logicalOperator: LogicalOperator;
93
- /** SDK-formatted filter payload for API calls */
94
- filterPayload: Filter | undefined;
95
- /** Overall validation state */
96
- isValid: boolean;
97
- /** Array of validation errors */
98
- validationErrors: ValidationError[];
99
-
100
- // Condition management
101
- /** Add a new filter condition (type-safe: lhsField constrained to keyof T) */
102
- addCondition: (condition: TypedFilterConditionInput<T>) => string;
103
- /** Update an existing condition */
104
- updateCondition: (id: string, updates: Partial<TypedFilterConditionInput<T>>) => boolean;
105
- /** Remove a condition by ID */
106
- removeCondition: (id: string) => boolean;
107
- /** Clear all conditions */
108
- clearConditions: () => void;
109
- /** Get a specific condition by ID */
110
- getCondition: (id: string) => FilterConditionWithId | undefined;
111
-
112
- // Logical operator management
113
- /** Set the root logical operator */
114
- setLogicalOperator: (operator: LogicalOperator) => void;
115
-
116
- // Bulk operations
117
- /** Replace all conditions */
118
- setConditions: (conditions: FilterConditionWithId[]) => void;
119
- /** Replace a specific condition */
120
- replaceCondition: (id: string, newCondition: TypedFilterConditionInput<T>) => boolean;
121
-
122
- // Validation
123
- /** Validate a single condition */
124
- validateCondition: (condition: Partial<FilterConditionWithId>) => ValidationResult;
125
- /** Validate all current conditions */
126
- validateAllConditions: () => ValidationResult;
127
-
128
- // State management
129
- /** Export current filter state */
130
- exportState: () => FilterState;
131
- /** Import a filter state */
132
- importState: (state: FilterState) => void;
133
- /** Reset to initial state */
134
- resetToInitial: () => void;
135
-
136
- // Utilities
137
- /** Get total number of conditions */
138
- 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
+
139
91
  /** Whether any conditions exist */
140
92
  hasConditions: boolean;
141
- /** Whether more conditions can be added */
142
- 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>;
143
177
  }