@ram_28/kf-ai-sdk 1.0.24 → 1.0.26
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/api.md +30 -15
- package/docs/useFilter.md +4 -2
- package/docs/useForm.md +12 -6
- package/docs/useKanban.md +5 -2
- package/docs/useTable.md +7 -4
- package/package.json +1 -1
package/docs/api.md
CHANGED
|
@@ -5,7 +5,8 @@ Direct API methods for CRUD operations, drafts, metrics, and metadata.
|
|
|
5
5
|
## Setup
|
|
6
6
|
|
|
7
7
|
```typescript
|
|
8
|
-
import { Product
|
|
8
|
+
import { Product } from "../sources";
|
|
9
|
+
import type { ProductForRole } from "../sources";
|
|
9
10
|
import { Roles } from "../sources/roles";
|
|
10
11
|
|
|
11
12
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -200,7 +201,8 @@ const response = await product.list(options?: ListOptionsType): Promise<ListResp
|
|
|
200
201
|
**Example:** Fetch paginated products with filter
|
|
201
202
|
|
|
202
203
|
```typescript
|
|
203
|
-
import { Product
|
|
204
|
+
import { Product } from "../sources";
|
|
205
|
+
import type { ProductForRole } from "../sources";
|
|
204
206
|
import { Roles } from "../sources/roles";
|
|
205
207
|
|
|
206
208
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -244,7 +246,8 @@ const record = await product.get(id: string): Promise<T>
|
|
|
244
246
|
**Example:** Fetch single product
|
|
245
247
|
|
|
246
248
|
```typescript
|
|
247
|
-
import { Product
|
|
249
|
+
import { Product } from "../sources";
|
|
250
|
+
import type { ProductForRole } from "../sources";
|
|
248
251
|
import { Roles } from "../sources/roles";
|
|
249
252
|
|
|
250
253
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -271,7 +274,8 @@ const response = await product.create(data: Partial<T>): Promise<CreateUpdateRes
|
|
|
271
274
|
**Example:** Create new product
|
|
272
275
|
|
|
273
276
|
```typescript
|
|
274
|
-
import { Product
|
|
277
|
+
import { Product } from "../sources";
|
|
278
|
+
import type { ProductForRole } from "../sources";
|
|
275
279
|
import { Roles } from "../sources/roles";
|
|
276
280
|
|
|
277
281
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -302,7 +306,8 @@ const response = await product.update(id: string, data: Partial<T>): Promise<Cre
|
|
|
302
306
|
**Example:** Update product price
|
|
303
307
|
|
|
304
308
|
```typescript
|
|
305
|
-
import { Product
|
|
309
|
+
import { Product } from "../sources";
|
|
310
|
+
import type { ProductForRole } from "../sources";
|
|
306
311
|
import { Roles } from "../sources/roles";
|
|
307
312
|
|
|
308
313
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -330,7 +335,8 @@ const response = await product.delete(id: string): Promise<DeleteResponseType>
|
|
|
330
335
|
**Example:** Delete product
|
|
331
336
|
|
|
332
337
|
```typescript
|
|
333
|
-
import { Product
|
|
338
|
+
import { Product } from "../sources";
|
|
339
|
+
import type { ProductForRole } from "../sources";
|
|
334
340
|
import { Roles } from "../sources/roles";
|
|
335
341
|
|
|
336
342
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -357,7 +363,8 @@ const response = await product.draft(data: Partial<T>): Promise<DraftResponseTyp
|
|
|
357
363
|
**Example:** Preview computed discount
|
|
358
364
|
|
|
359
365
|
```typescript
|
|
360
|
-
import { Product
|
|
366
|
+
import { Product } from "../sources";
|
|
367
|
+
import type { ProductForRole } from "../sources";
|
|
361
368
|
import { Roles } from "../sources/roles";
|
|
362
369
|
|
|
363
370
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -387,7 +394,8 @@ const response = await product.draftPatch(id: string, data: Partial<T>): Promise
|
|
|
387
394
|
**Example:** Update draft during editing
|
|
388
395
|
|
|
389
396
|
```typescript
|
|
390
|
-
import { Product
|
|
397
|
+
import { Product } from "../sources";
|
|
398
|
+
import type { ProductForRole } from "../sources";
|
|
391
399
|
import { Roles } from "../sources/roles";
|
|
392
400
|
|
|
393
401
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -417,7 +425,8 @@ const response = await product.metric(options: MetricOptionsType): Promise<Metri
|
|
|
417
425
|
**Example 1:** Total count
|
|
418
426
|
|
|
419
427
|
```typescript
|
|
420
|
-
import { Product
|
|
428
|
+
import { Product } from "../sources";
|
|
429
|
+
import type { ProductForRole } from "../sources";
|
|
421
430
|
import { Roles } from "../sources/roles";
|
|
422
431
|
|
|
423
432
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -436,7 +445,8 @@ console.log("Total products:", response.Data[0]["count__id"]);
|
|
|
436
445
|
**Example 2:** Sum with filter (low stock count)
|
|
437
446
|
|
|
438
447
|
```typescript
|
|
439
|
-
import { Product
|
|
448
|
+
import { Product } from "../sources";
|
|
449
|
+
import type { ProductForRole } from "../sources";
|
|
440
450
|
import { Roles } from "../sources/roles";
|
|
441
451
|
|
|
442
452
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -466,7 +476,8 @@ console.log("Low stock products:", response.Data[0]["count__id"]);
|
|
|
466
476
|
**Example 3:** Group by field (products by category)
|
|
467
477
|
|
|
468
478
|
```typescript
|
|
469
|
-
import { Product
|
|
479
|
+
import { Product } from "../sources";
|
|
480
|
+
import type { ProductForRole } from "../sources";
|
|
470
481
|
import { Roles } from "../sources/roles";
|
|
471
482
|
|
|
472
483
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -491,7 +502,8 @@ response.Data.forEach((row) => {
|
|
|
491
502
|
**Example 4:** Multiple metrics (stock sum and average by category)
|
|
492
503
|
|
|
493
504
|
```typescript
|
|
494
|
-
import { Product
|
|
505
|
+
import { Product } from "../sources";
|
|
506
|
+
import type { ProductForRole } from "../sources";
|
|
495
507
|
import { Roles } from "../sources/roles";
|
|
496
508
|
|
|
497
509
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -528,7 +540,8 @@ const response = await product.pivot(options: PivotOptionsType): Promise<PivotRe
|
|
|
528
540
|
**Example:** Sales pivot by region and quarter
|
|
529
541
|
|
|
530
542
|
```typescript
|
|
531
|
-
import { Order
|
|
543
|
+
import { Order } from "../sources";
|
|
544
|
+
import type { OrderForRole } from "../sources";
|
|
532
545
|
import { Roles } from "../sources/roles";
|
|
533
546
|
|
|
534
547
|
type AdminOrder = OrderForRole<typeof Roles.Admin>;
|
|
@@ -587,7 +600,8 @@ const response = await product.fields(): Promise<FieldsResponseType>
|
|
|
587
600
|
**Example:** Get field metadata
|
|
588
601
|
|
|
589
602
|
```typescript
|
|
590
|
-
import { Product
|
|
603
|
+
import { Product } from "../sources";
|
|
604
|
+
import type { ProductForRole } from "../sources";
|
|
591
605
|
import { Roles } from "../sources/roles";
|
|
592
606
|
|
|
593
607
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -625,7 +639,8 @@ const options = await product.fetchField(instanceId: string, fieldId: keyof T):
|
|
|
625
639
|
**Example:** Fetch supplier options for dropdown
|
|
626
640
|
|
|
627
641
|
```typescript
|
|
628
|
-
import { Product
|
|
642
|
+
import { Product } from "../sources";
|
|
643
|
+
import type { ProductForRole } from "../sources";
|
|
629
644
|
import { Roles } from "../sources/roles";
|
|
630
645
|
|
|
631
646
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
package/docs/useFilter.md
CHANGED
|
@@ -173,7 +173,8 @@ 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 } from "../sources";
|
|
177
|
+
import type { ProductForRole } from "../sources";
|
|
177
178
|
import { Roles } from "../sources/roles";
|
|
178
179
|
|
|
179
180
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -216,7 +217,8 @@ function TypeSafeFilter() {
|
|
|
216
217
|
```tsx
|
|
217
218
|
import { useFilter } from "@ram_28/kf-ai-sdk/filter";
|
|
218
219
|
import type { UseFilterOptionsType } from "@ram_28/kf-ai-sdk/filter/types";
|
|
219
|
-
import { Product
|
|
220
|
+
import { Product } from "../sources";
|
|
221
|
+
import type { ProductForRole } from "../sources";
|
|
220
222
|
import { Roles } from "../sources/roles";
|
|
221
223
|
|
|
222
224
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
package/docs/useForm.md
CHANGED
|
@@ -227,7 +227,8 @@ interface FormFieldConfigType {
|
|
|
227
227
|
|
|
228
228
|
```tsx
|
|
229
229
|
import { useForm } from "@ram_28/kf-ai-sdk/form";
|
|
230
|
-
import { Product
|
|
230
|
+
import { Product } from "../sources";
|
|
231
|
+
import type { ProductForRole } from "../sources";
|
|
231
232
|
import { Roles } from "../sources/roles";
|
|
232
233
|
|
|
233
234
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -283,7 +284,8 @@ Create form with validation and success handling.
|
|
|
283
284
|
import { useForm } from "@ram_28/kf-ai-sdk/form";
|
|
284
285
|
import type { FieldErrors } from "@ram_28/kf-ai-sdk/form/types";
|
|
285
286
|
import { useNavigate } from "react-router-dom";
|
|
286
|
-
import { Product
|
|
287
|
+
import { Product } from "../sources";
|
|
288
|
+
import type { ProductForRole } from "../sources";
|
|
287
289
|
import { Roles } from "../sources/roles";
|
|
288
290
|
|
|
289
291
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -362,7 +364,8 @@ Update mode with record loading state.
|
|
|
362
364
|
|
|
363
365
|
```tsx
|
|
364
366
|
import { useForm } from "@ram_28/kf-ai-sdk/form";
|
|
365
|
-
import { Product
|
|
367
|
+
import { Product } from "../sources";
|
|
368
|
+
import type { ProductForRole } from "../sources";
|
|
366
369
|
import { Roles } from "../sources/roles";
|
|
367
370
|
|
|
368
371
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -428,7 +431,8 @@ Working with computed fields and the watch function.
|
|
|
428
431
|
|
|
429
432
|
```tsx
|
|
430
433
|
import { useForm } from "@ram_28/kf-ai-sdk/form";
|
|
431
|
-
import { Product
|
|
434
|
+
import { Product } from "../sources";
|
|
435
|
+
import type { ProductForRole } from "../sources";
|
|
432
436
|
import { Roles } from "../sources/roles";
|
|
433
437
|
|
|
434
438
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -483,7 +487,8 @@ Static fields return options with `Value` and `Label`.
|
|
|
483
487
|
```tsx
|
|
484
488
|
import { useState } from "react";
|
|
485
489
|
import { useForm } from "@ram_28/kf-ai-sdk/form";
|
|
486
|
-
import { Product
|
|
490
|
+
import { Product } from "../sources";
|
|
491
|
+
import type { ProductForRole } from "../sources";
|
|
487
492
|
import { Roles } from "../sources/roles";
|
|
488
493
|
|
|
489
494
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -558,7 +563,8 @@ Reference fields return the full object structure. Use a custom dropdown to disp
|
|
|
558
563
|
```tsx
|
|
559
564
|
import { useState } from "react";
|
|
560
565
|
import { useForm } from "@ram_28/kf-ai-sdk/form";
|
|
561
|
-
import { Product
|
|
566
|
+
import { Product } from "../sources";
|
|
567
|
+
import type { ProductForRole } from "../sources";
|
|
562
568
|
import { Roles } from "../sources/roles";
|
|
563
569
|
|
|
564
570
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
package/docs/useKanban.md
CHANGED
|
@@ -428,7 +428,10 @@ function BoardWithPriorityFilter() {
|
|
|
428
428
|
Show only cards assigned to the current user.
|
|
429
429
|
|
|
430
430
|
```tsx
|
|
431
|
-
|
|
431
|
+
import { useAuth } from "@ram_28/kf-ai-sdk/auth";
|
|
432
|
+
|
|
433
|
+
function BoardWithMyTasks() {
|
|
434
|
+
const { user } = useAuth();
|
|
432
435
|
const kanban = useKanban<TaskData>({
|
|
433
436
|
source: "BDO_Tasks",
|
|
434
437
|
columns,
|
|
@@ -440,7 +443,7 @@ function BoardWithMyTasks({ currentUserId }: { currentUserId: string }) {
|
|
|
440
443
|
kanban.filter.addCondition({
|
|
441
444
|
Operator: "EQ",
|
|
442
445
|
LHSField: "assignee",
|
|
443
|
-
RHSValue:
|
|
446
|
+
RHSValue: user._id, // Pass user ID as a string
|
|
444
447
|
});
|
|
445
448
|
};
|
|
446
449
|
|
package/docs/useTable.md
CHANGED
|
@@ -221,7 +221,8 @@ 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 } from "../sources";
|
|
225
|
+
import type { ProductForRole } from "../sources";
|
|
225
226
|
import { Roles } from "../sources/roles";
|
|
226
227
|
|
|
227
228
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -282,7 +283,8 @@ import type {
|
|
|
282
283
|
UseTableReturnType,
|
|
283
284
|
ColumnDefinitionType,
|
|
284
285
|
} from "@ram_28/kf-ai-sdk/table/types";
|
|
285
|
-
import { Product
|
|
286
|
+
import { Product } from "../sources";
|
|
287
|
+
import type { ProductForRole } from "../sources";
|
|
286
288
|
import { Roles } from "../sources/roles";
|
|
287
289
|
|
|
288
290
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|
|
@@ -309,7 +311,7 @@ function MyItemsTable() {
|
|
|
309
311
|
{
|
|
310
312
|
Operator: "EQ",
|
|
311
313
|
LHSField: "_created_by",
|
|
312
|
-
RHSValue:
|
|
314
|
+
RHSValue: user._id, // Pass user ID as a string
|
|
313
315
|
RHSType: "Constant",
|
|
314
316
|
},
|
|
315
317
|
],
|
|
@@ -858,7 +860,8 @@ import type {
|
|
|
858
860
|
UseTableReturnType,
|
|
859
861
|
ColumnDefinitionType,
|
|
860
862
|
} from "@ram_28/kf-ai-sdk/table/types";
|
|
861
|
-
import { Product
|
|
863
|
+
import { Product } from "../sources";
|
|
864
|
+
import type { ProductForRole } from "../sources";
|
|
862
865
|
import { Roles } from "../sources/roles";
|
|
863
866
|
|
|
864
867
|
type BuyerProduct = ProductForRole<typeof Roles.Buyer>;
|