@ram_28/kf-ai-sdk 2.0.26 → 2.0.27

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.
@@ -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. **Don't confuse `StringField` (class) with `StringFieldType` (type alias)** Different modules.
45
- 3. **`fetchOptions()` requires a parent BDO** — Standalone fields will throw.
46
- 4. **SelectField meta `Type` is `"String"`**`Constraint.Enum` differentiates it.
47
- 5. **Always use pre-built components for File/Image** `<FileUpload>`, `<ImageUpload>`, `<FilePreview>`, `<ImageThumbnail>`.
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ram_28/kf-ai-sdk",
3
- "version": "2.0.26",
3
+ "version": "2.0.27",
4
4
  "description": "Type-safe, AI-driven SDK for building modern web applications with role-based access control",
5
5
  "author": "Ramprasad",
6
6
  "license": "MIT",