@ram_28/kf-ai-sdk 2.0.26 → 2.0.28
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/bdo/README.md +3 -3
- package/docs/bdo/api_reference.md +1 -1
- package/docs/examples/bdo/filtered-product-table.md +1 -1
- package/docs/examples/workflow/filtered-activity-table.md +1 -1
- package/docs/fields/README.md +25 -4
- package/docs/useActivityTable/README.md +3 -3
- package/docs/useBDOTable/README.md +3 -2
- package/package.json +1 -1
package/docs/bdo/README.md
CHANGED
|
@@ -82,7 +82,7 @@ const filtered = await product.count({
|
|
|
82
82
|
Filter: {
|
|
83
83
|
Operator: "And",
|
|
84
84
|
Condition: [
|
|
85
|
-
{ Operator: "
|
|
85
|
+
{ Operator: "EQ", LHSField: "Category", RHSValue: "Electronics", RHSType: "Constant" },
|
|
86
86
|
],
|
|
87
87
|
},
|
|
88
88
|
});
|
|
@@ -125,8 +125,8 @@ const items = await product.list({
|
|
|
125
125
|
Filter: {
|
|
126
126
|
Operator: "And",
|
|
127
127
|
Condition: [
|
|
128
|
-
{ Operator: "
|
|
129
|
-
{ Operator: "
|
|
128
|
+
{ Operator: "EQ", LHSField: "Category", RHSValue: "Electronics", RHSType: "Constant" },
|
|
129
|
+
{ Operator: "GTE", LHSField: "Price", RHSValue: 10, RHSType: "Constant" },
|
|
130
130
|
],
|
|
131
131
|
},
|
|
132
132
|
Sort: [{ Price: "DESC" }],
|
|
@@ -140,7 +140,7 @@ interface ConditionGroupType {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
interface ConditionType {
|
|
143
|
-
Operator: string; // "
|
|
143
|
+
Operator: string; // "EQ", "NE", "GT", "GTE", "LT", "LTE", "Contains", "StartsWith", "IN", "NIN", "Empty", "NotEmpty"
|
|
144
144
|
LHSField: string; // field name
|
|
145
145
|
RHSValue: any; // comparison value
|
|
146
146
|
RHSType?: string; // defaults to "Constant"
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { useState, useMemo } from "react";
|
|
7
7
|
import { useBDOTable } from "@ram_28/kf-ai-sdk/table";
|
|
8
8
|
import type { UseBDOTableReturnType } from "@ram_28/kf-ai-sdk/table/types";
|
|
9
|
-
import { ConditionOperator, RHSType } from "@ram_28/kf-ai-sdk/
|
|
9
|
+
import { ConditionOperator, RHSType } from "@ram_28/kf-ai-sdk/table";
|
|
10
10
|
import { BuyerProduct } from "@/bdo/buyer/Product";
|
|
11
11
|
|
|
12
12
|
export default function FilteredProductTable() {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { useState, useMemo } from "react";
|
|
7
7
|
import { useActivityTable, ActivityTableStatus } from "@ram_28/kf-ai-sdk/workflow";
|
|
8
8
|
import type { UseActivityTableReturnType } from "@ram_28/kf-ai-sdk/workflow";
|
|
9
|
-
import { ConditionOperator, RHSType } from "@ram_28/kf-ai-sdk/
|
|
9
|
+
import { ConditionOperator, RHSType } from "@ram_28/kf-ai-sdk/table";
|
|
10
10
|
import { EmployeeInputActivity } from "@/workflow/leave";
|
|
11
11
|
|
|
12
12
|
export default function FilteredActivityTable() {
|
package/docs/fields/README.md
CHANGED
|
@@ -38,13 +38,34 @@ import type {
|
|
|
38
38
|
} from "@ram_28/kf-ai-sdk/types";
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
+
## CRITICAL: `.get()` Returns `T | undefined`
|
|
42
|
+
|
|
43
|
+
**Every** field accessor's `.get()` method returns `T | undefined` — **never just `T`**. This means you MUST null-guard the return value before passing it to typed functions:
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
// ❌ WRONG — TypeScript error: 'string | undefined' not assignable to 'string | number'
|
|
47
|
+
const rowDate = new Date(row.start_time.get());
|
|
48
|
+
const label = format(row.start_time.get(), "MMM d");
|
|
49
|
+
getStatusBadge(row.status.get()); // param expects string, gets string | undefined
|
|
50
|
+
|
|
51
|
+
// ✅ CORRECT — Guard undefined before use
|
|
52
|
+
const startVal = row.start_time.get();
|
|
53
|
+
if (!startVal) return null; // or provide a fallback
|
|
54
|
+
const rowDate = new Date(startVal); // Now guaranteed string
|
|
55
|
+
const label = format(startVal, "MMM d"); // Now guaranteed string
|
|
56
|
+
getStatusBadge(row.status.get() ?? ""); // Fallback to empty string
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
This applies to ALL field types: `StringField.get()` → `string | undefined`, `NumberField.get()` → `number | undefined`, `DateTimeField.get()` → `string | undefined`, etc.
|
|
60
|
+
|
|
41
61
|
## Common Mistakes (READ FIRST)
|
|
42
62
|
|
|
43
63
|
1. **`item.Title` is not the value** — Use `item.Title.get()` to read, `.set()` to write.
|
|
44
|
-
2.
|
|
45
|
-
3.
|
|
46
|
-
4.
|
|
47
|
-
5. **
|
|
64
|
+
2. **`.get()` returns `T | undefined`** — Always null-guard before passing to `new Date()`, `format()`, template literals, or typed function parameters. See section above.
|
|
65
|
+
3. **Don't confuse `StringField` (class) with `StringFieldType` (type alias)** — Different modules.
|
|
66
|
+
4. **`fetchOptions()` requires a parent BDO** — Standalone fields will throw.
|
|
67
|
+
5. **SelectField meta `Type` is `"String"`** — `Constraint.Enum` differentiates it.
|
|
68
|
+
6. **Always use pre-built components for File/Image** — `<FileUpload>`, `<ImageUpload>`, `<FilePreview>`, `<ImageThumbnail>`.
|
|
48
69
|
|
|
49
70
|
## Quick Start
|
|
50
71
|
|
|
@@ -161,14 +161,14 @@ Sorting is controlled through the `sort` object. Column headers typically use `t
|
|
|
161
161
|
The table includes an integrated [`useFilter`](../useFilter/README.md) instance at `table.filter`. Use it to build filter conditions that narrow down the table results:
|
|
162
162
|
|
|
163
163
|
```tsx
|
|
164
|
-
import { ConditionOperator } from "@ram_28/kf-ai-sdk/table";
|
|
164
|
+
import { ConditionOperator, RHSType } from "@ram_28/kf-ai-sdk/table";
|
|
165
165
|
|
|
166
166
|
// Filter by leave type
|
|
167
167
|
table.filter.addCondition({
|
|
168
168
|
Operator: ConditionOperator.EQ,
|
|
169
169
|
LHSField: activity.LeaveType.id,
|
|
170
170
|
RHSValue: "PTO",
|
|
171
|
-
RHSType:
|
|
171
|
+
RHSType: RHSType.Constant,
|
|
172
172
|
});
|
|
173
173
|
|
|
174
174
|
// Date range filter
|
|
@@ -176,7 +176,7 @@ table.filter.addCondition({
|
|
|
176
176
|
Operator: ConditionOperator.GTE,
|
|
177
177
|
LHSField: activity.StartDate.id,
|
|
178
178
|
RHSValue: "2026-01-01",
|
|
179
|
-
RHSType:
|
|
179
|
+
RHSType: RHSType.Constant,
|
|
180
180
|
});
|
|
181
181
|
|
|
182
182
|
// Clear all filters
|
|
@@ -141,14 +141,14 @@ Sorting is controlled through the `sort` object. Column headers typically use `t
|
|
|
141
141
|
The table includes an integrated [`useFilter`](../useFilter/README.md) instance at `table.filter`. Use it to build filter conditions that narrow down the table results:
|
|
142
142
|
|
|
143
143
|
```tsx
|
|
144
|
-
import { ConditionOperator } from "@ram_28/kf-ai-sdk/table";
|
|
144
|
+
import { ConditionOperator, RHSType } from "@ram_28/kf-ai-sdk/table";
|
|
145
145
|
|
|
146
146
|
// Exact match
|
|
147
147
|
table.filter.addCondition({
|
|
148
148
|
Operator: ConditionOperator.EQ,
|
|
149
149
|
LHSField: product.Category.id,
|
|
150
150
|
RHSValue: "Electronics",
|
|
151
|
-
RHSType:
|
|
151
|
+
RHSType: RHSType.Constant,
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
// Range filter
|
|
@@ -156,6 +156,7 @@ table.filter.addCondition({
|
|
|
156
156
|
Operator: ConditionOperator.GTE,
|
|
157
157
|
LHSField: product.Price.id,
|
|
158
158
|
RHSValue: 100,
|
|
159
|
+
RHSType: RHSType.Constant,
|
|
159
160
|
});
|
|
160
161
|
|
|
161
162
|
// Clear all filters
|