@ram_28/kf-ai-sdk 1.0.10 → 1.0.12

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 (193) hide show
  1. package/README.md +55 -48
  2. package/dist/api/client.d.ts +23 -13
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/datetime.d.ts +5 -5
  5. package/dist/api/datetime.d.ts.map +1 -1
  6. package/dist/api/index.d.ts +1 -1
  7. package/dist/api/index.d.ts.map +1 -1
  8. package/dist/api/metadata.d.ts +2 -2
  9. package/dist/api/metadata.d.ts.map +1 -1
  10. package/dist/api.cjs +1 -0
  11. package/dist/api.d.ts +4 -0
  12. package/dist/api.d.ts.map +1 -0
  13. package/dist/api.mjs +27 -0
  14. package/dist/api.types.cjs +1 -0
  15. package/dist/api.types.d.ts +4 -0
  16. package/dist/api.types.d.ts.map +1 -0
  17. package/dist/api.types.mjs +1 -0
  18. package/dist/auth/AuthProvider.d.ts +3 -3
  19. package/dist/auth/AuthProvider.d.ts.map +1 -1
  20. package/dist/auth/authClient.d.ts +4 -4
  21. package/dist/auth/authClient.d.ts.map +1 -1
  22. package/dist/auth/authConfig.d.ts +5 -5
  23. package/dist/auth/authConfig.d.ts.map +1 -1
  24. package/dist/auth/index.d.ts +1 -1
  25. package/dist/auth/index.d.ts.map +1 -1
  26. package/dist/auth/types.d.ts +21 -21
  27. package/dist/auth/types.d.ts.map +1 -1
  28. package/dist/auth/useAuth.d.ts +2 -2
  29. package/dist/auth/useAuth.d.ts.map +1 -1
  30. package/dist/auth.cjs +1 -0
  31. package/dist/auth.d.ts +5 -0
  32. package/dist/auth.d.ts.map +1 -0
  33. package/dist/auth.mjs +280 -0
  34. package/dist/auth.types.cjs +1 -0
  35. package/dist/auth.types.d.ts +2 -0
  36. package/dist/auth.types.d.ts.map +1 -0
  37. package/dist/auth.types.mjs +1 -0
  38. package/dist/base-types.d.ts +2 -0
  39. package/dist/base-types.d.ts.map +1 -0
  40. package/dist/client-C15j4O5B.cjs +1 -0
  41. package/dist/client-CfvLiGfP.js +233 -0
  42. package/dist/cn-Dr87sK3i.js +2775 -0
  43. package/dist/cn-mXUIg4vp.cjs +1 -0
  44. package/dist/components/hooks/index.d.ts +3 -3
  45. package/dist/components/hooks/index.d.ts.map +1 -1
  46. package/dist/components/hooks/useFilter/index.d.ts +2 -2
  47. package/dist/components/hooks/useFilter/index.d.ts.map +1 -1
  48. package/dist/components/hooks/useFilter/types.d.ts +19 -31
  49. package/dist/components/hooks/useFilter/types.d.ts.map +1 -1
  50. package/dist/components/hooks/useFilter/useFilter.d.ts +2 -2
  51. package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -1
  52. package/dist/components/hooks/useForm/apiClient.d.ts +6 -6
  53. package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
  54. package/dist/components/hooks/useForm/expressionValidator.utils.d.ts +7 -7
  55. package/dist/components/hooks/useForm/expressionValidator.utils.d.ts.map +1 -1
  56. package/dist/components/hooks/useForm/index.d.ts +5 -5
  57. package/dist/components/hooks/useForm/index.d.ts.map +1 -1
  58. package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts +10 -10
  59. package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts.map +1 -1
  60. package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts +7 -12
  61. package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts.map +1 -1
  62. package/dist/components/hooks/useForm/schemaParser.utils.d.ts +7 -7
  63. package/dist/components/hooks/useForm/schemaParser.utils.d.ts.map +1 -1
  64. package/dist/components/hooks/useForm/types.d.ts +79 -70
  65. package/dist/components/hooks/useForm/types.d.ts.map +1 -1
  66. package/dist/components/hooks/useForm/useForm.d.ts +2 -2
  67. package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
  68. package/dist/components/hooks/useKanban/apiClient.d.ts +16 -16
  69. package/dist/components/hooks/useKanban/apiClient.d.ts.map +1 -1
  70. package/dist/components/hooks/useKanban/context.d.ts +3 -3
  71. package/dist/components/hooks/useKanban/context.d.ts.map +1 -1
  72. package/dist/components/hooks/useKanban/dragDropManager.d.ts +7 -7
  73. package/dist/components/hooks/useKanban/dragDropManager.d.ts.map +1 -1
  74. package/dist/components/hooks/useKanban/index.d.ts +1 -1
  75. package/dist/components/hooks/useKanban/index.d.ts.map +1 -1
  76. package/dist/components/hooks/useKanban/types.d.ts +65 -67
  77. package/dist/components/hooks/useKanban/types.d.ts.map +1 -1
  78. package/dist/components/hooks/useKanban/useKanban.d.ts +2 -2
  79. package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -1
  80. package/dist/components/hooks/useTable/index.d.ts +1 -1
  81. package/dist/components/hooks/useTable/index.d.ts.map +1 -1
  82. package/dist/components/hooks/useTable/types.d.ts +10 -10
  83. package/dist/components/hooks/useTable/types.d.ts.map +1 -1
  84. package/dist/components/hooks/useTable/useTable.d.ts +2 -2
  85. package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
  86. package/dist/filter.cjs +1 -0
  87. package/dist/filter.d.ts +3 -0
  88. package/dist/filter.d.ts.map +1 -0
  89. package/dist/filter.mjs +6 -0
  90. package/dist/filter.types.cjs +1 -0
  91. package/dist/filter.types.d.ts +2 -0
  92. package/dist/filter.types.d.ts.map +1 -0
  93. package/dist/filter.types.mjs +1 -0
  94. package/dist/form.cjs +1 -0
  95. package/dist/form.d.ts +3 -0
  96. package/dist/form.d.ts.map +1 -0
  97. package/dist/form.mjs +1346 -0
  98. package/dist/form.types.cjs +1 -0
  99. package/dist/form.types.d.ts +2 -0
  100. package/dist/form.types.d.ts.map +1 -0
  101. package/dist/form.types.mjs +1 -0
  102. package/dist/jsx-runtime-BYECrxsp.cjs +30 -0
  103. package/dist/jsx-runtime-DGlMoOmv.js +630 -0
  104. package/dist/kanban.cjs +13 -0
  105. package/dist/kanban.d.ts +5 -0
  106. package/dist/kanban.d.ts.map +1 -0
  107. package/dist/kanban.mjs +694 -0
  108. package/dist/kanban.types.cjs +1 -0
  109. package/dist/kanban.types.d.ts +2 -0
  110. package/dist/kanban.types.d.ts.map +1 -0
  111. package/dist/kanban.types.mjs +1 -0
  112. package/dist/kanban.ui.cjs +1 -0
  113. package/dist/kanban.ui.d.ts +2 -0
  114. package/dist/kanban.ui.d.ts.map +1 -0
  115. package/dist/kanban.ui.mjs +104 -0
  116. package/dist/metadata-2FLBsFcf.cjs +1 -0
  117. package/dist/metadata-DBcoDth-.js +43 -0
  118. package/dist/table.cjs +1 -0
  119. package/dist/table.d.ts +2 -0
  120. package/dist/table.d.ts.map +1 -0
  121. package/dist/table.mjs +148 -0
  122. package/dist/table.types.cjs +1 -0
  123. package/dist/table.types.d.ts +2 -0
  124. package/dist/table.types.d.ts.map +1 -0
  125. package/dist/table.types.mjs +1 -0
  126. package/dist/types/base-fields.d.ts +45 -45
  127. package/dist/types/base-fields.d.ts.map +1 -1
  128. package/dist/types/common.d.ts +45 -61
  129. package/dist/types/common.d.ts.map +1 -1
  130. package/dist/types.cjs +1 -0
  131. package/dist/types.mjs +1 -0
  132. package/dist/useFilter-CXFqEHyI.js +129 -0
  133. package/dist/useFilter-D-bCDo6Z.cjs +1 -0
  134. package/dist/utils/formatting.d.ts +4 -4
  135. package/dist/utils/formatting.d.ts.map +1 -1
  136. package/dist/utils.cjs +4 -0
  137. package/dist/utils.d.ts +3 -0
  138. package/dist/utils.d.ts.map +1 -0
  139. package/dist/utils.mjs +105 -0
  140. package/package.json +147 -9
  141. package/sdk/api/client.ts +76 -49
  142. package/sdk/api/datetime.ts +5 -5
  143. package/sdk/api/index.ts +28 -33
  144. package/sdk/api/metadata.ts +4 -4
  145. package/sdk/api.ts +24 -0
  146. package/sdk/api.types.ts +58 -0
  147. package/sdk/auth/AuthProvider.tsx +18 -18
  148. package/sdk/auth/authClient.ts +9 -9
  149. package/sdk/auth/authConfig.ts +9 -9
  150. package/sdk/auth/index.ts +5 -5
  151. package/sdk/auth/types.ts +21 -21
  152. package/sdk/auth/useAuth.ts +2 -2
  153. package/sdk/auth.ts +22 -0
  154. package/sdk/auth.types.ts +28 -0
  155. package/sdk/base-types.ts +45 -0
  156. package/sdk/components/hooks/index.ts +22 -22
  157. package/sdk/components/hooks/useFilter/index.ts +8 -14
  158. package/sdk/components/hooks/useFilter/types.ts +29 -58
  159. package/sdk/components/hooks/useFilter/useFilter.ts +41 -44
  160. package/sdk/components/hooks/useForm/apiClient.ts +8 -8
  161. package/sdk/components/hooks/useForm/expressionValidator.utils.ts +18 -18
  162. package/sdk/components/hooks/useForm/index.ts +24 -24
  163. package/sdk/components/hooks/useForm/optimizedExpressionValidator.utils.ts +22 -22
  164. package/sdk/components/hooks/useForm/ruleClassifier.utils.ts +26 -62
  165. package/sdk/components/hooks/useForm/schemaParser.utils.ts +24 -24
  166. package/sdk/components/hooks/useForm/types.ts +85 -75
  167. package/sdk/components/hooks/useForm/useForm.ts +160 -40
  168. package/sdk/components/hooks/useKanban/apiClient.ts +54 -54
  169. package/sdk/components/hooks/useKanban/context.ts +3 -3
  170. package/sdk/components/hooks/useKanban/dragDropManager.ts +19 -19
  171. package/sdk/components/hooks/useKanban/index.ts +26 -26
  172. package/sdk/components/hooks/useKanban/types.ts +69 -71
  173. package/sdk/components/hooks/useKanban/useKanban.ts +43 -51
  174. package/sdk/components/hooks/useKanban/useKanbanSimple.ts +4 -4
  175. package/sdk/components/hooks/useTable/index.ts +5 -1
  176. package/sdk/components/hooks/useTable/types.ts +10 -10
  177. package/sdk/components/hooks/useTable/useTable.ts +10 -10
  178. package/sdk/filter.ts +13 -0
  179. package/sdk/filter.types.ts +17 -0
  180. package/sdk/form.ts +15 -0
  181. package/sdk/form.types.ts +46 -0
  182. package/sdk/kanban.ts +23 -0
  183. package/sdk/kanban.types.ts +50 -0
  184. package/sdk/kanban.ui.ts +16 -0
  185. package/sdk/table.ts +7 -0
  186. package/sdk/table.types.ts +13 -0
  187. package/sdk/types/base-fields.ts +47 -47
  188. package/sdk/types/common.ts +47 -71
  189. package/sdk/types/index.ts +1 -1
  190. package/sdk/utils/formatting.ts +4 -4
  191. package/sdk/utils.ts +10 -0
  192. package/dist/index.cjs +0 -45
  193. package/dist/index.mjs +0 -6327
package/package.json CHANGED
@@ -1,22 +1,160 @@
1
1
  {
2
2
  "name": "@ram_28/kf-ai-sdk",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
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",
7
7
  "type": "module",
8
- "main": "./dist/index.cjs",
9
- "module": "./dist/index.mjs",
10
- "types": "./dist/index.d.ts",
8
+ "sideEffects": false,
11
9
  "exports": {
12
- ".": {
10
+ "./form": {
13
11
  "import": {
14
- "types": "./dist/index.d.ts",
15
- "default": "./dist/index.mjs"
12
+ "types": "./dist/form.d.ts",
13
+ "default": "./dist/form.mjs"
16
14
  },
17
15
  "require": {
18
- "types": "./dist/index.d.ts",
19
- "default": "./dist/index.cjs"
16
+ "types": "./dist/form.d.ts",
17
+ "default": "./dist/form.cjs"
18
+ }
19
+ },
20
+ "./form/types": {
21
+ "import": {
22
+ "types": "./dist/form.types.d.ts",
23
+ "default": "./dist/form.types.mjs"
24
+ },
25
+ "require": {
26
+ "types": "./dist/form.types.d.ts",
27
+ "default": "./dist/form.types.cjs"
28
+ }
29
+ },
30
+ "./table": {
31
+ "import": {
32
+ "types": "./dist/table.d.ts",
33
+ "default": "./dist/table.mjs"
34
+ },
35
+ "require": {
36
+ "types": "./dist/table.d.ts",
37
+ "default": "./dist/table.cjs"
38
+ }
39
+ },
40
+ "./table/types": {
41
+ "import": {
42
+ "types": "./dist/table.types.d.ts",
43
+ "default": "./dist/table.types.mjs"
44
+ },
45
+ "require": {
46
+ "types": "./dist/table.types.d.ts",
47
+ "default": "./dist/table.types.cjs"
48
+ }
49
+ },
50
+ "./kanban": {
51
+ "import": {
52
+ "types": "./dist/kanban.d.ts",
53
+ "default": "./dist/kanban.mjs"
54
+ },
55
+ "require": {
56
+ "types": "./dist/kanban.d.ts",
57
+ "default": "./dist/kanban.cjs"
58
+ }
59
+ },
60
+ "./kanban/types": {
61
+ "import": {
62
+ "types": "./dist/kanban.types.d.ts",
63
+ "default": "./dist/kanban.types.mjs"
64
+ },
65
+ "require": {
66
+ "types": "./dist/kanban.types.d.ts",
67
+ "default": "./dist/kanban.types.cjs"
68
+ }
69
+ },
70
+ "./kanban/ui": {
71
+ "import": {
72
+ "types": "./dist/kanban.ui.d.ts",
73
+ "default": "./dist/kanban.ui.mjs"
74
+ },
75
+ "require": {
76
+ "types": "./dist/kanban.ui.d.ts",
77
+ "default": "./dist/kanban.ui.cjs"
78
+ }
79
+ },
80
+ "./filter": {
81
+ "import": {
82
+ "types": "./dist/filter.d.ts",
83
+ "default": "./dist/filter.mjs"
84
+ },
85
+ "require": {
86
+ "types": "./dist/filter.d.ts",
87
+ "default": "./dist/filter.cjs"
88
+ }
89
+ },
90
+ "./filter/types": {
91
+ "import": {
92
+ "types": "./dist/filter.types.d.ts",
93
+ "default": "./dist/filter.types.mjs"
94
+ },
95
+ "require": {
96
+ "types": "./dist/filter.types.d.ts",
97
+ "default": "./dist/filter.types.cjs"
98
+ }
99
+ },
100
+ "./auth": {
101
+ "import": {
102
+ "types": "./dist/auth.d.ts",
103
+ "default": "./dist/auth.mjs"
104
+ },
105
+ "require": {
106
+ "types": "./dist/auth.d.ts",
107
+ "default": "./dist/auth.cjs"
108
+ }
109
+ },
110
+ "./auth/types": {
111
+ "import": {
112
+ "types": "./dist/auth.types.d.ts",
113
+ "default": "./dist/auth.types.mjs"
114
+ },
115
+ "require": {
116
+ "types": "./dist/auth.types.d.ts",
117
+ "default": "./dist/auth.types.cjs"
118
+ }
119
+ },
120
+ "./api": {
121
+ "import": {
122
+ "types": "./dist/api.d.ts",
123
+ "default": "./dist/api.mjs"
124
+ },
125
+ "require": {
126
+ "types": "./dist/api.d.ts",
127
+ "default": "./dist/api.cjs"
128
+ }
129
+ },
130
+ "./api/types": {
131
+ "import": {
132
+ "types": "./dist/api.types.d.ts",
133
+ "default": "./dist/api.types.mjs"
134
+ },
135
+ "require": {
136
+ "types": "./dist/api.types.d.ts",
137
+ "default": "./dist/api.types.cjs"
138
+ }
139
+ },
140
+ "./utils": {
141
+ "import": {
142
+ "types": "./dist/utils.d.ts",
143
+ "default": "./dist/utils.mjs"
144
+ },
145
+ "require": {
146
+ "types": "./dist/utils.d.ts",
147
+ "default": "./dist/utils.cjs"
148
+ }
149
+ },
150
+ "./types": {
151
+ "import": {
152
+ "types": "./dist/base-types.d.ts",
153
+ "default": "./dist/types.mjs"
154
+ },
155
+ "require": {
156
+ "types": "./dist/base-types.d.ts",
157
+ "default": "./dist/types.cjs"
20
158
  }
21
159
  }
22
160
  },
package/sdk/api/client.ts CHANGED
@@ -3,22 +3,22 @@
3
3
  // ============================================================
4
4
 
5
5
  import type {
6
- ListOptions,
7
- ListResponse,
8
- ReadResponse,
9
- CreateUpdateResponse,
10
- DeleteResponse,
11
- CountResponse,
12
- DateTimeEncoded,
13
- DateEncoded,
14
- MetricOptions,
15
- MetricResponse,
16
- PivotOptions,
17
- PivotResponse,
18
- DraftResponse,
19
- FieldsResponse,
20
- FetchFieldOption,
21
- FetchFieldResponse,
6
+ ListOptionsType,
7
+ ListResponseType,
8
+ ReadResponseType,
9
+ CreateUpdateResponseType,
10
+ DeleteResponseType,
11
+ CountResponseType,
12
+ DateTimeEncodedType,
13
+ DateEncodedType,
14
+ MetricOptionsType,
15
+ MetricResponseType,
16
+ PivotOptionsType,
17
+ PivotResponseType,
18
+ DraftResponseType,
19
+ FieldsResponseType,
20
+ FetchFieldOptionType,
21
+ FetchFieldResponseType,
22
22
  } from "../types/common";
23
23
 
24
24
  /**
@@ -33,19 +33,19 @@ export interface ResourceClient<T = any> {
33
33
  get(id: string): Promise<T>;
34
34
 
35
35
  /** Create new record */
36
- create(data: Partial<T> & { _id?: string }): Promise<CreateUpdateResponse>;
36
+ create(data: Partial<T> & { _id?: string }): Promise<CreateUpdateResponseType>;
37
37
 
38
38
  /** Update existing record */
39
- update(id: string, data: Partial<T>): Promise<CreateUpdateResponse>;
39
+ update(id: string, data: Partial<T>): Promise<CreateUpdateResponseType>;
40
40
 
41
41
  /** Delete record by ID */
42
- delete(id: string): Promise<DeleteResponse>;
42
+ delete(id: string): Promise<DeleteResponseType>;
43
43
 
44
44
  /** List records with optional filtering, sorting, and pagination */
45
- list(options?: ListOptions): Promise<ListResponse<T>>;
45
+ list(options?: ListOptionsType): Promise<ListResponseType<T>>;
46
46
 
47
47
  /** Get count of records matching the same criteria as list */
48
- count(options?: ListOptions): Promise<CountResponse>;
48
+ count(options?: ListOptionsType): Promise<CountResponseType>;
49
49
 
50
50
  // ============================================================
51
51
  // DRAFT/INTERACTIVE OPERATIONS
@@ -55,19 +55,28 @@ export interface ResourceClient<T = any> {
55
55
  * Create draft - compute fields without persisting
56
56
  * POST /{bo_id}/draft
57
57
  */
58
- draft(data: Partial<T>): Promise<DraftResponse>;
58
+ draft(data: Partial<T>): Promise<DraftResponseType>;
59
59
 
60
60
  /**
61
61
  * Update draft (commit) - compute and prepare for update
62
62
  * POST /{bo_id}/{instance_id}/draft
63
63
  */
64
- draftUpdate(id: string, data: Partial<T>): Promise<CreateUpdateResponse>;
64
+ draftUpdate(id: string, data: Partial<T>): Promise<CreateUpdateResponseType>;
65
65
 
66
66
  /**
67
67
  * Update draft (patch) - compute fields during editing
68
68
  * PATCH /{bo_id}/{instance_id}/draft
69
69
  */
70
- draftPatch(id: string, data: Partial<T>): Promise<DraftResponse>;
70
+ draftPatch(id: string, data: Partial<T>): Promise<DraftResponseType>;
71
+
72
+ /**
73
+ * Interactive draft - create/update draft without instance ID
74
+ * PATCH /{bo_id}/draft
75
+ * Used in interactive mode for create operations
76
+ */
77
+ draftInteraction(
78
+ data: Partial<T> & { _id?: string }
79
+ ): Promise<DraftResponseType & { _id: string }>;
71
80
 
72
81
  // ============================================================
73
82
  // QUERY OPERATIONS
@@ -77,13 +86,13 @@ export interface ResourceClient<T = any> {
77
86
  * Get aggregated metrics grouped by dimensions
78
87
  * POST /{bo_id}/metric
79
88
  */
80
- metric(options: Omit<MetricOptions, "Type">): Promise<MetricResponse>;
89
+ metric(options: Omit<MetricOptionsType, "Type">): Promise<MetricResponseType>;
81
90
 
82
91
  /**
83
92
  * Get pivot table data
84
93
  * POST /{bo_id}/pivot
85
94
  */
86
- pivot(options: Omit<PivotOptions, "Type">): Promise<PivotResponse>;
95
+ pivot(options: Omit<PivotOptionsType, "Type">): Promise<PivotResponseType>;
87
96
 
88
97
  // ============================================================
89
98
  // METADATA OPERATIONS
@@ -93,13 +102,13 @@ export interface ResourceClient<T = any> {
93
102
  * Get field definitions for this Business Object
94
103
  * GET /{bo_id}/fields
95
104
  */
96
- fields(): Promise<FieldsResponse>;
105
+ fields(): Promise<FieldsResponseType>;
97
106
 
98
107
  /**
99
108
  * Fetch reference data for a specific field (for lookup and dropdown fields)
100
109
  * GET /{bo_id}/{instance_id}/field/{field_id}/fetch
101
110
  */
102
- fetchField(instanceId: string, fieldId: string): Promise<FetchFieldOption[]>;
111
+ fetchField(instanceId: string, fieldId: string): Promise<FetchFieldOptionType[]>;
103
112
  }
104
113
 
105
114
  /**
@@ -163,12 +172,12 @@ function decodeResponseData<T>(data: any): T {
163
172
  if (typeof data === "object") {
164
173
  // Check for datetime encoding
165
174
  if ("$__dt__" in data) {
166
- return new Date((data as DateTimeEncoded).$__dt__ * 1000) as T;
175
+ return new Date((data as DateTimeEncodedType).$__dt__ * 1000) as T;
167
176
  }
168
177
 
169
178
  // Check for date encoding
170
179
  if ("$__d__" in data) {
171
- return new Date((data as DateEncoded).$__d__) as T;
180
+ return new Date((data as DateEncodedType).$__d__) as T;
172
181
  }
173
182
 
174
183
  // Recursively process object properties
@@ -202,13 +211,13 @@ export function api<T = any>(bo_id: string): ResourceClient<T> {
202
211
  throw new Error(`Failed to get ${bo_id} ${id}: ${response.statusText}`);
203
212
  }
204
213
 
205
- const responseData: ReadResponse<T> = await response.json();
214
+ const responseData: ReadResponseType<T> = await response.json();
206
215
  return decodeResponseData<T>(responseData.Data);
207
216
  },
208
217
 
209
218
  async create(
210
219
  data: Partial<T> & { _id?: string }
211
- ): Promise<CreateUpdateResponse> {
220
+ ): Promise<CreateUpdateResponseType> {
212
221
  const response = await fetch(`${baseUrl}/api/app/${bo_id}/create`, {
213
222
  method: "POST",
214
223
  headers: defaultHeaders,
@@ -222,7 +231,7 @@ export function api<T = any>(bo_id: string): ResourceClient<T> {
222
231
  return response.json();
223
232
  },
224
233
 
225
- async update(id: string, data: Partial<T>): Promise<CreateUpdateResponse> {
234
+ async update(id: string, data: Partial<T>): Promise<CreateUpdateResponseType> {
226
235
  const response = await fetch(`${baseUrl}/api/app/${bo_id}/${id}/update`, {
227
236
  method: "POST",
228
237
  headers: defaultHeaders,
@@ -238,7 +247,7 @@ export function api<T = any>(bo_id: string): ResourceClient<T> {
238
247
  return response.json();
239
248
  },
240
249
 
241
- async delete(id: string): Promise<DeleteResponse> {
250
+ async delete(id: string): Promise<DeleteResponseType> {
242
251
  const response = await fetch(`${baseUrl}/api/app/${bo_id}/${id}/delete`, {
243
252
  method: "DELETE",
244
253
  headers: defaultHeaders,
@@ -253,8 +262,8 @@ export function api<T = any>(bo_id: string): ResourceClient<T> {
253
262
  return response.json();
254
263
  },
255
264
 
256
- async list(options?: ListOptions): Promise<ListResponse<T>> {
257
- const requestBody: ListOptions = {
265
+ async list(options?: ListOptionsType): Promise<ListResponseType<T>> {
266
+ const requestBody: ListOptionsType = {
258
267
  Type: "List",
259
268
  ...options,
260
269
  };
@@ -269,13 +278,13 @@ export function api<T = any>(bo_id: string): ResourceClient<T> {
269
278
  throw new Error(`Failed to list ${bo_id}: ${response.statusText}`);
270
279
  }
271
280
 
272
- const responseData: ListResponse<any> = await response.json();
281
+ const responseData: ListResponseType<any> = await response.json();
273
282
  return {
274
283
  Data: responseData.Data.map((item) => decodeResponseData<T>(item)),
275
284
  };
276
285
  },
277
286
 
278
- async count(options?: ListOptions): Promise<CountResponse> {
287
+ async count(options?: ListOptionsType): Promise<CountResponseType> {
279
288
  // Note: Count uses metric endpoint with Count aggregation
280
289
  const requestBody = {
281
290
  Type: "Metric",
@@ -304,7 +313,7 @@ export function api<T = any>(bo_id: string): ResourceClient<T> {
304
313
  // DRAFT/INTERACTIVE OPERATIONS
305
314
  // ============================================================
306
315
 
307
- async draft(data: Partial<T>): Promise<DraftResponse> {
316
+ async draft(data: Partial<T>): Promise<DraftResponseType> {
308
317
  const response = await fetch(`${baseUrl}/api/app/${bo_id}/draft`, {
309
318
  method: "POST",
310
319
  headers: defaultHeaders,
@@ -323,7 +332,7 @@ export function api<T = any>(bo_id: string): ResourceClient<T> {
323
332
  async draftUpdate(
324
333
  id: string,
325
334
  data: Partial<T>
326
- ): Promise<CreateUpdateResponse> {
335
+ ): Promise<CreateUpdateResponseType> {
327
336
  const response = await fetch(`${baseUrl}/api/app/${bo_id}/${id}/draft`, {
328
337
  method: "POST",
329
338
  headers: defaultHeaders,
@@ -339,7 +348,7 @@ export function api<T = any>(bo_id: string): ResourceClient<T> {
339
348
  return response.json();
340
349
  },
341
350
 
342
- async draftPatch(id: string, data: Partial<T>): Promise<DraftResponse> {
351
+ async draftPatch(id: string, data: Partial<T>): Promise<DraftResponseType> {
343
352
  const response = await fetch(`${baseUrl}/api/app/${bo_id}/${id}/draft`, {
344
353
  method: "PATCH",
345
354
  headers: defaultHeaders,
@@ -355,14 +364,32 @@ export function api<T = any>(bo_id: string): ResourceClient<T> {
355
364
  return response.json();
356
365
  },
357
366
 
367
+ async draftInteraction(
368
+ data: Partial<T> & { _id?: string }
369
+ ): Promise<DraftResponseType & { _id: string }> {
370
+ const response = await fetch(`${baseUrl}/api/app/${bo_id}/draft`, {
371
+ method: "PATCH",
372
+ headers: defaultHeaders,
373
+ body: JSON.stringify(data),
374
+ });
375
+
376
+ if (!response.ok) {
377
+ throw new Error(
378
+ `Failed to create interactive draft for ${bo_id}: ${response.statusText}`
379
+ );
380
+ }
381
+
382
+ return response.json();
383
+ },
384
+
358
385
  // ============================================================
359
386
  // QUERY OPERATIONS
360
387
  // ============================================================
361
388
 
362
389
  async metric(
363
- options: Omit<MetricOptions, "Type">
364
- ): Promise<MetricResponse> {
365
- const requestBody: MetricOptions = {
390
+ options: Omit<MetricOptionsType, "Type">
391
+ ): Promise<MetricResponseType> {
392
+ const requestBody: MetricOptionsType = {
366
393
  Type: "Metric",
367
394
  ...options,
368
395
  };
@@ -382,8 +409,8 @@ export function api<T = any>(bo_id: string): ResourceClient<T> {
382
409
  return response.json();
383
410
  },
384
411
 
385
- async pivot(options: Omit<PivotOptions, "Type">): Promise<PivotResponse> {
386
- const requestBody: PivotOptions = {
412
+ async pivot(options: Omit<PivotOptionsType, "Type">): Promise<PivotResponseType> {
413
+ const requestBody: PivotOptionsType = {
387
414
  Type: "Pivot",
388
415
  ...options,
389
416
  };
@@ -407,7 +434,7 @@ export function api<T = any>(bo_id: string): ResourceClient<T> {
407
434
  // METADATA OPERATIONS
408
435
  // ============================================================
409
436
 
410
- async fields(): Promise<FieldsResponse> {
437
+ async fields(): Promise<FieldsResponseType> {
411
438
  const response = await fetch(`${baseUrl}/api/app/${bo_id}/fields`, {
412
439
  method: "GET",
413
440
  headers: defaultHeaders,
@@ -425,7 +452,7 @@ export function api<T = any>(bo_id: string): ResourceClient<T> {
425
452
  async fetchField(
426
453
  instanceId: string,
427
454
  fieldId: string
428
- ): Promise<FetchFieldOption[]> {
455
+ ): Promise<FetchFieldOptionType[]> {
429
456
  const response = await fetch(
430
457
  `${baseUrl}/api/app/${bo_id}/${instanceId}/field/${fieldId}/fetch`,
431
458
  {
@@ -440,7 +467,7 @@ export function api<T = any>(bo_id: string): ResourceClient<T> {
440
467
  );
441
468
  }
442
469
 
443
- const responseData: FetchFieldResponse = await response.json();
470
+ const responseData: FetchFieldResponseType = await response.json();
444
471
  return responseData.Data;
445
472
  },
446
473
  };
@@ -1,4 +1,4 @@
1
- import type { DateTimeEncoded, DateEncoded } from '../types/common';
1
+ import type { DateTimeEncodedType, DateEncodedType } from '../types/common';
2
2
 
3
3
  /**
4
4
  * Utility functions for datetime encoding/decoding
@@ -7,27 +7,27 @@ import type { DateTimeEncoded, DateEncoded } from '../types/common';
7
7
  /**
8
8
  * Encode a Date object to API datetime format
9
9
  */
10
- export function encodeDatetime(date: Date): DateTimeEncoded {
10
+ export function encodeDatetime(date: Date): DateTimeEncodedType {
11
11
  return { $__dt__: date.getTime() / 1000 };
12
12
  }
13
13
 
14
14
  /**
15
15
  * Decode API datetime format to Date object
16
16
  */
17
- export function decodeDatetime(encoded: DateTimeEncoded): Date {
17
+ export function decodeDatetime(encoded: DateTimeEncodedType): Date {
18
18
  return new Date(encoded.$__dt__ * 1000);
19
19
  }
20
20
 
21
21
  /**
22
22
  * Encode a Date object to API date format (YYYY-MM-DD)
23
23
  */
24
- export function encodeDate(date: Date): DateEncoded {
24
+ export function encodeDate(date: Date): DateEncodedType {
25
25
  return { $__d__: date.toISOString().split('T')[0] };
26
26
  }
27
27
 
28
28
  /**
29
29
  * Decode API date format to Date object
30
30
  */
31
- export function decodeDate(encoded: DateEncoded): Date {
31
+ export function decodeDate(encoded: DateEncodedType): Date {
32
32
  return new Date(encoded.$__d__);
33
33
  }
package/sdk/api/index.ts CHANGED
@@ -23,43 +23,38 @@ export type { BackendSchema, MetadataItem, FieldMetadata } from "./metadata";
23
23
  // Re-export common types for convenience
24
24
  export type {
25
25
  // Sort types
26
- SortDirection,
27
- SortOption,
28
- Sort,
29
- // Filter types (new names)
30
- Condition,
31
- ConditionGroup,
32
- ConditionGroupOperator,
33
- Filter,
34
- FilterRHSType,
35
- ConditionOperator,
36
- // Filter types (legacy - deprecated)
37
- FilterCondition,
38
- FilterOperator,
39
- FilterLogical,
40
- FilterNode,
26
+ SortDirectionType,
27
+ SortOptionType,
28
+ SortType,
29
+ // Filter types
30
+ ConditionType,
31
+ ConditionGroupType,
32
+ ConditionGroupOperatorType,
33
+ FilterType,
34
+ FilterRHSTypeType,
35
+ ConditionOperatorType,
41
36
  // List types
42
- ListOptions,
43
- ListResponse,
44
- ReadResponse,
45
- CreateUpdateResponse,
46
- DeleteResponse,
47
- CountResponse,
37
+ ListOptionsType,
38
+ ListResponseType,
39
+ ReadResponseType,
40
+ CreateUpdateResponseType,
41
+ DeleteResponseType,
42
+ CountResponseType,
48
43
  // DateTime types
49
- DateTimeEncoded,
50
- DateEncoded,
44
+ DateTimeEncodedType,
45
+ DateEncodedType,
51
46
  // Metric types
52
- MetricType,
53
- MetricField,
54
- MetricOptions,
55
- MetricResponse,
47
+ MetricTypeType,
48
+ MetricFieldType,
49
+ MetricOptionsType,
50
+ MetricResponseType,
56
51
  // Pivot types
57
- PivotHeaderItem,
58
- PivotResponseData,
59
- PivotOptions,
60
- PivotResponse,
52
+ PivotHeaderItemType,
53
+ PivotResponseDataType,
54
+ PivotOptionsType,
55
+ PivotResponseType,
61
56
  // Draft types
62
- DraftResponse,
57
+ DraftResponseType,
63
58
  // Fields types
64
- FieldsResponse,
59
+ FieldsResponseType,
65
60
  } from "../types/common";
@@ -3,7 +3,7 @@
3
3
  // ============================================================
4
4
  // Handles metadata/schema fetching operations for Business Objects
5
5
 
6
- import type { ListOptions, ListResponse } from "../types/common";
6
+ import type { ListOptionsType, ListResponseType } from "../types/common";
7
7
  import { getApiBaseUrl, getDefaultHeaders } from "./client";
8
8
 
9
9
  // ============================================================
@@ -97,8 +97,8 @@ export interface MetadataItem {
97
97
  * ```
98
98
  */
99
99
  export async function listMetadata(
100
- options?: ListOptions
101
- ): Promise<ListResponse<MetadataItem>> {
100
+ options?: ListOptionsType
101
+ ): Promise<ListResponseType<MetadataItem>> {
102
102
  try {
103
103
  const baseUrl = getApiBaseUrl();
104
104
  const headers = getDefaultHeaders();
@@ -121,7 +121,7 @@ export async function listMetadata(
121
121
 
122
122
  const result = await response.json();
123
123
 
124
- return result as ListResponse<MetadataItem>;
124
+ return result as ListResponseType<MetadataItem>;
125
125
  } catch (error) {
126
126
  console.error("Metadata list error:", error);
127
127
  throw new Error(
package/sdk/api.ts ADDED
@@ -0,0 +1,24 @@
1
+ // ============================================================
2
+ // API MODULE - Main Entry Point
3
+ // @ram_28/kf-ai-sdk/api
4
+ // ============================================================
5
+
6
+ // Main API client
7
+ export {
8
+ api,
9
+ setApiBaseUrl,
10
+ setDefaultHeaders,
11
+ getDefaultHeaders,
12
+ getApiBaseUrl,
13
+ } from './api/client';
14
+
15
+ // DateTime utilities
16
+ export {
17
+ encodeDatetime,
18
+ decodeDatetime,
19
+ encodeDate,
20
+ decodeDate,
21
+ } from './api/datetime';
22
+
23
+ // Metadata API client
24
+ export { getBdoSchema, listMetadata } from './api/metadata';