@ram_28/kf-ai-sdk 1.0.18 → 1.0.20
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 +45 -12
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api.cjs +1 -1
- package/dist/api.mjs +2 -2
- package/dist/auth.cjs +1 -1
- package/dist/auth.mjs +1 -1
- package/dist/{client-C15j4O5B.cjs → client-DgtkT50N.cjs} +1 -1
- package/dist/{client-CfvLiGfP.js → client-V-WzUb8H.js} +9 -5
- package/dist/components/hooks/useFilter/types.d.ts +14 -11
- package/dist/components/hooks/useFilter/types.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/useFilter.d.ts +1 -1
- package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -1
- package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
- package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/context.d.ts +1 -1
- package/dist/components/hooks/useKanban/context.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/types.d.ts +5 -22
- package/dist/components/hooks/useKanban/types.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -1
- package/dist/components/hooks/useTable/types.d.ts +19 -31
- package/dist/components/hooks/useTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
- package/dist/error-handling-CAoD0Kwb.cjs +1 -0
- package/dist/error-handling-CrhTtD88.js +14 -0
- package/dist/filter.cjs +1 -1
- package/dist/filter.mjs +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.mjs +825 -814
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/kanban.cjs +2 -2
- package/dist/kanban.mjs +335 -323
- package/dist/{metadata-2FLBsFcf.cjs → metadata-0lZAfuTP.cjs} +1 -1
- package/dist/{metadata-DBcoDth-.js → metadata-B88D_pVS.js} +1 -1
- package/dist/table.cjs +1 -1
- package/dist/table.mjs +113 -96
- package/dist/table.types.d.ts +1 -1
- package/dist/table.types.d.ts.map +1 -1
- package/dist/types/common.d.ts +26 -6
- package/dist/types/common.d.ts.map +1 -1
- package/dist/useFilter-DzpP_ag0.cjs +1 -0
- package/dist/useFilter-H5bgAZQF.js +120 -0
- package/dist/utils/api/buildListOptions.d.ts +43 -0
- package/dist/utils/api/buildListOptions.d.ts.map +1 -0
- package/dist/utils/api/index.d.ts +2 -0
- package/dist/utils/api/index.d.ts.map +1 -0
- package/dist/utils/error-handling.d.ts +41 -0
- package/dist/utils/error-handling.d.ts.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/docs/QUICK_REFERENCE.md +142 -420
- package/docs/useAuth.md +52 -340
- package/docs/useFilter.md +858 -162
- package/docs/useForm.md +712 -501
- package/docs/useKanban.md +534 -279
- package/docs/useTable.md +725 -214
- package/package.json +1 -1
- package/sdk/api/client.ts +7 -1
- package/sdk/components/hooks/useFilter/types.ts +14 -11
- package/sdk/components/hooks/useFilter/useFilter.ts +20 -18
- package/sdk/components/hooks/useForm/apiClient.ts +2 -1
- package/sdk/components/hooks/useForm/useForm.ts +47 -13
- package/sdk/components/hooks/useKanban/context.ts +5 -3
- package/sdk/components/hooks/useKanban/types.ts +7 -23
- package/sdk/components/hooks/useKanban/useKanban.ts +54 -18
- package/sdk/components/hooks/useTable/types.ts +26 -32
- package/sdk/components/hooks/useTable/useTable.llm.txt +8 -22
- package/sdk/components/hooks/useTable/useTable.ts +70 -25
- package/sdk/index.ts +154 -10
- package/sdk/table.types.ts +3 -0
- package/sdk/types/common.ts +31 -6
- package/sdk/utils/api/buildListOptions.ts +120 -0
- package/sdk/utils/api/index.ts +2 -0
- package/sdk/utils/error-handling.ts +150 -0
- package/sdk/utils/index.ts +6 -0
- package/dist/useFilter-Dofowpr_.cjs +0 -1
- package/dist/useFilter-Dv-mr9QW.js +0 -117
package/docs/QUICK_REFERENCE.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# KF AI SDK - Quick Reference
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Quick reference for common operations. See individual hook docs for detailed examples.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
4
6
|
|
|
5
7
|
```bash
|
|
6
8
|
npm install @ram_28/kf-ai-sdk
|
|
@@ -8,521 +10,241 @@ npm install @ram_28/kf-ai-sdk
|
|
|
8
10
|
|
|
9
11
|
```typescript
|
|
10
12
|
import { setApiBaseUrl } from "@ram_28/kf-ai-sdk/api";
|
|
11
|
-
|
|
12
|
-
// Configure API base URL (without /api/app - SDK adds proper paths automatically)
|
|
13
13
|
setApiBaseUrl("https://api.your-domain.com");
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## useTable
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
[Full Documentation](./useTable.md)
|
|
19
21
|
|
|
20
22
|
```typescript
|
|
21
23
|
import { useTable } from "@ram_28/kf-ai-sdk/table";
|
|
22
|
-
import type { UseTableOptionsType, UseTableReturnType, ColumnDefinitionType } from "@ram_28/kf-ai-sdk/table/types";
|
|
23
24
|
|
|
24
|
-
const table = useTable<
|
|
25
|
-
source: "
|
|
25
|
+
const table = useTable<Product>({
|
|
26
|
+
source: "BDO_Products",
|
|
26
27
|
columns: [
|
|
27
28
|
{ fieldId: "Title", enableSorting: true },
|
|
28
|
-
{ fieldId: "Price", enableSorting: true
|
|
29
|
+
{ fieldId: "Price", enableSorting: true },
|
|
29
30
|
],
|
|
31
|
+
initialState: {
|
|
32
|
+
pagination: { pageNo: 1, pageSize: 10 },
|
|
33
|
+
},
|
|
30
34
|
});
|
|
31
35
|
```
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
| Property | Description |
|
|
38
|
+
|----------|-------------|
|
|
39
|
+
| `table.rows` | Current data |
|
|
40
|
+
| `table.isLoading` | Loading state |
|
|
41
|
+
| `table.search.setQuery(q)` | Set search |
|
|
42
|
+
| `table.sort.toggle(field)` | Toggle sort |
|
|
43
|
+
| `table.filter.addCondition({...})` | Add filter |
|
|
44
|
+
| `table.pagination.goToNext()` | Next page |
|
|
34
45
|
|
|
35
|
-
|
|
36
|
-
| --------------------- | -------------------------- | ------------------ |
|
|
37
|
-
| `rows` | `T[]` | Current table data |
|
|
38
|
-
| `isLoading` | `boolean` | Loading state |
|
|
39
|
-
| `totalItems` | `number` | Total count |
|
|
40
|
-
| `search.query` | `string` | Current search |
|
|
41
|
-
| `search.setQuery` | `(query: string) => void` | Update search |
|
|
42
|
-
| `sort.toggle` | `(field: keyof T) => void` | Toggle sort |
|
|
43
|
-
| `pagination.goToNext` | `() => void` | Next page |
|
|
44
|
-
| `filter.addCondition` | `(condition) => string` | Add filter |
|
|
46
|
+
---
|
|
45
47
|
|
|
46
|
-
## useForm
|
|
48
|
+
## useForm
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
[Full Documentation](./useForm.md)
|
|
49
51
|
|
|
50
52
|
```typescript
|
|
51
53
|
import { useForm } from "@ram_28/kf-ai-sdk/form";
|
|
52
|
-
import type { UseFormOptionsType, UseFormReturnType, FormFieldConfigType } from "@ram_28/kf-ai-sdk/form/types";
|
|
53
54
|
|
|
54
|
-
const form = useForm<
|
|
55
|
-
source: "
|
|
55
|
+
const form = useForm<Product>({
|
|
56
|
+
source: "BDO_Products",
|
|
56
57
|
operation: "create", // or "update"
|
|
57
|
-
|
|
58
|
-
onComputationRule: async (context) => {
|
|
59
|
-
// Handle server-side computation rules
|
|
60
|
-
const result = await api(context.source).update(id, data);
|
|
61
|
-
return result.computedFields;
|
|
62
|
-
},
|
|
58
|
+
recordId: "...", // for update
|
|
63
59
|
});
|
|
64
60
|
```
|
|
65
61
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
| `
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
73
|
-
| `
|
|
74
|
-
| `isSubmitting` | `boolean` | Submit state |
|
|
75
|
-
| `getField` | `(fieldName) => ProcessedField` | Field metadata |
|
|
62
|
+
| Property | Description |
|
|
63
|
+
|----------|-------------|
|
|
64
|
+
| `form.register(field)` | Register input |
|
|
65
|
+
| `form.handleSubmit(onSuccess, onError)` | Submit handler |
|
|
66
|
+
| `form.errors` | Validation errors |
|
|
67
|
+
| `form.isValid` | Form validity |
|
|
68
|
+
| `form.getField(name)` | Field metadata |
|
|
69
|
+
| `form.watch(field)` | Watch value |
|
|
76
70
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
```typescript
|
|
80
|
-
const field = form.getField("Price");
|
|
81
|
-
if (field.permission.editable) {
|
|
82
|
-
// Field is editable for current role
|
|
83
|
-
}
|
|
84
|
-
if (field.permission.hidden) {
|
|
85
|
-
// Field should not be displayed
|
|
86
|
-
}
|
|
87
|
-
```
|
|
71
|
+
---
|
|
88
72
|
|
|
89
|
-
##
|
|
73
|
+
## useKanban
|
|
90
74
|
|
|
91
|
-
|
|
75
|
+
[Full Documentation](./useKanban.md)
|
|
92
76
|
|
|
93
77
|
```typescript
|
|
94
|
-
|
|
95
|
-
const adminProducts = new AmazonProductMaster("Admin");
|
|
96
|
-
|
|
97
|
-
// Seller - Limited access
|
|
98
|
-
const sellerProducts = new AmazonProductMaster("Seller");
|
|
78
|
+
import { useKanban } from "@ram_28/kf-ai-sdk/kanban";
|
|
99
79
|
|
|
100
|
-
|
|
101
|
-
|
|
80
|
+
const kanban = useKanban<TaskData>({
|
|
81
|
+
source: "BDO_Tasks",
|
|
82
|
+
columns: [
|
|
83
|
+
{ id: "todo", title: "To Do", position: 0 },
|
|
84
|
+
{ id: "done", title: "Done", position: 1 },
|
|
85
|
+
],
|
|
86
|
+
enableDragDrop: true,
|
|
87
|
+
});
|
|
102
88
|
```
|
|
103
89
|
|
|
104
|
-
|
|
90
|
+
| Property | Description |
|
|
91
|
+
|----------|-------------|
|
|
92
|
+
| `kanban.columns` | Columns with cards |
|
|
93
|
+
| `kanban.createCard({...})` | Create card |
|
|
94
|
+
| `kanban.moveCard(id, columnId)` | Move card |
|
|
95
|
+
| `kanban.getCardProps(card)` | Drag props |
|
|
96
|
+
| `kanban.filter.addCondition({...})` | Filter cards |
|
|
105
97
|
|
|
106
|
-
|
|
107
|
-
// Create
|
|
108
|
-
const result = await products.create({
|
|
109
|
-
ASIN: "B08N5WRWNW",
|
|
110
|
-
Title: "Product Name",
|
|
111
|
-
Price: 49.99,
|
|
112
|
-
});
|
|
98
|
+
---
|
|
113
99
|
|
|
114
|
-
|
|
115
|
-
const product = await products.get("PROD-001");
|
|
100
|
+
## useFilter
|
|
116
101
|
|
|
117
|
-
|
|
118
|
-
await products.update("PROD-001", { Price: 44.99 });
|
|
102
|
+
[Full Documentation](./useFilter.md)
|
|
119
103
|
|
|
120
|
-
|
|
121
|
-
|
|
104
|
+
```typescript
|
|
105
|
+
import { useFilter, isCondition, isConditionGroup } from "@ram_28/kf-ai-sdk/filter";
|
|
122
106
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
Sort: [{ Price: "DESC" }],
|
|
126
|
-
PageSize: 20,
|
|
127
|
-
Filter: {
|
|
128
|
-
Operator: "AND",
|
|
129
|
-
Condition: [
|
|
130
|
-
{ LhsField: "Category", Operator: "EQ", RhsValue: "Electronics" },
|
|
131
|
-
],
|
|
132
|
-
},
|
|
107
|
+
const filter = useFilter({
|
|
108
|
+
initialOperator: "And",
|
|
133
109
|
});
|
|
134
110
|
```
|
|
135
111
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
// Clear cache when role changes
|
|
144
|
-
clearExpressionCache();
|
|
145
|
-
```
|
|
112
|
+
| Property | Description |
|
|
113
|
+
|----------|-------------|
|
|
114
|
+
| `filter.addCondition({...})` | Add condition |
|
|
115
|
+
| `filter.addConditionGroup(op)` | Add group |
|
|
116
|
+
| `filter.clearAllConditions()` | Clear all |
|
|
117
|
+
| `filter.payload` | API-ready payload |
|
|
118
|
+
| `filter.hasConditions` | Has filters |
|
|
146
119
|
|
|
147
|
-
###
|
|
120
|
+
### Operators
|
|
148
121
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
122
|
+
| Operator | Description |
|
|
123
|
+
|----------|-------------|
|
|
124
|
+
| `EQ`, `NE` | Equal, Not Equal |
|
|
125
|
+
| `GT`, `GTE`, `LT`, `LTE` | Comparisons |
|
|
126
|
+
| `Between`, `NotBetween` | Range |
|
|
127
|
+
| `IN`, `NIN` | List match |
|
|
128
|
+
| `Contains`, `NotContains` | Text search |
|
|
129
|
+
| `Empty`, `NotEmpty` | Null check |
|
|
156
130
|
|
|
157
|
-
|
|
131
|
+
---
|
|
158
132
|
|
|
159
|
-
|
|
160
|
-
| ------------------ | ----------- | ----------------- | ------------------- |
|
|
161
|
-
| **Validation** | Client-side | Field validation | ASIN format check |
|
|
162
|
-
| **Computation** | Server-side | Calculated fields | Discount percentage |
|
|
163
|
-
| **Business Logic** | Server-side | Complex logic | Inventory updates |
|
|
133
|
+
## useAuth
|
|
164
134
|
|
|
165
|
-
|
|
135
|
+
[Full Documentation](./useAuth.md)
|
|
166
136
|
|
|
167
137
|
```typescript
|
|
168
|
-
|
|
169
|
-
"LENGTH(ASIN) == 10 AND MATCHES(ASIN, '^[A-Z0-9]{10}$')";
|
|
138
|
+
import { useAuth, AuthProvider } from "@ram_28/kf-ai-sdk/auth";
|
|
170
139
|
|
|
171
|
-
//
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
## Error Handling
|
|
176
|
-
|
|
177
|
-
### Form Errors
|
|
140
|
+
// Wrap app
|
|
141
|
+
<AuthProvider config={{ sessionEndpoint: "/api/id" }}>
|
|
142
|
+
<App />
|
|
143
|
+
</AuthProvider>
|
|
178
144
|
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
onError: (error) => toast.error(error.message),
|
|
182
|
-
onSubmitError: (error) => {
|
|
183
|
-
if (error.code === "VALIDATION_FAILED") {
|
|
184
|
-
// Handle validation errors
|
|
185
|
-
}
|
|
186
|
-
},
|
|
187
|
-
});
|
|
145
|
+
// Use in components
|
|
146
|
+
const auth = useAuth();
|
|
188
147
|
```
|
|
189
148
|
|
|
190
|
-
|
|
149
|
+
| Property | Description |
|
|
150
|
+
|----------|-------------|
|
|
151
|
+
| `auth.user` | Current user |
|
|
152
|
+
| `auth.isAuthenticated` | Auth status |
|
|
153
|
+
| `auth.login(provider?)` | Sign in |
|
|
154
|
+
| `auth.logout()` | Sign out |
|
|
155
|
+
| `auth.hasRole(role)` | Check role |
|
|
156
|
+
| `auth.hasAnyRole(roles)` | Check roles |
|
|
191
157
|
|
|
192
|
-
|
|
193
|
-
try {
|
|
194
|
-
await products.create(data);
|
|
195
|
-
} catch (error) {
|
|
196
|
-
switch (error.code) {
|
|
197
|
-
case "PERMISSION_DENIED":
|
|
198
|
-
// Handle permission error
|
|
199
|
-
break;
|
|
200
|
-
case "VALIDATION_FAILED":
|
|
201
|
-
// Handle validation error
|
|
202
|
-
break;
|
|
203
|
-
default:
|
|
204
|
-
// Handle other errors
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
```
|
|
158
|
+
---
|
|
208
159
|
|
|
209
|
-
##
|
|
160
|
+
## Common Patterns
|
|
210
161
|
|
|
211
|
-
###
|
|
162
|
+
### Filter by Category
|
|
212
163
|
|
|
213
164
|
```typescript
|
|
165
|
+
table.filter.clearAllConditions();
|
|
214
166
|
table.filter.addCondition({
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
167
|
+
Operator: "EQ",
|
|
168
|
+
LHSField: "Category",
|
|
169
|
+
RHSValue: "Electronics",
|
|
218
170
|
});
|
|
219
171
|
```
|
|
220
172
|
|
|
221
|
-
###
|
|
173
|
+
### Filter by Date Range
|
|
222
174
|
|
|
223
175
|
```typescript
|
|
224
176
|
table.filter.addCondition({
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
177
|
+
Operator: "Between",
|
|
178
|
+
LHSField: "CreatedAt",
|
|
179
|
+
RHSValue: [startDate, endDate],
|
|
228
180
|
});
|
|
181
|
+
```
|
|
229
182
|
|
|
183
|
+
### My Tasks Filter
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
230
186
|
table.filter.addCondition({
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
187
|
+
Operator: "EQ",
|
|
188
|
+
LHSField: "AssignedTo",
|
|
189
|
+
RHSValue: currentUserId,
|
|
234
190
|
});
|
|
235
|
-
|
|
236
|
-
table.filter.setLogicalOperator("AND");
|
|
237
191
|
```
|
|
238
192
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
### Sorting
|
|
193
|
+
### Sortable Column Header
|
|
242
194
|
|
|
243
195
|
```typescript
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
Title {table.sort.field === "Title" && table.sort.direction}
|
|
196
|
+
<th onClick={() => table.sort.toggle("Price")}>
|
|
197
|
+
Price {table.sort.field === "Price" && (table.sort.direction === "asc" ? "↑" : "↓")}
|
|
247
198
|
</th>
|
|
248
199
|
```
|
|
249
200
|
|
|
250
|
-
### Pagination
|
|
201
|
+
### Pagination Controls
|
|
251
202
|
|
|
252
203
|
```typescript
|
|
253
|
-
<button
|
|
254
|
-
disabled={!table.pagination.canGoPrevious}
|
|
255
|
-
onClick={table.pagination.goToPrevious}
|
|
256
|
-
>
|
|
204
|
+
<button onClick={table.pagination.goToPrevious} disabled={!table.pagination.canGoPrevious}>
|
|
257
205
|
Previous
|
|
258
206
|
</button>
|
|
259
|
-
|
|
260
|
-
<
|
|
261
|
-
Page {table.pagination.currentPage} of {table.pagination.totalPages}
|
|
262
|
-
</span>
|
|
263
|
-
|
|
264
|
-
<button
|
|
265
|
-
disabled={!table.pagination.canGoNext}
|
|
266
|
-
onClick={table.pagination.goToNext}
|
|
267
|
-
>
|
|
207
|
+
<span>Page {table.pagination.pageNo} of {table.pagination.totalPages}</span>
|
|
208
|
+
<button onClick={table.pagination.goToNext} disabled={!table.pagination.canGoNext}>
|
|
268
209
|
Next
|
|
269
210
|
</button>
|
|
270
211
|
```
|
|
271
212
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
### Role-Based Field Access
|
|
213
|
+
### Protected Route
|
|
275
214
|
|
|
276
215
|
```typescript
|
|
277
|
-
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
)}
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
### Method Permissions
|
|
287
|
-
|
|
288
|
-
```typescript
|
|
289
|
-
// TypeScript enforces this at compile time
|
|
290
|
-
const buyerProducts = AmazonProducts.Buyer();
|
|
291
|
-
// buyerProducts.create() // ❌ Compile error
|
|
292
|
-
// buyerProducts.delete() // ❌ Compile error
|
|
293
|
-
const products = await buyerProducts.list(); // ✅ OK
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
## Common Patterns
|
|
297
|
-
|
|
298
|
-
### Search with Debouncing
|
|
299
|
-
|
|
300
|
-
```typescript
|
|
301
|
-
const [search, setSearch] = useState("");
|
|
302
|
-
|
|
303
|
-
useEffect(() => {
|
|
304
|
-
const timer = setTimeout(() => {
|
|
305
|
-
table.search.setQuery(search);
|
|
306
|
-
}, 300);
|
|
307
|
-
|
|
308
|
-
return () => clearTimeout(timer);
|
|
309
|
-
}, [search, table.search]);
|
|
310
|
-
|
|
311
|
-
<input
|
|
312
|
-
value={search}
|
|
313
|
-
onChange={(e) => setSearch(e.target.value)}
|
|
314
|
-
placeholder="Search..."
|
|
315
|
-
/>
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
### Dynamic Field Rendering
|
|
319
|
-
|
|
320
|
-
```typescript
|
|
321
|
-
const fields = form.getFields();
|
|
322
|
-
|
|
323
|
-
{Object.entries(fields).map(([fieldName, field]) => {
|
|
324
|
-
if (field.permission.hidden) return null;
|
|
325
|
-
|
|
326
|
-
return (
|
|
327
|
-
<div key={fieldName}>
|
|
328
|
-
<label>{field.label}</label>
|
|
329
|
-
<input
|
|
330
|
-
{...form.register(fieldName)}
|
|
331
|
-
disabled={!field.permission.editable}
|
|
332
|
-
type={field.type}
|
|
333
|
-
/>
|
|
334
|
-
</div>
|
|
335
|
-
);
|
|
336
|
-
})}
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
### Conditional Business Logic
|
|
340
|
-
|
|
341
|
-
```typescript
|
|
342
|
-
const form = useForm({
|
|
343
|
-
onComputationRule: async (context) => {
|
|
344
|
-
switch (context.ruleType) {
|
|
345
|
-
case "Computation":
|
|
346
|
-
// Handle computation rules
|
|
347
|
-
return await calculateFields(context);
|
|
348
|
-
case "BusinessLogic":
|
|
349
|
-
// Handle business logic rules
|
|
350
|
-
return await executeBusinessLogic(context);
|
|
351
|
-
}
|
|
352
|
-
},
|
|
353
|
-
});
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
## Type Definitions
|
|
357
|
-
|
|
358
|
-
### Hook Types
|
|
359
|
-
|
|
360
|
-
```typescript
|
|
361
|
-
// useTable types
|
|
362
|
-
import type {
|
|
363
|
-
UseTableOptionsType,
|
|
364
|
-
UseTableReturnType,
|
|
365
|
-
ColumnDefinitionType,
|
|
366
|
-
} from '@ram_28/kf-ai-sdk/table/types';
|
|
367
|
-
|
|
368
|
-
// useFilter types
|
|
369
|
-
import type {
|
|
370
|
-
UseFilterOptionsType,
|
|
371
|
-
UseFilterReturnType,
|
|
372
|
-
ConditionType,
|
|
373
|
-
ConditionGroupType,
|
|
374
|
-
FilterType,
|
|
375
|
-
} from '@ram_28/kf-ai-sdk/filter/types';
|
|
376
|
-
|
|
377
|
-
// useForm types
|
|
378
|
-
import type {
|
|
379
|
-
UseFormOptionsType,
|
|
380
|
-
UseFormReturnType,
|
|
381
|
-
FormFieldConfigType,
|
|
382
|
-
FormSchemaConfigType,
|
|
383
|
-
FormOperationType,
|
|
384
|
-
BDOSchemaType,
|
|
385
|
-
} from '@ram_28/kf-ai-sdk/form/types';
|
|
386
|
-
|
|
387
|
-
// useKanban types
|
|
388
|
-
import type {
|
|
389
|
-
UseKanbanOptionsType,
|
|
390
|
-
UseKanbanReturnType,
|
|
391
|
-
KanbanCardType,
|
|
392
|
-
KanbanColumnType,
|
|
393
|
-
ColumnConfigType,
|
|
394
|
-
} from '@ram_28/kf-ai-sdk/kanban/types';
|
|
395
|
-
|
|
396
|
-
// useAuth types
|
|
397
|
-
import type {
|
|
398
|
-
UseAuthReturnType,
|
|
399
|
-
UserDetailsType,
|
|
400
|
-
AuthStatusType,
|
|
401
|
-
AuthProviderPropsType,
|
|
402
|
-
LoginOptionsType,
|
|
403
|
-
LogoutOptionsType,
|
|
404
|
-
} from '@ram_28/kf-ai-sdk/auth/types';
|
|
405
|
-
```
|
|
406
|
-
|
|
407
|
-
### Common Types
|
|
408
|
-
|
|
409
|
-
```typescript
|
|
410
|
-
import type {
|
|
411
|
-
// Filter operators
|
|
412
|
-
ConditionOperatorType, // "EQ" | "NE" | "GT" | "GTE" | "LT" | "LTE" | "Between" | "NotBetween" | "IN" | "NIN" | "Empty" | "NotEmpty" | "Contains" | "NotContains" | "MinLength" | "MaxLength"
|
|
413
|
-
ConditionGroupOperatorType, // "And" | "Or" | "Not"
|
|
414
|
-
FilterRHSTypeType, // "Constant" | "BOField" | "AppVariable"
|
|
415
|
-
|
|
416
|
-
// API types
|
|
417
|
-
ListOptionsType,
|
|
418
|
-
ListResponseType,
|
|
419
|
-
CreateUpdateResponseType,
|
|
420
|
-
} from '@ram_28/kf-ai-sdk/api/types';
|
|
421
|
-
```
|
|
422
|
-
|
|
423
|
-
### Base Field Types
|
|
424
|
-
|
|
425
|
-
```typescript
|
|
426
|
-
import type {
|
|
427
|
-
IdFieldType,
|
|
428
|
-
StringFieldType,
|
|
429
|
-
TextAreaFieldType,
|
|
430
|
-
NumberFieldType,
|
|
431
|
-
BooleanFieldType,
|
|
432
|
-
DateFieldType,
|
|
433
|
-
DateTimeFieldType,
|
|
434
|
-
CurrencyFieldType,
|
|
435
|
-
SelectFieldType,
|
|
436
|
-
LookupFieldType,
|
|
437
|
-
ReferenceFieldType,
|
|
438
|
-
} from '@ram_28/kf-ai-sdk/types';
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
### Quick Type Summary
|
|
442
|
-
|
|
443
|
-
| Type | Values/Purpose |
|
|
444
|
-
|------|----------------|
|
|
445
|
-
| `ConditionOperatorType` | `"EQ"`, `"NE"`, `"GT"`, `"GTE"`, `"LT"`, `"LTE"`, `"Between"`, `"NotBetween"`, `"IN"`, `"NIN"`, `"Empty"`, `"NotEmpty"`, `"Contains"`, `"NotContains"`, `"MinLength"`, `"MaxLength"` |
|
|
446
|
-
| `ConditionGroupOperatorType` | `"And"`, `"Or"`, `"Not"` (title case) |
|
|
447
|
-
| `FormOperationType` | `"create"`, `"update"` |
|
|
448
|
-
| `AuthStatusType` | `"loading"`, `"authenticated"`, `"unauthenticated"` |
|
|
449
|
-
| `FilterRHSTypeType` | `"Constant"`, `"BOField"`, `"AppVariable"` |
|
|
450
|
-
|
|
451
|
-
## Debugging Tips
|
|
452
|
-
|
|
453
|
-
### Debug Table Issues
|
|
454
|
-
|
|
455
|
-
```typescript
|
|
456
|
-
console.log("Table state:", {
|
|
457
|
-
isLoading: table.isLoading,
|
|
458
|
-
totalItems: table.totalItems,
|
|
459
|
-
currentPage: table.pagination.currentPage,
|
|
460
|
-
filters: table.filter.conditions,
|
|
461
|
-
sort: { field: table.sort.field, direction: table.sort.direction },
|
|
462
|
-
});
|
|
216
|
+
function ProtectedRoute({ children }) {
|
|
217
|
+
const auth = useAuth();
|
|
218
|
+
if (auth.isLoading) return <div>Loading...</div>;
|
|
219
|
+
if (!auth.isAuthenticated) return <div>Please sign in</div>;
|
|
220
|
+
return children;
|
|
221
|
+
}
|
|
463
222
|
```
|
|
464
223
|
|
|
465
|
-
###
|
|
224
|
+
### Role-Based UI
|
|
466
225
|
|
|
467
226
|
```typescript
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
errors: form.errors,
|
|
471
|
-
values: form.watch(),
|
|
472
|
-
schema: form.processedSchema,
|
|
473
|
-
});
|
|
227
|
+
{auth.hasRole("Admin") && <AdminPanel />}
|
|
228
|
+
{auth.hasAnyRole(["Seller", "Admin"]) && <ProductManagement />}
|
|
474
229
|
```
|
|
475
230
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
```typescript
|
|
479
|
-
import { getApiBaseUrl, getDefaultHeaders } from "@ram_28/kf-ai-sdk/api";
|
|
480
|
-
|
|
481
|
-
console.log("API Config:", {
|
|
482
|
-
baseUrl: getApiBaseUrl(),
|
|
483
|
-
headers: getDefaultHeaders(),
|
|
484
|
-
});
|
|
485
|
-
```
|
|
486
|
-
|
|
487
|
-
## Configuration
|
|
231
|
+
---
|
|
488
232
|
|
|
489
|
-
|
|
233
|
+
## Type Imports
|
|
490
234
|
|
|
491
235
|
```typescript
|
|
492
|
-
|
|
236
|
+
// Table
|
|
237
|
+
import type { UseTableOptionsType, UseTableReturnType, ColumnDefinitionType } from "@ram_28/kf-ai-sdk/table/types";
|
|
493
238
|
|
|
494
|
-
//
|
|
495
|
-
|
|
496
|
-
setDefaultHeaders({
|
|
497
|
-
Authorization: `Bearer ${token}`,
|
|
498
|
-
"X-API-Version": "1.0",
|
|
499
|
-
});
|
|
500
|
-
```
|
|
239
|
+
// Form
|
|
240
|
+
import type { UseFormOptionsType, UseFormReturnType, FormFieldConfigType } from "@ram_28/kf-ai-sdk/form/types";
|
|
501
241
|
|
|
502
|
-
|
|
242
|
+
// Kanban
|
|
243
|
+
import type { UseKanbanOptionsType, UseKanbanReturnType, KanbanCardType, ColumnConfigType } from "@ram_28/kf-ai-sdk/kanban/types";
|
|
503
244
|
|
|
504
|
-
|
|
505
|
-
import {
|
|
506
|
-
|
|
507
|
-
const queryClient = new QueryClient({
|
|
508
|
-
defaultOptions: {
|
|
509
|
-
queries: {
|
|
510
|
-
staleTime: 5 * 60 * 1000, // 5 minutes
|
|
511
|
-
gcTime: 10 * 60 * 1000 // 10 minutes
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
});
|
|
245
|
+
// Filter
|
|
246
|
+
import type { ConditionType, ConditionGroupType, ConditionOperatorType, FilterType } from "@ram_28/kf-ai-sdk/filter/types";
|
|
515
247
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
</QueryClientProvider>
|
|
248
|
+
// Auth
|
|
249
|
+
import type { UseAuthReturnType, UserDetailsType, AuthStatusType } from "@ram_28/kf-ai-sdk/auth/types";
|
|
519
250
|
```
|
|
520
|
-
|
|
521
|
-
---
|
|
522
|
-
|
|
523
|
-
## Quick Links
|
|
524
|
-
|
|
525
|
-
- [Full Implementation Guide](./IMPLEMENTATION_GUIDE.md)
|
|
526
|
-
- [Examples Directory](./examples/)
|
|
527
|
-
- [API Documentation](./api-docs/)
|
|
528
|
-
- [Business Object Schemas](./schemas/)
|