@ram_28/kf-ai-sdk 2.0.14 → 2.0.15
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 +2 -1
- package/dist/FileField-BWrSHNRq.js +296 -0
- package/dist/FileField-eDeuzln8.cjs +1 -0
- package/dist/api.cjs +1 -1
- package/dist/api.mjs +2 -2
- package/dist/auth.cjs +1 -1
- package/dist/auth.mjs +1 -1
- package/dist/bdo.cjs +1 -1
- package/dist/bdo.mjs +228 -472
- package/dist/{client-DnO2KKrw.cjs → client-D5k4SYuw.cjs} +1 -1
- package/dist/{client-iQTqFDNI.js → client-_ayziI1d.js} +33 -32
- package/dist/components/hooks/index.d.ts +9 -3
- package/dist/components/hooks/index.d.ts.map +1 -1
- package/dist/{workflow/components → components/hooks}/useActivityForm/createActivityItemProxy.d.ts +9 -5
- package/dist/components/hooks/useActivityForm/createActivityItemProxy.d.ts.map +1 -0
- package/dist/components/hooks/useActivityForm/createActivityResolver.d.ts +23 -0
- package/dist/components/hooks/useActivityForm/createActivityResolver.d.ts.map +1 -0
- package/dist/components/hooks/useActivityForm/index.d.ts.map +1 -0
- package/dist/{workflow/components → components/hooks}/useActivityForm/types.d.ts +11 -7
- package/dist/components/hooks/useActivityForm/types.d.ts.map +1 -0
- package/dist/{workflow/components → components/hooks}/useActivityForm/useActivityForm.d.ts +2 -2
- package/dist/components/hooks/useActivityForm/useActivityForm.d.ts.map +1 -0
- package/dist/components/hooks/useActivityTable/index.d.ts +4 -0
- package/dist/components/hooks/useActivityTable/index.d.ts.map +1 -0
- package/dist/components/hooks/useActivityTable/types.d.ts +36 -0
- package/dist/components/hooks/useActivityTable/types.d.ts.map +1 -0
- package/dist/components/hooks/useActivityTable/useActivityTable.d.ts +4 -0
- package/dist/components/hooks/useActivityTable/useActivityTable.d.ts.map +1 -0
- package/dist/components/hooks/useBDOTable/index.d.ts +3 -0
- package/dist/components/hooks/useBDOTable/index.d.ts.map +1 -0
- package/dist/components/hooks/useBDOTable/types.d.ts +26 -0
- package/dist/components/hooks/useBDOTable/types.d.ts.map +1 -0
- package/dist/components/hooks/useBDOTable/useBDOTable.d.ts +3 -0
- package/dist/components/hooks/useBDOTable/useBDOTable.d.ts.map +1 -0
- package/dist/components/hooks/useTable/index.d.ts +2 -2
- package/dist/components/hooks/useTable/index.d.ts.map +1 -1
- package/dist/components/hooks/useTable/types.d.ts +11 -10
- package/dist/components/hooks/useTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useTable/useTable.d.ts +1 -1
- package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
- package/dist/createResolver-AIgUwoS6.cjs +1 -0
- package/dist/createResolver-ZHXQ7QMa.js +1078 -0
- package/dist/form.cjs +1 -1
- package/dist/form.mjs +252 -314
- package/dist/{metadata-DpfI3zRN.js → metadata-Cc1mBcLS.js} +1 -1
- package/dist/{metadata-DgLSJkF5.cjs → metadata-DWXQPDav.cjs} +1 -1
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +1 -0
- package/dist/table.d.ts.map +1 -1
- package/dist/table.mjs +16 -192
- package/dist/table.types.d.ts +2 -1
- package/dist/table.types.d.ts.map +1 -1
- package/dist/types/base-fields.d.ts +4 -4
- package/dist/types/base-fields.d.ts.map +1 -1
- package/dist/useTable-CeRklbdT.cjs +1 -0
- package/dist/useTable-DS0-WInw.js +203 -0
- package/dist/workflow/Activity.d.ts +9 -9
- package/dist/workflow/Activity.d.ts.map +1 -1
- package/dist/workflow/client.d.ts.map +1 -1
- package/dist/workflow/createFieldFromMeta.d.ts +29 -0
- package/dist/workflow/createFieldFromMeta.d.ts.map +1 -0
- package/dist/workflow/index.d.ts +1 -2
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/types.d.ts +12 -12
- package/dist/workflow/types.d.ts.map +1 -1
- package/dist/workflow.cjs +1 -1
- package/dist/workflow.d.ts +5 -2
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.mjs +716 -338
- package/dist/workflow.types.d.ts +1 -0
- package/dist/workflow.types.d.ts.map +1 -1
- package/docs/gaps.md +410 -0
- package/docs/useActivityTable.md +481 -0
- package/docs/useBDOTable.md +317 -0
- package/docs/workflow.md +143 -34
- package/package.json +1 -1
- package/sdk/bdo/fields/UserField.ts +1 -1
- package/sdk/components/hooks/index.ts +28 -5
- package/sdk/components/hooks/useActivityForm/createActivityItemProxy.ts +400 -0
- package/sdk/components/hooks/useActivityForm/createActivityResolver.ts +87 -0
- package/sdk/{workflow/components → components/hooks}/useActivityForm/types.ts +21 -8
- package/sdk/components/hooks/useActivityForm/useActivityForm.ts +628 -0
- package/sdk/components/hooks/useActivityTable/index.ts +8 -0
- package/sdk/components/hooks/useActivityTable/types.ts +45 -0
- package/sdk/components/hooks/useActivityTable/useActivityTable.ts +71 -0
- package/sdk/components/hooks/useBDOTable/index.ts +2 -0
- package/sdk/components/hooks/useBDOTable/types.ts +24 -0
- package/sdk/components/hooks/useBDOTable/useBDOTable.ts +15 -0
- package/sdk/components/hooks/useTable/index.ts +3 -3
- package/sdk/components/hooks/useTable/types.ts +16 -12
- package/sdk/components/hooks/useTable/useTable.ts +56 -49
- package/sdk/table.ts +4 -1
- package/sdk/table.types.ts +7 -4
- package/sdk/types/base-fields.ts +4 -4
- package/sdk/workflow/Activity.ts +14 -13
- package/sdk/workflow/client.ts +21 -8
- package/sdk/workflow/createFieldFromMeta.ts +110 -0
- package/sdk/workflow/index.ts +1 -6
- package/sdk/workflow/types.ts +13 -12
- package/sdk/workflow.ts +11 -2
- package/sdk/workflow.types.ts +7 -0
- package/dist/BaseField-B6da88U7.js +0 -40
- package/dist/BaseField-Drp0-OxL.cjs +0 -1
- package/dist/error-handling-CAoD0Kwb.cjs +0 -1
- package/dist/error-handling-CrhTtD88.js +0 -14
- package/dist/index.esm-Cj63v5ny.js +0 -1014
- package/dist/index.esm-DuwT11sx.cjs +0 -1
- package/dist/workflow/components/useActivityForm/createActivityItemProxy.d.ts.map +0 -1
- package/dist/workflow/components/useActivityForm/createActivityResolver.d.ts +0 -22
- package/dist/workflow/components/useActivityForm/createActivityResolver.d.ts.map +0 -1
- package/dist/workflow/components/useActivityForm/index.d.ts.map +0 -1
- package/dist/workflow/components/useActivityForm/types.d.ts.map +0 -1
- package/dist/workflow/components/useActivityForm/useActivityForm.d.ts.map +0 -1
- package/docs/useTable.md +0 -369
- package/sdk/workflow/components/useActivityForm/createActivityItemProxy.ts +0 -130
- package/sdk/workflow/components/useActivityForm/createActivityResolver.ts +0 -61
- package/sdk/workflow/components/useActivityForm/useActivityForm.ts +0 -386
- /package/dist/{workflow/components → components/hooks}/useActivityForm/index.d.ts +0 -0
- /package/sdk/{workflow/components → components/hooks}/useActivityForm/index.ts +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// FIELD FACTORY — Runtime Field Construction from Metadata
|
|
3
|
+
// ============================================================
|
|
4
|
+
// Creates BaseField instances from raw BP activity Input metadata.
|
|
5
|
+
// Used by useActivityForm to dynamically build fields when BP
|
|
6
|
+
// metadata is fetched at runtime.
|
|
7
|
+
|
|
8
|
+
import { StringField } from '../bdo/fields/StringField';
|
|
9
|
+
import { NumberField } from '../bdo/fields/NumberField';
|
|
10
|
+
import { BooleanField } from '../bdo/fields/BooleanField';
|
|
11
|
+
import { DateField } from '../bdo/fields/DateField';
|
|
12
|
+
import { DateTimeField } from '../bdo/fields/DateTimeField';
|
|
13
|
+
import { TextField } from '../bdo/fields/TextField';
|
|
14
|
+
import { SelectField } from '../bdo/fields/SelectField';
|
|
15
|
+
import { ReferenceField } from '../bdo/fields/ReferenceField';
|
|
16
|
+
import { UserField } from '../bdo/fields/UserField';
|
|
17
|
+
import { FileField } from '../bdo/fields/FileField';
|
|
18
|
+
import type { BaseField } from '../bdo/fields/BaseField';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Create a BaseField instance from raw Input field metadata.
|
|
22
|
+
* Used by useActivityForm to dynamically construct fields from BP metadata.
|
|
23
|
+
*
|
|
24
|
+
* @param fieldId - The field identifier (e.g., "StartDate", "LeaveType")
|
|
25
|
+
* @param meta - Raw field metadata from BP Activity Input definition
|
|
26
|
+
* @returns A BaseField instance matching the metadata Type
|
|
27
|
+
*/
|
|
28
|
+
export function createFieldFromMeta(
|
|
29
|
+
fieldId: string,
|
|
30
|
+
meta: Record<string, unknown>,
|
|
31
|
+
): BaseField<unknown> {
|
|
32
|
+
const fullMeta = { _id: fieldId, ...meta };
|
|
33
|
+
const type = meta.Type as string;
|
|
34
|
+
|
|
35
|
+
// String + Enum constraint → SelectField
|
|
36
|
+
if (
|
|
37
|
+
type === 'String' &&
|
|
38
|
+
(meta.Constraint as Record<string, unknown> | undefined)?.Enum
|
|
39
|
+
) {
|
|
40
|
+
return new SelectField(fullMeta as any);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
switch (type) {
|
|
44
|
+
case 'String':
|
|
45
|
+
return new StringField(fullMeta as any);
|
|
46
|
+
case 'Number':
|
|
47
|
+
return new NumberField(fullMeta as any);
|
|
48
|
+
case 'Boolean':
|
|
49
|
+
return new BooleanField(fullMeta as any);
|
|
50
|
+
case 'Date':
|
|
51
|
+
return new DateField(fullMeta as any);
|
|
52
|
+
case 'DateTime':
|
|
53
|
+
return new DateTimeField(fullMeta as any);
|
|
54
|
+
case 'Text':
|
|
55
|
+
return new TextField(fullMeta as any);
|
|
56
|
+
case 'Reference':
|
|
57
|
+
return new ReferenceField(fullMeta as any);
|
|
58
|
+
case 'User':
|
|
59
|
+
return new UserField(fullMeta as any);
|
|
60
|
+
case 'File':
|
|
61
|
+
return new FileField(fullMeta as any);
|
|
62
|
+
default:
|
|
63
|
+
return new StringField(fullMeta as any);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Build a fields map from an Activity's Input metadata.
|
|
69
|
+
*
|
|
70
|
+
* @param input - The Input object from BP Activity definition
|
|
71
|
+
* (Record of fieldId → raw field metadata)
|
|
72
|
+
* @returns Record of fieldId → BaseField instance
|
|
73
|
+
*/
|
|
74
|
+
export function buildFieldsFromInput(
|
|
75
|
+
input: Record<string, Record<string, unknown>>,
|
|
76
|
+
): Record<string, BaseField<unknown>> {
|
|
77
|
+
const fields: Record<string, BaseField<unknown>> = {};
|
|
78
|
+
for (const [fieldId, fieldMeta] of Object.entries(input)) {
|
|
79
|
+
fields[fieldId] = createFieldFromMeta(fieldId, fieldMeta);
|
|
80
|
+
}
|
|
81
|
+
return fields;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Search all activities in a BP blob for a field definition by name.
|
|
86
|
+
* Used to discover field metadata for Context-derived readonly fields.
|
|
87
|
+
*
|
|
88
|
+
* @param currentActivityDef - The current activity definition (to skip)
|
|
89
|
+
* @param bpSchema - The full BP schema (with BDOBlob)
|
|
90
|
+
* @param fieldName - The field name to search for
|
|
91
|
+
* @returns The field metadata or null if not found
|
|
92
|
+
*/
|
|
93
|
+
export function findFieldInBpActivities(
|
|
94
|
+
currentActivityDef: Record<string, unknown> | null,
|
|
95
|
+
bpSchema: Record<string, unknown> | null | undefined,
|
|
96
|
+
fieldName: string,
|
|
97
|
+
): Record<string, unknown> | null {
|
|
98
|
+
const blob = (bpSchema as any)?.BDOBlob;
|
|
99
|
+
if (!blob?.Activity) return null;
|
|
100
|
+
|
|
101
|
+
const currentId = (currentActivityDef as any)?.Id;
|
|
102
|
+
|
|
103
|
+
for (const activity of blob.Activity as any[]) {
|
|
104
|
+
if (activity.Id === currentId) continue;
|
|
105
|
+
if (activity.Input?.[fieldName]) {
|
|
106
|
+
return activity.Input[fieldName];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
}
|
package/sdk/workflow/index.ts
CHANGED
|
@@ -12,9 +12,4 @@ export type {
|
|
|
12
12
|
ActivityProgressType,
|
|
13
13
|
WorkflowStartResponseType,
|
|
14
14
|
} from './types';
|
|
15
|
-
|
|
16
|
-
export { useActivityForm } from './components/useActivityForm';
|
|
17
|
-
export type {
|
|
18
|
-
UseActivityFormOptions,
|
|
19
|
-
UseActivityFormReturn,
|
|
20
|
-
} from './components/useActivityForm';
|
|
15
|
+
export { createFieldFromMeta, buildFieldsFromInput } from './createFieldFromMeta';
|
package/sdk/workflow/types.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import type {
|
|
6
6
|
ListResponseType,
|
|
7
|
-
|
|
7
|
+
ListOptionsType,
|
|
8
|
+
CountResponseType,
|
|
8
9
|
DraftResponseType,
|
|
9
10
|
CreateUpdateResponseType,
|
|
10
11
|
} from "../types/common";
|
|
@@ -13,9 +14,8 @@ import type {
|
|
|
13
14
|
StringFieldType,
|
|
14
15
|
SelectFieldType,
|
|
15
16
|
DateTimeFieldType,
|
|
16
|
-
|
|
17
|
+
UserFieldType,
|
|
17
18
|
} from "../types/base-fields";
|
|
18
|
-
import type { UserRefType } from "../types/base-fields";
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Response from Workflow.start()
|
|
@@ -48,8 +48,9 @@ export interface ActivityProgressType {
|
|
|
48
48
|
*/
|
|
49
49
|
export type ActivityInstanceFieldsType = {
|
|
50
50
|
_id: StringFieldType;
|
|
51
|
+
BPInstanceId: StringFieldType;
|
|
51
52
|
Status: SelectFieldType<"InProgress" | "Completed">;
|
|
52
|
-
AssignedTo:
|
|
53
|
+
AssignedTo: UserFieldType[];
|
|
53
54
|
CompletedAt: DateTimeFieldType;
|
|
54
55
|
};
|
|
55
56
|
|
|
@@ -62,17 +63,17 @@ export type ActivityInstanceFieldsType = {
|
|
|
62
63
|
export interface ActivityOperations<T> {
|
|
63
64
|
// ── List-level ──────────────────────────────────────────────
|
|
64
65
|
|
|
65
|
-
/** List in-progress activity instances (
|
|
66
|
-
inProgressList(): Promise<ListResponseType<ActivityInstanceFieldsType & T>>;
|
|
66
|
+
/** List in-progress activity instances (POST .../inprogress/list) */
|
|
67
|
+
inProgressList(options?: ListOptionsType): Promise<ListResponseType<ActivityInstanceFieldsType & T>>;
|
|
67
68
|
|
|
68
|
-
/** List completed activity instances (
|
|
69
|
-
completedList(): Promise<ListResponseType<ActivityInstanceFieldsType & T>>;
|
|
69
|
+
/** List completed activity instances (POST .../completed/list) */
|
|
70
|
+
completedList(options?: ListOptionsType): Promise<ListResponseType<ActivityInstanceFieldsType & T>>;
|
|
70
71
|
|
|
71
|
-
/** Get in-progress activity
|
|
72
|
-
inProgressMetric(): Promise<
|
|
72
|
+
/** Get in-progress activity count (POST .../inprogress/metric) */
|
|
73
|
+
inProgressMetric(options?: ListOptionsType): Promise<CountResponseType>;
|
|
73
74
|
|
|
74
|
-
/** Get completed activity
|
|
75
|
-
completedMetric(): Promise<
|
|
75
|
+
/** Get completed activity count (POST .../completed/metric) */
|
|
76
|
+
completedMetric(options?: ListOptionsType): Promise<CountResponseType>;
|
|
76
77
|
|
|
77
78
|
// ── Instance-level ──────────────────────────────────────────
|
|
78
79
|
|
package/sdk/workflow.ts
CHANGED
|
@@ -17,9 +17,18 @@ export type {
|
|
|
17
17
|
ActivityProgressType,
|
|
18
18
|
WorkflowStartResponseType,
|
|
19
19
|
} from './workflow/types';
|
|
20
|
+
export { createFieldFromMeta, buildFieldsFromInput } from './workflow/createFieldFromMeta';
|
|
20
21
|
|
|
21
|
-
export { useActivityForm } from './
|
|
22
|
+
export { useActivityForm } from './components/hooks/useActivityForm';
|
|
22
23
|
export type {
|
|
23
24
|
UseActivityFormOptions,
|
|
24
25
|
UseActivityFormReturn,
|
|
25
|
-
} from './
|
|
26
|
+
} from './components/hooks/useActivityForm';
|
|
27
|
+
|
|
28
|
+
export { useActivityTable, ActivityTableStatus } from './components/hooks/useActivityTable';
|
|
29
|
+
export type {
|
|
30
|
+
UseActivityTableOptionsType,
|
|
31
|
+
UseActivityTableReturnType,
|
|
32
|
+
ActivityTableStatusType,
|
|
33
|
+
ActivityRowType,
|
|
34
|
+
} from './components/hooks/useActivityTable';
|
package/sdk/workflow.types.ts
CHANGED
|
@@ -9,3 +9,10 @@ export type {
|
|
|
9
9
|
ActivityProgressType,
|
|
10
10
|
WorkflowStartResponseType,
|
|
11
11
|
} from './workflow/types';
|
|
12
|
+
|
|
13
|
+
export type {
|
|
14
|
+
UseActivityTableOptionsType,
|
|
15
|
+
UseActivityTableReturnType,
|
|
16
|
+
ActivityTableStatusType,
|
|
17
|
+
ActivityRowType,
|
|
18
|
+
} from './components/hooks/useActivityTable/types';
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
var i = Object.defineProperty;
|
|
2
|
-
var s = (t, e, a) => e in t ? i(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
|
|
3
|
-
var r = (t, e, a) => s(t, typeof e != "symbol" ? e + "" : e, a);
|
|
4
|
-
class u {
|
|
5
|
-
constructor(e) {
|
|
6
|
-
/** Full raw backend meta */
|
|
7
|
-
r(this, "_meta");
|
|
8
|
-
r(this, "_parentBoId");
|
|
9
|
-
this._meta = e;
|
|
10
|
-
}
|
|
11
|
-
// === Convenience getters (transform backend naming → SDK naming) ===
|
|
12
|
-
get id() {
|
|
13
|
-
return this._meta._id;
|
|
14
|
-
}
|
|
15
|
-
get label() {
|
|
16
|
-
return this._meta.Name || this._meta._id;
|
|
17
|
-
}
|
|
18
|
-
get readOnly() {
|
|
19
|
-
return this._meta.ReadOnly ?? !1;
|
|
20
|
-
}
|
|
21
|
-
get required() {
|
|
22
|
-
var e;
|
|
23
|
-
return ((e = this._meta.Constraint) == null ? void 0 : e.Required) ?? this._meta.Required ?? !1;
|
|
24
|
-
}
|
|
25
|
-
get defaultValue() {
|
|
26
|
-
var e;
|
|
27
|
-
return this._meta.DefaultValue ?? ((e = this._meta.Constraint) == null ? void 0 : e.DefaultValue);
|
|
28
|
-
}
|
|
29
|
-
get primaryKey() {
|
|
30
|
-
var e;
|
|
31
|
-
return ((e = this._meta.Constraint) == null ? void 0 : e.PrimaryKey) ?? !1;
|
|
32
|
-
}
|
|
33
|
-
/** Full raw meta (the exact JSON passed to constructor) */
|
|
34
|
-
get meta() {
|
|
35
|
-
return this._meta;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
export {
|
|
39
|
-
u as B
|
|
40
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var i=Object.defineProperty;var s=(t,e,a)=>e in t?i(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a;var r=(t,e,a)=>s(t,typeof e!="symbol"?e+"":e,a);class u{constructor(e){r(this,"_meta");r(this,"_parentBoId");this._meta=e}get id(){return this._meta._id}get label(){return this._meta.Name||this._meta._id}get readOnly(){return this._meta.ReadOnly??!1}get required(){var e;return((e=this._meta.Constraint)==null?void 0:e.Required)??this._meta.Required??!1}get defaultValue(){var e;return this._meta.DefaultValue??((e=this._meta.Constraint)==null?void 0:e.DefaultValue)}get primaryKey(){var e;return((e=this._meta.Constraint)==null?void 0:e.PrimaryKey)??!1}get meta(){return this._meta}}exports.BaseField=u;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function o(t){if(t instanceof Error)return t;if(typeof t=="string")return new Error(t);if(t!==null&&typeof t=="object"&&"message"in t&&typeof t.message=="string"){const n=new Error(t.message);return Object.assign(n,t),n}return new Error(String(t))}exports.toError=o;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
function o(n) {
|
|
2
|
-
if (n instanceof Error)
|
|
3
|
-
return n;
|
|
4
|
-
if (typeof n == "string")
|
|
5
|
-
return new Error(n);
|
|
6
|
-
if (n !== null && typeof n == "object" && "message" in n && typeof n.message == "string") {
|
|
7
|
-
const t = new Error(n.message);
|
|
8
|
-
return Object.assign(t, n), t;
|
|
9
|
-
}
|
|
10
|
-
return new Error(String(n));
|
|
11
|
-
}
|
|
12
|
-
export {
|
|
13
|
-
o as t
|
|
14
|
-
};
|