@ram_28/kf-ai-sdk 2.0.12 → 2.0.14

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.
Files changed (69) hide show
  1. package/dist/api/client.d.ts.map +1 -1
  2. package/dist/api.cjs +1 -1
  3. package/dist/api.mjs +2 -2
  4. package/dist/attachment-constants-B5jlqoKI.cjs +1 -0
  5. package/dist/attachment-constants-C2UHWxmp.js +63 -0
  6. package/dist/auth.cjs +1 -1
  7. package/dist/auth.mjs +1 -1
  8. package/dist/bdo/core/types.d.ts +4 -0
  9. package/dist/bdo/core/types.d.ts.map +1 -1
  10. package/dist/bdo/fields/NumberField.d.ts.map +1 -1
  11. package/dist/bdo/fields/ReferenceField.d.ts +3 -2
  12. package/dist/bdo/fields/ReferenceField.d.ts.map +1 -1
  13. package/dist/bdo/fields/SelectField.d.ts +1 -1
  14. package/dist/bdo/fields/SelectField.d.ts.map +1 -1
  15. package/dist/bdo/fields/UserField.d.ts +5 -0
  16. package/dist/bdo/fields/UserField.d.ts.map +1 -1
  17. package/dist/bdo.cjs +1 -1
  18. package/dist/bdo.mjs +107 -153
  19. package/dist/client-DnO2KKrw.cjs +1 -0
  20. package/dist/{client-CMERmrC-.js → client-iQTqFDNI.js} +34 -30
  21. package/dist/components/hooks/useForm/createItemProxy.d.ts +4 -0
  22. package/dist/components/hooks/useForm/createItemProxy.d.ts.map +1 -1
  23. package/dist/components/hooks/useForm/createResolver.d.ts.map +1 -1
  24. package/dist/components/hooks/useForm/useForm.d.ts +1 -0
  25. package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
  26. package/dist/form.cjs +1 -1
  27. package/dist/form.mjs +368 -203
  28. package/dist/{metadata-BfJtHz84.cjs → metadata-DgLSJkF5.cjs} +1 -1
  29. package/dist/{metadata-CwAo6a8e.js → metadata-DpfI3zRN.js} +1 -1
  30. package/dist/table.cjs +1 -1
  31. package/dist/table.mjs +1 -1
  32. package/dist/workflow/types.d.ts +3 -2
  33. package/dist/workflow/types.d.ts.map +1 -1
  34. package/dist/workflow.cjs +1 -1
  35. package/dist/workflow.d.ts +0 -2
  36. package/dist/workflow.d.ts.map +1 -1
  37. package/dist/workflow.mjs +204 -274
  38. package/dist/workflow.types.d.ts +0 -1
  39. package/dist/workflow.types.d.ts.map +1 -1
  40. package/docs/api.md +45 -253
  41. package/docs/bdo.md +130 -711
  42. package/docs/useAuth.md +42 -104
  43. package/docs/useFilter.md +117 -1591
  44. package/docs/useForm.md +266 -861
  45. package/docs/useTable.md +255 -1096
  46. package/docs/workflow.md +10 -155
  47. package/package.json +1 -1
  48. package/sdk/api/client.ts +18 -4
  49. package/sdk/bdo/core/types.ts +1 -0
  50. package/sdk/bdo/fields/NumberField.ts +2 -1
  51. package/sdk/bdo/fields/ReferenceField.ts +4 -3
  52. package/sdk/bdo/fields/SelectField.ts +2 -2
  53. package/sdk/bdo/fields/UserField.ts +14 -0
  54. package/sdk/components/hooks/useForm/createItemProxy.ts +221 -4
  55. package/sdk/components/hooks/useForm/createResolver.ts +16 -1
  56. package/sdk/components/hooks/useForm/useForm.ts +151 -50
  57. package/sdk/workflow/types.ts +3 -2
  58. package/sdk/workflow.ts +0 -7
  59. package/sdk/workflow.types.ts +0 -7
  60. package/dist/client-BnVxSHAm.cjs +0 -1
  61. package/dist/workflow/components/useActivityTable/index.d.ts +0 -4
  62. package/dist/workflow/components/useActivityTable/index.d.ts.map +0 -1
  63. package/dist/workflow/components/useActivityTable/types.d.ts +0 -53
  64. package/dist/workflow/components/useActivityTable/types.d.ts.map +0 -1
  65. package/dist/workflow/components/useActivityTable/useActivityTable.d.ts +0 -4
  66. package/dist/workflow/components/useActivityTable/useActivityTable.d.ts.map +0 -1
  67. package/sdk/workflow/components/useActivityTable/index.ts +0 -8
  68. package/sdk/workflow/components/useActivityTable/types.ts +0 -67
  69. package/sdk/workflow/components/useActivityTable/useActivityTable.ts +0 -145
@@ -1,3 +1,2 @@
1
1
  export type { ActivityInstanceFieldsType, ActivityOperations, ActivityProgressType, WorkflowStartResponseType, } from './workflow/types';
2
- export type { UseActivityTableOptionsType, UseActivityTableReturnType, ActivityTableStatusType, ActivityRowType, } from './workflow/components/useActivityTable/types';
3
2
  //# sourceMappingURL=workflow.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.types.d.ts","sourceRoot":"","sources":["../sdk/workflow.types.ts"],"names":[],"mappings":"AAKA,YAAY,EACV,0BAA0B,EAC1B,kBAAkB,EAClB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,uBAAuB,EACvB,eAAe,GAChB,MAAM,8CAA8C,CAAC"}
1
+ {"version":3,"file":"workflow.types.d.ts","sourceRoot":"","sources":["../sdk/workflow.types.ts"],"names":[],"mappings":"AAKA,YAAY,EACV,0BAA0B,EAC1B,kBAAkB,EAClB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,kBAAkB,CAAC"}
package/docs/api.md CHANGED
@@ -1,303 +1,95 @@
1
1
  # API Types Reference
2
2
 
3
- Request and response types for all BDO methods, grouped by method.
3
+ Request and response types for BDO methods. For usage patterns, see [bdo.md](bdo.md).
4
4
 
5
- For the BDO pattern, field classes, and `ItemType` accessor documentation, see [bdo.md](bdo.md).
6
-
7
- ---
8
-
9
- ## Read Operations
10
-
11
- ### get
12
-
13
- Fetches a single record by ID.
5
+ ## Imports
14
6
 
15
7
  ```typescript
16
- async get(id: string): Promise<ItemType<TEditable, TReadonly>>
8
+ import { api } from "@ram_28/kf-ai-sdk/api";
9
+ import type { ListOptionsType, CreateUpdateResponseType, DeleteResponseType, DraftResponseType, MetricOptionsType, MetricResponseType, PivotOptionsType, PivotResponseType } from "@ram_28/kf-ai-sdk/api/types";
17
10
  ```
18
11
 
19
- **Request:** `id: string`
20
-
21
- **Response:** [`ItemType<TEditable, TReadonly>`](bdo.md#itemtype--runtime-accessor-pattern) — Proxy-wrapped record with field accessors.
22
-
23
12
  ---
24
13
 
25
- ### list
14
+ ## Common Mistakes (READ FIRST)
26
15
 
27
- Fetches paginated records with optional filtering, sorting, and pagination.
16
+ ### 1. Calling `api` directly instead of as factory
28
17
 
29
18
  ```typescript
30
- async list(options?: ListOptionsType): Promise<ItemType<TEditable, TReadonly>[]>
31
- ```
32
-
33
- **Request:**
34
-
35
- ```typescript
36
- interface ListOptionsType {
37
- // Specific fields to return (omit for all fields)
38
- Field?: string[];
39
-
40
- // Filter criteria
41
- Filter?: FilterType;
42
-
43
- // Sort configuration: [{ "fieldName": "ASC" | "DESC" }]
44
- Sort?: SortType;
45
-
46
- // Page number (1-indexed, default: 1)
47
- Page?: number;
19
+ // WRONG — api is a function, not a client
20
+ api.get(id); api.delete(id);
48
21
 
49
- // Records per page (default: 10)
50
- PageSize?: number;
51
- }
22
+ // CORRECT call api(boId) first
23
+ api(bdo.meta._id).get(id);
24
+ api(bdo.meta._id).delete(id);
52
25
  ```
53
26
 
54
- **Response:** [`ItemType<TEditable, TReadonly>[]`](bdo.md#itemtype--runtime-accessor-pattern) Array of Proxy-wrapped records.
55
-
56
- > **Search:** Use a `Filter` with the `Contains` operator on the desired field. See [useFilter docs](useFilter.md).
57
-
58
- ---
59
-
60
- ### count
27
+ ### 2. Using `api()` when BDO methods are available
61
28
 
62
- Returns the count of records matching filter criteria.
29
+ Prefer BDO methods when they're `public` on the role's class. Use `api()` only for `protected` methods.
63
30
 
64
31
  ```typescript
65
- async count(options?: ListOptionsType): Promise<number>
66
- ```
67
-
68
- **Request:** `ListOptionsType` (same as [list](#list))
32
+ // PREFERRED — BDO method
33
+ const items = await bdo.list();
69
34
 
70
- **Response:** `number` count returned directly (internally unwraps `{ Count: number }`).
71
-
72
- ---
73
-
74
- ## Write Operations
75
-
76
- ### create
77
-
78
- Creates a new record.
79
-
80
- ```typescript
81
- async create(data: Partial<TEditable>): Promise<ItemType<TEditable, TReadonly>>
35
+ // USE api() ONLY when BDO method is protected
36
+ await api(bdo.meta._id).delete(id);
82
37
  ```
83
38
 
84
- **Request:** `Partial<TEditable>` field values for the new record.
85
-
86
- **Response:** [`ItemType<TEditable, TReadonly>`](bdo.md#itemtype--runtime-accessor-pattern) — the created record with `_id` from the API and input data as field accessors.
87
-
88
- ---
39
+ ### 3. Wrong metric response key format
89
40
 
90
- ### update
91
-
92
- Updates an existing record.
41
+ Key pattern is `{lowercase_type}_{Field}` with single underscore.
93
42
 
94
43
  ```typescript
95
- async update(id: string, data: Partial<TEditable>): Promise<CreateUpdateResponseType>
96
- ```
97
-
98
- **Request:** `id: string`, `data: Partial<TEditable>`
44
+ // WRONG
45
+ const count = result.Data[0].count;
99
46
 
100
- **Response:**
101
-
102
- ```typescript
103
- interface CreateUpdateResponseType {
104
- _id: string;
105
- }
47
+ // ✅ CORRECT
48
+ const count = result.Data?.[0]?.["count__id"] ?? 0; // Count of _id
49
+ const total = result.Data?.[0]?.["sum_unit_price"] ?? 0; // Sum of unit_price
106
50
  ```
107
51
 
108
52
  ---
109
53
 
110
- ### delete
111
-
112
- Deletes a record by ID.
54
+ ## Response Types
113
55
 
114
56
  ```typescript
115
- async delete(id: string): Promise<DeleteResponseType>
116
- ```
117
-
118
- **Request:** `id: string`
119
-
120
- **Response:**
121
-
122
- ```typescript
123
- interface DeleteResponseType {
124
- status: "success";
125
- }
126
- ```
127
-
128
- ---
129
-
130
- ## Draft Operations
57
+ interface CreateUpdateResponseType { _id: string; }
58
+ interface DeleteResponseType { status: "success"; }
59
+ interface DraftResponseType { [fieldName: string]: any; }
131
60
 
132
- ### draft
133
-
134
- Previews computed field values for a new record without saving.
135
-
136
- ```typescript
137
- async draft(data: Partial<TEditable>): Promise<DraftResponseType>
138
- ```
139
-
140
- **Request:** `Partial<TEditable>` — field values to compute against.
141
-
142
- **Response:**
143
-
144
- ```typescript
145
- interface DraftResponseType {
146
- // Keys are field names, values are server-computed results
147
- [fieldName: string]: any;
61
+ interface ListOptionsType {
62
+ Field?: string[];
63
+ Filter?: FilterType;
64
+ Sort?: Record<string, "ASC" | "DESC">[];
65
+ Page?: number; // 1-indexed
66
+ PageSize?: number; // Default: 10
148
67
  }
149
- ```
150
-
151
- ---
152
-
153
- ### draftPatch
154
-
155
- Previews computed field values for an existing record being edited.
156
68
 
157
- ```typescript
158
- async draftPatch(id: string, data: Partial<TEditable>): Promise<DraftResponseType>
159
- ```
160
-
161
- **Request:** `id: string`, `data: Partial<TEditable>`
162
-
163
- **Response:** `DraftResponseType` (same as [draft](#draft))
164
-
165
- ---
166
-
167
- ### draftInteraction
168
-
169
- Creates/updates a draft without requiring an instance ID. Returns computed fields along with a temporary `_id`.
170
-
171
- ```typescript
172
- async draftInteraction(data: Partial<TEditable>): Promise<DraftResponseType & { _id: string }>
173
- ```
174
-
175
- **Request:** `Partial<TEditable>`
176
-
177
- **Response:** `DraftResponseType & { _id: string }` — computed fields plus a temporary draft ID.
178
-
179
- ---
180
-
181
- ## Analytics Operations
182
-
183
- ### metric
184
-
185
- Performs aggregation queries on records.
186
-
187
- ```typescript
188
- async metric(options: Omit<MetricOptionsType, "Type">): Promise<MetricResponseType>
189
- ```
190
-
191
- > `Type` is added internally — pass only `GroupBy`, `Metric`, and optional `Filter`.
192
-
193
- **Request:**
194
-
195
- ```typescript
196
69
  interface MetricOptionsType {
197
- Type: "Metric"; // added internally
198
- GroupBy: string[]; // fields to group by (empty array for totals)
199
- Metric: MetricFieldType[];
70
+ GroupBy: string[];
71
+ Metric: { Field: string; Type: AggregationType; }[];
200
72
  Filter?: FilterType;
201
73
  }
202
74
 
203
- interface MetricFieldType {
204
- Field: string;
205
- Type: AggregationType;
206
- }
207
- ```
208
-
209
- **Response:**
210
-
211
- ```typescript
212
- interface MetricResponseType {
213
- // Keys follow pattern: {type}_{Field}
214
- // e.g., "count__id", "sum_Stock", "avg_Price"
215
- Data: Record<string, any>[];
216
- }
217
- ```
75
+ interface MetricResponseType { Data: Record<string, any>[]; }
218
76
 
219
- **Response key pattern:** `{lowercase_type}_{Field}` — e.g., `{ Field: "Stock", Type: "Sum" }` produces key `"sum_Stock"`.
220
-
221
- ---
222
-
223
- ### pivot
224
-
225
- Creates pivot table aggregations with row and column dimensions.
226
-
227
- ```typescript
228
- async pivot(options: Omit<PivotOptionsType, "Type">): Promise<PivotResponseType>
229
- ```
230
-
231
- > `Type` is added internally — pass only `Row`, `Column`, `Metric`, and optional `Filter`.
232
-
233
- **Request:**
234
-
235
- ```typescript
236
77
  interface PivotOptionsType {
237
- Type: "Pivot"; // added internally
238
- Row: string[]; // row dimension fields
239
- Column: string[]; // column dimension fields
240
- Metric: MetricFieldType[];
78
+ Row: string[];
79
+ Column: string[];
80
+ Metric: { Field: string; Type: AggregationType; }[];
241
81
  Filter?: FilterType;
242
82
  }
243
- ```
244
-
245
- **Response:**
246
83
 
247
- ```typescript
248
84
  interface PivotResponseType {
249
- Data: {
250
- RowHeader: PivotHeaderItemType[];
251
- ColumnHeader: PivotHeaderItemType[];
252
- Value: (number | string | null)[][]; // [row][column]
253
- };
254
- }
255
-
256
- interface PivotHeaderItemType {
257
- Key: string;
258
- Children?: PivotHeaderItemType[];
85
+ Data: { RowHeader: { Key: string }[]; ColumnHeader: { Key: string }[]; Value: (number | string | null)[][]; };
259
86
  }
260
- ```
261
-
262
- ---
263
87
 
264
- ## Shared Types
88
+ type AggregationType = "Sum" | "Avg" | "Count" | "Max" | "Min" | "DistinctCount" | "BlankCount" | "NotBlankCount" | "Concat" | "DistinctConcat";
265
89
 
266
- ### FilterType
90
+ // Filter type (for bdo.list() Filter parameter)
91
+ interface FilterType { Operator: "And" | "Or" | "Not"; Condition: Array<ConditionType | ConditionGroupType>; }
92
+ interface ConditionType { Operator: string; LHSField: string; RHSValue: any; RHSType?: "Constant" | "BDOField" | "AppVariable"; }
267
93
 
268
- ```typescript
269
- type FilterType = ConditionGroupType;
270
-
271
- interface ConditionGroupType {
272
- Operator: "And" | "Or" | "Not";
273
- Condition: Array<ConditionType | ConditionGroupType>;
274
- }
275
-
276
- interface ConditionType {
277
- Operator: ConditionOperatorType;
278
- LHSField: string;
279
- RHSValue: any;
280
- RHSType?: "Constant" | "BDOField" | "AppVariable";
281
- }
282
- ```
283
-
284
- **Condition Operators:** `EQ`, `NE`, `GT`, `GTE`, `LT`, `LTE`, `Between`, `NotBetween`, `IN`, `NIN`, `Empty`, `NotEmpty`, `Contains`, `NotContains`, `MinLength`, `MaxLength`
285
-
286
- For full filter documentation, see the [useFilter docs](useFilter.md).
287
-
288
- ### SortType
289
-
290
- ```typescript
291
94
  type SortType = Record<string, "ASC" | "DESC">[];
292
95
  ```
293
-
294
- Format: `[{ "fieldName": "ASC" }, { "anotherField": "DESC" }]`
295
-
296
- ### AggregationType
297
-
298
- ```typescript
299
- type AggregationType =
300
- | "Sum" | "Avg" | "Count" | "Max" | "Min"
301
- | "DistinctCount" | "BlankCount" | "NotBlankCount"
302
- | "Concat" | "DistinctConcat";
303
- ```