@ram_28/kf-ai-sdk 2.0.2 → 2.0.4
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/dist/BaseField-B6da88U7.js +40 -0
- package/dist/BaseField-Drp0-OxL.cjs +1 -0
- package/dist/api/client.d.ts +7 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api.cjs +1 -1
- package/dist/api.mjs +3 -3
- package/dist/auth.cjs +1 -1
- package/dist/auth.mjs +2 -2
- package/dist/bdo/core/BaseBdo.d.ts +4 -0
- package/dist/bdo/core/BaseBdo.d.ts.map +1 -1
- package/dist/bdo.cjs +1 -1
- package/dist/bdo.mjs +91 -118
- package/dist/client-BULEEaCP.js +222 -0
- package/dist/client-DtPpfJc1.cjs +1 -0
- package/dist/components/hooks/useForm/index.d.ts +1 -1
- package/dist/components/hooks/useForm/index.d.ts.map +1 -1
- package/dist/components/hooks/useForm/types.d.ts +15 -2
- package/dist/components/hooks/useForm/types.d.ts.map +1 -1
- package/dist/components/hooks/useForm/useDraftInteraction.d.ts +26 -0
- package/dist/components/hooks/useForm/useDraftInteraction.d.ts.map +1 -0
- package/dist/components/hooks/useForm/useForm.d.ts +1 -0
- package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
- package/dist/{constants-CM9xOACN.js → constants-BQrBcCON.js} +5 -5
- package/dist/error-handling-CAoD0Kwb.cjs +1 -0
- package/dist/error-handling-CrhTtD88.js +14 -0
- package/dist/filter.mjs +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.mjs +313 -1187
- package/dist/form.types.d.ts +1 -1
- package/dist/form.types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm-Cj63v5ny.js +1014 -0
- package/dist/index.esm-DuwT11sx.cjs +1 -0
- package/dist/{metadata-BN57S6W9.cjs → metadata-BJWukIqS.cjs} +1 -1
- package/dist/{metadata-P7DGCgIG.js → metadata-CJuFxytC.js} +1 -1
- package/dist/table.cjs +1 -1
- package/dist/table.mjs +83 -93
- package/dist/types/constants.d.ts +2 -2
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/workflow/Activity.d.ts +85 -0
- package/dist/workflow/Activity.d.ts.map +1 -0
- package/dist/workflow/ActivityInstance.d.ts +96 -0
- package/dist/workflow/ActivityInstance.d.ts.map +1 -0
- package/dist/workflow/client.d.ts +39 -0
- package/dist/workflow/client.d.ts.map +1 -0
- package/dist/workflow/components/useActivityForm/createActivityItemProxy.d.ts +16 -0
- package/dist/workflow/components/useActivityForm/createActivityItemProxy.d.ts.map +1 -0
- package/dist/workflow/components/useActivityForm/createActivityResolver.d.ts +22 -0
- package/dist/workflow/components/useActivityForm/createActivityResolver.d.ts.map +1 -0
- package/dist/workflow/components/useActivityForm/index.d.ts +3 -0
- package/dist/workflow/components/useActivityForm/index.d.ts.map +1 -0
- package/dist/workflow/components/useActivityForm/types.d.ts +80 -0
- package/dist/workflow/components/useActivityForm/types.d.ts.map +1 -0
- package/dist/workflow/components/useActivityForm/useActivityForm.d.ts +4 -0
- package/dist/workflow/components/useActivityForm/useActivityForm.d.ts.map +1 -0
- package/dist/workflow/index.d.ts +8 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/types.d.ts +53 -0
- package/dist/workflow/types.d.ts.map +1 -0
- package/dist/workflow.cjs +1 -0
- package/dist/workflow.d.ts +8 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.mjs +565 -0
- package/dist/workflow.types.cjs +1 -0
- package/dist/workflow.types.d.ts +2 -0
- package/dist/workflow.types.d.ts.map +1 -0
- package/dist/workflow.types.mjs +1 -0
- package/docs/workflow.md +703 -0
- package/package.json +21 -1
- package/sdk/api/client.ts +85 -52
- package/sdk/api/index.ts +1 -0
- package/sdk/api/metadata.ts +4 -4
- package/sdk/bdo/core/BaseBdo.ts +10 -0
- package/sdk/components/hooks/useForm/index.ts +1 -0
- package/sdk/components/hooks/useForm/types.ts +17 -3
- package/sdk/components/hooks/useForm/useDraftInteraction.ts +251 -0
- package/sdk/components/hooks/useForm/useForm.ts +115 -24
- package/sdk/form.types.ts +1 -0
- package/sdk/index.ts +6 -0
- package/sdk/types/constants.ts +2 -2
- package/sdk/workflow/Activity.ts +181 -0
- package/sdk/workflow/ActivityInstance.ts +339 -0
- package/sdk/workflow/client.ts +208 -0
- package/sdk/workflow/components/useActivityForm/createActivityItemProxy.ts +126 -0
- package/sdk/workflow/components/useActivityForm/createActivityResolver.ts +61 -0
- package/sdk/workflow/components/useActivityForm/index.ts +5 -0
- package/sdk/workflow/components/useActivityForm/types.ts +166 -0
- package/sdk/workflow/components/useActivityForm/useActivityForm.ts +386 -0
- package/sdk/workflow/index.ts +20 -0
- package/sdk/workflow/types.ts +84 -0
- package/sdk/workflow.ts +25 -0
- package/sdk/workflow.types.ts +11 -0
- package/dist/client-Bo-RLKJi.cjs +0 -1
- package/dist/client-eA4VvNTo.js +0 -178
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ram_28/kf-ai-sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
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",
|
|
@@ -107,6 +107,26 @@
|
|
|
107
107
|
"default": "./dist/api.types.cjs"
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
|
+
"./workflow": {
|
|
111
|
+
"import": {
|
|
112
|
+
"types": "./dist/workflow.d.ts",
|
|
113
|
+
"default": "./dist/workflow.mjs"
|
|
114
|
+
},
|
|
115
|
+
"require": {
|
|
116
|
+
"types": "./dist/workflow.d.ts",
|
|
117
|
+
"default": "./dist/workflow.cjs"
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"./workflow/types": {
|
|
121
|
+
"import": {
|
|
122
|
+
"types": "./dist/workflow.types.d.ts",
|
|
123
|
+
"default": "./dist/workflow.types.mjs"
|
|
124
|
+
},
|
|
125
|
+
"require": {
|
|
126
|
+
"types": "./dist/workflow.types.d.ts",
|
|
127
|
+
"default": "./dist/workflow.types.cjs"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
110
130
|
"./utils": {
|
|
111
131
|
"import": {
|
|
112
132
|
"types": "./dist/utils.d.ts",
|
package/sdk/api/client.ts
CHANGED
|
@@ -30,7 +30,9 @@ export interface ResourceClientType<T = any> {
|
|
|
30
30
|
get(id: string): Promise<T>;
|
|
31
31
|
|
|
32
32
|
/** Create new record */
|
|
33
|
-
create(
|
|
33
|
+
create(
|
|
34
|
+
data: Partial<T> & { _id?: string },
|
|
35
|
+
): Promise<CreateUpdateResponseType>;
|
|
34
36
|
|
|
35
37
|
/** Update existing record */
|
|
36
38
|
update(id: string, data: Partial<T>): Promise<CreateUpdateResponseType>;
|
|
@@ -72,7 +74,7 @@ export interface ResourceClientType<T = any> {
|
|
|
72
74
|
* Used in interactive mode for create operations
|
|
73
75
|
*/
|
|
74
76
|
draftInteraction(
|
|
75
|
-
data: Partial<T> & { _id?: string }
|
|
77
|
+
data: Partial<T> & { _id?: string },
|
|
76
78
|
): Promise<DraftResponseType & { _id: string }>;
|
|
77
79
|
|
|
78
80
|
// ============================================================
|
|
@@ -111,7 +113,7 @@ export interface ResourceClientType<T = any> {
|
|
|
111
113
|
*/
|
|
112
114
|
fetchField<TResult = FetchFieldOptionType>(
|
|
113
115
|
instanceId: string,
|
|
114
|
-
fieldId: string
|
|
116
|
+
fieldId: string,
|
|
115
117
|
): Promise<TResult[]>;
|
|
116
118
|
}
|
|
117
119
|
|
|
@@ -162,30 +164,27 @@ export function getApiBaseUrl(): string {
|
|
|
162
164
|
}
|
|
163
165
|
|
|
164
166
|
/**
|
|
165
|
-
*
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
let errorBody: any;
|
|
169
|
-
try { errorBody = await response.json(); } catch {}
|
|
170
|
-
const message = errorBody?.error || errorBody?.message || response.statusText;
|
|
171
|
-
throw new Error(`${context}: ${message}`);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Create a resource client for the specified Business Object
|
|
176
|
-
* @param bo_id - Business Object identifier (e.g., "user", "leave", "vendor")
|
|
167
|
+
* Create a resource client for a given base path.
|
|
168
|
+
* This is the shared implementation used by both `api()` and workflow owner methods.
|
|
169
|
+
* @param basePath - URL path segment (e.g., "/api/app/user" or "/api/app/process/leave_bp/vendor_ado")
|
|
177
170
|
* @returns Resource client with CRUD operations matching API spec
|
|
178
171
|
*/
|
|
179
|
-
export function
|
|
172
|
+
export function createResourceClient<T = any>(
|
|
173
|
+
basePath: string,
|
|
174
|
+
): ResourceClientType<T> {
|
|
175
|
+
const baseUrl = apiConfig.baseUrl;
|
|
176
|
+
|
|
180
177
|
return {
|
|
181
178
|
async get(id: string): Promise<T> {
|
|
182
|
-
const response = await fetch(`${
|
|
179
|
+
const response = await fetch(`${baseUrl}${basePath}/${id}/read`, {
|
|
183
180
|
method: "GET",
|
|
184
181
|
headers: getDefaultHeaders(),
|
|
185
182
|
});
|
|
186
183
|
|
|
187
184
|
if (!response.ok) {
|
|
188
|
-
|
|
185
|
+
throw new Error(
|
|
186
|
+
`Failed to get ${basePath} ${id}: ${response.statusText}`,
|
|
187
|
+
);
|
|
189
188
|
}
|
|
190
189
|
|
|
191
190
|
const responseData: ReadResponseType<T> = await response.json();
|
|
@@ -193,43 +192,50 @@ export function api<T = any>(bo_id: string): ResourceClientType<T> {
|
|
|
193
192
|
},
|
|
194
193
|
|
|
195
194
|
async create(
|
|
196
|
-
data: Partial<T> & { _id?: string }
|
|
195
|
+
data: Partial<T> & { _id?: string },
|
|
197
196
|
): Promise<CreateUpdateResponseType> {
|
|
198
|
-
const response = await fetch(`${
|
|
197
|
+
const response = await fetch(`${baseUrl}${basePath}/create`, {
|
|
199
198
|
method: "POST",
|
|
200
199
|
headers: getDefaultHeaders(),
|
|
201
200
|
body: JSON.stringify(data),
|
|
202
201
|
});
|
|
203
202
|
|
|
204
203
|
if (!response.ok) {
|
|
205
|
-
|
|
204
|
+
throw new Error(`Failed to create ${basePath}: ${response.statusText}`);
|
|
206
205
|
}
|
|
207
206
|
|
|
208
207
|
return response.json();
|
|
209
208
|
},
|
|
210
209
|
|
|
211
|
-
async update(
|
|
212
|
-
|
|
210
|
+
async update(
|
|
211
|
+
id: string,
|
|
212
|
+
data: Partial<T>,
|
|
213
|
+
): Promise<CreateUpdateResponseType> {
|
|
214
|
+
const response = await fetch(`${baseUrl}${basePath}/${id}/update`, {
|
|
213
215
|
method: "POST",
|
|
214
216
|
headers: getDefaultHeaders(),
|
|
215
217
|
body: JSON.stringify(data),
|
|
216
218
|
});
|
|
217
219
|
|
|
218
220
|
if (!response.ok) {
|
|
219
|
-
|
|
221
|
+
throw new Error(
|
|
222
|
+
`Failed to update ${basePath} ${id}: ${response.statusText}`,
|
|
223
|
+
);
|
|
220
224
|
}
|
|
221
225
|
|
|
222
226
|
return response.json();
|
|
223
227
|
},
|
|
224
228
|
|
|
225
229
|
async delete(id: string): Promise<DeleteResponseType> {
|
|
226
|
-
const response = await fetch(`${
|
|
230
|
+
const response = await fetch(`${baseUrl}${basePath}/${id}/delete`, {
|
|
227
231
|
method: "DELETE",
|
|
228
232
|
headers: getDefaultHeaders(),
|
|
229
233
|
});
|
|
230
234
|
|
|
231
235
|
if (!response.ok) {
|
|
232
|
-
|
|
236
|
+
throw new Error(
|
|
237
|
+
`Failed to delete ${basePath} ${id}: ${response.statusText}`,
|
|
238
|
+
);
|
|
233
239
|
}
|
|
234
240
|
|
|
235
241
|
return response.json();
|
|
@@ -241,14 +247,14 @@ export function api<T = any>(bo_id: string): ResourceClientType<T> {
|
|
|
241
247
|
...options,
|
|
242
248
|
};
|
|
243
249
|
|
|
244
|
-
const response = await fetch(`${
|
|
250
|
+
const response = await fetch(`${baseUrl}${basePath}/list`, {
|
|
245
251
|
method: "POST",
|
|
246
252
|
headers: getDefaultHeaders(),
|
|
247
253
|
body: JSON.stringify(requestBody),
|
|
248
254
|
});
|
|
249
255
|
|
|
250
256
|
if (!response.ok) {
|
|
251
|
-
|
|
257
|
+
throw new Error(`Failed to list ${basePath}: ${response.statusText}`);
|
|
252
258
|
}
|
|
253
259
|
|
|
254
260
|
const responseData: ListResponseType<T> = await response.json();
|
|
@@ -264,14 +270,14 @@ export function api<T = any>(bo_id: string): ResourceClientType<T> {
|
|
|
264
270
|
...(options?.Filter && { Filter: options.Filter }),
|
|
265
271
|
};
|
|
266
272
|
|
|
267
|
-
const response = await fetch(`${
|
|
273
|
+
const response = await fetch(`${baseUrl}${basePath}/metric`, {
|
|
268
274
|
method: "POST",
|
|
269
275
|
headers: getDefaultHeaders(),
|
|
270
276
|
body: JSON.stringify(requestBody),
|
|
271
277
|
});
|
|
272
278
|
|
|
273
279
|
if (!response.ok) {
|
|
274
|
-
|
|
280
|
+
throw new Error(`Failed to count ${basePath}: ${response.statusText}`);
|
|
275
281
|
}
|
|
276
282
|
|
|
277
283
|
const result = await response.json();
|
|
@@ -285,14 +291,16 @@ export function api<T = any>(bo_id: string): ResourceClientType<T> {
|
|
|
285
291
|
// ============================================================
|
|
286
292
|
|
|
287
293
|
async draft(data: Partial<T>): Promise<DraftResponseType> {
|
|
288
|
-
const response = await fetch(`${
|
|
294
|
+
const response = await fetch(`${baseUrl}${basePath}/draft`, {
|
|
289
295
|
method: "POST",
|
|
290
296
|
headers: getDefaultHeaders(),
|
|
291
297
|
body: JSON.stringify(data),
|
|
292
298
|
});
|
|
293
299
|
|
|
294
300
|
if (!response.ok) {
|
|
295
|
-
|
|
301
|
+
throw new Error(
|
|
302
|
+
`Failed to create draft for ${basePath}: ${response.statusText}`,
|
|
303
|
+
);
|
|
296
304
|
}
|
|
297
305
|
|
|
298
306
|
return response.json();
|
|
@@ -300,46 +308,52 @@ export function api<T = any>(bo_id: string): ResourceClientType<T> {
|
|
|
300
308
|
|
|
301
309
|
async draftUpdate(
|
|
302
310
|
id: string,
|
|
303
|
-
data: Partial<T
|
|
311
|
+
data: Partial<T>,
|
|
304
312
|
): Promise<CreateUpdateResponseType> {
|
|
305
|
-
const response = await fetch(`${
|
|
313
|
+
const response = await fetch(`${baseUrl}${basePath}/${id}/draft`, {
|
|
306
314
|
method: "POST",
|
|
307
315
|
headers: getDefaultHeaders(),
|
|
308
316
|
body: JSON.stringify(data),
|
|
309
317
|
});
|
|
310
318
|
|
|
311
319
|
if (!response.ok) {
|
|
312
|
-
|
|
320
|
+
throw new Error(
|
|
321
|
+
`Failed to update draft for ${basePath} ${id}: ${response.statusText}`,
|
|
322
|
+
);
|
|
313
323
|
}
|
|
314
324
|
|
|
315
325
|
return response.json();
|
|
316
326
|
},
|
|
317
327
|
|
|
318
328
|
async draftPatch(id: string, data: Partial<T>): Promise<DraftResponseType> {
|
|
319
|
-
const response = await fetch(`${
|
|
329
|
+
const response = await fetch(`${baseUrl}${basePath}/${id}/draft`, {
|
|
320
330
|
method: "PATCH",
|
|
321
331
|
headers: getDefaultHeaders(),
|
|
322
332
|
body: JSON.stringify(data),
|
|
323
333
|
});
|
|
324
334
|
|
|
325
335
|
if (!response.ok) {
|
|
326
|
-
|
|
336
|
+
throw new Error(
|
|
337
|
+
`Failed to patch draft for ${basePath} ${id}: ${response.statusText}`,
|
|
338
|
+
);
|
|
327
339
|
}
|
|
328
340
|
|
|
329
341
|
return response.json();
|
|
330
342
|
},
|
|
331
343
|
|
|
332
344
|
async draftInteraction(
|
|
333
|
-
data: Partial<T> & { _id?: string }
|
|
345
|
+
data: Partial<T> & { _id?: string },
|
|
334
346
|
): Promise<DraftResponseType & { _id: string }> {
|
|
335
|
-
const response = await fetch(`${
|
|
347
|
+
const response = await fetch(`${baseUrl}${basePath}/draft`, {
|
|
336
348
|
method: "PATCH",
|
|
337
349
|
headers: getDefaultHeaders(),
|
|
338
350
|
body: JSON.stringify(data),
|
|
339
351
|
});
|
|
340
352
|
|
|
341
353
|
if (!response.ok) {
|
|
342
|
-
|
|
354
|
+
throw new Error(
|
|
355
|
+
`Failed to create interactive draft for ${basePath}: ${response.statusText}`,
|
|
356
|
+
);
|
|
343
357
|
}
|
|
344
358
|
|
|
345
359
|
const json = await response.json();
|
|
@@ -356,40 +370,46 @@ export function api<T = any>(bo_id: string): ResourceClientType<T> {
|
|
|
356
370
|
// ============================================================
|
|
357
371
|
|
|
358
372
|
async metric(
|
|
359
|
-
options: Omit<MetricOptionsType, "Type"
|
|
373
|
+
options: Omit<MetricOptionsType, "Type">,
|
|
360
374
|
): Promise<MetricResponseType> {
|
|
361
375
|
const requestBody: MetricOptionsType = {
|
|
362
376
|
Type: "Metric",
|
|
363
377
|
...options,
|
|
364
378
|
};
|
|
365
379
|
|
|
366
|
-
const response = await fetch(`${
|
|
380
|
+
const response = await fetch(`${baseUrl}${basePath}/metric`, {
|
|
367
381
|
method: "POST",
|
|
368
382
|
headers: getDefaultHeaders(),
|
|
369
383
|
body: JSON.stringify(requestBody),
|
|
370
384
|
});
|
|
371
385
|
|
|
372
386
|
if (!response.ok) {
|
|
373
|
-
|
|
387
|
+
throw new Error(
|
|
388
|
+
`Failed to get metrics for ${basePath}: ${response.statusText}`,
|
|
389
|
+
);
|
|
374
390
|
}
|
|
375
391
|
|
|
376
392
|
return response.json();
|
|
377
393
|
},
|
|
378
394
|
|
|
379
|
-
async pivot(
|
|
395
|
+
async pivot(
|
|
396
|
+
options: Omit<PivotOptionsType, "Type">,
|
|
397
|
+
): Promise<PivotResponseType> {
|
|
380
398
|
const requestBody: PivotOptionsType = {
|
|
381
399
|
Type: "Pivot",
|
|
382
400
|
...options,
|
|
383
401
|
};
|
|
384
402
|
|
|
385
|
-
const response = await fetch(`${
|
|
403
|
+
const response = await fetch(`${baseUrl}${basePath}/pivot`, {
|
|
386
404
|
method: "POST",
|
|
387
405
|
headers: getDefaultHeaders(),
|
|
388
406
|
body: JSON.stringify(requestBody),
|
|
389
407
|
});
|
|
390
408
|
|
|
391
409
|
if (!response.ok) {
|
|
392
|
-
|
|
410
|
+
throw new Error(
|
|
411
|
+
`Failed to get pivot data for ${basePath}: ${response.statusText}`,
|
|
412
|
+
);
|
|
393
413
|
}
|
|
394
414
|
|
|
395
415
|
return response.json();
|
|
@@ -400,13 +420,15 @@ export function api<T = any>(bo_id: string): ResourceClientType<T> {
|
|
|
400
420
|
// ============================================================
|
|
401
421
|
|
|
402
422
|
async fields(): Promise<FieldsResponseType> {
|
|
403
|
-
const response = await fetch(`${
|
|
423
|
+
const response = await fetch(`${baseUrl}${basePath}/fields`, {
|
|
404
424
|
method: "GET",
|
|
405
425
|
headers: getDefaultHeaders(),
|
|
406
426
|
});
|
|
407
427
|
|
|
408
428
|
if (!response.ok) {
|
|
409
|
-
|
|
429
|
+
throw new Error(
|
|
430
|
+
`Failed to get fields for ${basePath}: ${response.statusText}`,
|
|
431
|
+
);
|
|
410
432
|
}
|
|
411
433
|
|
|
412
434
|
return response.json();
|
|
@@ -414,18 +436,20 @@ export function api<T = any>(bo_id: string): ResourceClientType<T> {
|
|
|
414
436
|
|
|
415
437
|
async fetchField<TResult = FetchFieldOptionType>(
|
|
416
438
|
instanceId: string,
|
|
417
|
-
fieldId: string
|
|
439
|
+
fieldId: string,
|
|
418
440
|
): Promise<TResult[]> {
|
|
419
441
|
const response = await fetch(
|
|
420
|
-
`${
|
|
442
|
+
`${baseUrl}${basePath}/${instanceId}/field/${fieldId}/fetch`,
|
|
421
443
|
{
|
|
422
444
|
method: "GET",
|
|
423
445
|
headers: getDefaultHeaders(),
|
|
424
|
-
}
|
|
446
|
+
},
|
|
425
447
|
);
|
|
426
448
|
|
|
427
449
|
if (!response.ok) {
|
|
428
|
-
|
|
450
|
+
throw new Error(
|
|
451
|
+
`Failed to fetch field ${fieldId} for ${basePath}: ${response.statusText}`,
|
|
452
|
+
);
|
|
429
453
|
}
|
|
430
454
|
|
|
431
455
|
const responseData: { Data: TResult[] } = await response.json();
|
|
@@ -433,3 +457,12 @@ export function api<T = any>(bo_id: string): ResourceClientType<T> {
|
|
|
433
457
|
},
|
|
434
458
|
};
|
|
435
459
|
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Create a resource client for the specified Business Object
|
|
463
|
+
* @param bo_id - Business Object identifier (e.g., "user", "leave", "vendor")
|
|
464
|
+
* @returns Resource client with CRUD operations matching API spec
|
|
465
|
+
*/
|
|
466
|
+
export function api<T = any>(bo_id: string): ResourceClientType<T> {
|
|
467
|
+
return createResourceClient<T>(`/api/app/${bo_id}`);
|
|
468
|
+
}
|
package/sdk/api/index.ts
CHANGED
package/sdk/api/metadata.ts
CHANGED
|
@@ -43,7 +43,7 @@ export async function getBdoSchema(metaId: string): Promise<BackendSchemaType> {
|
|
|
43
43
|
|
|
44
44
|
if (!response.ok) {
|
|
45
45
|
throw new Error(
|
|
46
|
-
`Failed to fetch schema for ${metaId}: ${response.statusText}
|
|
46
|
+
`Failed to fetch schema for ${metaId}: ${response.statusText}`,
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -58,7 +58,7 @@ export async function getBdoSchema(metaId: string): Promise<BackendSchemaType> {
|
|
|
58
58
|
} catch (error) {
|
|
59
59
|
console.error(`Schema fetch error for ${metaId}:`, error);
|
|
60
60
|
throw new Error(
|
|
61
|
-
`Failed to load BDO schema: ${error instanceof Error ? error.message : "Unknown error"}
|
|
61
|
+
`Failed to load BDO schema: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -83,7 +83,7 @@ export interface MetadataItemType {
|
|
|
83
83
|
* @returns Promise resolving to list of metadata items
|
|
84
84
|
*/
|
|
85
85
|
export async function listMetadata(
|
|
86
|
-
options?: ListOptionsType
|
|
86
|
+
options?: ListOptionsType,
|
|
87
87
|
): Promise<ListResponseType<MetadataItemType>> {
|
|
88
88
|
try {
|
|
89
89
|
const baseUrl = getApiBaseUrl();
|
|
@@ -111,7 +111,7 @@ export async function listMetadata(
|
|
|
111
111
|
} catch (error) {
|
|
112
112
|
console.error("Metadata list error:", error);
|
|
113
113
|
throw new Error(
|
|
114
|
-
`Failed to list metadata: ${error instanceof Error ? error.message : "Unknown error"}
|
|
114
|
+
`Failed to list metadata: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
115
115
|
);
|
|
116
116
|
}
|
|
117
117
|
}
|
package/sdk/bdo/core/BaseBdo.ts
CHANGED
|
@@ -258,6 +258,16 @@ export abstract class BaseBdo<
|
|
|
258
258
|
return new Item<TEditable & TReadonly>(this, (data ?? {}) as Partial<TEditable & TReadonly>) as ItemType<TEditable, TReadonly>;
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
+
/**
|
|
262
|
+
* Commit an update draft - finalize changes on an existing record
|
|
263
|
+
*/
|
|
264
|
+
protected async draftUpdate(
|
|
265
|
+
id: string,
|
|
266
|
+
data: Partial<TEditable>
|
|
267
|
+
): Promise<CreateUpdateResponseType> {
|
|
268
|
+
return api<TEntity>(this.meta._id).draftUpdate(id, data as Partial<TEntity>);
|
|
269
|
+
}
|
|
270
|
+
|
|
261
271
|
/**
|
|
262
272
|
* Patch an existing draft - compute fields during editing
|
|
263
273
|
*/
|
|
@@ -55,6 +55,12 @@ export interface UpdatableBdo<TEditable = any> extends BaseBdoShape {
|
|
|
55
55
|
/** BDO that supports both create and update */
|
|
56
56
|
export type FormBdo<TEditable = any> = CreatableBdo<TEditable> & UpdatableBdo<TEditable>;
|
|
57
57
|
|
|
58
|
+
/** BDO that supports interactive create (draft interaction during create) */
|
|
59
|
+
export interface InteractiveCreatableBdo<TEditable = any> extends CreatableBdo<TEditable> {
|
|
60
|
+
draftInteraction(data: Partial<TEditable>): Promise<any>;
|
|
61
|
+
draft(data: Partial<TEditable>): Promise<any>;
|
|
62
|
+
}
|
|
63
|
+
|
|
58
64
|
// ============================================================
|
|
59
65
|
// HANDLE SUBMIT TYPE
|
|
60
66
|
// ============================================================
|
|
@@ -92,6 +98,8 @@ interface UseFormCreateOptionsType<B extends BaseBdo<any, any, any>> {
|
|
|
92
98
|
recordId?: undefined;
|
|
93
99
|
defaultValues?: Partial<ExtractEditableType<B>>;
|
|
94
100
|
mode?: "onBlur" | "onChange" | "onSubmit" | "onTouched" | "all";
|
|
101
|
+
interactionMode?: "interactive" | "non-interactive";
|
|
102
|
+
/** @deprecated Use interactionMode instead */
|
|
95
103
|
enableDraft?: boolean;
|
|
96
104
|
enableConstraintValidation?: boolean;
|
|
97
105
|
enableExpressionValidation?: boolean;
|
|
@@ -104,6 +112,8 @@ interface UseFormUpdateOptionsType<B extends BaseBdo<any, any, any>> {
|
|
|
104
112
|
recordId: string;
|
|
105
113
|
defaultValues?: Partial<ExtractEditableType<B>>;
|
|
106
114
|
mode?: "onBlur" | "onChange" | "onSubmit" | "onTouched" | "all";
|
|
115
|
+
interactionMode?: "interactive" | "non-interactive";
|
|
116
|
+
/** @deprecated Use interactionMode instead */
|
|
107
117
|
enableDraft?: boolean;
|
|
108
118
|
enableConstraintValidation?: boolean;
|
|
109
119
|
enableExpressionValidation?: boolean;
|
|
@@ -116,6 +126,8 @@ interface UseFormAutoOptionsType<B extends BaseBdo<any, any, any>> {
|
|
|
116
126
|
recordId?: string;
|
|
117
127
|
defaultValues?: Partial<ExtractEditableType<B>>;
|
|
118
128
|
mode?: "onBlur" | "onChange" | "onSubmit" | "onTouched" | "all";
|
|
129
|
+
interactionMode?: "interactive" | "non-interactive";
|
|
130
|
+
/** @deprecated Use interactionMode instead */
|
|
119
131
|
enableDraft?: boolean;
|
|
120
132
|
enableConstraintValidation?: boolean;
|
|
121
133
|
enableExpressionValidation?: boolean;
|
|
@@ -223,7 +235,9 @@ export interface UseFormReturnType<B extends BaseBdo<any, any, any>> {
|
|
|
223
235
|
// Error
|
|
224
236
|
loadError: Error | null;
|
|
225
237
|
|
|
226
|
-
// Draft
|
|
227
|
-
draftId
|
|
228
|
-
|
|
238
|
+
// Draft / Interactive mode
|
|
239
|
+
draftId: string | undefined;
|
|
240
|
+
isInitializingDraft: boolean;
|
|
241
|
+
isInteracting: boolean;
|
|
242
|
+
interactionError: Error | null;
|
|
229
243
|
}
|