@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.
Files changed (77) hide show
  1. package/README.md +45 -12
  2. package/dist/api/client.d.ts.map +1 -1
  3. package/dist/api.cjs +1 -1
  4. package/dist/api.mjs +2 -2
  5. package/dist/auth.cjs +1 -1
  6. package/dist/auth.mjs +1 -1
  7. package/dist/{client-C15j4O5B.cjs → client-DgtkT50N.cjs} +1 -1
  8. package/dist/{client-CfvLiGfP.js → client-V-WzUb8H.js} +9 -5
  9. package/dist/components/hooks/useFilter/types.d.ts +14 -11
  10. package/dist/components/hooks/useFilter/types.d.ts.map +1 -1
  11. package/dist/components/hooks/useFilter/useFilter.d.ts +1 -1
  12. package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -1
  13. package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
  14. package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
  15. package/dist/components/hooks/useKanban/context.d.ts +1 -1
  16. package/dist/components/hooks/useKanban/context.d.ts.map +1 -1
  17. package/dist/components/hooks/useKanban/types.d.ts +5 -22
  18. package/dist/components/hooks/useKanban/types.d.ts.map +1 -1
  19. package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -1
  20. package/dist/components/hooks/useTable/types.d.ts +19 -31
  21. package/dist/components/hooks/useTable/types.d.ts.map +1 -1
  22. package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
  23. package/dist/error-handling-CAoD0Kwb.cjs +1 -0
  24. package/dist/error-handling-CrhTtD88.js +14 -0
  25. package/dist/filter.cjs +1 -1
  26. package/dist/filter.mjs +1 -1
  27. package/dist/form.cjs +1 -1
  28. package/dist/form.mjs +825 -814
  29. package/dist/index.d.ts +18 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/kanban.cjs +2 -2
  32. package/dist/kanban.mjs +335 -323
  33. package/dist/{metadata-2FLBsFcf.cjs → metadata-0lZAfuTP.cjs} +1 -1
  34. package/dist/{metadata-DBcoDth-.js → metadata-B88D_pVS.js} +1 -1
  35. package/dist/table.cjs +1 -1
  36. package/dist/table.mjs +113 -96
  37. package/dist/table.types.d.ts +1 -1
  38. package/dist/table.types.d.ts.map +1 -1
  39. package/dist/types/common.d.ts +26 -6
  40. package/dist/types/common.d.ts.map +1 -1
  41. package/dist/useFilter-DzpP_ag0.cjs +1 -0
  42. package/dist/useFilter-H5bgAZQF.js +120 -0
  43. package/dist/utils/api/buildListOptions.d.ts +43 -0
  44. package/dist/utils/api/buildListOptions.d.ts.map +1 -0
  45. package/dist/utils/api/index.d.ts +2 -0
  46. package/dist/utils/api/index.d.ts.map +1 -0
  47. package/dist/utils/error-handling.d.ts +41 -0
  48. package/dist/utils/error-handling.d.ts.map +1 -0
  49. package/dist/utils/index.d.ts +2 -0
  50. package/dist/utils/index.d.ts.map +1 -1
  51. package/docs/QUICK_REFERENCE.md +142 -420
  52. package/docs/useAuth.md +52 -340
  53. package/docs/useFilter.md +858 -162
  54. package/docs/useForm.md +712 -501
  55. package/docs/useKanban.md +534 -279
  56. package/docs/useTable.md +725 -214
  57. package/package.json +1 -1
  58. package/sdk/api/client.ts +7 -1
  59. package/sdk/components/hooks/useFilter/types.ts +14 -11
  60. package/sdk/components/hooks/useFilter/useFilter.ts +20 -18
  61. package/sdk/components/hooks/useForm/apiClient.ts +2 -1
  62. package/sdk/components/hooks/useForm/useForm.ts +47 -13
  63. package/sdk/components/hooks/useKanban/context.ts +5 -3
  64. package/sdk/components/hooks/useKanban/types.ts +7 -23
  65. package/sdk/components/hooks/useKanban/useKanban.ts +54 -18
  66. package/sdk/components/hooks/useTable/types.ts +26 -32
  67. package/sdk/components/hooks/useTable/useTable.llm.txt +8 -22
  68. package/sdk/components/hooks/useTable/useTable.ts +70 -25
  69. package/sdk/index.ts +154 -10
  70. package/sdk/table.types.ts +3 -0
  71. package/sdk/types/common.ts +31 -6
  72. package/sdk/utils/api/buildListOptions.ts +120 -0
  73. package/sdk/utils/api/index.ts +2 -0
  74. package/sdk/utils/error-handling.ts +150 -0
  75. package/sdk/utils/index.ts +6 -0
  76. package/dist/useFilter-Dofowpr_.cjs +0 -1
  77. package/dist/useFilter-Dv-mr9QW.js +0 -117
@@ -1,6 +1,8 @@
1
1
  # KF AI SDK - Quick Reference
2
2
 
3
- ## Installation & Setup
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
- ## useTable Hook
16
+ ---
17
+
18
+ ## useTable
17
19
 
18
- ### Basic Usage
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<ProductType>({
25
- source: "BDO_AmazonProductMaster",
25
+ const table = useTable<Product>({
26
+ source: "BDO_Products",
26
27
  columns: [
27
28
  { fieldId: "Title", enableSorting: true },
28
- { fieldId: "Price", enableSorting: true, enableFiltering: true },
29
+ { fieldId: "Price", enableSorting: true },
29
30
  ],
31
+ initialState: {
32
+ pagination: { pageNo: 1, pageSize: 10 },
33
+ },
30
34
  });
31
35
  ```
32
36
 
33
- ### Key Properties
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
- | Property | Type | Description |
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 Hook
48
+ ## useForm
47
49
 
48
- ### Basic Usage
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<ProductType>({
55
- source: "BDO_AmazonProductMaster",
55
+ const form = useForm<Product>({
56
+ source: "BDO_Products",
56
57
  operation: "create", // or "update"
57
- userRole: "Seller",
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
- ### Key Properties
67
-
68
- | Property | Type | Description |
69
- | -------------- | ------------------------------------ | -------------- |
70
- | `register` | `(name, options?) => RegisterReturn` | Register field |
71
- | `handleSubmit` | `() => (e?) => Promise<void>` | Submit handler |
72
- | `errors` | `FieldErrors<T>` | Form errors |
73
- | `isValid` | `boolean` | Form validity |
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
- ### Field Permissions
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
- ## Business Object Classes
73
+ ## useKanban
90
74
 
91
- ### Role-Based Access
75
+ [Full Documentation](./useKanban.md)
92
76
 
93
77
  ```typescript
94
- // Admin - Full access
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
- // Buyer - Read-only
101
- const buyerProducts = new AmazonProductMaster("Buyer");
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
- ### CRUD Operations
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
- ```typescript
107
- // Create
108
- const result = await products.create({
109
- ASIN: "B08N5WRWNW",
110
- Title: "Product Name",
111
- Price: 49.99,
112
- });
98
+ ---
113
99
 
114
- // Read
115
- const product = await products.get("PROD-001");
100
+ ## useFilter
116
101
 
117
- // Update
118
- await products.update("PROD-001", { Price: 44.99 });
102
+ [Full Documentation](./useFilter.md)
119
103
 
120
- // Delete (Admin only)
121
- await products.delete("PROD-001");
104
+ ```typescript
105
+ import { useFilter, isCondition, isConditionGroup } from "@ram_28/kf-ai-sdk/filter";
122
106
 
123
- // List with options
124
- const list = await products.list({
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
- ## Performance Optimizations
137
-
138
- ### Expression Caching
139
-
140
- ```typescript
141
- import { clearExpressionCache } from "@ram_28/kf-ai-sdk/form";
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
- ### Dependency Tracking
120
+ ### Operators
148
121
 
149
- ```typescript
150
- // Automatically optimized - only watches relevant fields
151
- const form = useForm({
152
- source: "BDO_AmazonProductMaster",
153
- // Price changes will only trigger discount recalculation
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
- ## Rule Types
131
+ ---
158
132
 
159
- | Rule Type | Execution | Purpose | Example |
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
- ### Rule Implementation
135
+ [Full Documentation](./useAuth.md)
166
136
 
167
137
  ```typescript
168
- // Client-side validation (automatic)
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
- // Server-side computation (triggers API call)
172
- "IF(MRP > 0, ((MRP - Price) / MRP) * 100, 0)";
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
- ```typescript
180
- const form = useForm({
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
- ### API Errors
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
- ```typescript
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
- ## Filter Conditions
160
+ ## Common Patterns
210
161
 
211
- ### Basic Filters
162
+ ### Filter by Category
212
163
 
213
164
  ```typescript
165
+ table.filter.clearAllConditions();
214
166
  table.filter.addCondition({
215
- fieldName: "Price",
216
- operator: "GT",
217
- value: 50,
167
+ Operator: "EQ",
168
+ LHSField: "Category",
169
+ RHSValue: "Electronics",
218
170
  });
219
171
  ```
220
172
 
221
- ### Complex Filters
173
+ ### Filter by Date Range
222
174
 
223
175
  ```typescript
224
176
  table.filter.addCondition({
225
- fieldName: "Category",
226
- operator: "IN",
227
- value: ["Electronics", "Books"],
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
- fieldName: "Price",
232
- operator: "BETWEEN",
233
- value: { min: 10, max: 100 },
187
+ Operator: "EQ",
188
+ LHSField: "AssignedTo",
189
+ RHSValue: currentUserId,
234
190
  });
235
-
236
- table.filter.setLogicalOperator("AND");
237
191
  ```
238
192
 
239
- ## Sorting & Pagination
240
-
241
- ### Sorting
193
+ ### Sortable Column Header
242
194
 
243
195
  ```typescript
244
- // Toggle sort on click
245
- <th onClick={() => table.sort.toggle("Title")}>
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
- <span>
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
- ## Permission Checks
273
-
274
- ### Role-Based Field Access
213
+ ### Protected Route
275
214
 
276
215
  ```typescript
277
- // Check if field is editable
278
- const canEdit = form.getField("Cost")?.permission.editable;
279
-
280
- // Conditional rendering based on permissions
281
- {form.getField("Cost")?.permission.readable && (
282
- <input {...form.register("Cost")} disabled={!canEdit} />
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
- ### Debug Form Issues
224
+ ### Role-Based UI
466
225
 
467
226
  ```typescript
468
- console.log("Form state:", {
469
- isValid: form.isValid,
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
- ### Debug API Issues
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
- ### API Setup
233
+ ## Type Imports
490
234
 
491
235
  ```typescript
492
- import { setApiBaseUrl, setDefaultHeaders } from "@ram_28/kf-ai-sdk/api";
236
+ // Table
237
+ import type { UseTableOptionsType, UseTableReturnType, ColumnDefinitionType } from "@ram_28/kf-ai-sdk/table/types";
493
238
 
494
- // Set base URL - SDK automatically appends /api/app/{bo_id} paths
495
- setApiBaseUrl("https://api.example.com");
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
- ### React Query Setup
242
+ // Kanban
243
+ import type { UseKanbanOptionsType, UseKanbanReturnType, KanbanCardType, ColumnConfigType } from "@ram_28/kf-ai-sdk/kanban/types";
503
244
 
504
- ```typescript
505
- import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
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
- <QueryClientProvider client={queryClient}>
517
- <App />
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/)