@ram_28/kf-ai-sdk 1.0.19 → 1.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 +45 -12
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/datetime.d.ts +59 -10
- package/dist/api/datetime.d.ts.map +1 -1
- package/dist/api/index.d.ts +3 -2
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api.cjs +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.mjs +43 -21
- package/dist/api.types.d.ts +2 -1
- package/dist/api.types.d.ts.map +1 -1
- package/dist/auth/AuthProvider.d.ts.map +1 -1
- package/dist/auth.cjs +1 -1
- package/dist/auth.mjs +34 -34
- package/dist/base-types.d.ts +1 -1
- package/dist/base-types.d.ts.map +1 -1
- package/dist/client-BIkaIr2y.js +217 -0
- package/dist/client-DxjRcEtN.cjs +1 -0
- package/dist/components/hooks/useFilter/types.d.ts +14 -11
- package/dist/components/hooks/useFilter/types.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/useFilter.d.ts +1 -1
- package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -1
- package/dist/components/hooks/useForm/apiClient.d.ts +45 -4
- package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
- package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/types.d.ts +5 -22
- package/dist/components/hooks/useKanban/types.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -1
- package/dist/components/hooks/useTable/types.d.ts +19 -31
- package/dist/components/hooks/useTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
- package/dist/error-handling-CAoD0Kwb.cjs +1 -0
- package/dist/error-handling-CrhTtD88.js +14 -0
- package/dist/filter.cjs +1 -1
- package/dist/filter.mjs +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.mjs +736 -750
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/kanban.cjs +2 -2
- package/dist/kanban.mjs +333 -323
- package/dist/{metadata-0lZAfuTP.cjs → metadata-Bz8zJqC1.cjs} +1 -1
- package/dist/{metadata-B88D_pVS.js → metadata-VbQzyD2C.js} +1 -1
- package/dist/table.cjs +1 -1
- package/dist/table.mjs +113 -96
- package/dist/table.types.d.ts +1 -1
- package/dist/table.types.d.ts.map +1 -1
- package/dist/types/base-fields.d.ts +71 -17
- package/dist/types/base-fields.d.ts.map +1 -1
- package/dist/types/common.d.ts +26 -18
- package/dist/types/common.d.ts.map +1 -1
- package/dist/useFilter-DzpP_ag0.cjs +1 -0
- package/dist/useFilter-H5bgAZQF.js +120 -0
- package/dist/utils/api/buildListOptions.d.ts +43 -0
- package/dist/utils/api/buildListOptions.d.ts.map +1 -0
- package/dist/utils/api/index.d.ts +2 -0
- package/dist/utils/api/index.d.ts.map +1 -0
- package/dist/utils/error-handling.d.ts +41 -0
- package/dist/utils/error-handling.d.ts.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/docs/QUICK_REFERENCE.md +142 -420
- package/docs/useAuth.md +52 -340
- package/docs/useFilter.md +858 -162
- package/docs/useForm.md +712 -501
- package/docs/useKanban.md +534 -279
- package/docs/useTable.md +725 -214
- package/package.json +1 -1
- package/sdk/api/client.ts +3 -41
- package/sdk/api/datetime.ts +98 -14
- package/sdk/api/index.ts +12 -6
- package/sdk/api.ts +6 -3
- package/sdk/api.types.ts +3 -4
- package/sdk/auth/AuthProvider.tsx +22 -24
- package/sdk/base-types.ts +2 -0
- package/sdk/components/hooks/useFilter/types.ts +14 -11
- package/sdk/components/hooks/useFilter/useFilter.ts +20 -18
- package/sdk/components/hooks/useForm/apiClient.ts +120 -5
- package/sdk/components/hooks/useForm/useForm.ts +97 -61
- package/sdk/components/hooks/useKanban/types.ts +7 -23
- package/sdk/components/hooks/useKanban/useKanban.ts +54 -18
- package/sdk/components/hooks/useTable/types.ts +26 -32
- package/sdk/components/hooks/useTable/useTable.llm.txt +8 -22
- package/sdk/components/hooks/useTable/useTable.ts +70 -25
- package/sdk/index.ts +157 -10
- package/sdk/table.types.ts +3 -0
- package/sdk/types/base-fields.ts +71 -17
- package/sdk/types/common.ts +33 -19
- package/sdk/utils/api/buildListOptions.ts +120 -0
- package/sdk/utils/api/index.ts +2 -0
- package/sdk/utils/error-handling.ts +150 -0
- package/sdk/utils/index.ts +6 -0
- package/dist/client-DgtkT50N.cjs +0 -1
- package/dist/client-V-WzUb8H.js +0 -237
- package/dist/useFilter-Dofowpr_.cjs +0 -1
- package/dist/useFilter-Dv-mr9QW.js +0 -117
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { useState as h, useMemo as M, useCallback as c } from "react";
|
|
2
|
+
const u = (r) => "Condition" in r, D = (r) => "LHSField" in r;
|
|
3
|
+
let k = 0;
|
|
4
|
+
const f = () => {
|
|
5
|
+
const r = Math.random().toString(36).substring(2, 9);
|
|
6
|
+
return `filter_${Date.now()}_${r}_${++k}`;
|
|
7
|
+
}, x = (r) => r.id ? r : { ...r, id: f() }, O = (r) => r.map((o) => {
|
|
8
|
+
const n = x(o);
|
|
9
|
+
return u(n) ? {
|
|
10
|
+
...n,
|
|
11
|
+
Condition: O(n.Condition)
|
|
12
|
+
} : n;
|
|
13
|
+
}), v = (r) => r.map((o) => {
|
|
14
|
+
if (u(o)) {
|
|
15
|
+
const { id: g, ...C } = o;
|
|
16
|
+
return {
|
|
17
|
+
...C,
|
|
18
|
+
Condition: v(o.Condition)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const { id: n, ...t } = o;
|
|
22
|
+
return t;
|
|
23
|
+
}), G = (r, o) => {
|
|
24
|
+
for (const n of r) {
|
|
25
|
+
if (n.id === o)
|
|
26
|
+
return n;
|
|
27
|
+
if (u(n)) {
|
|
28
|
+
const t = G(n.Condition, o);
|
|
29
|
+
if (t) return t;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}, p = (r, o, n) => r.map((t) => t.id === o ? n(t) : u(t) ? {
|
|
33
|
+
...t,
|
|
34
|
+
Condition: p(t.Condition, o, n)
|
|
35
|
+
} : t), I = (r, o) => r.filter((n) => n.id !== o).map((n) => u(n) ? {
|
|
36
|
+
...n,
|
|
37
|
+
Condition: I(n.Condition, o)
|
|
38
|
+
} : n), l = (r, o, n) => r.map((t) => t.id === o && u(t) ? {
|
|
39
|
+
...t,
|
|
40
|
+
Condition: [...t.Condition, n]
|
|
41
|
+
} : u(t) ? {
|
|
42
|
+
...t,
|
|
43
|
+
Condition: l(t.Condition, o, n)
|
|
44
|
+
} : t);
|
|
45
|
+
function H(r = {}) {
|
|
46
|
+
const [o, n] = h(
|
|
47
|
+
() => O(r.conditions || [])
|
|
48
|
+
), [t, g] = h(
|
|
49
|
+
r.operator || "And"
|
|
50
|
+
), C = M(() => {
|
|
51
|
+
if (o.length !== 0)
|
|
52
|
+
return {
|
|
53
|
+
Operator: t,
|
|
54
|
+
Condition: v(o)
|
|
55
|
+
};
|
|
56
|
+
}, [o, t]), S = o.length > 0, w = c(
|
|
57
|
+
(i, s) => {
|
|
58
|
+
const d = f(), e = { ...i, id: d };
|
|
59
|
+
return n(s ? (a) => l(a, s, e) : (a) => [...a, e]), d;
|
|
60
|
+
},
|
|
61
|
+
[]
|
|
62
|
+
), F = c(
|
|
63
|
+
(i, s) => {
|
|
64
|
+
const d = f(), e = {
|
|
65
|
+
id: d,
|
|
66
|
+
Operator: i,
|
|
67
|
+
Condition: []
|
|
68
|
+
};
|
|
69
|
+
return n(s ? (a) => l(a, s, e) : (a) => [...a, e]), d;
|
|
70
|
+
},
|
|
71
|
+
[]
|
|
72
|
+
), T = c(
|
|
73
|
+
(i, s) => {
|
|
74
|
+
n(
|
|
75
|
+
(d) => p(d, i, (e) => u(e) ? e : { ...e, ...s })
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
[]
|
|
79
|
+
), _ = c(
|
|
80
|
+
(i, s) => {
|
|
81
|
+
n(
|
|
82
|
+
(d) => p(d, i, (e) => u(e) ? { ...e, Operator: s } : e)
|
|
83
|
+
);
|
|
84
|
+
},
|
|
85
|
+
[]
|
|
86
|
+
), $ = c((i) => {
|
|
87
|
+
n((s) => I(s, i));
|
|
88
|
+
}, []), b = c(
|
|
89
|
+
(i) => G(o, i),
|
|
90
|
+
[o]
|
|
91
|
+
), y = c(() => {
|
|
92
|
+
n([]);
|
|
93
|
+
}, []), A = c((i) => {
|
|
94
|
+
g(i);
|
|
95
|
+
}, []);
|
|
96
|
+
return {
|
|
97
|
+
// State
|
|
98
|
+
operator: t,
|
|
99
|
+
items: o,
|
|
100
|
+
payload: C,
|
|
101
|
+
hasConditions: S,
|
|
102
|
+
// Add operations
|
|
103
|
+
addCondition: w,
|
|
104
|
+
addConditionGroup: F,
|
|
105
|
+
// Update operations
|
|
106
|
+
updateCondition: T,
|
|
107
|
+
updateGroupOperator: _,
|
|
108
|
+
// Remove & access
|
|
109
|
+
removeCondition: $,
|
|
110
|
+
getCondition: b,
|
|
111
|
+
// Utility
|
|
112
|
+
clearAllConditions: y,
|
|
113
|
+
setRootOperator: A
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
u as a,
|
|
118
|
+
D as i,
|
|
119
|
+
H as u
|
|
120
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ListOptionsType, FilterType, SortType } from "../../types/common";
|
|
2
|
+
/**
|
|
3
|
+
* Options for building list API request options
|
|
4
|
+
*/
|
|
5
|
+
export interface BuildListOptionsParams<T = any> {
|
|
6
|
+
/** Search query string */
|
|
7
|
+
search?: string;
|
|
8
|
+
/** Filter payload */
|
|
9
|
+
filter?: FilterType<T>;
|
|
10
|
+
/** Sort configuration */
|
|
11
|
+
sort?: {
|
|
12
|
+
field: keyof T | null;
|
|
13
|
+
direction: "asc" | "desc" | null;
|
|
14
|
+
};
|
|
15
|
+
/** Sort array in API format */
|
|
16
|
+
sortArray?: SortType;
|
|
17
|
+
/** Pagination settings */
|
|
18
|
+
pagination?: {
|
|
19
|
+
pageNo: number;
|
|
20
|
+
pageSize: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Build list options for count queries
|
|
25
|
+
* Excludes pagination and sorting (they don't affect count)
|
|
26
|
+
*/
|
|
27
|
+
export declare function buildCountOptions<T = any>(params: Pick<BuildListOptionsParams<T>, "search" | "filter">): ListOptionsType;
|
|
28
|
+
/**
|
|
29
|
+
* Build list options for data queries
|
|
30
|
+
* Includes all options: search, filter, sort, pagination
|
|
31
|
+
*/
|
|
32
|
+
export declare function buildListOptions<T = any>(params: BuildListOptionsParams<T>): ListOptionsType;
|
|
33
|
+
/**
|
|
34
|
+
* Combine filter payload with additional column filter
|
|
35
|
+
* Used for kanban column-specific queries
|
|
36
|
+
*/
|
|
37
|
+
export declare function combineFilters<T = any>(baseFilter: FilterType<T> | undefined, additionalCondition: {
|
|
38
|
+
LHSField: string;
|
|
39
|
+
Operator: string;
|
|
40
|
+
RHSValue: any;
|
|
41
|
+
RHSType?: string;
|
|
42
|
+
}): FilterType<T>;
|
|
43
|
+
//# sourceMappingURL=buildListOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildListOptions.d.ts","sourceRoot":"","sources":["../../../sdk/utils/api/buildListOptions.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,CAAC,GAAG,GAAG;IAC7C,0BAA0B;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qBAAqB;IACrB,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACvB,yBAAyB;IACzB,IAAI,CAAC,EAAE;QACL,KAAK,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;QACtB,SAAS,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC;KAClC,CAAC;IACF,+BAA+B;IAC/B,SAAS,CAAC,EAAE,QAAQ,CAAC;IACrB,0BAA0B;IAC1B,UAAU,CAAC,EAAE;QACX,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,GAAG,EACvC,MAAM,EAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC,GAC3D,eAAe,CAYjB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,GAAG,EACtC,MAAM,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAChC,eAAe,CAyBjB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,GAAG,GAAG,EACpC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,EACrC,mBAAmB,EAAE;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,GAAG,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACA,UAAU,CAAC,CAAC,CAAC,CAyBf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../sdk/utils/api/index.ts"],"names":[],"mappings":"AACA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safely convert unknown error to Error object
|
|
3
|
+
* Handles all possible error types that could be thrown
|
|
4
|
+
*/
|
|
5
|
+
export declare function toError(err: unknown): Error;
|
|
6
|
+
/**
|
|
7
|
+
* Type guard to check if a value is an Error
|
|
8
|
+
*/
|
|
9
|
+
export declare function isError(value: unknown): value is Error;
|
|
10
|
+
/**
|
|
11
|
+
* Type guard to check if error has a specific code
|
|
12
|
+
*/
|
|
13
|
+
export declare function hasErrorCode(err: unknown, code: string): err is Error & {
|
|
14
|
+
code: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Type guard to check if error is a network error
|
|
18
|
+
*/
|
|
19
|
+
export declare function isNetworkError(err: unknown): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Type guard to check if error is a timeout error
|
|
22
|
+
*/
|
|
23
|
+
export declare function isTimeoutError(err: unknown): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Type guard to check if error is an abort error
|
|
26
|
+
*/
|
|
27
|
+
export declare function isAbortError(err: unknown): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Extract error message from unknown error
|
|
30
|
+
*/
|
|
31
|
+
export declare function getErrorMessage(err: unknown): string;
|
|
32
|
+
/**
|
|
33
|
+
* Safe error handler wrapper for async functions
|
|
34
|
+
* Returns a tuple of [result, error]
|
|
35
|
+
*/
|
|
36
|
+
export declare function tryCatch<T>(fn: () => Promise<T>): Promise<[T, null] | [null, Error]>;
|
|
37
|
+
/**
|
|
38
|
+
* Create a wrapped error with original error as cause
|
|
39
|
+
*/
|
|
40
|
+
export declare function wrapError(message: string, cause: unknown): Error;
|
|
41
|
+
//# sourceMappingURL=error-handling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handling.d.ts","sourceRoot":"","sources":["../../sdk/utils/error-handling.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,CA0B3C;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAEtD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,MAAM,GACX,GAAG,IAAI,KAAK,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAMjC;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAYpD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAQpD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAIlD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAmBpD;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAC9B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAOpC;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,CAUhE"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../sdk/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAG7B,cAAc,MAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../sdk/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAG7B,cAAc,MAAM,CAAC;AAGrB,cAAc,kBAAkB,CAAC;AAGjC,cAAc,OAAO,CAAC"}
|