@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.
- package/README.md +55 -48
- package/dist/api/client.d.ts +23 -13
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/datetime.d.ts +5 -5
- package/dist/api/datetime.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/metadata.d.ts +2 -2
- package/dist/api/metadata.d.ts.map +1 -1
- package/dist/api.cjs +1 -0
- package/dist/api.d.ts +4 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.mjs +27 -0
- package/dist/api.types.cjs +1 -0
- package/dist/api.types.d.ts +4 -0
- package/dist/api.types.d.ts.map +1 -0
- package/dist/api.types.mjs +1 -0
- package/dist/auth/AuthProvider.d.ts +3 -3
- package/dist/auth/AuthProvider.d.ts.map +1 -1
- package/dist/auth/authClient.d.ts +4 -4
- package/dist/auth/authClient.d.ts.map +1 -1
- package/dist/auth/authConfig.d.ts +5 -5
- package/dist/auth/authConfig.d.ts.map +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/types.d.ts +21 -21
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/useAuth.d.ts +2 -2
- package/dist/auth/useAuth.d.ts.map +1 -1
- package/dist/auth.cjs +1 -0
- package/dist/auth.d.ts +5 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.mjs +280 -0
- package/dist/auth.types.cjs +1 -0
- package/dist/auth.types.d.ts +2 -0
- package/dist/auth.types.d.ts.map +1 -0
- package/dist/auth.types.mjs +1 -0
- package/dist/base-types.d.ts +2 -0
- package/dist/base-types.d.ts.map +1 -0
- package/dist/client-C15j4O5B.cjs +1 -0
- package/dist/client-CfvLiGfP.js +233 -0
- package/dist/cn-Dr87sK3i.js +2775 -0
- package/dist/cn-mXUIg4vp.cjs +1 -0
- package/dist/components/hooks/index.d.ts +3 -3
- package/dist/components/hooks/index.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/index.d.ts +2 -2
- package/dist/components/hooks/useFilter/index.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/types.d.ts +19 -31
- package/dist/components/hooks/useFilter/types.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/useFilter.d.ts +2 -2
- package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -1
- package/dist/components/hooks/useForm/apiClient.d.ts +6 -6
- package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
- package/dist/components/hooks/useForm/expressionValidator.utils.d.ts +7 -7
- package/dist/components/hooks/useForm/expressionValidator.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/index.d.ts +5 -5
- package/dist/components/hooks/useForm/index.d.ts.map +1 -1
- package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts +10 -10
- package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts +7 -12
- package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/schemaParser.utils.d.ts +7 -7
- package/dist/components/hooks/useForm/schemaParser.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/types.d.ts +79 -70
- package/dist/components/hooks/useForm/types.d.ts.map +1 -1
- package/dist/components/hooks/useForm/useForm.d.ts +2 -2
- package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/apiClient.d.ts +16 -16
- package/dist/components/hooks/useKanban/apiClient.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/context.d.ts +3 -3
- package/dist/components/hooks/useKanban/context.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/dragDropManager.d.ts +7 -7
- package/dist/components/hooks/useKanban/dragDropManager.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/index.d.ts +1 -1
- package/dist/components/hooks/useKanban/index.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/types.d.ts +65 -67
- package/dist/components/hooks/useKanban/types.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/useKanban.d.ts +2 -2
- package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -1
- package/dist/components/hooks/useTable/index.d.ts +1 -1
- package/dist/components/hooks/useTable/index.d.ts.map +1 -1
- package/dist/components/hooks/useTable/types.d.ts +10 -10
- package/dist/components/hooks/useTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useTable/useTable.d.ts +2 -2
- package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
- package/dist/filter.cjs +1 -0
- package/dist/filter.d.ts +3 -0
- package/dist/filter.d.ts.map +1 -0
- package/dist/filter.mjs +6 -0
- package/dist/filter.types.cjs +1 -0
- package/dist/filter.types.d.ts +2 -0
- package/dist/filter.types.d.ts.map +1 -0
- package/dist/filter.types.mjs +1 -0
- package/dist/form.cjs +1 -0
- package/dist/form.d.ts +3 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.mjs +1346 -0
- package/dist/form.types.cjs +1 -0
- package/dist/form.types.d.ts +2 -0
- package/dist/form.types.d.ts.map +1 -0
- package/dist/form.types.mjs +1 -0
- package/dist/jsx-runtime-BYECrxsp.cjs +30 -0
- package/dist/jsx-runtime-DGlMoOmv.js +630 -0
- package/dist/kanban.cjs +13 -0
- package/dist/kanban.d.ts +5 -0
- package/dist/kanban.d.ts.map +1 -0
- package/dist/kanban.mjs +694 -0
- package/dist/kanban.types.cjs +1 -0
- package/dist/kanban.types.d.ts +2 -0
- package/dist/kanban.types.d.ts.map +1 -0
- package/dist/kanban.types.mjs +1 -0
- package/dist/kanban.ui.cjs +1 -0
- package/dist/kanban.ui.d.ts +2 -0
- package/dist/kanban.ui.d.ts.map +1 -0
- package/dist/kanban.ui.mjs +104 -0
- package/dist/metadata-2FLBsFcf.cjs +1 -0
- package/dist/metadata-DBcoDth-.js +43 -0
- package/dist/table.cjs +1 -0
- package/dist/table.d.ts +2 -0
- package/dist/table.d.ts.map +1 -0
- package/dist/table.mjs +148 -0
- package/dist/table.types.cjs +1 -0
- package/dist/table.types.d.ts +2 -0
- package/dist/table.types.d.ts.map +1 -0
- package/dist/table.types.mjs +1 -0
- package/dist/types/base-fields.d.ts +45 -45
- package/dist/types/base-fields.d.ts.map +1 -1
- package/dist/types/common.d.ts +45 -61
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types.cjs +1 -0
- package/dist/types.mjs +1 -0
- package/dist/useFilter-CXFqEHyI.js +129 -0
- package/dist/useFilter-D-bCDo6Z.cjs +1 -0
- package/dist/utils/formatting.d.ts +4 -4
- package/dist/utils/formatting.d.ts.map +1 -1
- package/dist/utils.cjs +4 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.mjs +105 -0
- package/package.json +147 -9
- package/sdk/api/client.ts +76 -49
- package/sdk/api/datetime.ts +5 -5
- package/sdk/api/index.ts +28 -33
- package/sdk/api/metadata.ts +4 -4
- package/sdk/api.ts +24 -0
- package/sdk/api.types.ts +58 -0
- package/sdk/auth/AuthProvider.tsx +18 -18
- package/sdk/auth/authClient.ts +9 -9
- package/sdk/auth/authConfig.ts +9 -9
- package/sdk/auth/index.ts +5 -5
- package/sdk/auth/types.ts +21 -21
- package/sdk/auth/useAuth.ts +2 -2
- package/sdk/auth.ts +22 -0
- package/sdk/auth.types.ts +28 -0
- package/sdk/base-types.ts +45 -0
- package/sdk/components/hooks/index.ts +22 -22
- package/sdk/components/hooks/useFilter/index.ts +8 -14
- package/sdk/components/hooks/useFilter/types.ts +29 -58
- package/sdk/components/hooks/useFilter/useFilter.ts +41 -44
- package/sdk/components/hooks/useForm/apiClient.ts +8 -8
- package/sdk/components/hooks/useForm/expressionValidator.utils.ts +18 -18
- package/sdk/components/hooks/useForm/index.ts +24 -24
- package/sdk/components/hooks/useForm/optimizedExpressionValidator.utils.ts +22 -22
- package/sdk/components/hooks/useForm/ruleClassifier.utils.ts +26 -62
- package/sdk/components/hooks/useForm/schemaParser.utils.ts +24 -24
- package/sdk/components/hooks/useForm/types.ts +85 -75
- package/sdk/components/hooks/useForm/useForm.ts +160 -40
- package/sdk/components/hooks/useKanban/apiClient.ts +54 -54
- package/sdk/components/hooks/useKanban/context.ts +3 -3
- package/sdk/components/hooks/useKanban/dragDropManager.ts +19 -19
- package/sdk/components/hooks/useKanban/index.ts +26 -26
- package/sdk/components/hooks/useKanban/types.ts +69 -71
- package/sdk/components/hooks/useKanban/useKanban.ts +43 -51
- package/sdk/components/hooks/useKanban/useKanbanSimple.ts +4 -4
- package/sdk/components/hooks/useTable/index.ts +5 -1
- package/sdk/components/hooks/useTable/types.ts +10 -10
- package/sdk/components/hooks/useTable/useTable.ts +10 -10
- package/sdk/filter.ts +13 -0
- package/sdk/filter.types.ts +17 -0
- package/sdk/form.ts +15 -0
- package/sdk/form.types.ts +46 -0
- package/sdk/kanban.ts +23 -0
- package/sdk/kanban.types.ts +50 -0
- package/sdk/kanban.ui.ts +16 -0
- package/sdk/table.ts +7 -0
- package/sdk/table.types.ts +13 -0
- package/sdk/types/base-fields.ts +47 -47
- package/sdk/types/common.ts +47 -71
- package/sdk/types/index.ts +1 -1
- package/sdk/utils/formatting.ts +4 -4
- package/sdk/utils.ts +10 -0
- package/dist/index.cjs +0 -45
- 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.
|
|
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
|
-
"
|
|
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/
|
|
15
|
-
"default": "./dist/
|
|
12
|
+
"types": "./dist/form.d.ts",
|
|
13
|
+
"default": "./dist/form.mjs"
|
|
16
14
|
},
|
|
17
15
|
"require": {
|
|
18
|
-
"types": "./dist/
|
|
19
|
-
"default": "./dist/
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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<
|
|
36
|
+
create(data: Partial<T> & { _id?: string }): Promise<CreateUpdateResponseType>;
|
|
37
37
|
|
|
38
38
|
/** Update existing record */
|
|
39
|
-
update(id: string, data: Partial<T>): Promise<
|
|
39
|
+
update(id: string, data: Partial<T>): Promise<CreateUpdateResponseType>;
|
|
40
40
|
|
|
41
41
|
/** Delete record by ID */
|
|
42
|
-
delete(id: string): Promise<
|
|
42
|
+
delete(id: string): Promise<DeleteResponseType>;
|
|
43
43
|
|
|
44
44
|
/** List records with optional filtering, sorting, and pagination */
|
|
45
|
-
list(options?:
|
|
45
|
+
list(options?: ListOptionsType): Promise<ListResponseType<T>>;
|
|
46
46
|
|
|
47
47
|
/** Get count of records matching the same criteria as list */
|
|
48
|
-
count(options?:
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
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
|
|
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
|
|
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:
|
|
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<
|
|
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<
|
|
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<
|
|
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?:
|
|
257
|
-
const requestBody:
|
|
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:
|
|
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?:
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
364
|
-
): Promise<
|
|
365
|
-
const requestBody:
|
|
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<
|
|
386
|
-
const requestBody:
|
|
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<
|
|
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<
|
|
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:
|
|
470
|
+
const responseData: FetchFieldResponseType = await response.json();
|
|
444
471
|
return responseData.Data;
|
|
445
472
|
},
|
|
446
473
|
};
|
package/sdk/api/datetime.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
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):
|
|
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:
|
|
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):
|
|
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:
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// Filter types
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
ListOptionsType,
|
|
38
|
+
ListResponseType,
|
|
39
|
+
ReadResponseType,
|
|
40
|
+
CreateUpdateResponseType,
|
|
41
|
+
DeleteResponseType,
|
|
42
|
+
CountResponseType,
|
|
48
43
|
// DateTime types
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
DateTimeEncodedType,
|
|
45
|
+
DateEncodedType,
|
|
51
46
|
// Metric types
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
MetricTypeType,
|
|
48
|
+
MetricFieldType,
|
|
49
|
+
MetricOptionsType,
|
|
50
|
+
MetricResponseType,
|
|
56
51
|
// Pivot types
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
PivotHeaderItemType,
|
|
53
|
+
PivotResponseDataType,
|
|
54
|
+
PivotOptionsType,
|
|
55
|
+
PivotResponseType,
|
|
61
56
|
// Draft types
|
|
62
|
-
|
|
57
|
+
DraftResponseType,
|
|
63
58
|
// Fields types
|
|
64
|
-
|
|
59
|
+
FieldsResponseType,
|
|
65
60
|
} from "../types/common";
|
package/sdk/api/metadata.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// ============================================================
|
|
4
4
|
// Handles metadata/schema fetching operations for Business Objects
|
|
5
5
|
|
|
6
|
-
import type {
|
|
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?:
|
|
101
|
-
): Promise<
|
|
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
|
|
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';
|