@ram_28/kf-ai-sdk 2.0.16 → 2.0.18
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/README.md +16 -8
- package/dist/{FileField-BWrSHNRq.js → FileField-CZjS2uLh.js} +3 -3
- package/dist/{FileField-eDeuzln8.cjs → FileField-DU4UWo_t.cjs} +1 -1
- package/dist/api.cjs +1 -1
- package/dist/api.mjs +1 -1
- package/dist/auth/authConfig.d.ts +1 -1
- package/dist/auth/types.d.ts +1 -1
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth.cjs +1 -1
- package/dist/auth.mjs +1 -1
- package/dist/bdo/core/Item.d.ts +0 -4
- package/dist/bdo/core/Item.d.ts.map +1 -1
- package/dist/bdo/fields/ReferenceField.d.ts +1 -1
- package/dist/bdo/fields/ReferenceField.d.ts.map +1 -1
- package/dist/bdo/fields/SelectField.d.ts +1 -1
- package/dist/bdo/fields/SelectField.d.ts.map +1 -1
- package/dist/bdo/fields/UserField.d.ts +1 -1
- package/dist/bdo/fields/UserField.d.ts.map +1 -1
- package/dist/bdo.cjs +1 -1
- package/dist/bdo.mjs +53 -62
- package/dist/components/hooks/useActivityForm/types.d.ts +4 -5
- package/dist/components/hooks/useActivityForm/types.d.ts.map +1 -1
- package/dist/components/hooks/useActivityForm/useActivityForm.d.ts.map +1 -1
- package/dist/components/hooks/useActivityTable/types.d.ts +5 -4
- package/dist/components/hooks/useActivityTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useActivityTable/useActivityTable.d.ts.map +1 -1
- package/dist/components/hooks/useBDOForm/createItemProxy.d.ts +2 -3
- package/dist/components/hooks/useBDOForm/createItemProxy.d.ts.map +1 -1
- package/dist/components/hooks/useBDOTable/types.d.ts +20 -12
- package/dist/components/hooks/useBDOTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useBDOTable/useBDOTable.d.ts +2 -2
- package/dist/components/hooks/useBDOTable/useBDOTable.d.ts.map +1 -1
- package/dist/{constants-ConHc1oS.js → constants-Cyi942Yr.js} +5 -5
- package/dist/constants-DEmYwKfC.cjs +1 -0
- package/dist/filter.cjs +1 -1
- package/dist/filter.mjs +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.mjs +226 -243
- package/dist/table.cjs +1 -1
- package/dist/table.mjs +15 -16
- package/dist/table.types.d.ts +1 -1
- package/dist/table.types.d.ts.map +1 -1
- package/dist/types/constants.d.ts +1 -1
- package/dist/workflow/Activity.d.ts +8 -5
- package/dist/workflow/Activity.d.ts.map +1 -1
- package/dist/workflow.cjs +1 -1
- package/dist/workflow.mjs +461 -476
- package/docs/README.md +57 -0
- package/docs/bdo/README.md +161 -0
- package/docs/bdo/api_reference.md +281 -0
- package/docs/examples/bdo/create-product.md +69 -0
- package/docs/examples/bdo/edit-product-dialog.md +95 -0
- package/docs/examples/bdo/filtered-product-table.md +100 -0
- package/docs/examples/bdo/product-listing.md +73 -0
- package/docs/examples/bdo/supplier-dropdown.md +60 -0
- package/docs/examples/fields/complex-fields.md +248 -0
- package/docs/examples/fields/primitive-fields.md +217 -0
- package/docs/examples/workflow/approve-leave-request.md +76 -0
- package/docs/examples/workflow/filtered-activity-table.md +101 -0
- package/docs/examples/workflow/my-pending-requests.md +90 -0
- package/docs/examples/workflow/start-new-workflow.md +47 -0
- package/docs/examples/workflow/submit-leave-request.md +72 -0
- package/docs/examples/workflow/workflow-progress.md +49 -0
- package/docs/fields/README.md +141 -0
- package/docs/fields/api_reference.md +134 -0
- package/docs/useActivityForm/README.md +244 -0
- package/docs/useActivityForm/api_reference.md +279 -0
- package/docs/useActivityTable/README.md +263 -0
- package/docs/useActivityTable/api_reference.md +294 -0
- package/docs/useBDOForm/README.md +175 -0
- package/docs/useBDOForm/api_reference.md +244 -0
- package/docs/useBDOTable/README.md +242 -0
- package/docs/useBDOTable/api_reference.md +253 -0
- package/docs/useFilter/README.md +323 -0
- package/docs/useFilter/api_reference.md +228 -0
- package/docs/workflow/README.md +158 -0
- package/docs/workflow/api_reference.md +161 -0
- package/package.json +1 -1
- package/sdk/auth/authConfig.ts +1 -1
- package/sdk/auth/types.ts +1 -1
- package/sdk/bdo/core/Item.ts +1 -10
- package/sdk/bdo/fields/ReferenceField.ts +1 -1
- package/sdk/bdo/fields/SelectField.ts +1 -1
- package/sdk/bdo/fields/UserField.ts +1 -1
- package/sdk/components/hooks/useActivityForm/types.ts +4 -6
- package/sdk/components/hooks/useActivityForm/useActivityForm.ts +10 -73
- package/sdk/components/hooks/useActivityTable/types.ts +4 -5
- package/sdk/components/hooks/useActivityTable/useActivityTable.ts +10 -8
- package/sdk/components/hooks/useBDOForm/createItemProxy.ts +17 -58
- package/sdk/components/hooks/useBDOTable/types.ts +20 -10
- package/sdk/components/hooks/useBDOTable/useBDOTable.ts +12 -8
- package/sdk/table.types.ts +2 -0
- package/sdk/types/constants.ts +1 -1
- package/sdk/workflow/Activity.ts +39 -7
- package/dist/constants-QX2RX-wu.cjs +0 -1
- package/docs/api.md +0 -95
- package/docs/bdo.md +0 -224
- package/docs/gaps.md +0 -360
- package/docs/useActivityForm.md +0 -393
- package/docs/useActivityTable.md +0 -418
- package/docs/useBDOForm.md +0 -376
- package/docs/useBDOTable.md +0 -284
- package/docs/useFilter.md +0 -188
- package/docs/workflow.md +0 -560
- /package/docs/{useAuth.md → useAuth/README.md} +0 -0
package/docs/useFilter.md
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
# Filter SDK API
|
|
2
|
-
|
|
3
|
-
React hook for building filter conditions for tables, forms, and API calls.
|
|
4
|
-
|
|
5
|
-
## Imports
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
import { useFilter, isCondition, isConditionGroup, ConditionOperator, GroupOperator, FilterValueSource } from "@ram_28/kf-ai-sdk/filter";
|
|
9
|
-
import type { UseFilterOptionsType, UseFilterReturnType, ConditionType, ConditionGroupType, FilterType } from "@ram_28/kf-ai-sdk/filter/types";
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## Common Mistakes (READ FIRST)
|
|
15
|
-
|
|
16
|
-
### 1. Importing `RHSType` instead of `FilterValueSource`
|
|
17
|
-
|
|
18
|
-
There is NO named export `RHSType`. Import `FilterValueSource`. The JSON key IS called `RHSType`, but the value comes from `FilterValueSource`.
|
|
19
|
-
|
|
20
|
-
```typescript
|
|
21
|
-
// ❌ WRONG — RHSType is not an importable enum
|
|
22
|
-
import { RHSType } from "@ram_28/kf-ai-sdk/filter";
|
|
23
|
-
|
|
24
|
-
// ✅ CORRECT
|
|
25
|
-
import { FilterValueSource } from "@ram_28/kf-ai-sdk/filter";
|
|
26
|
-
{ RHSType: FilterValueSource.Constant }
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### 2. Wrong field name casing in ConditionType
|
|
30
|
-
|
|
31
|
-
`ConditionType` uses **PascalCase**: `Operator`, `LHSField`, `RHSValue`, `RHSType`. NOT camelCase.
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
// ❌ WRONG — camelCase
|
|
35
|
-
{ operator: "EQ", lhsField: "status", rhsValue: "Active" }
|
|
36
|
-
|
|
37
|
-
// ✅ CORRECT — PascalCase
|
|
38
|
-
{ Operator: ConditionOperator.EQ, LHSField: bdo.status.id, RHSValue: "Active", RHSType: FilterValueSource.Constant }
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### 3. Mixing hook init format with API format
|
|
42
|
-
|
|
43
|
-
Hook init (`UseFilterOptionsType`) uses lowercase `conditions`/`operator`. API format (`FilterType`/`ConditionType`) uses uppercase `Condition`/`Operator`.
|
|
44
|
-
|
|
45
|
-
```typescript
|
|
46
|
-
// Hook initialization — lowercase
|
|
47
|
-
useTable({ initialState: { filter: { conditions: [...], operator: "And" } } });
|
|
48
|
-
|
|
49
|
-
// API calls — uppercase
|
|
50
|
-
bdo.list({ Filter: { Operator: "And", Condition: [...] } });
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### 4. Hardcoded operator strings
|
|
54
|
-
|
|
55
|
-
ALWAYS use `ConditionOperator` constants. NEVER write `"Equals"`, `"equals"`, or `"eq"`.
|
|
56
|
-
|
|
57
|
-
```typescript
|
|
58
|
-
// ❌ WRONG
|
|
59
|
-
{ Operator: "Equals" } { Operator: "equals" } { Operator: "eq" }
|
|
60
|
-
|
|
61
|
-
// ✅ CORRECT
|
|
62
|
-
{ Operator: ConditionOperator.EQ } // "EQ"
|
|
63
|
-
{ Operator: ConditionOperator.Contains } // "Contains"
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### 5. Accessing `filter.conditions` instead of `filter.items`
|
|
67
|
-
|
|
68
|
-
```typescript
|
|
69
|
-
// ❌ WRONG — conditions does NOT exist
|
|
70
|
-
filter.conditions.length
|
|
71
|
-
|
|
72
|
-
// ✅ CORRECT
|
|
73
|
-
filter.items.length
|
|
74
|
-
filter.hasConditions // boolean shortcut
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### 6. Using `as const` on Operator values
|
|
78
|
-
|
|
79
|
-
```typescript
|
|
80
|
-
// ❌ WRONG — causes narrowing errors in arrays
|
|
81
|
-
[{ Operator: ConditionOperator.EQ as const, ... }]
|
|
82
|
-
|
|
83
|
-
// ✅ CORRECT — type the array
|
|
84
|
-
const conditions: Omit<ConditionType, "id">[] = [{ Operator: ConditionOperator.EQ, ... }];
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
## Constants
|
|
90
|
-
|
|
91
|
-
```typescript
|
|
92
|
-
// Condition operators
|
|
93
|
-
ConditionOperator.EQ ConditionOperator.NE // Equal, Not Equal
|
|
94
|
-
ConditionOperator.GT ConditionOperator.GTE // Greater Than (or Equal)
|
|
95
|
-
ConditionOperator.LT ConditionOperator.LTE // Less Than (or Equal)
|
|
96
|
-
ConditionOperator.Contains ConditionOperator.NotContains // String contains
|
|
97
|
-
ConditionOperator.IN ConditionOperator.NIN // Value in/not-in list
|
|
98
|
-
ConditionOperator.Empty ConditionOperator.NotEmpty // Null/empty check
|
|
99
|
-
ConditionOperator.Between ConditionOperator.NotBetween // Range
|
|
100
|
-
|
|
101
|
-
// Group operators
|
|
102
|
-
GroupOperator.And GroupOperator.Or GroupOperator.Not
|
|
103
|
-
|
|
104
|
-
// RHS value source (KEY is "RHSType", VALUE from FilterValueSource)
|
|
105
|
-
FilterValueSource.Constant // "Constant" — literal value
|
|
106
|
-
FilterValueSource.BDOField // "BDOField" — compare against another field
|
|
107
|
-
FilterValueSource.AppVariable // "AppVariable" — app variable
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
---
|
|
111
|
-
|
|
112
|
-
## Type Definitions
|
|
113
|
-
|
|
114
|
-
```typescript
|
|
115
|
-
interface ConditionType<T = any> {
|
|
116
|
-
id?: string; // Auto-generated
|
|
117
|
-
Operator: ConditionOperatorType; // PascalCase
|
|
118
|
-
LHSField: keyof T | string;
|
|
119
|
-
RHSValue: any;
|
|
120
|
-
RHSType?: "Constant" | "BDOField" | "AppVariable";
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
interface ConditionGroupType<T = any> {
|
|
124
|
-
id?: string;
|
|
125
|
-
Operator: "And" | "Or" | "Not";
|
|
126
|
-
Condition: Array<ConditionType<T> | ConditionGroupType<T>>;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
interface UseFilterOptionsType<T = any> { // lowercase — hook init
|
|
130
|
-
conditions?: Array<ConditionType<T> | ConditionGroupType<T>>;
|
|
131
|
-
operator?: "And" | "Or" | "Not";
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
interface UseFilterReturnType<T = any> {
|
|
135
|
-
operator: "And" | "Or" | "Not";
|
|
136
|
-
items: Array<ConditionType<T> | ConditionGroupType<T>>;
|
|
137
|
-
payload: FilterType<T> | undefined; // API-ready, undefined if empty
|
|
138
|
-
hasConditions: boolean;
|
|
139
|
-
addCondition: (condition: Omit<ConditionType<T>, "id">, parentId?: string) => string;
|
|
140
|
-
addConditionGroup: (operator: "And" | "Or" | "Not", parentId?: string) => string;
|
|
141
|
-
updateCondition: (id: string, updates: Partial<Omit<ConditionType<T>, "id">>) => void;
|
|
142
|
-
removeCondition: (id: string) => void;
|
|
143
|
-
clearAllConditions: () => void;
|
|
144
|
-
setRootOperator: (op: "And" | "Or" | "Not") => void;
|
|
145
|
-
}
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
---
|
|
149
|
-
|
|
150
|
-
## Usage Example
|
|
151
|
-
|
|
152
|
-
```tsx
|
|
153
|
-
import { useFilter, ConditionOperator, GroupOperator, FilterValueSource } from "@ram_28/kf-ai-sdk/filter";
|
|
154
|
-
import type { UseFilterOptionsType } from "@ram_28/kf-ai-sdk/filter/types";
|
|
155
|
-
|
|
156
|
-
// Standalone filter
|
|
157
|
-
const filter = useFilter<AdminProductFieldType>();
|
|
158
|
-
filter.addCondition({ Operator: ConditionOperator.EQ, LHSField: bdo.status.id, RHSValue: "Active", RHSType: FilterValueSource.Constant });
|
|
159
|
-
filter.addCondition({ Operator: ConditionOperator.GT, LHSField: bdo.unit_price.id, RHSValue: 100, RHSType: FilterValueSource.Constant });
|
|
160
|
-
|
|
161
|
-
// With useTable initialState
|
|
162
|
-
const table = useTable<AdminProductFieldType>({
|
|
163
|
-
source: bdo.meta._id,
|
|
164
|
-
columns,
|
|
165
|
-
initialState: {
|
|
166
|
-
filter: {
|
|
167
|
-
conditions: [
|
|
168
|
-
{ Operator: ConditionOperator.EQ, LHSField: "_created_by", RHSValue: user._id, RHSType: FilterValueSource.Constant },
|
|
169
|
-
],
|
|
170
|
-
operator: GroupOperator.And,
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// Dynamic filter with useEffect
|
|
176
|
-
useEffect(() => {
|
|
177
|
-
table.filter.clearAllConditions();
|
|
178
|
-
if (status !== "all") {
|
|
179
|
-
table.filter.addCondition({ Operator: ConditionOperator.EQ, LHSField: bdo.status.id, RHSValue: status, RHSType: FilterValueSource.Constant });
|
|
180
|
-
}
|
|
181
|
-
}, [status]);
|
|
182
|
-
|
|
183
|
-
// Nested: Category = "Electronics" AND (Price < 100 OR OnSale = true)
|
|
184
|
-
filter.addCondition({ Operator: ConditionOperator.EQ, LHSField: bdo.category.id, RHSValue: "Electronics", RHSType: FilterValueSource.Constant });
|
|
185
|
-
const orGroupId = filter.addConditionGroup(GroupOperator.Or);
|
|
186
|
-
filter.addCondition({ Operator: ConditionOperator.LT, LHSField: bdo.price.id, RHSValue: 100, RHSType: FilterValueSource.Constant }, orGroupId);
|
|
187
|
-
filter.addCondition({ Operator: ConditionOperator.EQ, LHSField: bdo.on_sale.id, RHSValue: true, RHSType: FilterValueSource.Constant }, orGroupId);
|
|
188
|
-
```
|