@ram_28/kf-ai-sdk 1.0.23 → 1.0.24
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/docs/QUICK_REFERENCE.md +24 -0
- package/docs/api.md +30 -30
- package/docs/datetime.md +144 -0
- package/docs/useFilter.md +4 -4
- package/docs/useForm.md +12 -12
- package/docs/useTable.md +6 -6
- package/package.json +1 -1
package/docs/QUICK_REFERENCE.md
CHANGED
|
@@ -230,6 +230,30 @@ function ProtectedRoute({ children }) {
|
|
|
230
230
|
|
|
231
231
|
---
|
|
232
232
|
|
|
233
|
+
## Date Handling
|
|
234
|
+
|
|
235
|
+
### Display Encoded Date
|
|
236
|
+
```typescript
|
|
237
|
+
import { decodeDate } from "@ram_28/kf-ai-sdk/api";
|
|
238
|
+
import { formatDate } from "@ram_28/kf-ai-sdk/utils";
|
|
239
|
+
|
|
240
|
+
const readable = formatDate(decodeDate(record.OrderDate), 'medium');
|
|
241
|
+
// => "Mar 15, 2025"
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Display Timestamp
|
|
245
|
+
```typescript
|
|
246
|
+
import { decodeDateTime } from "@ram_28/kf-ai-sdk/api";
|
|
247
|
+
import { formatDateTime } from "@ram_28/kf-ai-sdk/utils";
|
|
248
|
+
|
|
249
|
+
const readable = formatDateTime(decodeDateTime(record._created_at), 'medium');
|
|
250
|
+
// => "Mar 15, 2025, 10:30:45 AM"
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
[Full Documentation](./datetime.md)
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
233
257
|
## Type Imports
|
|
234
258
|
|
|
235
259
|
```typescript
|
package/docs/api.md
CHANGED
|
@@ -5,10 +5,10 @@ Direct API methods for CRUD operations, drafts, metrics, and metadata.
|
|
|
5
5
|
## Setup
|
|
6
6
|
|
|
7
7
|
```typescript
|
|
8
|
-
import { Product,
|
|
8
|
+
import { Product, type ProductForRole } from "../sources";
|
|
9
9
|
import { Roles } from "../sources/roles";
|
|
10
10
|
|
|
11
|
-
type BuyerProduct =
|
|
11
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
12
12
|
|
|
13
13
|
const product = new Product(Roles.Buyer);
|
|
14
14
|
```
|
|
@@ -200,10 +200,10 @@ const response = await product.list(options?: ListOptionsType): Promise<ListResp
|
|
|
200
200
|
**Example:** Fetch paginated products with filter
|
|
201
201
|
|
|
202
202
|
```typescript
|
|
203
|
-
import { Product,
|
|
203
|
+
import { Product, type ProductForRole } from "../sources";
|
|
204
204
|
import { Roles } from "../sources/roles";
|
|
205
205
|
|
|
206
|
-
type BuyerProduct =
|
|
206
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
207
207
|
|
|
208
208
|
const product = new Product(Roles.Buyer);
|
|
209
209
|
|
|
@@ -244,10 +244,10 @@ const record = await product.get(id: string): Promise<T>
|
|
|
244
244
|
**Example:** Fetch single product
|
|
245
245
|
|
|
246
246
|
```typescript
|
|
247
|
-
import { Product,
|
|
247
|
+
import { Product, type ProductForRole } from "../sources";
|
|
248
248
|
import { Roles } from "../sources/roles";
|
|
249
249
|
|
|
250
|
-
type BuyerProduct =
|
|
250
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
251
251
|
|
|
252
252
|
const product = new Product(Roles.Buyer);
|
|
253
253
|
|
|
@@ -271,10 +271,10 @@ const response = await product.create(data: Partial<T>): Promise<CreateUpdateRes
|
|
|
271
271
|
**Example:** Create new product
|
|
272
272
|
|
|
273
273
|
```typescript
|
|
274
|
-
import { Product,
|
|
274
|
+
import { Product, type ProductForRole } from "../sources";
|
|
275
275
|
import { Roles } from "../sources/roles";
|
|
276
276
|
|
|
277
|
-
type BuyerProduct =
|
|
277
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
278
278
|
|
|
279
279
|
const product = new Product(Roles.Buyer);
|
|
280
280
|
|
|
@@ -302,10 +302,10 @@ const response = await product.update(id: string, data: Partial<T>): Promise<Cre
|
|
|
302
302
|
**Example:** Update product price
|
|
303
303
|
|
|
304
304
|
```typescript
|
|
305
|
-
import { Product,
|
|
305
|
+
import { Product, type ProductForRole } from "../sources";
|
|
306
306
|
import { Roles } from "../sources/roles";
|
|
307
307
|
|
|
308
|
-
type BuyerProduct =
|
|
308
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
309
309
|
|
|
310
310
|
const product = new Product(Roles.Buyer);
|
|
311
311
|
|
|
@@ -330,10 +330,10 @@ const response = await product.delete(id: string): Promise<DeleteResponseType>
|
|
|
330
330
|
**Example:** Delete product
|
|
331
331
|
|
|
332
332
|
```typescript
|
|
333
|
-
import { Product,
|
|
333
|
+
import { Product, type ProductForRole } from "../sources";
|
|
334
334
|
import { Roles } from "../sources/roles";
|
|
335
335
|
|
|
336
|
-
type BuyerProduct =
|
|
336
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
337
337
|
|
|
338
338
|
const product = new Product(Roles.Buyer);
|
|
339
339
|
|
|
@@ -357,10 +357,10 @@ const response = await product.draft(data: Partial<T>): Promise<DraftResponseTyp
|
|
|
357
357
|
**Example:** Preview computed discount
|
|
358
358
|
|
|
359
359
|
```typescript
|
|
360
|
-
import { Product,
|
|
360
|
+
import { Product, type ProductForRole } from "../sources";
|
|
361
361
|
import { Roles } from "../sources/roles";
|
|
362
362
|
|
|
363
|
-
type BuyerProduct =
|
|
363
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
364
364
|
|
|
365
365
|
const product = new Product(Roles.Buyer);
|
|
366
366
|
|
|
@@ -387,10 +387,10 @@ const response = await product.draftPatch(id: string, data: Partial<T>): Promise
|
|
|
387
387
|
**Example:** Update draft during editing
|
|
388
388
|
|
|
389
389
|
```typescript
|
|
390
|
-
import { Product,
|
|
390
|
+
import { Product, type ProductForRole } from "../sources";
|
|
391
391
|
import { Roles } from "../sources/roles";
|
|
392
392
|
|
|
393
|
-
type BuyerProduct =
|
|
393
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
394
394
|
|
|
395
395
|
const product = new Product(Roles.Buyer);
|
|
396
396
|
|
|
@@ -417,10 +417,10 @@ const response = await product.metric(options: MetricOptionsType): Promise<Metri
|
|
|
417
417
|
**Example 1:** Total count
|
|
418
418
|
|
|
419
419
|
```typescript
|
|
420
|
-
import { Product,
|
|
420
|
+
import { Product, type ProductForRole } from "../sources";
|
|
421
421
|
import { Roles } from "../sources/roles";
|
|
422
422
|
|
|
423
|
-
type BuyerProduct =
|
|
423
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
424
424
|
|
|
425
425
|
const product = new Product(Roles.Buyer);
|
|
426
426
|
|
|
@@ -436,10 +436,10 @@ console.log("Total products:", response.Data[0]["count__id"]);
|
|
|
436
436
|
**Example 2:** Sum with filter (low stock count)
|
|
437
437
|
|
|
438
438
|
```typescript
|
|
439
|
-
import { Product,
|
|
439
|
+
import { Product, type ProductForRole } from "../sources";
|
|
440
440
|
import { Roles } from "../sources/roles";
|
|
441
441
|
|
|
442
|
-
type BuyerProduct =
|
|
442
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
443
443
|
|
|
444
444
|
const product = new Product(Roles.Buyer);
|
|
445
445
|
|
|
@@ -466,10 +466,10 @@ console.log("Low stock products:", response.Data[0]["count__id"]);
|
|
|
466
466
|
**Example 3:** Group by field (products by category)
|
|
467
467
|
|
|
468
468
|
```typescript
|
|
469
|
-
import { Product,
|
|
469
|
+
import { Product, type ProductForRole } from "../sources";
|
|
470
470
|
import { Roles } from "../sources/roles";
|
|
471
471
|
|
|
472
|
-
type BuyerProduct =
|
|
472
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
473
473
|
|
|
474
474
|
const product = new Product(Roles.Buyer);
|
|
475
475
|
|
|
@@ -491,10 +491,10 @@ response.Data.forEach((row) => {
|
|
|
491
491
|
**Example 4:** Multiple metrics (stock sum and average by category)
|
|
492
492
|
|
|
493
493
|
```typescript
|
|
494
|
-
import { Product,
|
|
494
|
+
import { Product, type ProductForRole } from "../sources";
|
|
495
495
|
import { Roles } from "../sources/roles";
|
|
496
496
|
|
|
497
|
-
type BuyerProduct =
|
|
497
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
498
498
|
|
|
499
499
|
const product = new Product(Roles.Buyer);
|
|
500
500
|
|
|
@@ -528,10 +528,10 @@ const response = await product.pivot(options: PivotOptionsType): Promise<PivotRe
|
|
|
528
528
|
**Example:** Sales pivot by region and quarter
|
|
529
529
|
|
|
530
530
|
```typescript
|
|
531
|
-
import { Order,
|
|
531
|
+
import { Order, type OrderForRole } from "../sources";
|
|
532
532
|
import { Roles } from "../sources/roles";
|
|
533
533
|
|
|
534
|
-
type AdminOrder =
|
|
534
|
+
type AdminOrder = OrderForRole<typeof Roles.Admin>;
|
|
535
535
|
|
|
536
536
|
const order = new Order(Roles.Admin);
|
|
537
537
|
|
|
@@ -587,10 +587,10 @@ const response = await product.fields(): Promise<FieldsResponseType>
|
|
|
587
587
|
**Example:** Get field metadata
|
|
588
588
|
|
|
589
589
|
```typescript
|
|
590
|
-
import { Product,
|
|
590
|
+
import { Product, type ProductForRole } from "../sources";
|
|
591
591
|
import { Roles } from "../sources/roles";
|
|
592
592
|
|
|
593
|
-
type BuyerProduct =
|
|
593
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
594
594
|
|
|
595
595
|
const product = new Product(Roles.Buyer);
|
|
596
596
|
|
|
@@ -625,10 +625,10 @@ const options = await product.fetchField(instanceId: string, fieldId: keyof T):
|
|
|
625
625
|
**Example:** Fetch supplier options for dropdown
|
|
626
626
|
|
|
627
627
|
```typescript
|
|
628
|
-
import { Product,
|
|
628
|
+
import { Product, type ProductForRole } from "../sources";
|
|
629
629
|
import { Roles } from "../sources/roles";
|
|
630
630
|
|
|
631
|
-
type BuyerProduct =
|
|
631
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
632
632
|
|
|
633
633
|
const product = new Product(Roles.Buyer);
|
|
634
634
|
|
package/docs/datetime.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Date & DateTime Handling
|
|
2
|
+
|
|
3
|
+
Working with Date and DateTime fields in the SDK.
|
|
4
|
+
|
|
5
|
+
## API Response Format
|
|
6
|
+
|
|
7
|
+
The backend returns dates in encoded format:
|
|
8
|
+
- **Date**: `{ "$__d__": "YYYY-MM-DD" }`
|
|
9
|
+
- **DateTime**: `{ "$__dt__": unix_timestamp_seconds }`
|
|
10
|
+
|
|
11
|
+
## Imports
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
// Decoding & formatting for API
|
|
15
|
+
import {
|
|
16
|
+
decodeDate,
|
|
17
|
+
decodeDateTime,
|
|
18
|
+
formatDate,
|
|
19
|
+
formatDateTime,
|
|
20
|
+
parseDate,
|
|
21
|
+
parseDateTime,
|
|
22
|
+
} from "@ram_28/kf-ai-sdk/api";
|
|
23
|
+
|
|
24
|
+
// UI display formatting
|
|
25
|
+
import {
|
|
26
|
+
formatDate,
|
|
27
|
+
formatDateTime
|
|
28
|
+
} from "@ram_28/kf-ai-sdk/utils";
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Decoding API Responses
|
|
32
|
+
|
|
33
|
+
Convert encoded dates to JavaScript Date objects.
|
|
34
|
+
|
|
35
|
+
### decodeDate
|
|
36
|
+
```typescript
|
|
37
|
+
const apiResponse = { "$__d__": "2025-03-15" };
|
|
38
|
+
const date = decodeDate(apiResponse);
|
|
39
|
+
// => Date object for March 15, 2025
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### decodeDateTime
|
|
43
|
+
```typescript
|
|
44
|
+
const apiResponse = { "$__dt__": 1769110463 };
|
|
45
|
+
const date = decodeDateTime(apiResponse);
|
|
46
|
+
// => Date object with full timestamp
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Formatting for API Requests
|
|
50
|
+
|
|
51
|
+
Convert Date objects to strings the API expects.
|
|
52
|
+
|
|
53
|
+
### formatDate (API)
|
|
54
|
+
```typescript
|
|
55
|
+
import { formatDate } from "@ram_28/kf-ai-sdk/api";
|
|
56
|
+
|
|
57
|
+
const date = new Date(2025, 2, 15);
|
|
58
|
+
formatDate(date); // => "2025-03-15"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### formatDateTime (API)
|
|
62
|
+
```typescript
|
|
63
|
+
import { formatDateTime } from "@ram_28/kf-ai-sdk/api";
|
|
64
|
+
|
|
65
|
+
const date = new Date(2025, 2, 15, 10, 30, 45);
|
|
66
|
+
formatDateTime(date); // => "2025-03-15 10:30:45"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Formatting for UI Display
|
|
70
|
+
|
|
71
|
+
Convert Date objects to human-readable strings.
|
|
72
|
+
|
|
73
|
+
### formatDate (UI)
|
|
74
|
+
```typescript
|
|
75
|
+
import { formatDate } from "@ram_28/kf-ai-sdk/utils";
|
|
76
|
+
|
|
77
|
+
const date = new Date(2025, 2, 15);
|
|
78
|
+
formatDate(date, 'short'); // => "3/15/25"
|
|
79
|
+
formatDate(date, 'medium'); // => "Mar 15, 2025"
|
|
80
|
+
formatDate(date, 'long'); // => "March 15, 2025"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### formatDateTime (UI)
|
|
84
|
+
```typescript
|
|
85
|
+
import { formatDateTime } from "@ram_28/kf-ai-sdk/utils";
|
|
86
|
+
|
|
87
|
+
const date = new Date(2025, 2, 15, 10, 30, 45);
|
|
88
|
+
formatDateTime(date, 'short'); // => "3/15/25, 10:30 AM"
|
|
89
|
+
formatDateTime(date, 'medium'); // => "Mar 15, 2025, 10:30:45 AM"
|
|
90
|
+
formatDateTime(date, 'long'); // => "March 15, 2025 at 10:30:45 AM"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Common Patterns
|
|
94
|
+
|
|
95
|
+
### Display a date from API response
|
|
96
|
+
```typescript
|
|
97
|
+
import { decodeDate } from "@ram_28/kf-ai-sdk/api";
|
|
98
|
+
import { formatDate } from "@ram_28/kf-ai-sdk/utils";
|
|
99
|
+
|
|
100
|
+
function displayDate(encodedDate: { $__d__: string }) {
|
|
101
|
+
const date = decodeDate(encodedDate);
|
|
102
|
+
return formatDate(date, 'medium');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Usage in component
|
|
106
|
+
<span>{displayDate(record.OrderDate)}</span>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Display created/modified timestamps
|
|
110
|
+
```typescript
|
|
111
|
+
import { decodeDateTime } from "@ram_28/kf-ai-sdk/api";
|
|
112
|
+
import { formatDateTime } from "@ram_28/kf-ai-sdk/utils";
|
|
113
|
+
|
|
114
|
+
function displayTimestamp(encodedDateTime: { $__dt__: number }) {
|
|
115
|
+
const date = decodeDateTime(encodedDateTime);
|
|
116
|
+
return formatDateTime(date, 'medium');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Usage
|
|
120
|
+
<span>Created: {displayTimestamp(record._created_at)}</span>
|
|
121
|
+
<span>Modified: {displayTimestamp(record._modified_at)}</span>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Submit a date to the API
|
|
125
|
+
```typescript
|
|
126
|
+
import { formatDate } from "@ram_28/kf-ai-sdk/api";
|
|
127
|
+
|
|
128
|
+
// From a date picker value
|
|
129
|
+
const datePickerValue = "2025-03-15"; // HTML date input value
|
|
130
|
+
// Already in correct format, use directly
|
|
131
|
+
|
|
132
|
+
// From a Date object
|
|
133
|
+
const dateObj = new Date();
|
|
134
|
+
const apiValue = formatDate(dateObj); // => "2025-03-15"
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Type Definitions
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
import type {
|
|
141
|
+
DateEncodedType, // { $__d__: string }
|
|
142
|
+
DateTimeEncodedType, // { $__dt__: number }
|
|
143
|
+
} from "@ram_28/kf-ai-sdk/api";
|
|
144
|
+
```
|
package/docs/useFilter.md
CHANGED
|
@@ -173,10 +173,10 @@ Use the generic type parameter to get TypeScript validation on field names.
|
|
|
173
173
|
|
|
174
174
|
```tsx
|
|
175
175
|
import { useFilter } from "@ram_28/kf-ai-sdk/filter";
|
|
176
|
-
import { Product,
|
|
176
|
+
import { Product, type ProductForRole } from "../sources";
|
|
177
177
|
import { Roles } from "../sources/roles";
|
|
178
178
|
|
|
179
|
-
type BuyerProduct =
|
|
179
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
180
180
|
|
|
181
181
|
function TypeSafeFilter() {
|
|
182
182
|
// Pass the type parameter for type-safe LHSField
|
|
@@ -216,10 +216,10 @@ function TypeSafeFilter() {
|
|
|
216
216
|
```tsx
|
|
217
217
|
import { useFilter } from "@ram_28/kf-ai-sdk/filter";
|
|
218
218
|
import type { UseFilterOptionsType } from "@ram_28/kf-ai-sdk/filter/types";
|
|
219
|
-
import { Product,
|
|
219
|
+
import { Product, type ProductForRole } from "../sources";
|
|
220
220
|
import { Roles } from "../sources/roles";
|
|
221
221
|
|
|
222
|
-
type BuyerProduct =
|
|
222
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
223
223
|
|
|
224
224
|
// Type-safe filter options
|
|
225
225
|
const initialFilter: UseFilterOptionsType<BuyerProduct> = {
|
package/docs/useForm.md
CHANGED
|
@@ -227,10 +227,10 @@ interface FormFieldConfigType {
|
|
|
227
227
|
|
|
228
228
|
```tsx
|
|
229
229
|
import { useForm } from "@ram_28/kf-ai-sdk/form";
|
|
230
|
-
import { Product,
|
|
230
|
+
import { Product, type ProductForRole } from "../sources";
|
|
231
231
|
import { Roles } from "../sources/roles";
|
|
232
232
|
|
|
233
|
-
type BuyerProduct =
|
|
233
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
234
234
|
|
|
235
235
|
function CreateProductForm() {
|
|
236
236
|
const product = new Product(Roles.Buyer);
|
|
@@ -283,10 +283,10 @@ Create form with validation and success handling.
|
|
|
283
283
|
import { useForm } from "@ram_28/kf-ai-sdk/form";
|
|
284
284
|
import type { FieldErrors } from "@ram_28/kf-ai-sdk/form/types";
|
|
285
285
|
import { useNavigate } from "react-router-dom";
|
|
286
|
-
import { Product,
|
|
286
|
+
import { Product, type ProductForRole } from "../sources";
|
|
287
287
|
import { Roles } from "../sources/roles";
|
|
288
288
|
|
|
289
|
-
type BuyerProduct =
|
|
289
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
290
290
|
|
|
291
291
|
function ProductListingForm() {
|
|
292
292
|
const product = new Product(Roles.Buyer);
|
|
@@ -362,10 +362,10 @@ Update mode with record loading state.
|
|
|
362
362
|
|
|
363
363
|
```tsx
|
|
364
364
|
import { useForm } from "@ram_28/kf-ai-sdk/form";
|
|
365
|
-
import { Product,
|
|
365
|
+
import { Product, type ProductForRole } from "../sources";
|
|
366
366
|
import { Roles } from "../sources/roles";
|
|
367
367
|
|
|
368
|
-
type BuyerProduct =
|
|
368
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
369
369
|
|
|
370
370
|
function EditProductForm({ productId }: { productId: string }) {
|
|
371
371
|
const product = new Product(Roles.Buyer);
|
|
@@ -428,10 +428,10 @@ Working with computed fields and the watch function.
|
|
|
428
428
|
|
|
429
429
|
```tsx
|
|
430
430
|
import { useForm } from "@ram_28/kf-ai-sdk/form";
|
|
431
|
-
import { Product,
|
|
431
|
+
import { Product, type ProductForRole } from "../sources";
|
|
432
432
|
import { Roles } from "../sources/roles";
|
|
433
433
|
|
|
434
|
-
type BuyerProduct =
|
|
434
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
435
435
|
|
|
436
436
|
function PricingForm() {
|
|
437
437
|
const product = new Product(Roles.Buyer);
|
|
@@ -483,10 +483,10 @@ Static fields return options with `Value` and `Label`.
|
|
|
483
483
|
```tsx
|
|
484
484
|
import { useState } from "react";
|
|
485
485
|
import { useForm } from "@ram_28/kf-ai-sdk/form";
|
|
486
|
-
import { Product,
|
|
486
|
+
import { Product, type ProductForRole } from "../sources";
|
|
487
487
|
import { Roles } from "../sources/roles";
|
|
488
488
|
|
|
489
|
-
type BuyerProduct =
|
|
489
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
490
490
|
|
|
491
491
|
function ProductCategoryForm({ recordId }: { recordId: string }) {
|
|
492
492
|
const product = new Product(Roles.Buyer);
|
|
@@ -558,10 +558,10 @@ Reference fields return the full object structure. Use a custom dropdown to disp
|
|
|
558
558
|
```tsx
|
|
559
559
|
import { useState } from "react";
|
|
560
560
|
import { useForm } from "@ram_28/kf-ai-sdk/form";
|
|
561
|
-
import { Product,
|
|
561
|
+
import { Product, type ProductForRole } from "../sources";
|
|
562
562
|
import { Roles } from "../sources/roles";
|
|
563
563
|
|
|
564
|
-
type BuyerProduct =
|
|
564
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
565
565
|
|
|
566
566
|
type SupplierOption = {
|
|
567
567
|
_id: string;
|
package/docs/useTable.md
CHANGED
|
@@ -221,10 +221,10 @@ A minimal table displaying data with loading and error states.
|
|
|
221
221
|
```tsx
|
|
222
222
|
import { useTable } from "@ram_28/kf-ai-sdk/table";
|
|
223
223
|
import type { ColumnDefinitionType } from "@ram_28/kf-ai-sdk/table/types";
|
|
224
|
-
import { Product,
|
|
224
|
+
import { Product, type ProductForRole } from "../sources";
|
|
225
225
|
import { Roles } from "../sources/roles";
|
|
226
226
|
|
|
227
|
-
type BuyerProduct =
|
|
227
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
228
228
|
|
|
229
229
|
function ProductsTable() {
|
|
230
230
|
const product = new Product(Roles.Buyer);
|
|
@@ -282,10 +282,10 @@ import type {
|
|
|
282
282
|
UseTableReturnType,
|
|
283
283
|
ColumnDefinitionType,
|
|
284
284
|
} from "@ram_28/kf-ai-sdk/table/types";
|
|
285
|
-
import { Product,
|
|
285
|
+
import { Product, type ProductForRole } from "../sources";
|
|
286
286
|
import { Roles } from "../sources/roles";
|
|
287
287
|
|
|
288
|
-
type BuyerProduct =
|
|
288
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
289
289
|
|
|
290
290
|
function MyItemsTable() {
|
|
291
291
|
const product = new Product(Roles.Buyer);
|
|
@@ -858,10 +858,10 @@ import type {
|
|
|
858
858
|
UseTableReturnType,
|
|
859
859
|
ColumnDefinitionType,
|
|
860
860
|
} from "@ram_28/kf-ai-sdk/table/types";
|
|
861
|
-
import { Product,
|
|
861
|
+
import { Product, type ProductForRole } from "../sources";
|
|
862
862
|
import { Roles } from "../sources/roles";
|
|
863
863
|
|
|
864
|
-
type BuyerProduct =
|
|
864
|
+
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
865
865
|
|
|
866
866
|
function ProductListPage() {
|
|
867
867
|
const product = new Product(Roles.Buyer);
|