@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.
Files changed (105) hide show
  1. package/README.md +16 -8
  2. package/dist/{FileField-BWrSHNRq.js → FileField-CZjS2uLh.js} +3 -3
  3. package/dist/{FileField-eDeuzln8.cjs → FileField-DU4UWo_t.cjs} +1 -1
  4. package/dist/api.cjs +1 -1
  5. package/dist/api.mjs +1 -1
  6. package/dist/auth/authConfig.d.ts +1 -1
  7. package/dist/auth/types.d.ts +1 -1
  8. package/dist/auth/types.d.ts.map +1 -1
  9. package/dist/auth.cjs +1 -1
  10. package/dist/auth.mjs +1 -1
  11. package/dist/bdo/core/Item.d.ts +0 -4
  12. package/dist/bdo/core/Item.d.ts.map +1 -1
  13. package/dist/bdo/fields/ReferenceField.d.ts +1 -1
  14. package/dist/bdo/fields/ReferenceField.d.ts.map +1 -1
  15. package/dist/bdo/fields/SelectField.d.ts +1 -1
  16. package/dist/bdo/fields/SelectField.d.ts.map +1 -1
  17. package/dist/bdo/fields/UserField.d.ts +1 -1
  18. package/dist/bdo/fields/UserField.d.ts.map +1 -1
  19. package/dist/bdo.cjs +1 -1
  20. package/dist/bdo.mjs +53 -62
  21. package/dist/components/hooks/useActivityForm/types.d.ts +4 -5
  22. package/dist/components/hooks/useActivityForm/types.d.ts.map +1 -1
  23. package/dist/components/hooks/useActivityForm/useActivityForm.d.ts.map +1 -1
  24. package/dist/components/hooks/useActivityTable/types.d.ts +5 -4
  25. package/dist/components/hooks/useActivityTable/types.d.ts.map +1 -1
  26. package/dist/components/hooks/useActivityTable/useActivityTable.d.ts.map +1 -1
  27. package/dist/components/hooks/useBDOForm/createItemProxy.d.ts +2 -3
  28. package/dist/components/hooks/useBDOForm/createItemProxy.d.ts.map +1 -1
  29. package/dist/components/hooks/useBDOTable/types.d.ts +20 -12
  30. package/dist/components/hooks/useBDOTable/types.d.ts.map +1 -1
  31. package/dist/components/hooks/useBDOTable/useBDOTable.d.ts +2 -2
  32. package/dist/components/hooks/useBDOTable/useBDOTable.d.ts.map +1 -1
  33. package/dist/{constants-ConHc1oS.js → constants-Cyi942Yr.js} +5 -5
  34. package/dist/constants-DEmYwKfC.cjs +1 -0
  35. package/dist/filter.cjs +1 -1
  36. package/dist/filter.mjs +1 -1
  37. package/dist/form.cjs +1 -1
  38. package/dist/form.mjs +226 -243
  39. package/dist/table.cjs +1 -1
  40. package/dist/table.mjs +15 -16
  41. package/dist/table.types.d.ts +1 -1
  42. package/dist/table.types.d.ts.map +1 -1
  43. package/dist/types/constants.d.ts +1 -1
  44. package/dist/workflow/Activity.d.ts +8 -5
  45. package/dist/workflow/Activity.d.ts.map +1 -1
  46. package/dist/workflow.cjs +1 -1
  47. package/dist/workflow.mjs +461 -476
  48. package/docs/README.md +57 -0
  49. package/docs/bdo/README.md +161 -0
  50. package/docs/bdo/api_reference.md +281 -0
  51. package/docs/examples/bdo/create-product.md +69 -0
  52. package/docs/examples/bdo/edit-product-dialog.md +95 -0
  53. package/docs/examples/bdo/filtered-product-table.md +100 -0
  54. package/docs/examples/bdo/product-listing.md +73 -0
  55. package/docs/examples/bdo/supplier-dropdown.md +60 -0
  56. package/docs/examples/fields/complex-fields.md +248 -0
  57. package/docs/examples/fields/primitive-fields.md +217 -0
  58. package/docs/examples/workflow/approve-leave-request.md +76 -0
  59. package/docs/examples/workflow/filtered-activity-table.md +101 -0
  60. package/docs/examples/workflow/my-pending-requests.md +90 -0
  61. package/docs/examples/workflow/start-new-workflow.md +47 -0
  62. package/docs/examples/workflow/submit-leave-request.md +72 -0
  63. package/docs/examples/workflow/workflow-progress.md +49 -0
  64. package/docs/fields/README.md +141 -0
  65. package/docs/fields/api_reference.md +134 -0
  66. package/docs/useActivityForm/README.md +244 -0
  67. package/docs/useActivityForm/api_reference.md +279 -0
  68. package/docs/useActivityTable/README.md +263 -0
  69. package/docs/useActivityTable/api_reference.md +294 -0
  70. package/docs/useBDOForm/README.md +175 -0
  71. package/docs/useBDOForm/api_reference.md +244 -0
  72. package/docs/useBDOTable/README.md +242 -0
  73. package/docs/useBDOTable/api_reference.md +253 -0
  74. package/docs/useFilter/README.md +323 -0
  75. package/docs/useFilter/api_reference.md +228 -0
  76. package/docs/workflow/README.md +158 -0
  77. package/docs/workflow/api_reference.md +161 -0
  78. package/package.json +1 -1
  79. package/sdk/auth/authConfig.ts +1 -1
  80. package/sdk/auth/types.ts +1 -1
  81. package/sdk/bdo/core/Item.ts +1 -10
  82. package/sdk/bdo/fields/ReferenceField.ts +1 -1
  83. package/sdk/bdo/fields/SelectField.ts +1 -1
  84. package/sdk/bdo/fields/UserField.ts +1 -1
  85. package/sdk/components/hooks/useActivityForm/types.ts +4 -6
  86. package/sdk/components/hooks/useActivityForm/useActivityForm.ts +10 -73
  87. package/sdk/components/hooks/useActivityTable/types.ts +4 -5
  88. package/sdk/components/hooks/useActivityTable/useActivityTable.ts +10 -8
  89. package/sdk/components/hooks/useBDOForm/createItemProxy.ts +17 -58
  90. package/sdk/components/hooks/useBDOTable/types.ts +20 -10
  91. package/sdk/components/hooks/useBDOTable/useBDOTable.ts +12 -8
  92. package/sdk/table.types.ts +2 -0
  93. package/sdk/types/constants.ts +1 -1
  94. package/sdk/workflow/Activity.ts +39 -7
  95. package/dist/constants-QX2RX-wu.cjs +0 -1
  96. package/docs/api.md +0 -95
  97. package/docs/bdo.md +0 -224
  98. package/docs/gaps.md +0 -360
  99. package/docs/useActivityForm.md +0 -393
  100. package/docs/useActivityTable.md +0 -418
  101. package/docs/useBDOForm.md +0 -376
  102. package/docs/useBDOTable.md +0 -284
  103. package/docs/useFilter.md +0 -188
  104. package/docs/workflow.md +0 -560
  105. /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
- ```