@ram_28/kf-ai-sdk 2.0.21 → 2.0.23

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.
@@ -21,8 +21,13 @@ export interface ConditionGroupBuilder {
21
21
  }
22
22
  /**
23
23
  * Hook options (minimal configuration)
24
- * Used for initializing useFilter, and also for initialState in useTable/useKanban
24
+ * Used for initializing useFilter, and also for initialState in useTable/useBDOTable
25
25
  * @template T - Data type for type-safe field names (defaults to any)
26
+ *
27
+ * NAMING: Hook options use camelCase (`conditions`, `operator`).
28
+ * Condition OBJECTS inside the array use PascalCase (`Operator`, `LHSField`, `RHSValue`).
29
+ * `operator` combines all conditions ("And"/"Or"/"Not").
30
+ * `ConditionType.Operator` compares a single field ("EQ"/"GT"/etc.).
26
31
  */
27
32
  export interface UseFilterOptionsType<T = any> {
28
33
  /** Filter conditions */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../sdk/components/hooks/useFilter/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,UAAU,EACV,aAAa,EACd,MAAM,uBAAuB,CAAC;AAG/B,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,UAAU,EACV,aAAa,GACd,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC3B,MAAM,aAAa,GAAG,kBAAkB,KACvC,IAAI,IAAI,kBAEV,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,GACtB,MAAM,aAAa,GAAG,kBAAkB,KACvC,IAAI,IAAI,aAEV,CAAC;AAMF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,kCAAkC;IAClC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB,oCAAoC;IACpC,YAAY,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,qBAA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AAC;IAMnF,2BAA2B;IAC3B,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAE/B,qDAAqD;IACrD,eAAe,EAAE,CAAC,EAAE,EAAE,0BAA0B,KAAK,IAAI,CAAC;CAC3D"}
@@ -23,11 +23,11 @@ import {
23
23
  SelectTrigger,
24
24
  SelectValue,
25
25
  } from "@/components/ui/select";
26
- import { ReferenceSelect } from "@/components/ui/reference-select";
27
- import { FileUpload } from "@/components/ui/file-upload";
28
- import { ImageUpload } from "@/components/ui/image-upload";
29
- import { FilePreview } from "@/components/ui/file-preview";
30
- import { ImageThumbnail } from "@/components/ui/image-thumbnail";
26
+ import { ReferenceSelect } from "@/components/system/reference-select";
27
+ import { FileUpload } from "@/components/system/file-upload";
28
+ import { ImageUpload } from "@/components/system/image-upload";
29
+ import { FilePreview } from "@/components/system/file-preview";
30
+ import { ImageThumbnail } from "@/components/system/image-thumbnail";
31
31
 
32
32
  export default function ComplexFieldsForm({ recordId }: { recordId?: string }) {
33
33
  const fieldTest = useMemo(() => new AdminFieldTest(), []);
@@ -204,8 +204,8 @@ export default function ComplexFieldsForm({ recordId }: { recordId?: string }) {
204
204
  For tables and detail pages, use `<FilePreview>` and `<ImageThumbnail>`:
205
205
 
206
206
  ```tsx
207
- import { FilePreview } from "@/components/ui/file-preview";
208
- import { ImageThumbnail } from "@/components/ui/image-thumbnail";
207
+ import { FilePreview } from "@/components/system/file-preview";
208
+ import { ImageThumbnail } from "@/components/system/image-thumbnail";
209
209
 
210
210
  // In a table row or detail page
211
211
  function RecordRow({ record }: { record: ItemType<...> }) {
@@ -126,13 +126,13 @@ const { data: options = [] } = useQuery({
126
126
 
127
127
  ## UI Components
128
128
 
129
- | Component | Field | Mode | Key Props |
130
- | ------------------- | --------- | --------- | ------------------------------------------------- |
131
- | `<ReferenceSelect>` | Reference | Edit | `bdoField`, `instanceId`, `value`, `onChange` |
132
- | `<FileUpload>` | File | Edit | `field`, `value`, `boId`, `instanceId`, `fieldId` |
133
- | `<ImageUpload>` | Image | Edit | `field`, `value`, `boId`, `instanceId`, `fieldId` |
134
- | `<FilePreview>` | File | Read-only | `boId`, `instanceId`, `fieldId`, `value` |
135
- | `<ImageThumbnail>` | Image | Read-only | `boId`, `instanceId`, `fieldId`, `value` |
129
+ | Component | Field | Mode | Import Path | Key Props |
130
+ | ------------------- | --------- | --------- | -------------------------------------- | ------------------------------------------------- |
131
+ | `<ReferenceSelect>` | Reference | Edit | `@/components/system/reference-select` | `bdoField`, `instanceId`, `value`, `onChange` |
132
+ | `<FileUpload>` | File | Edit | `@/components/system/file-upload` | `field`, `value`, `boId`, `instanceId`, `fieldId` |
133
+ | `<ImageUpload>` | Image | Edit | `@/components/system/image-upload` | `field`, `value`, `boId`, `instanceId`, `fieldId` |
134
+ | `<FilePreview>` | File | Read-only | `@/components/system/file-preview` | `boId`, `instanceId`, `fieldId`, `value` |
135
+ | `<ImageThumbnail>` | Image | Read-only | `@/components/system/image-thumbnail` | `boId`, `instanceId`, `fieldId`, `value` |
136
136
 
137
137
  ## Further Reading
138
138
 
@@ -229,7 +229,7 @@ filter.addCondition(
229
229
  The root operator combines all top-level conditions. It defaults to `"And"` and can be set via the `operator` option or changed later with `setRootOperator()`:
230
230
 
231
231
  ```tsx
232
- // Set at initialization
232
+ // Set at initialization — camelCase hook option, NOT a condition property
233
233
  const filter = useFilter<AdminProductFieldType>({
234
234
  operator: "Or",
235
235
  });
@@ -265,16 +265,22 @@ const table = useBDOTable({
265
265
  bdo: product,
266
266
  initialState: {
267
267
  filter: {
268
+ // Inside condition objects → PascalCase: Operator, LHSField, RHSValue
268
269
  conditions: [
269
270
  { Operator: ConditionOperator.EQ, LHSField: "status", RHSValue: "Active" },
270
271
  ],
272
+ // Hook option → camelCase: operator (combines conditions, NOT a condition property)
271
273
  operator: "And",
272
274
  },
273
275
  },
274
276
  });
275
277
 
276
- // Same API as standalone useFilter
277
- table.filter.addCondition({ ... });
278
+ // Same API as standalone useFilter — condition objects always PascalCase
279
+ table.filter.addCondition({
280
+ Operator: ConditionOperator.EQ, // PascalCase! NOT operator:
281
+ LHSField: product.Category.id,
282
+ RHSValue: "Electronics",
283
+ });
278
284
  table.filter.clearAllConditions();
279
285
  ```
280
286
 
@@ -316,8 +322,9 @@ filter.items.map((item) => {
316
322
 
317
323
  ## Common Mistakes
318
324
 
325
+ - **NEVER write `operator:` (lowercase) inside condition objects** -- this is the #1 error. Condition objects require PascalCase `Operator:`. The camelCase `operator` is ONLY for hook options like `useFilter({ operator: "And" })`. Inside `addCondition({...})` or `conditions: [{...}]`, ALWAYS write `{ Operator: ConditionOperator.EQ, ... }`.
319
326
  - **Don't read `filter.conditions`** -- the property is `filter.items`.
320
327
  - **Don't expect `payload` to be an empty object when empty** -- it's `undefined`. Use a simple falsy check: `if (filter.payload) { ... }`.
321
328
  - **Don't use string literals** -- use `ConditionOperator.EQ`, `GroupOperator.And`, `FilterValueSource.Constant` instead.
322
329
  - **Don't expect IDs in `payload`** -- they're stripped automatically before the payload is built.
323
- - **Don't mix PascalCase and camelCase** -- condition properties are PascalCase (`Operator`, `LHSField`, `RHSValue`, `RHSType`), while hook options are camelCase (`conditions`, `operator`).
330
+ - **Don't mix PascalCase and camelCase** -- condition properties are PascalCase (`Operator`, `LHSField`, `RHSValue`, `RHSType`), while hook options are camelCase (`conditions`, `operator`). Writing `operator: "EQ"` (lowercase) in a condition causes TS2561.
@@ -30,7 +30,7 @@ const filter: UseFilterReturnType<T> = useFilter<T>(options: UseFilterOptionsTyp
30
30
  - Initial filter conditions. Each item is cloned and assigned an auto-generated `id`.
31
31
  - `operator?: ConditionGroupOperatorType`
32
32
  - **Optional**, defaults to `"And"`
33
- - Root operator for combining top-level conditions.
33
+ - Root operator for combining top-level conditions. NOT the same as `ConditionType.Operator`.
34
34
 
35
35
  ## Return Value
36
36
 
@@ -198,7 +198,8 @@ type FilterRHSType = (typeof FilterValueSource)[keyof typeof FilterValueSource];
198
198
  interface UseFilterOptionsType<T = any> {
199
199
  /** Initial filter conditions. Each item is cloned and assigned an auto-generated id. */
200
200
  conditions?: Array<ConditionType<T> | ConditionGroupType<T>>;
201
- /** Root operator for combining conditions. Defaults to "And". */
201
+ /** Root operator for combining conditions. Defaults to "And".
202
+ * NOT the same as ConditionType.Operator — this combines conditions, not compares fields. */
202
203
  operator?: ConditionGroupOperatorType;
203
204
  }
204
205
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ram_28/kf-ai-sdk",
3
- "version": "2.0.21",
3
+ "version": "2.0.23",
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",
@@ -57,8 +57,13 @@ export interface ConditionGroupBuilder {
57
57
 
58
58
  /**
59
59
  * Hook options (minimal configuration)
60
- * Used for initializing useFilter, and also for initialState in useTable/useKanban
60
+ * Used for initializing useFilter, and also for initialState in useTable/useBDOTable
61
61
  * @template T - Data type for type-safe field names (defaults to any)
62
+ *
63
+ * NAMING: Hook options use camelCase (`conditions`, `operator`).
64
+ * Condition OBJECTS inside the array use PascalCase (`Operator`, `LHSField`, `RHSValue`).
65
+ * `operator` combines all conditions ("And"/"Or"/"Not").
66
+ * `ConditionType.Operator` compares a single field ("EQ"/"GT"/etc.).
62
67
  */
63
68
  export interface UseFilterOptionsType<T = any> {
64
69
  /** Filter conditions */