@ram_28/kf-ai-sdk 2.0.20-beta.2 → 2.0.21
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/README.md +16 -8
- package/dist/api.cjs +1 -1
- package/dist/api.mjs +1 -1
- package/dist/auth/authConfig.d.ts +1 -1
- package/dist/auth/types.d.ts +1 -1
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth.cjs +1 -1
- package/dist/auth.mjs +1 -1
- package/dist/bdo/core/Item.d.ts.map +1 -1
- package/dist/bdo.cjs +1 -1
- package/dist/bdo.mjs +1 -1
- package/dist/components/hooks/useActivityForm/types.d.ts +4 -5
- package/dist/components/hooks/useActivityForm/types.d.ts.map +1 -1
- package/dist/components/hooks/useActivityForm/useActivityForm.d.ts.map +1 -1
- package/dist/components/hooks/useActivityTable/types.d.ts +5 -4
- package/dist/components/hooks/useActivityTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useActivityTable/useActivityTable.d.ts.map +1 -1
- package/dist/components/hooks/useBDOForm/createItemProxy.d.ts +2 -2
- package/dist/components/hooks/useBDOForm/createItemProxy.d.ts.map +1 -1
- package/dist/components/hooks/useBDOTable/types.d.ts +20 -12
- package/dist/components/hooks/useBDOTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useBDOTable/useBDOTable.d.ts +2 -2
- package/dist/components/hooks/useBDOTable/useBDOTable.d.ts.map +1 -1
- package/dist/{constants-ConHc1oS.js → constants-Cyi942Yr.js} +5 -5
- package/dist/constants-DEmYwKfC.cjs +1 -0
- package/dist/filter.cjs +1 -1
- package/dist/filter.mjs +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.mjs +1 -1
- package/dist/table.cjs +1 -1
- package/dist/table.mjs +15 -16
- package/dist/table.types.d.ts +1 -1
- package/dist/table.types.d.ts.map +1 -1
- package/dist/types/constants.d.ts +1 -1
- package/dist/workflow/Activity.d.ts +8 -5
- package/dist/workflow/Activity.d.ts.map +1 -1
- package/dist/workflow.cjs +1 -1
- package/dist/workflow.mjs +461 -476
- package/docs/README.md +57 -0
- package/docs/bdo/README.md +161 -0
- package/docs/bdo/api_reference.md +281 -0
- package/docs/examples/bdo/create-product.md +69 -0
- package/docs/examples/bdo/edit-product-dialog.md +95 -0
- package/docs/examples/bdo/filtered-product-table.md +100 -0
- package/docs/examples/bdo/product-listing.md +73 -0
- package/docs/examples/bdo/supplier-dropdown.md +60 -0
- package/docs/examples/fields/complex-fields.md +248 -0
- package/docs/examples/fields/primitive-fields.md +217 -0
- package/docs/examples/workflow/approve-leave-request.md +76 -0
- package/docs/examples/workflow/filtered-activity-table.md +101 -0
- package/docs/examples/workflow/my-pending-requests.md +90 -0
- package/docs/examples/workflow/start-new-workflow.md +47 -0
- package/docs/examples/workflow/submit-leave-request.md +72 -0
- package/docs/examples/workflow/workflow-progress.md +49 -0
- package/docs/fields/README.md +141 -0
- package/docs/fields/api_reference.md +134 -0
- package/docs/useActivityForm/README.md +244 -0
- package/docs/useActivityForm/api_reference.md +279 -0
- package/docs/useActivityTable/README.md +263 -0
- package/docs/useActivityTable/api_reference.md +294 -0
- package/docs/useBDOForm/README.md +175 -0
- package/docs/useBDOForm/api_reference.md +244 -0
- package/docs/useBDOTable/README.md +242 -0
- package/docs/useBDOTable/api_reference.md +253 -0
- package/docs/useFilter/README.md +323 -0
- package/docs/useFilter/api_reference.md +228 -0
- package/docs/workflow/README.md +158 -0
- package/docs/workflow/api_reference.md +161 -0
- package/package.json +15 -14
- package/sdk/auth/authConfig.ts +1 -1
- package/sdk/auth/types.ts +1 -1
- package/sdk/bdo/core/Item.ts +2 -1
- package/sdk/bdo/expressions/evaluator.ts +8 -4
- package/sdk/components/hooks/useActivityForm/types.ts +4 -6
- package/sdk/components/hooks/useActivityForm/useActivityForm.ts +10 -73
- package/sdk/components/hooks/useActivityTable/types.ts +4 -5
- package/sdk/components/hooks/useActivityTable/useActivityTable.ts +10 -8
- package/sdk/components/hooks/useBDOForm/createItemProxy.ts +9 -5
- package/sdk/components/hooks/useBDOTable/types.ts +20 -10
- package/sdk/components/hooks/useBDOTable/useBDOTable.ts +12 -8
- package/sdk/table.types.ts +2 -0
- package/sdk/types/constants.ts +1 -1
- package/sdk/workflow/Activity.ts +39 -7
- package/dist/constants-QX2RX-wu.cjs +0 -1
- package/docs/api.md +0 -95
- package/docs/bdo.md +0 -224
- package/docs/gaps.md +0 -360
- package/docs/useActivityForm.md +0 -393
- package/docs/useActivityTable.md +0 -418
- package/docs/useBDOForm.md +0 -498
- package/docs/useBDOTable.md +0 -284
- package/docs/useFilter.md +0 -188
- package/docs/workflow.md +0 -560
- /package/docs/{useAuth.md → useAuth/README.md} +0 -0
|
@@ -10,12 +10,9 @@ import { useForm as useReactHookForm } from 'react-hook-form';
|
|
|
10
10
|
import { useQuery } from '@tanstack/react-query';
|
|
11
11
|
|
|
12
12
|
import type { Activity } from '../../../workflow/Activity';
|
|
13
|
-
import type {
|
|
14
|
-
UseActivityFormOptions,
|
|
15
|
-
UseActivityFormReturn,
|
|
16
|
-
AllActivityFields,
|
|
17
|
-
} from './types';
|
|
13
|
+
import type { UseActivityFormOptions, UseActivityFormReturn } from './types';
|
|
18
14
|
|
|
15
|
+
import type { CreateUpdateResponseType } from '../../../types/common';
|
|
19
16
|
import { createActivityResolver } from './createActivityResolver';
|
|
20
17
|
import { createActivityItemProxy } from './createActivityItemProxy';
|
|
21
18
|
import {
|
|
@@ -300,13 +297,13 @@ export function useActivityForm<A extends Activity<any, any, any>>(
|
|
|
300
297
|
);
|
|
301
298
|
|
|
302
299
|
// ============================================================
|
|
303
|
-
// HANDLE SUBMIT — activity.update()
|
|
300
|
+
// HANDLE SUBMIT — activity.update() + activity.complete()
|
|
304
301
|
// ============================================================
|
|
305
302
|
|
|
306
303
|
const handleSubmit = useCallback(
|
|
307
304
|
(
|
|
308
305
|
onSuccess?: (
|
|
309
|
-
data:
|
|
306
|
+
data: CreateUpdateResponseType,
|
|
310
307
|
e?: React.BaseSyntheticEvent,
|
|
311
308
|
) => void | Promise<void>,
|
|
312
309
|
onError?: (
|
|
@@ -319,7 +316,7 @@ export function useActivityForm<A extends Activity<any, any, any>>(
|
|
|
319
316
|
setIsSubmitting(true);
|
|
320
317
|
|
|
321
318
|
try {
|
|
322
|
-
// Only send dirty (changed) fields — matches useBDOForm
|
|
319
|
+
// Only send dirty (changed) fields — matches useBDOForm behavior
|
|
323
320
|
// Use getValues() to capture Image/File values set via setValue()
|
|
324
321
|
// that RHF resolver doesn't include in `data`
|
|
325
322
|
const cleanedData: Record<string, unknown> = {};
|
|
@@ -339,7 +336,7 @@ export function useActivityForm<A extends Activity<any, any, any>>(
|
|
|
339
336
|
: value;
|
|
340
337
|
}
|
|
341
338
|
|
|
342
|
-
//
|
|
339
|
+
// Send remaining dirty fields via update
|
|
343
340
|
if (Object.keys(cleanedData).length > 0) {
|
|
344
341
|
await activityRef.update(
|
|
345
342
|
activity_instance_id,
|
|
@@ -347,69 +344,10 @@ export function useActivityForm<A extends Activity<any, any, any>>(
|
|
|
347
344
|
);
|
|
348
345
|
}
|
|
349
346
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
onError?.(toError(error), event);
|
|
353
|
-
} finally {
|
|
354
|
-
setIsSubmitting(false);
|
|
355
|
-
}
|
|
356
|
-
},
|
|
357
|
-
(errors, event) => {
|
|
358
|
-
onError?.(errors, event);
|
|
359
|
-
},
|
|
360
|
-
);
|
|
361
|
-
},
|
|
362
|
-
[rhf, activityRef, readonlyFieldNames, allFields, activity_instance_id],
|
|
363
|
-
) as UseActivityFormReturn<A>['handleSubmit'];
|
|
364
|
-
|
|
365
|
-
// ============================================================
|
|
366
|
-
// HANDLE COMPLETE — activity.update() + activity.complete()
|
|
367
|
-
// ============================================================
|
|
368
|
-
|
|
369
|
-
const handleComplete = useCallback(
|
|
370
|
-
(
|
|
371
|
-
onSuccess?: (
|
|
372
|
-
data: AllActivityFields<A>,
|
|
373
|
-
e?: React.BaseSyntheticEvent,
|
|
374
|
-
) => void | Promise<void>,
|
|
375
|
-
onError?: (
|
|
376
|
-
error: any,
|
|
377
|
-
e?: React.BaseSyntheticEvent,
|
|
378
|
-
) => void | Promise<void>,
|
|
379
|
-
) => {
|
|
380
|
-
return rhf.handleSubmit(
|
|
381
|
-
async (data, event) => {
|
|
382
|
-
setIsSubmitting(true);
|
|
383
|
-
|
|
384
|
-
try {
|
|
385
|
-
// Only send dirty (changed) fields — matches useBDOForm update behavior
|
|
386
|
-
// Use getValues() to capture Image/File values set via setValue()
|
|
387
|
-
// that RHF resolver doesn't include in `data`
|
|
388
|
-
const cleanedData: Record<string, unknown> = {};
|
|
389
|
-
const readonlySet = new Set(readonlyFieldNames);
|
|
390
|
-
const dirtyFields = rhf.formState.dirtyFields;
|
|
391
|
-
const allValues = rhf.getValues() as Record<string, unknown>;
|
|
392
|
-
|
|
393
|
-
for (const key of Object.keys(allValues)) {
|
|
394
|
-
if (readonlySet.has(key) || !dirtyFields[key]) continue;
|
|
395
|
-
const value =
|
|
396
|
-
allValues[key] !== undefined
|
|
397
|
-
? allValues[key]
|
|
398
|
-
: (data as Record<string, unknown>)[key];
|
|
399
|
-
const field = allFields[key];
|
|
400
|
-
cleanedData[key] = field
|
|
401
|
-
? coerceFieldValue(field, value)
|
|
402
|
-
: value;
|
|
403
|
-
}
|
|
347
|
+
// Complete the activity — advances the workflow
|
|
348
|
+
const result = await activityRef.complete(activity_instance_id);
|
|
404
349
|
|
|
405
|
-
|
|
406
|
-
await activityRef.update(
|
|
407
|
-
activity_instance_id,
|
|
408
|
-
cleanedData as any,
|
|
409
|
-
);
|
|
410
|
-
}
|
|
411
|
-
await activityRef.complete(activity_instance_id);
|
|
412
|
-
await onSuccess?.(data as AllActivityFields<A>, event);
|
|
350
|
+
await onSuccess?.(result, event);
|
|
413
351
|
} catch (error) {
|
|
414
352
|
onError?.(toError(error), event);
|
|
415
353
|
} finally {
|
|
@@ -422,7 +360,7 @@ export function useActivityForm<A extends Activity<any, any, any>>(
|
|
|
422
360
|
);
|
|
423
361
|
},
|
|
424
362
|
[rhf, activityRef, readonlyFieldNames, allFields, activity_instance_id],
|
|
425
|
-
) as UseActivityFormReturn<A>['
|
|
363
|
+
) as UseActivityFormReturn<A>['handleSubmit'];
|
|
426
364
|
|
|
427
365
|
// ============================================================
|
|
428
366
|
// CLEAR ERRORS
|
|
@@ -448,7 +386,6 @@ export function useActivityForm<A extends Activity<any, any, any>>(
|
|
|
448
386
|
// Form methods
|
|
449
387
|
register,
|
|
450
388
|
handleSubmit,
|
|
451
|
-
handleComplete,
|
|
452
389
|
watch: rhf.watch as any,
|
|
453
390
|
setValue: rhf.setValue as any,
|
|
454
391
|
getValues: rhf.getValues as any,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Activity } from '../../../workflow/Activity';
|
|
2
|
-
import type { ActivityInstanceFieldsType } from '../../../workflow/types';
|
|
3
2
|
import type { UseTableReturnType, PaginationStateType } from '../useTable/types';
|
|
4
3
|
import type { UseFilterOptionsType } from '../useFilter/types';
|
|
5
4
|
import type { SortType } from '../../../types/common';
|
|
@@ -16,12 +15,12 @@ export type ActivityTableStatusType =
|
|
|
16
15
|
(typeof ActivityTableStatus)[keyof typeof ActivityTableStatus];
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
|
-
* Row type
|
|
20
|
-
*
|
|
18
|
+
* Row type — inferred from Activity's getInProgressList() return type.
|
|
19
|
+
* Resolves to ActivityInstanceType (proxy with .get()/.set()).
|
|
21
20
|
*/
|
|
22
21
|
export type ActivityRowType<A extends Activity<any, any, any>> =
|
|
23
|
-
A extends
|
|
24
|
-
?
|
|
22
|
+
A extends { getInProgressList(opts?: any): Promise<(infer R)[]> }
|
|
23
|
+
? R
|
|
25
24
|
: never;
|
|
26
25
|
|
|
27
26
|
export interface UseActivityTableOptionsType<
|
|
@@ -13,22 +13,24 @@ export function useActivityTable<A extends Activity<any, any, any>>(
|
|
|
13
13
|
const { activity, status, ...rest } = options;
|
|
14
14
|
const { businessProcessId, activityId } = activity.meta;
|
|
15
15
|
|
|
16
|
-
const ops = useMemo(() => activity._getOps(), [activity]);
|
|
17
|
-
|
|
18
16
|
const listFn = useMemo(
|
|
19
17
|
() =>
|
|
20
18
|
status === 'inprogress'
|
|
21
|
-
? (opts: any) =>
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
? async (opts: any) => ({
|
|
20
|
+
Data: (await activity.getInProgressList(opts)) as ActivityRowType<A>[],
|
|
21
|
+
})
|
|
22
|
+
: async (opts: any) => ({
|
|
23
|
+
Data: (await activity.getCompletedList(opts)) as ActivityRowType<A>[],
|
|
24
|
+
}),
|
|
25
|
+
[activity, status],
|
|
24
26
|
);
|
|
25
27
|
|
|
26
28
|
const countFn = useMemo(
|
|
27
29
|
() =>
|
|
28
30
|
status === 'inprogress'
|
|
29
|
-
? (opts: any) =>
|
|
30
|
-
: (opts: any) =>
|
|
31
|
-
[
|
|
31
|
+
? async (opts: any) => ({ Count: await activity.inProgressCount(opts) })
|
|
32
|
+
: async (opts: any) => ({ Count: await activity.completedCount(opts) }),
|
|
33
|
+
[activity, status],
|
|
32
34
|
);
|
|
33
35
|
|
|
34
36
|
return useTable<ActivityRowType<A>>({
|
|
@@ -21,8 +21,8 @@ import type {
|
|
|
21
21
|
* Key principle: Item has NO state. It's a view over RHF's state.
|
|
22
22
|
* Editable fields get set(), readonly fields do not.
|
|
23
23
|
*
|
|
24
|
-
* In create mode (no _id),
|
|
25
|
-
*
|
|
24
|
+
* In create mode (no _id), attachment and fetch operations use 'draft' as the
|
|
25
|
+
* instanceId, which the backend accepts as a placeholder.
|
|
26
26
|
*
|
|
27
27
|
* @param bdo - The BDO instance for field metadata
|
|
28
28
|
* @param form - The RHF useForm return object
|
|
@@ -36,6 +36,8 @@ export function createItemProxy<B extends BaseBdo<any, any, any>>(
|
|
|
36
36
|
const accessorCache = new Map<string, EditableFormFieldAccessorType<unknown> | ReadonlyFormFieldAccessorType<unknown>>();
|
|
37
37
|
|
|
38
38
|
const boIdShared = bdo.getBoId();
|
|
39
|
+
|
|
40
|
+
/** Returns the real _id in edit mode, or 'draft' in create mode */
|
|
39
41
|
const getInstanceId = (): string =>
|
|
40
42
|
(form.getValues("_id" as Path<FieldValues>) as string) || "draft";
|
|
41
43
|
|
|
@@ -148,15 +150,16 @@ export function createItemProxy<B extends BaseBdo<any, any, any>>(
|
|
|
148
150
|
validate,
|
|
149
151
|
};
|
|
150
152
|
|
|
151
|
-
// Enrich Image/File field accessors with attachment methods
|
|
153
|
+
// Enrich Image/File field accessors with attachment methods (draft-based upload)
|
|
152
154
|
if (fieldMeta.Type === "Image" || fieldMeta.Type === "File") {
|
|
153
155
|
const boId = boIdShared;
|
|
154
156
|
|
|
155
157
|
if (fieldMeta.Type === "Image") {
|
|
156
|
-
// Image: single file upload
|
|
158
|
+
// Image: single file upload — always uploads immediately (draft in create mode)
|
|
157
159
|
(accessor as any).upload = async (file: File): Promise<FileType> => {
|
|
158
160
|
validateFileExtension(file.name, "Image");
|
|
159
161
|
const id = getInstanceId();
|
|
162
|
+
|
|
160
163
|
const [uploadInfo] = await api(boId).getUploadUrl(id, prop, [
|
|
161
164
|
{ FileName: file.name, Size: file.size, FileExtension: extractFileExtension(file.name) },
|
|
162
165
|
]);
|
|
@@ -192,10 +195,11 @@ export function createItemProxy<B extends BaseBdo<any, any, any>>(
|
|
|
192
195
|
return api(boId).getDownloadUrl(instanceId, prop, val._id, viewType);
|
|
193
196
|
};
|
|
194
197
|
} else {
|
|
195
|
-
// File field — multi-file
|
|
198
|
+
// File field — multi-file, always uploads immediately (draft in create mode)
|
|
196
199
|
(accessor as any).upload = async (files: File[]): Promise<FileType[]> => {
|
|
197
200
|
for (const file of files) validateFileExtension(file.name, "File");
|
|
198
201
|
const id = getInstanceId();
|
|
202
|
+
|
|
199
203
|
const requests = files.map((file) => ({
|
|
200
204
|
FileName: file.name,
|
|
201
205
|
Size: file.size,
|
|
@@ -1,22 +1,32 @@
|
|
|
1
|
+
import type { ListOptionsType, SortType } from '../../../types/common';
|
|
1
2
|
import type { UseTableReturnType, PaginationStateType } from '../useTable/types';
|
|
2
3
|
import type { UseFilterOptionsType } from '../useFilter/types';
|
|
3
|
-
import type { SortType } from '../../../types/common';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
/** Structural constraint — any object with list() and count() */
|
|
6
|
+
export interface BDOTableSourceType {
|
|
7
|
+
meta: { readonly _id: string; readonly name: string };
|
|
8
|
+
list(options?: ListOptionsType): Promise<any[]>;
|
|
9
|
+
count(options?: ListOptionsType): Promise<number>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Infer row type from BDO's list() return type */
|
|
13
|
+
export type BDORowType<B extends BDOTableSourceType> =
|
|
14
|
+
B extends { list(opts?: any): Promise<(infer R)[]> } ? R : never;
|
|
15
|
+
|
|
16
|
+
export interface UseBDOTableOptionsType<B extends BDOTableSourceType> {
|
|
17
|
+
/** BDO instance — list() and count() are called for data */
|
|
18
|
+
bdo: B;
|
|
10
19
|
/** Initial state */
|
|
11
20
|
initialState?: {
|
|
12
21
|
sort?: SortType;
|
|
13
22
|
pagination?: PaginationStateType;
|
|
14
|
-
filter?: UseFilterOptionsType<
|
|
23
|
+
filter?: UseFilterOptionsType<BDORowType<B>>;
|
|
15
24
|
};
|
|
16
25
|
/** Error callback */
|
|
17
26
|
onError?: (error: Error) => void;
|
|
18
|
-
/** Success callback — receives rows from current page */
|
|
19
|
-
onSuccess?: (data:
|
|
27
|
+
/** Success callback — receives Item rows from current page */
|
|
28
|
+
onSuccess?: (data: BDORowType<B>[]) => void;
|
|
20
29
|
}
|
|
21
30
|
|
|
22
|
-
export type UseBDOTableReturnType<
|
|
31
|
+
export type UseBDOTableReturnType<B extends BDOTableSourceType> =
|
|
32
|
+
UseTableReturnType<BDORowType<B>>;
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { api } from '../../../api/client';
|
|
2
1
|
import { useTable } from '../useTable';
|
|
3
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
BDOTableSourceType,
|
|
4
|
+
BDORowType,
|
|
5
|
+
UseBDOTableOptionsType,
|
|
6
|
+
UseBDOTableReturnType,
|
|
7
|
+
} from './types';
|
|
4
8
|
|
|
5
|
-
export function useBDOTable<
|
|
6
|
-
options: UseBDOTableOptionsType<
|
|
7
|
-
): UseBDOTableReturnType<
|
|
9
|
+
export function useBDOTable<B extends BDOTableSourceType>(
|
|
10
|
+
options: UseBDOTableOptionsType<B>,
|
|
11
|
+
): UseBDOTableReturnType<B> {
|
|
8
12
|
const { bdo, ...rest } = options;
|
|
9
13
|
|
|
10
|
-
return useTable<
|
|
14
|
+
return useTable<BDORowType<B>>({
|
|
11
15
|
queryKey: ['table', bdo.meta._id],
|
|
12
|
-
listFn: (opts) =>
|
|
13
|
-
countFn: (opts) =>
|
|
16
|
+
listFn: async (opts) => ({ Data: await bdo.list(opts) }),
|
|
17
|
+
countFn: async (opts) => ({ Count: await bdo.count(opts) }),
|
|
14
18
|
...rest,
|
|
15
19
|
});
|
|
16
20
|
}
|
package/sdk/table.types.ts
CHANGED
package/sdk/types/constants.ts
CHANGED
package/sdk/workflow/Activity.ts
CHANGED
|
@@ -23,13 +23,15 @@ import { createActivityInstance } from "./ActivityInstance";
|
|
|
23
23
|
import type { ActivityInstanceType } from "./ActivityInstance";
|
|
24
24
|
import type { ActivityInstanceFieldsType, ActivityOperations } from "./types";
|
|
25
25
|
import type {
|
|
26
|
-
ListResponseType,
|
|
27
26
|
ListOptionsType,
|
|
28
27
|
MetricOptionsType,
|
|
29
28
|
MetricResponseType,
|
|
30
29
|
} from "../types/common";
|
|
31
30
|
import { BaseField } from "../bdo/fields/BaseField";
|
|
32
31
|
|
|
32
|
+
/** Activity system fields treated as readonly on list results */
|
|
33
|
+
type ActivitySystemReadonlyType = Omit<ActivityInstanceFieldsType, '_id'>;
|
|
34
|
+
|
|
33
35
|
// ============================================================
|
|
34
36
|
// ABSTRACT BASE CLASS
|
|
35
37
|
// ============================================================
|
|
@@ -128,18 +130,48 @@ export abstract class Activity<
|
|
|
128
130
|
|
|
129
131
|
/**
|
|
130
132
|
* List in-progress activity instances.
|
|
131
|
-
*
|
|
133
|
+
* Each row is wrapped in an ActivityInstance proxy with field accessors.
|
|
132
134
|
*/
|
|
133
|
-
async getInProgressList(
|
|
134
|
-
|
|
135
|
+
async getInProgressList(
|
|
136
|
+
options?: ListOptionsType,
|
|
137
|
+
): Promise<ActivityInstanceType<
|
|
138
|
+
ActivityInstanceFieldsType & TEntity,
|
|
139
|
+
TEditable,
|
|
140
|
+
TReadonly & ActivitySystemReadonlyType
|
|
141
|
+
>[]> {
|
|
142
|
+
const ops = this._ops();
|
|
143
|
+
const response = await ops.inProgressList(options);
|
|
144
|
+
const fields = this._discoverFields();
|
|
145
|
+
return response.Data.map((data) =>
|
|
146
|
+
createActivityInstance<
|
|
147
|
+
ActivityInstanceFieldsType & TEntity,
|
|
148
|
+
TEditable,
|
|
149
|
+
TReadonly & ActivitySystemReadonlyType
|
|
150
|
+
>(ops, (data as any)._id, data as (ActivityInstanceFieldsType & TEntity), fields),
|
|
151
|
+
);
|
|
135
152
|
}
|
|
136
153
|
|
|
137
154
|
/**
|
|
138
155
|
* List completed activity instances.
|
|
139
|
-
*
|
|
156
|
+
* Each row is wrapped in an ActivityInstance proxy with field accessors.
|
|
140
157
|
*/
|
|
141
|
-
async getCompletedList(
|
|
142
|
-
|
|
158
|
+
async getCompletedList(
|
|
159
|
+
options?: ListOptionsType,
|
|
160
|
+
): Promise<ActivityInstanceType<
|
|
161
|
+
ActivityInstanceFieldsType & TEntity,
|
|
162
|
+
TEditable,
|
|
163
|
+
TReadonly & ActivitySystemReadonlyType
|
|
164
|
+
>[]> {
|
|
165
|
+
const ops = this._ops();
|
|
166
|
+
const response = await ops.completedList(options);
|
|
167
|
+
const fields = this._discoverFields();
|
|
168
|
+
return response.Data.map((data) =>
|
|
169
|
+
createActivityInstance<
|
|
170
|
+
ActivityInstanceFieldsType & TEntity,
|
|
171
|
+
TEditable,
|
|
172
|
+
TReadonly & ActivitySystemReadonlyType
|
|
173
|
+
>(ops, (data as any)._id, data as (ActivityInstanceFieldsType & TEntity), fields),
|
|
174
|
+
);
|
|
143
175
|
}
|
|
144
176
|
|
|
145
177
|
/**
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const t={EQ:"EQ",NE:"NE",GT:"GT",GTE:"GTE",LT:"LT",LTE:"LTE",Between:"Between",NotBetween:"NotBetween",IN:"IN",NIN:"NIN",Empty:"Empty",NotEmpty:"NotEmpty",Contains:"Contains",NotContains:"NotContains",MinLength:"MinLength",MaxLength:"MaxLength",Length:"Length"},e={And:"And",Or:"Or",Not:"Not"},n={Constant:"Constant",BDOField:"BDOField",AppVariable:"AppVariable"},o={ASC:"ASC",DESC:"DESC"},i={Sum:"Sum",Avg:"Avg",Count:"Count",Max:"Max",Min:"Min",DistinctCount:"DistinctCount",BlankCount:"BlankCount",NotBlankCount:"NotBlankCount",Concat:"Concat",DistinctConcat:"DistinctConcat"},a={List:"List",Metric:"Metric",Pivot:"Pivot"},c={Create:"create",Update:"update"},r={Interactive:"interactive",NonInteractive:"non-interactive"},s={OnBlur:"onBlur",OnChange:"onChange",OnSubmit:"onSubmit",OnTouched:"onTouched",All:"all"},d={Loading:"loading",Authenticated:"authenticated",Unauthenticated:"unauthenticated"},u={Google:"google",Microsoft:"microsoft",GitHub:"github",Custom:"custom"},C={Id:"_id",CreatedAt:"_created_at",ModifiedAt:"_modified_at",CreatedBy:"_created_by",ModifiedBy:"_modified_by",Version:"_version",MergeVersion:"_m_version"},E={GET:"GET",POST:"POST",PATCH:"PATCH",DELETE:"DELETE"},p={SEARCH_DEBOUNCE_MS:300,PAGE_SIZE:10,PAGE:1,SEARCH_MAX_LENGTH:255},T={Date:"$__d__",DateTime:"$__dt__"},l={Success:"success"};exports.AuthProviderName=u;exports.AuthStatus=d;exports.ConditionOperator=t;exports.DateEncodingKey=T;exports.Defaults=p;exports.DeleteStatus=l;exports.FormOperation=c;exports.GroupOperator=e;exports.HttpMethod=E;exports.InteractionMode=r;exports.MetricType=i;exports.QueryType=a;exports.RHSType=n;exports.SortDirection=o;exports.SystemField=C;exports.ValidationMode=s;
|
package/docs/api.md
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
# API Types Reference
|
|
2
|
-
|
|
3
|
-
Request and response types for BDO methods. For usage patterns, see [bdo.md](bdo.md).
|
|
4
|
-
|
|
5
|
-
## Imports
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
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";
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## Common Mistakes (READ FIRST)
|
|
15
|
-
|
|
16
|
-
### 1. Calling `api` directly instead of as factory
|
|
17
|
-
|
|
18
|
-
```typescript
|
|
19
|
-
// ❌ WRONG — api is a function, not a client
|
|
20
|
-
api.get(id); api.delete(id);
|
|
21
|
-
|
|
22
|
-
// ✅ CORRECT — call api(boId) first
|
|
23
|
-
api(bdo.meta._id).get(id);
|
|
24
|
-
api(bdo.meta._id).delete(id);
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### 2. Using `api()` when BDO methods are available
|
|
28
|
-
|
|
29
|
-
Prefer BDO methods when they're `public` on the role's class. Use `api()` only for `protected` methods.
|
|
30
|
-
|
|
31
|
-
```typescript
|
|
32
|
-
// ✅ PREFERRED — BDO method
|
|
33
|
-
const items = await bdo.list();
|
|
34
|
-
|
|
35
|
-
// ✅ USE api() ONLY when BDO method is protected
|
|
36
|
-
await api(bdo.meta._id).delete(id);
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### 3. Wrong metric response key format
|
|
40
|
-
|
|
41
|
-
Key pattern is `{lowercase_type}_{Field}` with single underscore.
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
// ❌ WRONG
|
|
45
|
-
const count = result.Data[0].count;
|
|
46
|
-
|
|
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
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
## Response Types
|
|
55
|
-
|
|
56
|
-
```typescript
|
|
57
|
-
interface CreateUpdateResponseType { _id: string; }
|
|
58
|
-
interface DeleteResponseType { status: "success"; }
|
|
59
|
-
interface DraftResponseType { [fieldName: string]: any; }
|
|
60
|
-
|
|
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
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
interface MetricOptionsType {
|
|
70
|
-
GroupBy: string[];
|
|
71
|
-
Metric: { Field: string; Type: AggregationType; }[];
|
|
72
|
-
Filter?: FilterType;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
interface MetricResponseType { Data: Record<string, any>[]; }
|
|
76
|
-
|
|
77
|
-
interface PivotOptionsType {
|
|
78
|
-
Row: string[];
|
|
79
|
-
Column: string[];
|
|
80
|
-
Metric: { Field: string; Type: AggregationType; }[];
|
|
81
|
-
Filter?: FilterType;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
interface PivotResponseType {
|
|
85
|
-
Data: { RowHeader: { Key: string }[]; ColumnHeader: { Key: string }[]; Value: (number | string | null)[][]; };
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
type AggregationType = "Sum" | "Avg" | "Count" | "Max" | "Min" | "DistinctCount" | "BlankCount" | "NotBlankCount" | "Concat" | "DistinctConcat";
|
|
89
|
-
|
|
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"; }
|
|
93
|
-
|
|
94
|
-
type SortType = Record<string, "ASC" | "DESC">[];
|
|
95
|
-
```
|