@ram_28/kf-ai-sdk 2.0.22 → 2.0.24

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/dist/auth.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var J=Object.defineProperty;var X=(e,t,o)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var Q=(e,t,o)=>X(e,typeof t!="symbol"?t+"":t,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),n=require("react"),M=require("@tanstack/react-query"),K=require("./client-D5k4SYuw.cjs"),W=require("./constants-DEmYwKfC.cjs"),Y={sessionEndpoint:"/api/id",providers:{google:{loginPath:"/api/auth/google/login",logoutPath:"/api/auth/logout"}},defaultProvider:"google",autoRedirect:!1,sessionCheckInterval:0,retry:{count:3,delay:1e3},staleTime:5*60*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!0};let h={...Y};function G(e){h={...h,...e,providers:{...h.providers,...e.providers},retry:{...h.retry,...e.retry}}}function Z(e,t){h.providers[e]=t}function b(){return{...h}}function k(){return h.baseUrl||K.getApiBaseUrl()||(typeof window<"u"?window.location.origin:"")}function H(e){return h.providers[e]}function D(){h={...Y}}class m extends Error{constructor(o,r){super(o);Q(this,"statusCode");this.name="AuthenticationError",this.statusCode=r}}async function ee(){const e=b(),t=k(),o=K.getDefaultHeaders(),r=await fetch(`${t}${e.sessionEndpoint}`,{method:"GET",headers:o,credentials:"include"});if(!r.ok)throw r.status===401||r.status===403?new m("Not authenticated",r.status):new m(`Session check failed: ${r.statusText}`,r.status);return await r.json()}function N(e,t){return new Promise(()=>{const o=b(),r=k();if(!r)throw new Error('Auth base URL is not configured. Call setApiBaseUrl("https://...") or configureAuth({ baseUrl: "https://..." }) first.');const i=e||o.defaultProvider,l=H(i);if(!l){const A=Object.keys(o.providers||{}).join(", ")||"none";throw new Error(`Auth provider "${i}" is not configured. Available providers: ${A}`)}if(!l.loginPath)throw new Error(`Login path not configured for provider "${i}". Configure it with: configureAuth({ providers: { ${i}: { loginPath: '/api/auth/...' } } })`);let g;try{g=new URL(`${r}${l.loginPath}`)}catch{throw new Error(`Failed to construct login URL. Base URL: "${r}", Login path: "${l.loginPath}". Ensure baseUrl is a valid URL (e.g., "https://example.com").`)}(t!=null&&t.callbackUrl||o.callbackUrl)&&g.searchParams.set("callbackUrl",(t==null?void 0:t.callbackUrl)||o.callbackUrl||window.location.href),t!=null&&t.params&&Object.entries(t.params).forEach(([A,v])=>{g.searchParams.set(A,v)}),window.open(g.toString(),"_blank")})}async function te(e){const t=b(),o=k(),r=H(t.defaultProvider),i=r==null?void 0:r.logoutPath;if(i&&(e==null?void 0:e.callLogoutEndpoint)!==!1)try{await fetch(`${o}${i}`)}catch(l){console.warn("Logout endpoint call failed:",l)}e!=null&&e.redirectUrl?window.location.href=e.redirectUrl:t.loginRedirectUrl&&(window.location.href=t.loginRedirectUrl)}const V=n.createContext(null),_=["auth","session"];function re({children:e,config:t,onAuthChange:o,onError:r,loadingComponent:i,unauthenticatedComponent:l,skipInitialCheck:g=!1}){const A=n.useRef(!1);t&&!A.current&&(G(t),A.current=!0);const v=M.useQueryClient(),c=b(),{data:u,isLoading:f,error:U,refetch:R,isFetching:C}=M.useQuery({queryKey:_,queryFn:ee,enabled:!g,retry:(s,w)=>w instanceof m&&(w.statusCode===401||w.statusCode===403)?!1:s<c.retry.count,retryDelay:c.retry.delay,staleTime:c.staleTime,gcTime:c.staleTime*2,refetchOnWindowFocus:c.refetchOnWindowFocus??!0,refetchOnReconnect:c.refetchOnReconnect??!0,refetchInterval:c.sessionCheckInterval||!1}),[S,L]=n.useState(null),d=n.useMemo(()=>f||C?"loading":Object.keys((u==null?void 0:u.userDetails)||{}).length>0?"authenticated":"unauthenticated",[f,C,u]),a=(u==null?void 0:u.userDetails)||null,x=(u==null?void 0:u.staticBaseUrl)||null,$=(u==null?void 0:u.buildId)||null,j=d==="authenticated",P=n.useRef(o);P.current=o;const E=n.useRef(r);E.current=r,n.useEffect(()=>{var s;f||(s=P.current)==null||s.call(P,d,a)},[d,a,f]),n.useEffect(()=>{var s;U&&(L(U),(s=E.current)==null||s.call(E,U))},[U]),n.useEffect(()=>{d==="unauthenticated"&&c.autoRedirect&&!f&&N()},[d,f,c.autoRedirect]);const p=n.useCallback((s,w)=>{N(s,w)},[]),q=n.useCallback(async s=>{v.removeQueries({queryKey:_}),await te(s)},[v]),B=n.useCallback(async()=>{if(C)return u||null;try{return(await R()).data||null}catch(s){return L(s),null}},[R,C,u]),O=n.useCallback(s=>(a==null?void 0:a.Role)===s,[a]),I=n.useCallback(s=>s.includes((a==null?void 0:a.Role)||""),[a]),F=n.useCallback(()=>{L(null)},[]),T=n.useCallback(()=>{R()},[R]),z=n.useMemo(()=>({user:a,staticBaseUrl:x,buildId:$,status:d,isAuthenticated:j,isLoading:f,login:p,logout:q,refreshSession:B,hasRole:O,hasAnyRole:I,error:S,clearError:F,_forceCheck:T}),[a,x,$,d,j,f,p,q,B,O,I,S,F,T]);return d==="loading"&&i?y.jsx(y.Fragment,{children:i}):d==="unauthenticated"&&!c.autoRedirect&&l?y.jsx(y.Fragment,{children:l}):y.jsx(V.Provider,{value:z,children:e})}function ne(){const e=n.useContext(V);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}function oe(){const e=ne();return n.useMemo(()=>({user:e.user,staticBaseUrl:e.staticBaseUrl,buildId:e.buildId,status:e.status,isAuthenticated:e.isAuthenticated,isLoading:e.isLoading,login:e.login,logout:e.logout,refreshSession:e.refreshSession,hasRole:e.hasRole,hasAnyRole:e.hasAnyRole,error:e.error,clearError:e.clearError}),[e.user,e.staticBaseUrl,e.buildId,e.status,e.isAuthenticated,e.isLoading,e.login,e.logout,e.refreshSession,e.hasRole,e.hasAnyRole,e.error,e.clearError])}exports.AuthProviderName=W.AuthProviderName;exports.AuthStatus=W.AuthStatus;exports.AuthProvider=re;exports.AuthenticationError=m;exports.configureAuth=G;exports.getAuthBaseUrl=k;exports.getAuthConfig=b;exports.resetAuthConfig=D;exports.setAuthProvider=Z;exports.useAuth=oe;
1
+ "use strict";var J=Object.defineProperty;var X=(e,t,o)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var Q=(e,t,o)=>X(e,typeof t!="symbol"?t+"":t,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),n=require("react"),M=require("@tanstack/react-query"),K=require("./client-D5k4SYuw.cjs"),W=require("./constants-DEmYwKfC.cjs"),Y={sessionEndpoint:"/api/id",providers:{google:{loginPath:"/api/auth/google/login",logoutPath:"/api/auth/logout"}},defaultProvider:"google",autoRedirect:!1,sessionCheckInterval:0,retry:{count:3,delay:1e3},staleTime:5*60*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!0};let h={...Y};function G(e){h={...h,...e,providers:{...h.providers,...e.providers},retry:{...h.retry,...e.retry}}}function Z(e,t){h.providers[e]=t}function b(){return{...h}}function k(){return h.baseUrl||K.getApiBaseUrl()||(typeof window<"u"?window.location.origin:"")}function H(e){return h.providers[e]}function D(){h={...Y}}class E extends Error{constructor(o,r){super(o);Q(this,"statusCode");this.name="AuthenticationError",this.statusCode=r}}async function ee(){const e=b(),t=k(),o=K.getDefaultHeaders(),r=await fetch(`${t}${e.sessionEndpoint}`,{method:"GET",headers:o,credentials:"include"});if(!r.ok)throw r.status===401||r.status===403?new E("Not authenticated",r.status):new E(`Session check failed: ${r.statusText}`,r.status);return await r.json()}function N(e,t){return new Promise(()=>{const o=b(),r=k();if(!r)throw new Error('Auth base URL is not configured. Call setApiBaseUrl("https://...") or configureAuth({ baseUrl: "https://..." }) first.');const i=e||o.defaultProvider,l=H(i);if(!l){const A=Object.keys(o.providers||{}).join(", ")||"none";throw new Error(`Auth provider "${i}" is not configured. Available providers: ${A}`)}if(!l.loginPath)throw new Error(`Login path not configured for provider "${i}". Configure it with: configureAuth({ providers: { ${i}: { loginPath: '/api/auth/...' } } })`);let g;try{g=new URL(`${r}${l.loginPath}`)}catch{throw new Error(`Failed to construct login URL. Base URL: "${r}", Login path: "${l.loginPath}". Ensure baseUrl is a valid URL (e.g., "https://example.com").`)}(t!=null&&t.callbackUrl||o.callbackUrl)&&g.searchParams.set("callbackUrl",(t==null?void 0:t.callbackUrl)||o.callbackUrl||window.location.href),t!=null&&t.params&&Object.entries(t.params).forEach(([A,v])=>{g.searchParams.set(A,v)}),window.open(g.toString(),"_blank")})}async function te(e){const t=b(),o=k(),r=H(t.defaultProvider),i=r==null?void 0:r.logoutPath;if(i&&(e==null?void 0:e.callLogoutEndpoint)!==!1)try{await fetch(`${o}${i}`,{method:"POST"})}catch(l){console.warn("Logout endpoint call failed:",l)}e!=null&&e.redirectUrl?window.location.href=e.redirectUrl:t.loginRedirectUrl&&(window.location.href=t.loginRedirectUrl)}const V=n.createContext(null),_=["auth","session"];function re({children:e,config:t,onAuthChange:o,onError:r,loadingComponent:i,unauthenticatedComponent:l,skipInitialCheck:g=!1}){const A=n.useRef(!1);t&&!A.current&&(G(t),A.current=!0);const v=M.useQueryClient(),c=b(),{data:u,isLoading:f,error:U,refetch:R,isFetching:P}=M.useQuery({queryKey:_,queryFn:ee,enabled:!g,retry:(s,w)=>w instanceof E&&(w.statusCode===401||w.statusCode===403)?!1:s<c.retry.count,retryDelay:c.retry.delay,staleTime:c.staleTime,gcTime:c.staleTime*2,refetchOnWindowFocus:c.refetchOnWindowFocus??!0,refetchOnReconnect:c.refetchOnReconnect??!0,refetchInterval:c.sessionCheckInterval||!1}),[L,S]=n.useState(null),d=n.useMemo(()=>f||P?"loading":Object.keys((u==null?void 0:u.userDetails)||{}).length>0?"authenticated":"unauthenticated",[f,P,u]),a=(u==null?void 0:u.userDetails)||null,x=(u==null?void 0:u.staticBaseUrl)||null,$=(u==null?void 0:u.buildId)||null,O=d==="authenticated",C=n.useRef(o);C.current=o;const m=n.useRef(r);m.current=r,n.useEffect(()=>{var s;f||(s=C.current)==null||s.call(C,d,a)},[d,a,f]),n.useEffect(()=>{var s;U&&(S(U),(s=m.current)==null||s.call(m,U))},[U]),n.useEffect(()=>{d==="unauthenticated"&&c.autoRedirect&&!f&&N()},[d,f,c.autoRedirect]);const j=n.useCallback((s,w)=>{N(s,w)},[]),p=n.useCallback(async s=>{v.removeQueries({queryKey:_}),await te(s)},[v]),q=n.useCallback(async()=>{if(P)return u||null;try{return(await R()).data||null}catch(s){return S(s),null}},[R,P,u]),B=n.useCallback(s=>(a==null?void 0:a.Role)===s,[a]),I=n.useCallback(s=>s.includes((a==null?void 0:a.Role)||""),[a]),T=n.useCallback(()=>{S(null)},[]),F=n.useCallback(()=>{R()},[R]),z=n.useMemo(()=>({user:a,staticBaseUrl:x,buildId:$,status:d,isAuthenticated:O,isLoading:f,login:j,logout:p,refreshSession:q,hasRole:B,hasAnyRole:I,error:L,clearError:T,_forceCheck:F}),[a,x,$,d,O,f,j,p,q,B,I,L,T,F]);return d==="loading"&&i?y.jsx(y.Fragment,{children:i}):d==="unauthenticated"&&!c.autoRedirect&&l?y.jsx(y.Fragment,{children:l}):y.jsx(V.Provider,{value:z,children:e})}function ne(){const e=n.useContext(V);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}function oe(){const e=ne();return n.useMemo(()=>({user:e.user,staticBaseUrl:e.staticBaseUrl,buildId:e.buildId,status:e.status,isAuthenticated:e.isAuthenticated,isLoading:e.isLoading,login:e.login,logout:e.logout,refreshSession:e.refreshSession,hasRole:e.hasRole,hasAnyRole:e.hasAnyRole,error:e.error,clearError:e.clearError}),[e.user,e.staticBaseUrl,e.buildId,e.status,e.isAuthenticated,e.isLoading,e.login,e.logout,e.refreshSession,e.hasRole,e.hasAnyRole,e.error,e.clearError])}exports.AuthProviderName=W.AuthProviderName;exports.AuthStatus=W.AuthStatus;exports.AuthProvider=re;exports.AuthenticationError=E;exports.configureAuth=G;exports.getAuthBaseUrl=k;exports.getAuthConfig=b;exports.resetAuthConfig=D;exports.setAuthProvider=Z;exports.useAuth=oe;
package/dist/auth.mjs CHANGED
@@ -43,10 +43,10 @@ function ie(e) {
43
43
  function ge(e, t) {
44
44
  d.providers[e] = t;
45
45
  }
46
- function E() {
46
+ function P() {
47
47
  return { ...d };
48
48
  }
49
- function $() {
49
+ function S() {
50
50
  return d.baseUrl || ne() || (typeof window < "u" ? window.location.origin : "");
51
51
  }
52
52
  function M(e) {
@@ -63,7 +63,7 @@ class x extends Error {
63
63
  }
64
64
  }
65
65
  async function ae() {
66
- const e = E(), t = $(), n = oe(), r = await fetch(`${t}${e.sessionEndpoint}`, {
66
+ const e = P(), t = S(), n = oe(), r = await fetch(`${t}${e.sessionEndpoint}`, {
67
67
  method: "GET",
68
68
  headers: n,
69
69
  credentials: "include"
@@ -77,7 +77,7 @@ async function ae() {
77
77
  }
78
78
  function Y(e, t) {
79
79
  return new Promise(() => {
80
- const n = E(), r = $();
80
+ const n = P(), r = S();
81
81
  if (!r)
82
82
  throw new Error(
83
83
  'Auth base URL is not configured. Call setApiBaseUrl("https://...") or configureAuth({ baseUrl: "https://..." }) first.'
@@ -110,10 +110,10 @@ function Y(e, t) {
110
110
  });
111
111
  }
112
112
  async function se(e) {
113
- const t = E(), n = $(), r = M(t.defaultProvider), s = r == null ? void 0 : r.logoutPath;
113
+ const t = P(), n = S(), r = M(t.defaultProvider), s = r == null ? void 0 : r.logoutPath;
114
114
  if (s && (e == null ? void 0 : e.callLogoutEndpoint) !== !1)
115
115
  try {
116
- await fetch(`${n}${s}`);
116
+ await fetch(`${n}${s}`, { method: "POST" });
117
117
  } catch (u) {
118
118
  console.warn("Logout endpoint call failed:", u);
119
119
  }
@@ -131,7 +131,7 @@ function ye({
131
131
  }) {
132
132
  const w = p(!1);
133
133
  t && !w.current && (ie(t), w.current = !0);
134
- const A = te(), c = E(), {
134
+ const A = te(), c = P(), {
135
135
  data: i,
136
136
  isLoading: h,
137
137
  error: U,
@@ -148,7 +148,7 @@ function ye({
148
148
  refetchOnWindowFocus: c.refetchOnWindowFocus ?? !0,
149
149
  refetchOnReconnect: c.refetchOnReconnect ?? !0,
150
150
  refetchInterval: c.sessionCheckInterval || !1
151
- }), [S, P] = Z(null), l = k(() => h || m ? "loading" : Object.keys((i == null ? void 0 : i.userDetails) || {}).length > 0 ? "authenticated" : "unauthenticated", [h, m, i]), a = (i == null ? void 0 : i.userDetails) || null, B = (i == null ? void 0 : i.staticBaseUrl) || null, I = (i == null ? void 0 : i.buildId) || null, O = l === "authenticated", b = p(n);
151
+ }), [$, E] = Z(null), l = k(() => h || m ? "loading" : Object.keys((i == null ? void 0 : i.userDetails) || {}).length > 0 ? "authenticated" : "unauthenticated", [h, m, i]), a = (i == null ? void 0 : i.userDetails) || null, O = (i == null ? void 0 : i.staticBaseUrl) || null, B = (i == null ? void 0 : i.buildId) || null, I = l === "authenticated", b = p(n);
152
152
  b.current = n;
153
153
  const R = p(r);
154
154
  R.current = r, L(() => {
@@ -156,16 +156,16 @@ function ye({
156
156
  h || (o = b.current) == null || o.call(b, l, a);
157
157
  }, [l, a, h]), L(() => {
158
158
  var o;
159
- U && (P(U), (o = R.current) == null || o.call(R, U));
159
+ U && (E(U), (o = R.current) == null || o.call(R, U));
160
160
  }, [U]), L(() => {
161
161
  l === "unauthenticated" && c.autoRedirect && !h && Y();
162
162
  }, [l, h, c.autoRedirect]);
163
- const F = f(
163
+ const T = f(
164
164
  (o, y) => {
165
165
  Y(o, y);
166
166
  },
167
167
  []
168
- ), T = f(
168
+ ), F = f(
169
169
  async (o) => {
170
170
  A.removeQueries({ queryKey: G }), await se(o);
171
171
  },
@@ -176,7 +176,7 @@ function ye({
176
176
  try {
177
177
  return (await v()).data || null;
178
178
  } catch (o) {
179
- return P(o), null;
179
+ return E(o), null;
180
180
  }
181
181
  }, [v, m, i]), q = f(
182
182
  (o) => (a == null ? void 0 : a.Role) === o,
@@ -185,39 +185,39 @@ function ye({
185
185
  (o) => o.includes((a == null ? void 0 : a.Role) || ""),
186
186
  [a]
187
187
  ), _ = f(() => {
188
- P(null);
188
+ E(null);
189
189
  }, []), K = f(() => {
190
190
  v();
191
191
  }, [v]), z = k(
192
192
  () => ({
193
193
  user: a,
194
- staticBaseUrl: B,
195
- buildId: I,
194
+ staticBaseUrl: O,
195
+ buildId: B,
196
196
  status: l,
197
- isAuthenticated: O,
197
+ isAuthenticated: I,
198
198
  isLoading: h,
199
- login: F,
200
- logout: T,
199
+ login: T,
200
+ logout: F,
201
201
  refreshSession: j,
202
202
  hasRole: q,
203
203
  hasAnyRole: Q,
204
- error: S,
204
+ error: $,
205
205
  clearError: _,
206
206
  _forceCheck: K
207
207
  }),
208
208
  [
209
209
  a,
210
+ O,
210
211
  B,
211
- I,
212
212
  l,
213
- O,
213
+ I,
214
214
  h,
215
- F,
216
215
  T,
216
+ F,
217
217
  j,
218
218
  q,
219
219
  Q,
220
- S,
220
+ $,
221
221
  _,
222
222
  K
223
223
  ]
@@ -271,8 +271,8 @@ export {
271
271
  be as AuthStatus,
272
272
  x as AuthenticationError,
273
273
  ie as configureAuth,
274
- $ as getAuthBaseUrl,
275
- E as getAuthConfig,
274
+ S as getAuthBaseUrl,
275
+ P as getAuthConfig,
276
276
  we as resetAuthConfig,
277
277
  ge as setAuthProvider,
278
278
  Ae as useAuth
@@ -21,8 +21,13 @@ export interface ConditionGroupBuilder {
21
21
  }
22
22
  /**
23
23
  * Hook options (minimal configuration)
24
- * Used for initializing useFilter, and also for initialState in useTable/useKanban
24
+ * Used for initializing useFilter, and also for initialState in useTable/useBDOTable
25
25
  * @template T - Data type for type-safe field names (defaults to any)
26
+ *
27
+ * NAMING: Hook options use camelCase (`conditions`, `operator`).
28
+ * Condition OBJECTS inside the array use PascalCase (`Operator`, `LHSField`, `RHSValue`).
29
+ * `operator` combines all conditions ("And"/"Or"/"Not").
30
+ * `ConditionType.Operator` compares a single field ("EQ"/"GT"/etc.).
26
31
  */
27
32
  export interface UseFilterOptionsType<T = any> {
28
33
  /** Filter conditions */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.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AC,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAErF;;;;;OAKG;IACH,iBAAiB,EAAE,CAAC,QAAQ,EAAE,0BAA0B,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAMvF;;;;OAIG;IACH,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC;IAEtF;;;;OAIG;IACH,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,0BAA0B,KAAK,IAAI,CAAC;IAMhF;;;OAGG;IACH,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAEtC;;;;OAIG;IACH,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,aAAa,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAMnF,2BAA2B;IAC3B,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAE/B,qDAAqD;IACrD,eAAe,EAAE,CAAC,EAAE,EAAE,0BAA0B,KAAK,IAAI,CAAC;CAC3D"}
@@ -229,7 +229,7 @@ filter.addCondition(
229
229
  The root operator combines all top-level conditions. It defaults to `"And"` and can be set via the `operator` option or changed later with `setRootOperator()`:
230
230
 
231
231
  ```tsx
232
- // Set at initialization
232
+ // Set at initialization — camelCase hook option, NOT a condition property
233
233
  const filter = useFilter<AdminProductFieldType>({
234
234
  operator: "Or",
235
235
  });
@@ -265,16 +265,22 @@ const table = useBDOTable({
265
265
  bdo: product,
266
266
  initialState: {
267
267
  filter: {
268
+ // Inside condition objects → PascalCase: Operator, LHSField, RHSValue
268
269
  conditions: [
269
270
  { Operator: ConditionOperator.EQ, LHSField: "status", RHSValue: "Active" },
270
271
  ],
272
+ // Hook option → camelCase: operator (combines conditions, NOT a condition property)
271
273
  operator: "And",
272
274
  },
273
275
  },
274
276
  });
275
277
 
276
- // Same API as standalone useFilter
277
- table.filter.addCondition({ ... });
278
+ // Same API as standalone useFilter — condition objects always PascalCase
279
+ table.filter.addCondition({
280
+ Operator: ConditionOperator.EQ, // PascalCase! NOT operator:
281
+ LHSField: product.Category.id,
282
+ RHSValue: "Electronics",
283
+ });
278
284
  table.filter.clearAllConditions();
279
285
  ```
280
286
 
@@ -316,8 +322,9 @@ filter.items.map((item) => {
316
322
 
317
323
  ## Common Mistakes
318
324
 
325
+ - **NEVER write `operator:` (lowercase) inside condition objects** -- this is the #1 error. Condition objects require PascalCase `Operator:`. The camelCase `operator` is ONLY for hook options like `useFilter({ operator: "And" })`. Inside `addCondition({...})` or `conditions: [{...}]`, ALWAYS write `{ Operator: ConditionOperator.EQ, ... }`.
319
326
  - **Don't read `filter.conditions`** -- the property is `filter.items`.
320
327
  - **Don't expect `payload` to be an empty object when empty** -- it's `undefined`. Use a simple falsy check: `if (filter.payload) { ... }`.
321
328
  - **Don't use string literals** -- use `ConditionOperator.EQ`, `GroupOperator.And`, `FilterValueSource.Constant` instead.
322
329
  - **Don't expect IDs in `payload`** -- they're stripped automatically before the payload is built.
323
- - **Don't mix PascalCase and camelCase** -- condition properties are PascalCase (`Operator`, `LHSField`, `RHSValue`, `RHSType`), while hook options are camelCase (`conditions`, `operator`).
330
+ - **Don't mix PascalCase and camelCase** -- condition properties are PascalCase (`Operator`, `LHSField`, `RHSValue`, `RHSType`), while hook options are camelCase (`conditions`, `operator`). Writing `operator: "EQ"` (lowercase) in a condition causes TS2561.
@@ -30,7 +30,7 @@ const filter: UseFilterReturnType<T> = useFilter<T>(options: UseFilterOptionsTyp
30
30
  - Initial filter conditions. Each item is cloned and assigned an auto-generated `id`.
31
31
  - `operator?: ConditionGroupOperatorType`
32
32
  - **Optional**, defaults to `"And"`
33
- - Root operator for combining top-level conditions.
33
+ - Root operator for combining top-level conditions. NOT the same as `ConditionType.Operator`.
34
34
 
35
35
  ## Return Value
36
36
 
@@ -198,7 +198,8 @@ type FilterRHSType = (typeof FilterValueSource)[keyof typeof FilterValueSource];
198
198
  interface UseFilterOptionsType<T = any> {
199
199
  /** Initial filter conditions. Each item is cloned and assigned an auto-generated id. */
200
200
  conditions?: Array<ConditionType<T> | ConditionGroupType<T>>;
201
- /** Root operator for combining conditions. Defaults to "And". */
201
+ /** Root operator for combining conditions. Defaults to "And".
202
+ * NOT the same as ConditionType.Operator — this combines conditions, not compares fields. */
202
203
  operator?: ConditionGroupOperatorType;
203
204
  }
204
205
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ram_28/kf-ai-sdk",
3
- "version": "2.0.22",
3
+ "version": "2.0.24",
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",
@@ -155,7 +155,7 @@ export async function performLogout(
155
155
 
156
156
  if (logoutPath && options?.callLogoutEndpoint !== false) {
157
157
  try {
158
- await fetch(`${baseUrl}${logoutPath}`);
158
+ await fetch(`${baseUrl}${logoutPath}`, { method: "POST" });
159
159
  } catch (error) {
160
160
  console.warn("Logout endpoint call failed:", error);
161
161
  }
@@ -57,8 +57,13 @@ export interface ConditionGroupBuilder {
57
57
 
58
58
  /**
59
59
  * Hook options (minimal configuration)
60
- * Used for initializing useFilter, and also for initialState in useTable/useKanban
60
+ * Used for initializing useFilter, and also for initialState in useTable/useBDOTable
61
61
  * @template T - Data type for type-safe field names (defaults to any)
62
+ *
63
+ * NAMING: Hook options use camelCase (`conditions`, `operator`).
64
+ * Condition OBJECTS inside the array use PascalCase (`Operator`, `LHSField`, `RHSValue`).
65
+ * `operator` combines all conditions ("And"/"Or"/"Not").
66
+ * `ConditionType.Operator` compares a single field ("EQ"/"GT"/etc.).
62
67
  */
63
68
  export interface UseFilterOptionsType<T = any> {
64
69
  /** Filter conditions */