@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
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const o=require("./client-
|
|
1
|
+
"use strict";const o=require("./client-DxjRcEtN.cjs");async function c(e){try{const r=o.getApiBaseUrl(),s=o.getDefaultHeaders(),a=await fetch(`${r}/api/app/meta/bdo/${e}`,{method:"GET",headers:s});if(!a.ok)throw new Error(`Failed to fetch schema for ${e}: ${a.statusText}`);const t=await a.json();if(!t||typeof t!="object")throw new Error(`Invalid BDO schema response for ${e}`);return t}catch(r){throw console.error(`Schema fetch error for ${e}:`,r),new Error(`Failed to load BDO schema: ${r instanceof Error?r.message:"Unknown error"}`)}}async function n(e){try{const r=o.getApiBaseUrl(),s=o.getDefaultHeaders(),a=e!=null&&e.Filter||e!=null&&e.Sort?"POST":"GET",t=await fetch(`${r}/api/app/metadata/list`,{method:a,headers:s,...a==="POST"&&e&&{body:JSON.stringify(e)}});if(!t.ok)throw new Error(`Failed to list metadata: ${t.statusText}`);return await t.json()}catch(r){throw console.error("Metadata list error:",r),new Error(`Failed to list metadata: ${r instanceof Error?r.message:"Unknown error"}`)}}exports.getBdoSchema=c;exports.listMetadata=n;
|
package/dist/table.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),O=require("@tanstack/react-query"),A=require("./client-DxjRcEtN.cjs"),h=require("./error-handling-CAoD0Kwb.cjs"),re=require("./useFilter-DzpP_ag0.cjs");function oe(o){var Q,z,M,P,F,w,R,x;const[s,b]=t.useState({query:"",debouncedQuery:""}),c=t.useRef(null),j=300,G=()=>{var r,y;const e=(r=o.initialState)==null?void 0:r.sort;if(e&&e.length>0){const D=e[0],L=Object.keys(D)[0],te=(y=D[L])==null?void 0:y.toLowerCase();return{field:L,direction:te}}return{field:null,direction:null}},[n,p]=t.useState(G),[a,i]=t.useState({pageNo:((z=(Q=o.initialState)==null?void 0:Q.pagination)==null?void 0:z.pageNo)||1,pageSize:((P=(M=o.initialState)==null?void 0:M.pagination)==null?void 0:P.pageSize)||10}),u=re.useFilter({conditions:(w=(F=o.initialState)==null?void 0:F.filter)==null?void 0:w.conditions,operator:((x=(R=o.initialState)==null?void 0:R.filter)==null?void 0:x.operator)||"And"}),l=t.useMemo(()=>{const e={};return s.debouncedQuery&&(e.Search=s.debouncedQuery),u.payload&&(e.Filter=u.payload),e},[s.debouncedQuery,u.payload]),N=t.useMemo(()=>{const e={...l};return n.field&&n.direction&&(e.Sort=[{[String(n.field)]:n.direction==="asc"?"ASC":"DESC"}]),e.Page=a.pageNo,e.PageSize=a.pageSize,e},[l,n,a]),{data:g,isLoading:H,isFetching:I,error:q,refetch:E}=O.useQuery({queryKey:["table",o.source,N],queryFn:async()=>{try{const e=await A.api(o.source).list(N);return o.onSuccess&&o.onSuccess(e.Data),e}catch(e){throw o.onError&&o.onError(h.toError(e)),e}},staleTime:0,gcTime:0}),{data:d,isLoading:K,isFetching:_,error:T,refetch:k}=O.useQuery({queryKey:["table-count",o.source,l],queryFn:async()=>{try{return await A.api(o.source).count(l)}catch(e){throw o.onError&&o.onError(h.toError(e)),e}},staleTime:0,gcTime:0}),B=t.useMemo(()=>(g==null?void 0:g.Data)||[],[g]),f=t.useMemo(()=>(d==null?void 0:d.Count)||0,[d]),S=t.useMemo(()=>Math.ceil(f/a.pageSize),[f,a.pageSize]),U=t.useCallback(e=>{p(r=>{if(r.field===e){if(r.direction==="asc")return{field:e,direction:"desc"};if(r.direction==="desc")return{field:null,direction:null}}return{field:e,direction:"asc"}})},[]),J=t.useCallback(()=>{p({field:null,direction:null})},[]),V=t.useCallback((e,r)=>{p({field:e,direction:r})},[]),W=t.useCallback(e=>{if(e.length>255){console.warn("Search query exceeds maximum length of 255 characters");return}b(r=>({...r,query:e})),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{b(r=>({...r,debouncedQuery:e})),i(r=>({...r,pageNo:1}))},j)},[]),X=t.useCallback(()=>{c.current&&clearTimeout(c.current),b({query:"",debouncedQuery:""}),i(e=>({...e,pageNo:1}))},[]);t.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]);const m=a.pageNo<S,C=a.pageNo>1,Y=t.useCallback(()=>{m&&i(e=>({...e,pageNo:e.pageNo+1}))},[m]),Z=t.useCallback(()=>{C&&i(e=>({...e,pageNo:e.pageNo-1}))},[C]),$=t.useCallback(e=>{const r=Math.max(1,Math.min(e,S));i(y=>({...y,pageNo:r}))},[S]),v=t.useCallback(e=>{i(r=>({...r,pageSize:e,pageNo:1}))},[]),ee=t.useCallback(async()=>{const[e]=await Promise.all([E(),k()]);return e.data||{Data:[]}},[E,k]);return{rows:B,totalItems:f,isLoading:H||K,isFetching:I||_,error:q?h.toError(q):T?h.toError(T):null,search:{query:s.query,setQuery:W,clear:X},sort:{field:n.field,direction:n.direction,toggle:U,clear:J,set:V},filter:u,pagination:{pageNo:a.pageNo,pageSize:a.pageSize,totalPages:S,totalItems:f,canGoNext:m,canGoPrevious:C,goToNext:Y,goToPrevious:Z,goToPage:$,setPageSize:v},refetch:ee}}exports.useTable=oe;
|
package/dist/table.mjs
CHANGED
|
@@ -1,148 +1,165 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { useQuery as
|
|
3
|
-
import { a as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { useState as q, useRef as ne, useMemo as s, useCallback as o, useEffect as ie } from "react";
|
|
2
|
+
import { useQuery as G } from "@tanstack/react-query";
|
|
3
|
+
import { a as I } from "./client-BIkaIr2y.js";
|
|
4
|
+
import { t as p } from "./error-handling-CrhTtD88.js";
|
|
5
|
+
import { u as ce } from "./useFilter-H5bgAZQF.js";
|
|
6
|
+
function de(r) {
|
|
7
|
+
var w, F, x, R, D, L, M, A;
|
|
8
|
+
const [u, m] = q({
|
|
9
|
+
query: "",
|
|
10
|
+
debouncedQuery: ""
|
|
11
|
+
}), i = ne(null), K = 300, _ = () => {
|
|
12
|
+
var t, h;
|
|
13
|
+
const e = (t = r.initialState) == null ? void 0 : t.sort;
|
|
14
|
+
if (e && e.length > 0) {
|
|
15
|
+
const O = e[0], k = Object.keys(O)[0], oe = (h = O[k]) == null ? void 0 : h.toLowerCase();
|
|
16
|
+
return { field: k, direction: oe };
|
|
17
|
+
}
|
|
18
|
+
return { field: null, direction: null };
|
|
19
|
+
}, [c, N] = q(_), [n, a] = q({
|
|
20
|
+
pageNo: ((F = (w = r.initialState) == null ? void 0 : w.pagination) == null ? void 0 : F.pageNo) || 1,
|
|
21
|
+
pageSize: ((R = (x = r.initialState) == null ? void 0 : x.pagination) == null ? void 0 : R.pageSize) || 10
|
|
22
|
+
}), l = ce({
|
|
23
|
+
conditions: (L = (D = r.initialState) == null ? void 0 : D.filter) == null ? void 0 : L.conditions,
|
|
24
|
+
operator: ((A = (M = r.initialState) == null ? void 0 : M.filter) == null ? void 0 : A.operator) || "And"
|
|
25
|
+
}), g = s(() => {
|
|
19
26
|
const e = {};
|
|
20
|
-
return
|
|
21
|
-
}, [
|
|
22
|
-
const e = { ...
|
|
23
|
-
return
|
|
27
|
+
return u.debouncedQuery && (e.Search = u.debouncedQuery), l.payload && (e.Filter = l.payload), e;
|
|
28
|
+
}, [u.debouncedQuery, l.payload]), E = s(() => {
|
|
29
|
+
const e = { ...g };
|
|
30
|
+
return c.field && c.direction && (e.Sort = [
|
|
24
31
|
{
|
|
25
|
-
[String(
|
|
32
|
+
[String(c.field)]: c.direction === "asc" ? "ASC" : "DESC"
|
|
26
33
|
}
|
|
27
|
-
]),
|
|
28
|
-
}, [
|
|
29
|
-
data:
|
|
30
|
-
isLoading:
|
|
31
|
-
isFetching:
|
|
32
|
-
error:
|
|
33
|
-
refetch:
|
|
34
|
-
} =
|
|
35
|
-
queryKey: ["table",
|
|
34
|
+
]), e.Page = n.pageNo, e.PageSize = n.pageSize, e;
|
|
35
|
+
}, [g, c, n]), {
|
|
36
|
+
data: d,
|
|
37
|
+
isLoading: j,
|
|
38
|
+
isFetching: B,
|
|
39
|
+
error: z,
|
|
40
|
+
refetch: C
|
|
41
|
+
} = G({
|
|
42
|
+
queryKey: ["table", r.source, E],
|
|
36
43
|
queryFn: async () => {
|
|
37
44
|
try {
|
|
38
|
-
const e = await
|
|
39
|
-
return
|
|
45
|
+
const e = await I(r.source).list(E);
|
|
46
|
+
return r.onSuccess && r.onSuccess(e.Data), e;
|
|
40
47
|
} catch (e) {
|
|
41
|
-
throw
|
|
48
|
+
throw r.onError && r.onError(p(e)), e;
|
|
42
49
|
}
|
|
43
50
|
},
|
|
44
51
|
staleTime: 0,
|
|
45
52
|
gcTime: 0
|
|
46
53
|
}), {
|
|
47
54
|
data: f,
|
|
48
|
-
isLoading:
|
|
49
|
-
isFetching:
|
|
50
|
-
error:
|
|
51
|
-
refetch:
|
|
52
|
-
} =
|
|
53
|
-
queryKey: ["table-count",
|
|
55
|
+
isLoading: H,
|
|
56
|
+
isFetching: U,
|
|
57
|
+
error: P,
|
|
58
|
+
refetch: Q
|
|
59
|
+
} = G({
|
|
60
|
+
queryKey: ["table-count", r.source, g],
|
|
54
61
|
queryFn: async () => {
|
|
55
62
|
try {
|
|
56
|
-
return await
|
|
63
|
+
return await I(r.source).count(g);
|
|
57
64
|
} catch (e) {
|
|
58
|
-
throw
|
|
65
|
+
throw r.onError && r.onError(p(e)), e;
|
|
59
66
|
}
|
|
60
67
|
},
|
|
61
68
|
staleTime: 0,
|
|
62
69
|
gcTime: 0
|
|
63
|
-
}),
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
if (
|
|
70
|
+
}), J = s(() => (d == null ? void 0 : d.Data) || [], [d]), S = s(() => (f == null ? void 0 : f.Count) || 0, [f]), y = s(() => Math.ceil(S / n.pageSize), [S, n.pageSize]), V = o((e) => {
|
|
71
|
+
N((t) => {
|
|
72
|
+
if (t.field === e) {
|
|
73
|
+
if (t.direction === "asc")
|
|
67
74
|
return { field: e, direction: "desc" };
|
|
68
|
-
if (
|
|
75
|
+
if (t.direction === "desc")
|
|
69
76
|
return { field: null, direction: null };
|
|
70
77
|
}
|
|
71
78
|
return { field: e, direction: "asc" };
|
|
72
79
|
});
|
|
73
|
-
}, []),
|
|
74
|
-
|
|
75
|
-
}, []),
|
|
76
|
-
(e,
|
|
77
|
-
|
|
80
|
+
}, []), W = o(() => {
|
|
81
|
+
N({ field: null, direction: null });
|
|
82
|
+
}, []), X = o(
|
|
83
|
+
(e, t) => {
|
|
84
|
+
N({ field: e, direction: t });
|
|
78
85
|
},
|
|
79
86
|
[]
|
|
80
|
-
),
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}, [
|
|
87
|
+
), Y = o((e) => {
|
|
88
|
+
if (e.length > 255) {
|
|
89
|
+
console.warn("Search query exceeds maximum length of 255 characters");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
m((t) => ({ ...t, query: e })), i.current && clearTimeout(i.current), i.current = setTimeout(() => {
|
|
93
|
+
m((t) => ({ ...t, debouncedQuery: e })), a((t) => ({ ...t, pageNo: 1 }));
|
|
94
|
+
}, K);
|
|
95
|
+
}, []), Z = o(() => {
|
|
96
|
+
i.current && clearTimeout(i.current), m({ query: "", debouncedQuery: "" }), a((e) => ({ ...e, pageNo: 1 }));
|
|
97
|
+
}, []);
|
|
98
|
+
ie(() => () => {
|
|
99
|
+
i.current && clearTimeout(i.current);
|
|
100
|
+
}, []);
|
|
101
|
+
const b = n.pageNo < y, T = n.pageNo > 1, $ = o(() => {
|
|
102
|
+
b && a((e) => ({ ...e, pageNo: e.pageNo + 1 }));
|
|
103
|
+
}, [b]), v = o(() => {
|
|
104
|
+
T && a((e) => ({ ...e, pageNo: e.pageNo - 1 }));
|
|
105
|
+
}, [T]), ee = o(
|
|
89
106
|
(e) => {
|
|
90
|
-
const
|
|
91
|
-
|
|
107
|
+
const t = Math.max(1, Math.min(e, y));
|
|
108
|
+
a((h) => ({ ...h, pageNo: t }));
|
|
92
109
|
},
|
|
93
|
-
[
|
|
94
|
-
),
|
|
95
|
-
|
|
96
|
-
...
|
|
110
|
+
[y]
|
|
111
|
+
), te = o((e) => {
|
|
112
|
+
a((t) => ({
|
|
113
|
+
...t,
|
|
97
114
|
pageSize: e,
|
|
98
115
|
pageNo: 1
|
|
99
116
|
}));
|
|
100
|
-
}, []),
|
|
101
|
-
const [e] = await Promise.all([
|
|
117
|
+
}, []), re = o(async () => {
|
|
118
|
+
const [e] = await Promise.all([C(), Q()]);
|
|
102
119
|
return e.data || { Data: [] };
|
|
103
|
-
}, [
|
|
120
|
+
}, [C, Q]);
|
|
104
121
|
return {
|
|
105
122
|
// Data
|
|
106
|
-
rows:
|
|
107
|
-
totalItems:
|
|
123
|
+
rows: J,
|
|
124
|
+
totalItems: S,
|
|
108
125
|
// Loading States
|
|
109
|
-
isLoading:
|
|
110
|
-
isFetching:
|
|
126
|
+
isLoading: j || H,
|
|
127
|
+
isFetching: B || U,
|
|
111
128
|
// Error Handling
|
|
112
|
-
error:
|
|
129
|
+
error: z ? p(z) : P ? p(P) : null,
|
|
113
130
|
// Search (Flat Access)
|
|
114
131
|
search: {
|
|
115
|
-
query:
|
|
116
|
-
setQuery:
|
|
117
|
-
clear:
|
|
132
|
+
query: u.query,
|
|
133
|
+
setQuery: Y,
|
|
134
|
+
clear: Z
|
|
118
135
|
},
|
|
119
136
|
// Sorting (Flat Access)
|
|
120
137
|
sort: {
|
|
121
|
-
field:
|
|
122
|
-
direction:
|
|
123
|
-
toggle:
|
|
124
|
-
clear:
|
|
125
|
-
set:
|
|
138
|
+
field: c.field,
|
|
139
|
+
direction: c.direction,
|
|
140
|
+
toggle: V,
|
|
141
|
+
clear: W,
|
|
142
|
+
set: X
|
|
126
143
|
},
|
|
127
144
|
// Filter (Simplified chainable API)
|
|
128
145
|
filter: l,
|
|
129
146
|
// Pagination (Flat Access)
|
|
130
147
|
pagination: {
|
|
131
|
-
|
|
132
|
-
pageSize:
|
|
133
|
-
totalPages:
|
|
134
|
-
totalItems:
|
|
135
|
-
canGoNext:
|
|
136
|
-
canGoPrevious:
|
|
137
|
-
goToNext:
|
|
138
|
-
goToPrevious:
|
|
139
|
-
goToPage:
|
|
140
|
-
setPageSize:
|
|
148
|
+
pageNo: n.pageNo,
|
|
149
|
+
pageSize: n.pageSize,
|
|
150
|
+
totalPages: y,
|
|
151
|
+
totalItems: S,
|
|
152
|
+
canGoNext: b,
|
|
153
|
+
canGoPrevious: T,
|
|
154
|
+
goToNext: $,
|
|
155
|
+
goToPrevious: v,
|
|
156
|
+
goToPage: ee,
|
|
157
|
+
setPageSize: te
|
|
141
158
|
},
|
|
142
159
|
// Operations
|
|
143
|
-
refetch:
|
|
160
|
+
refetch: re
|
|
144
161
|
};
|
|
145
162
|
}
|
|
146
163
|
export {
|
|
147
|
-
|
|
164
|
+
de as useTable
|
|
148
165
|
};
|
package/dist/table.types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { UseTableOptionsType, UseTableReturnType, ColumnDefinitionType, } from './components/hooks/useTable/types';
|
|
1
|
+
export type { UseTableOptionsType, UseTableReturnType, ColumnDefinitionType, PaginationStateType, } from './components/hooks/useTable/types';
|
|
2
2
|
//# sourceMappingURL=table.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.types.d.ts","sourceRoot":"","sources":["../sdk/table.types.ts"],"names":[],"mappings":"AAKA,YAAY,EAEV,mBAAmB,EACnB,kBAAkB,EAGlB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"table.types.d.ts","sourceRoot":"","sources":["../sdk/table.types.ts"],"names":[],"mappings":"AAKA,YAAY,EAEV,mBAAmB,EACnB,kBAAkB,EAGlB,oBAAoB,EAGpB,mBAAmB,GACpB,MAAM,mCAAmC,CAAC"}
|
|
@@ -57,26 +57,44 @@ export type LongFieldType = number;
|
|
|
57
57
|
* Use this for true/false values, flags, toggles
|
|
58
58
|
*/
|
|
59
59
|
export type BooleanFieldType = boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Encoded date format from API response
|
|
62
|
+
* API returns: { "$__d__": "YYYY-MM-DD" }
|
|
63
|
+
*/
|
|
64
|
+
export interface DateEncodedType {
|
|
65
|
+
$__d__: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Encoded datetime format from API response
|
|
69
|
+
* API returns: { "$__dt__": unix_timestamp_seconds }
|
|
70
|
+
*/
|
|
71
|
+
export interface DateTimeEncodedType {
|
|
72
|
+
$__dt__: number;
|
|
73
|
+
}
|
|
60
74
|
/**
|
|
61
75
|
* Date field (date only, no time)
|
|
62
|
-
*
|
|
76
|
+
* API Response Format: { "$__d__": "YYYY-MM-DD" }
|
|
77
|
+
* API Request Format: "YYYY-MM-DD"
|
|
63
78
|
* Storage: DATE in database
|
|
64
79
|
* Use this for birth dates, due dates, calendar events
|
|
65
80
|
*
|
|
66
81
|
* @example
|
|
67
|
-
*
|
|
82
|
+
* // Response from API:
|
|
83
|
+
* { "$__d__": "2025-03-15" }
|
|
68
84
|
*/
|
|
69
|
-
export type DateFieldType =
|
|
85
|
+
export type DateFieldType = DateEncodedType;
|
|
70
86
|
/**
|
|
71
87
|
* DateTime field (date and time)
|
|
72
|
-
*
|
|
88
|
+
* API Response Format: { "$__dt__": unix_timestamp_seconds }
|
|
89
|
+
* API Request Format: "YYYY-MM-DD HH:MM:SS"
|
|
73
90
|
* Storage: DATETIME/TIMESTAMP in database
|
|
74
91
|
* Use this for created_at, updated_at, event timestamps
|
|
75
92
|
*
|
|
76
93
|
* @example
|
|
77
|
-
*
|
|
94
|
+
* // Response from API:
|
|
95
|
+
* { "$__dt__": 1769110463 }
|
|
78
96
|
*/
|
|
79
|
-
export type DateTimeFieldType =
|
|
97
|
+
export type DateTimeFieldType = DateTimeEncodedType;
|
|
80
98
|
/**
|
|
81
99
|
* Currency field supporting multiple value formats
|
|
82
100
|
* Resolves to: CurrencyValueType
|
|
@@ -106,7 +124,49 @@ export type CurrencyValueType = {
|
|
|
106
124
|
* JSONFieldType<{settings: {theme: string}}> // => {settings: {theme: string}}
|
|
107
125
|
*/
|
|
108
126
|
export type JSONFieldType<T = JSONValueType> = T;
|
|
109
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Reference/Lookup field for relationships to other Business Data Objects
|
|
129
|
+
*
|
|
130
|
+
* @template TReferencedType - The full type of the referenced BDO record
|
|
131
|
+
*
|
|
132
|
+
* Runtime behavior:
|
|
133
|
+
* - The field stores the full referenced record (e.g., full supplier object)
|
|
134
|
+
* - API returns the complete record from the referenced BDO
|
|
135
|
+
* - On save, the full object is sent in the payload
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* SupplierInfo: ReferenceFieldType<BaseSupplierType>;
|
|
139
|
+
* // At runtime: { _id: "...", SupplierId: "...", SupplierName: "...", ... }
|
|
140
|
+
*/
|
|
141
|
+
export type ReferenceFieldType<TReferencedType = unknown> = TReferencedType;
|
|
142
|
+
/**
|
|
143
|
+
* Extract the referenced type from a ReferenceFieldType
|
|
144
|
+
* Note: Since ReferenceFieldType<T> = T, this just returns T if it has _id
|
|
145
|
+
*/
|
|
146
|
+
export type ExtractReferenceType<T> = T extends {
|
|
147
|
+
_id: string;
|
|
148
|
+
} ? T : never;
|
|
149
|
+
/**
|
|
150
|
+
* Extract the type that fetchField should return for a given field type
|
|
151
|
+
* - For Reference fields (objects with _id) → the full referenced record type
|
|
152
|
+
* - For other field types → { Value: string; Label: string } (static dropdown)
|
|
153
|
+
*
|
|
154
|
+
* Detection: All BDO types have _id: string, so we check for that property
|
|
155
|
+
* to distinguish reference fields from primitive fields like StringFieldType.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* type SupplierOptions = ExtractFetchFieldType<BaseProductType["SupplierInfo"]>;
|
|
159
|
+
* // Result: BaseSupplierType (has _id)
|
|
160
|
+
*
|
|
161
|
+
* type CategoryOptions = ExtractFetchFieldType<BaseProductType["Category"]>;
|
|
162
|
+
* // Result: { Value: string; Label: string } (string has no _id)
|
|
163
|
+
*/
|
|
164
|
+
export type ExtractFetchFieldType<T> = T extends {
|
|
165
|
+
_id: string;
|
|
166
|
+
} ? T : {
|
|
167
|
+
Value: string;
|
|
168
|
+
Label: string;
|
|
169
|
+
};
|
|
110
170
|
/**
|
|
111
171
|
* Valid JSON value types
|
|
112
172
|
*/
|
|
@@ -128,17 +188,11 @@ export interface JSONArrayType extends Array<JSONValueType> {
|
|
|
128
188
|
*/
|
|
129
189
|
export type SelectFieldType<T extends string> = T;
|
|
130
190
|
/**
|
|
131
|
-
* Lookup
|
|
132
|
-
* @template
|
|
133
|
-
*
|
|
134
|
-
* Storage: VARCHAR in database (stores the ID)
|
|
135
|
-
* Use this for foreign keys, relationships, references
|
|
136
|
-
*
|
|
137
|
-
* @example
|
|
138
|
-
* LookupFieldType // => string (referenced record ID)
|
|
139
|
-
* LookupFieldType<IdFieldType> // => string (typed as IdFieldType)
|
|
191
|
+
* Alias for ReferenceFieldType (Lookup = Reference in the backend)
|
|
192
|
+
* @template TReferencedType - The full type of the referenced BDO record
|
|
193
|
+
* @deprecated Use ReferenceFieldType instead
|
|
140
194
|
*/
|
|
141
|
-
export type LookupFieldType<
|
|
195
|
+
export type LookupFieldType<TReferencedType = unknown> = ReferenceFieldType<TReferencedType>;
|
|
142
196
|
/**
|
|
143
197
|
* Array field with MultiValue support
|
|
144
198
|
* @template T - Type of array elements
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-fields.d.ts","sourceRoot":"","sources":["../../sdk/types/base-fields.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,eAAe,CACzB,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,UAAU,SAAS,MAAM,GAAG,KAAK,EACjC,UAAU,SAAS,MAAM,GAAG,KAAK,IAC/B,CAAC,CAAC;AAEN;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEvC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,CAAC,UAAU,SAAS,MAAM,GAAG,KAAK,IAAI,MAAM,CAAC;AAExE;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAEvC
|
|
1
|
+
{"version":3,"file":"base-fields.d.ts","sourceRoot":"","sources":["../../sdk/types/base-fields.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,eAAe,CACzB,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,UAAU,SAAS,MAAM,GAAG,KAAK,EACjC,UAAU,SAAS,MAAM,GAAG,KAAK,IAC/B,CAAC,CAAC;AAEN;;;;;;;;GAQG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AC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvC;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,cAAc,GACd,aAAa,CAAC;AAElB,MAAM,WAAW,cAAc;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAC;CAC9B;AAED,MAAM,WAAW,aAAc,SAAQ,KAAK,CAAC,aAAa,CAAC;CAAG;AAE9D;;;;;;;;;GASG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,CAAC;AAElD;;;;GAIG;AACH,MAAM,MAAM,eAAe,CAAC,eAAe,GAAG,OAAO,IAAI,kBAAkB,CAAC,eAAe,CAAC,CAAC;AAM7F;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AAEpC;;;;;;;;;GASG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;AAE/D;;;;;;;;;GASG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;AAMjD;;;GAGG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,CAAC,SAAS,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC"}
|
package/dist/types/common.d.ts
CHANGED
|
@@ -27,14 +27,15 @@ export type ConditionGroupOperatorType = "And" | "Or" | "Not";
|
|
|
27
27
|
export type FilterRHSTypeType = "Constant" | "BOField" | "AppVariable";
|
|
28
28
|
/**
|
|
29
29
|
* Leaf condition (actual field comparison)
|
|
30
|
+
* @template T - Data type for type-safe field names (defaults to any)
|
|
30
31
|
*/
|
|
31
|
-
export interface ConditionType {
|
|
32
|
+
export interface ConditionType<T = any> {
|
|
32
33
|
/** Optional ID for hook state management (omitted in API payload) */
|
|
33
34
|
id?: string;
|
|
34
35
|
/** Condition operator */
|
|
35
36
|
Operator: ConditionOperatorType;
|
|
36
|
-
/** Left-hand side field name */
|
|
37
|
-
LHSField: string;
|
|
37
|
+
/** Left-hand side field name (keyof T when generic is provided) */
|
|
38
|
+
LHSField: T extends any ? keyof T | string : string;
|
|
38
39
|
/** Right-hand side value */
|
|
39
40
|
RHSValue: any;
|
|
40
41
|
/** Right-hand side type (optional, defaults to Constant) */
|
|
@@ -42,31 +43,21 @@ export interface ConditionType {
|
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
44
45
|
* Group combining conditions (recursive structure)
|
|
46
|
+
* @template T - Data type for type-safe field names (defaults to any)
|
|
45
47
|
*/
|
|
46
|
-
export interface ConditionGroupType {
|
|
48
|
+
export interface ConditionGroupType<T = any> {
|
|
47
49
|
/** Optional ID for hook state management (omitted in API payload) */
|
|
48
50
|
id?: string;
|
|
49
51
|
/** Group operator (And, Or, Not) */
|
|
50
52
|
Operator: ConditionGroupOperatorType;
|
|
51
53
|
/** Nested conditions (can be Condition or ConditionGroup) */
|
|
52
|
-
Condition: Array<ConditionType | ConditionGroupType
|
|
54
|
+
Condition: Array<ConditionType<T> | ConditionGroupType<T>>;
|
|
53
55
|
}
|
|
54
56
|
/**
|
|
55
57
|
* Root filter type (alias for ConditionGroup)
|
|
58
|
+
* @template T - Data type for type-safe field names (defaults to any)
|
|
56
59
|
*/
|
|
57
|
-
export type FilterType = ConditionGroupType
|
|
58
|
-
/**
|
|
59
|
-
* DateTime encoding format used by the API
|
|
60
|
-
*/
|
|
61
|
-
export interface DateTimeEncodedType {
|
|
62
|
-
$__dt__: number;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Date encoding format used by the API
|
|
66
|
-
*/
|
|
67
|
-
export interface DateEncodedType {
|
|
68
|
-
$__d__: string;
|
|
69
|
-
}
|
|
60
|
+
export type FilterType<T = any> = ConditionGroupType<T>;
|
|
70
61
|
/**
|
|
71
62
|
* Standard paginated list response
|
|
72
63
|
* @template T - Type of items in the list
|
|
@@ -228,4 +219,21 @@ export interface FetchFieldResponseType {
|
|
|
228
219
|
/** Array of field options */
|
|
229
220
|
Data: FetchFieldOptionType[];
|
|
230
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Column definition for data display and behavior
|
|
224
|
+
* Used by useTable and useKanban for defining field configurations
|
|
225
|
+
* @template T - Data type for type-safe field names
|
|
226
|
+
*/
|
|
227
|
+
export interface ColumnDefinitionType<T> {
|
|
228
|
+
/** Field name from the data type */
|
|
229
|
+
fieldId: keyof T;
|
|
230
|
+
/** Display label (optional, defaults to fieldId) */
|
|
231
|
+
label?: string;
|
|
232
|
+
/** Enable sorting for this field */
|
|
233
|
+
enableSorting?: boolean;
|
|
234
|
+
/** Enable filtering for this field */
|
|
235
|
+
enableFiltering?: boolean;
|
|
236
|
+
/** Custom transform function (overrides auto-formatting) */
|
|
237
|
+
transform?: (value: any, item: T) => React.ReactNode;
|
|
238
|
+
}
|
|
231
239
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../sdk/types/common.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,MAAM,CAAC;AAE/C;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,cAAc,EAAE,CAAC;AAExC;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAC7B,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GACzC,SAAS,GAAG,YAAY,GAAG,IAAI,GAAG,KAAK,GACvC,OAAO,GAAG,UAAU,GAAG,UAAU,GAAG,aAAa,GACjD,WAAW,GAAG,WAAW,CAAC;AAE9B;;;G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8B;IAC9B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,yBAAyB;IACzB,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,+BAA+B;IAC/B,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,8CAA8C;IAC9C,IAAI,EAAE,qBAAqB,CAAC;CAC7B;AAMD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,4BAA4B;IAC5B,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,CAAC;CAC1B;AAMD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;CAC7B;AAMD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,6BAA6B;IAC7B,IAAI,EAAE,oBAAoB,EAAE,CAAC;CAC9B;AAMD;;;;GAIG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC,CAAC;IACjB,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oCAAoC;IACpC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,sCAAsC;IACtC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,4DAA4D;IAC5D,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;CACtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const u=require("react"),d=t=>"Condition"in t,y=t=>"LHSField"in t;let A=0;const l=()=>{const t=Math.random().toString(36).substring(2,9);return`filter_${Date.now()}_${t}_${++A}`},M=t=>t.id?t:{...t,id:l()},k=t=>t.map(o=>{const n=M(o);return d(n)?{...n,Condition:k(n.Condition)}:n}),g=t=>t.map(o=>{if(d(o)){const{id:b,...C}=o;return{...C,Condition:g(o.Condition)}}const{id:n,...r}=o;return r}),h=(t,o)=>{for(const n of t){if(n.id===o)return n;if(d(n)){const r=h(n.Condition,o);if(r)return r}}},f=(t,o,n)=>t.map(r=>r.id===o?n(r):d(r)?{...r,Condition:f(r.Condition,o,n)}:r),O=(t,o)=>t.filter(n=>n.id!==o).map(n=>d(n)?{...n,Condition:O(n.Condition,o)}:n),p=(t,o,n)=>t.map(r=>r.id===o&&d(r)?{...r,Condition:[...r.Condition,n]}:d(r)?{...r,Condition:p(r.Condition,o,n)}:r);function R(t={}){const[o,n]=u.useState(()=>k(t.conditions||[])),[r,b]=u.useState(t.operator||"And"),C=u.useMemo(()=>{if(o.length!==0)return{Operator:r,Condition:g(o)}},[o,r]),G=o.length>0,S=u.useCallback((i,s)=>{const c=l(),e={...i,id:c};return n(s?a=>p(a,s,e):a=>[...a,e]),c},[]),v=u.useCallback((i,s)=>{const c=l(),e={id:c,Operator:i,Condition:[]};return n(s?a=>p(a,s,e):a=>[...a,e]),c},[]),F=u.useCallback((i,s)=>{n(c=>f(c,i,e=>d(e)?e:{...e,...s}))},[]),I=u.useCallback((i,s)=>{n(c=>f(c,i,e=>d(e)?{...e,Operator:s}:e))},[]),w=u.useCallback(i=>{n(s=>O(s,i))},[]),T=u.useCallback(i=>h(o,i),[o]),_=u.useCallback(()=>{n([])},[]),$=u.useCallback(i=>{b(i)},[]);return{operator:r,items:o,payload:C,hasConditions:G,addCondition:S,addConditionGroup:v,updateCondition:F,updateGroupOperator:I,removeCondition:w,getCondition:T,clearAllConditions:_,setRootOperator:$}}exports.isCondition=y;exports.isConditionGroup=d;exports.useFilter=R;
|