@ram_28/kf-ai-sdk 1.0.13 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/auth.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var z=Object.defineProperty;var J=(e,t,n)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var M=(e,t,n)=>J(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("./jsx-runtime-BYECrxsp.cjs"),r=require("react"),K=require("./useQuery-BScHEo7x.cjs"),L=require("./client-C15j4O5B.cjs"),H={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={...H};function N(e){h={...h,...e,providers:{...h.providers,...e.providers},retry:{...h.retry,...e.retry}}}function X(e,t){h.providers[e]=t}function R(){return{...h}}function x(){return h.baseUrl||L.getApiBaseUrl()||(typeof window<"u"?window.location.origin:"")}function Y(e){return h.providers[e]}function Z(){h={...H}}class P extends Error{constructor(n,s){super(n);M(this,"statusCode");this.name="AuthenticationError",this.statusCode=s}}async function D(){const e=R(),t=x(),n=L.getDefaultHeaders(),s=await fetch(`${t}${e.sessionEndpoint}`,{method:"GET",headers:n,credentials:"include"});if(!s.ok)throw s.status===401||s.status===403?new P("Not authenticated",s.status):new P(`Session check failed: ${s.statusText}`,s.status);return await s.json()}function W(e,t){return new Promise(()=>{const n=R(),s=x();if(!s)throw new Error('Auth base URL is not configured. Call setApiBaseUrl("https://...") or configureAuth({ baseUrl: "https://..." }) first.');const u=e||n.defaultProvider,c=Y(u);if(!c){const w=Object.keys(n.providers||{}).join(", ")||"none";throw new Error(`Auth provider "${u}" is not configured. Available providers: ${w}`)}if(!c.loginPath)throw new Error(`Login path not configured for provider "${u}". Configure it with: configureAuth({ providers: { ${u}: { loginPath: '/api/auth/...' } } })`);let f;try{f=new URL(`${s}${c.loginPath}`)}catch{throw new Error(`Failed to construct login URL. Base URL: "${s}", Login path: "${c.loginPath}". Ensure baseUrl is a valid URL (e.g., "https://example.com").`)}(t!=null&&t.callbackUrl||n.callbackUrl)&&f.searchParams.set("callbackUrl",(t==null?void 0:t.callbackUrl)||n.callbackUrl||window.location.href),t!=null&&t.params&&Object.entries(t.params).forEach(([w,b])=>{f.searchParams.set(w,b)}),window.location.href=f.toString()})}async function ee(e){const t=R(),n=x(),s=L.getDefaultHeaders(),u=Y(t.defaultProvider),c=u==null?void 0:u.logoutPath;if(c&&(e==null?void 0:e.callLogoutEndpoint)!==!1)try{await fetch(`${n}${c}`,{method:"POST",headers:s,credentials:"include"})}catch(f){console.warn("Logout endpoint call failed:",f)}e!=null&&e.redirectUrl?window.location.href=e.redirectUrl:t.loginRedirectUrl&&(window.location.href=t.loginRedirectUrl)}const G=r.createContext(null),_=["auth","session"];function te({children:e,config:t,onAuthChange:n,onError:s,loadingComponent:u,unauthenticatedComponent:c,skipInitialCheck:f=!1}){const w=r.useRef(!1);t&&!w.current&&(N(t),w.current=!0);const b=K.useQueryClient(),l=R(),{data:i,isLoading:g,error:v,refetch:U,isFetching:E}=K.useQuery({queryKey:_,queryFn:D,enabled:!f,retry:(o,y)=>y instanceof P&&(y.statusCode===401||y.statusCode===403)?!1:o<l.retry.count,retryDelay:l.retry.delay,staleTime:l.staleTime,gcTime:l.staleTime*2,refetchOnWindowFocus:l.refetchOnWindowFocus??!0,refetchOnReconnect:l.refetchOnReconnect??!0,refetchInterval:l.sessionCheckInterval||!1}),[j,k]=r.useState(null),d=r.useMemo(()=>g||E?"loading":i!=null&&i.userDetails?"authenticated":"unauthenticated",[g,E,i]),a=(i==null?void 0:i.userDetails)||null,p=(i==null?void 0:i.staticBaseUrl)||null,S=(i==null?void 0:i.buildId)||null,$=d==="authenticated",m=r.useRef(n);m.current=n;const C=r.useRef(s);C.current=s,r.useEffect(()=>{var o;g||(o=m.current)==null||o.call(m,d,a)},[d,a,g]),r.useEffect(()=>{var o;v&&(k(v),(o=C.current)==null||o.call(C,v))},[v]),r.useEffect(()=>{d==="unauthenticated"&&l.autoRedirect&&!g&&W()},[d,g,l.autoRedirect]);const B=r.useCallback((o,y)=>{W(o,y)},[]),O=r.useCallback(async o=>{b.removeQueries({queryKey:_}),await ee(o)},[b]),q=r.useCallback(async()=>{if(E)return i||null;try{return(await U()).data||null}catch(o){return k(o),null}},[U,E,i]),I=r.useCallback(o=>(a==null?void 0:a.Role)===o,[a]),T=r.useCallback(o=>o.includes((a==null?void 0:a.Role)||""),[a]),F=r.useCallback(()=>{k(null)},[]),Q=r.useCallback(()=>{U()},[U]),V=r.useMemo(()=>({user:a,staticBaseUrl:p,buildId:S,status:d,isAuthenticated:$,isLoading:g,login:B,logout:O,refreshSession:q,hasRole:I,hasAnyRole:T,error:j,clearError:F,_forceCheck:Q}),[a,p,S,d,$,g,B,O,q,I,T,j,F,Q]);return d==="loading"&&u?A.jsxRuntimeExports.jsx(A.jsxRuntimeExports.Fragment,{children:u}):d==="unauthenticated"&&!l.autoRedirect&&c?A.jsxRuntimeExports.jsx(A.jsxRuntimeExports.Fragment,{children:c}):A.jsxRuntimeExports.jsx(G.Provider,{value:V,children:e})}function re(){const e=r.useContext(G);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}function ne(){const e=re();return r.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.AuthProvider=te;exports.AuthenticationError=P;exports.configureAuth=N;exports.getAuthBaseUrl=x;exports.getAuthConfig=R;exports.resetAuthConfig=Z;exports.setAuthProvider=X;exports.useAuth=ne;
1
+ "use strict";var z=Object.defineProperty;var J=(e,t,n)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var M=(e,t,n)=>J(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("react/jsx-runtime"),r=require("react"),K=require("@tanstack/react-query"),x=require("./client-C15j4O5B.cjs"),H={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={...H};function N(e){h={...h,...e,providers:{...h.providers,...e.providers},retry:{...h.retry,...e.retry}}}function X(e,t){h.providers[e]=t}function b(){return{...h}}function k(){return h.baseUrl||x.getApiBaseUrl()||(typeof window<"u"?window.location.origin:"")}function Y(e){return h.providers[e]}function Z(){h={...H}}class m extends Error{constructor(n,o){super(n);M(this,"statusCode");this.name="AuthenticationError",this.statusCode=o}}async function D(){const e=b(),t=k(),n=x.getDefaultHeaders(),o=await fetch(`${t}${e.sessionEndpoint}`,{method:"GET",headers:n,credentials:"include"});if(!o.ok)throw o.status===401||o.status===403?new m("Not authenticated",o.status):new m(`Session check failed: ${o.statusText}`,o.status);return await o.json()}function W(e,t){return new Promise(()=>{const n=b(),o=k();if(!o)throw new Error('Auth base URL is not configured. Call setApiBaseUrl("https://...") or configureAuth({ baseUrl: "https://..." }) first.');const i=e||n.defaultProvider,c=Y(i);if(!c){const w=Object.keys(n.providers||{}).join(", ")||"none";throw new Error(`Auth provider "${i}" is not configured. Available providers: ${w}`)}if(!c.loginPath)throw new Error(`Login path not configured for provider "${i}". Configure it with: configureAuth({ providers: { ${i}: { loginPath: '/api/auth/...' } } })`);let f;try{f=new URL(`${o}${c.loginPath}`)}catch{throw new Error(`Failed to construct login URL. Base URL: "${o}", Login path: "${c.loginPath}". Ensure baseUrl is a valid URL (e.g., "https://example.com").`)}(t!=null&&t.callbackUrl||n.callbackUrl)&&f.searchParams.set("callbackUrl",(t==null?void 0:t.callbackUrl)||n.callbackUrl||window.location.href),t!=null&&t.params&&Object.entries(t.params).forEach(([w,v])=>{f.searchParams.set(w,v)}),window.location.href=f.toString()})}async function ee(e){const t=b(),n=k(),o=x.getDefaultHeaders(),i=Y(t.defaultProvider),c=i==null?void 0:i.logoutPath;if(c&&(e==null?void 0:e.callLogoutEndpoint)!==!1)try{await fetch(`${n}${c}`,{method:"POST",headers:o,credentials:"include"})}catch(f){console.warn("Logout endpoint call failed:",f)}e!=null&&e.redirectUrl?window.location.href=e.redirectUrl:t.loginRedirectUrl&&(window.location.href=t.loginRedirectUrl)}const G=r.createContext(null),_=["auth","session"];function te({children:e,config:t,onAuthChange:n,onError:o,loadingComponent:i,unauthenticatedComponent:c,skipInitialCheck:f=!1}){const w=r.useRef(!1);t&&!w.current&&(N(t),w.current=!0);const v=K.useQueryClient(),l=b(),{data:a,isLoading:g,error:U,refetch:R,isFetching:C}=K.useQuery({queryKey:_,queryFn:D,enabled:!f,retry:(s,y)=>y instanceof m&&(y.statusCode===401||y.statusCode===403)?!1:s<l.retry.count,retryDelay:l.retry.delay,staleTime:l.staleTime,gcTime:l.staleTime*2,refetchOnWindowFocus:l.refetchOnWindowFocus??!0,refetchOnReconnect:l.refetchOnReconnect??!0,refetchInterval:l.sessionCheckInterval||!1}),[S,L]=r.useState(null),d=r.useMemo(()=>g||C?"loading":a!=null&&a.userDetails?"authenticated":"unauthenticated",[g,C,a]),u=(a==null?void 0:a.userDetails)||null,$=(a==null?void 0:a.staticBaseUrl)||null,B=(a==null?void 0:a.buildId)||null,O=d==="authenticated",E=r.useRef(n);E.current=n;const P=r.useRef(o);P.current=o,r.useEffect(()=>{var s;g||(s=E.current)==null||s.call(E,d,u)},[d,u,g]),r.useEffect(()=>{var s;U&&(L(U),(s=P.current)==null||s.call(P,U))},[U]),r.useEffect(()=>{d==="unauthenticated"&&l.autoRedirect&&!g&&W()},[d,g,l.autoRedirect]);const j=r.useCallback((s,y)=>{W(s,y)},[]),p=r.useCallback(async s=>{v.removeQueries({queryKey:_}),await ee(s)},[v]),q=r.useCallback(async()=>{if(C)return a||null;try{return(await R()).data||null}catch(s){return L(s),null}},[R,C,a]),I=r.useCallback(s=>(u==null?void 0:u.Role)===s,[u]),T=r.useCallback(s=>s.includes((u==null?void 0:u.Role)||""),[u]),F=r.useCallback(()=>{L(null)},[]),Q=r.useCallback(()=>{R()},[R]),V=r.useMemo(()=>({user:u,staticBaseUrl:$,buildId:B,status:d,isAuthenticated:O,isLoading:g,login:j,logout:p,refreshSession:q,hasRole:I,hasAnyRole:T,error:S,clearError:F,_forceCheck:Q}),[u,$,B,d,O,g,j,p,q,I,T,S,F,Q]);return d==="loading"&&i?A.jsx(A.Fragment,{children:i}):d==="unauthenticated"&&!l.autoRedirect&&c?A.jsx(A.Fragment,{children:c}):A.jsx(G.Provider,{value:V,children:e})}function re(){const e=r.useContext(G);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}function ne(){const e=re();return r.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.AuthProvider=te;exports.AuthenticationError=m;exports.configureAuth=N;exports.getAuthBaseUrl=k;exports.getAuthConfig=b;exports.resetAuthConfig=Z;exports.setAuthProvider=X;exports.useAuth=ne;
package/dist/auth.mjs CHANGED
@@ -1,11 +1,11 @@
1
- var J = Object.defineProperty;
2
- var X = (e, t, r) => t in e ? J(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var _ = (e, t, r) => X(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { j as U } from "./jsx-runtime-DGlMoOmv.js";
5
- import { useRef as x, useState as Z, useMemo as p, useEffect as L, useCallback as g, createContext as D, useContext as ee } from "react";
6
- import { a as te, u as re } from "./useQuery-KpZFg80c.js";
7
- import { c as ne, g as G } from "./client-CfvLiGfP.js";
8
- const H = {
1
+ var X = Object.defineProperty;
2
+ var Z = (e, t, r) => t in e ? X(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var _ = (e, t, r) => Z(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { jsx as C, Fragment as N } from "react/jsx-runtime";
5
+ import { useRef as L, useState as D, useMemo as $, useEffect as p, useCallback as g, createContext as ee, useContext as te } from "react";
6
+ import { useQueryClient as re, useQuery as ne } from "@tanstack/react-query";
7
+ import { c as oe, g as H } from "./client-CfvLiGfP.js";
8
+ const M = {
9
9
  sessionEndpoint: "/api/id",
10
10
  providers: {
11
11
  google: {
@@ -24,8 +24,8 @@ const H = {
24
24
  refetchOnWindowFocus: !1,
25
25
  refetchOnReconnect: !0
26
26
  };
27
- let d = { ...H };
28
- function oe(e) {
27
+ let d = { ...M };
28
+ function ie(e) {
29
29
  d = {
30
30
  ...d,
31
31
  ...e,
@@ -39,58 +39,58 @@ function oe(e) {
39
39
  }
40
40
  };
41
41
  }
42
- function fe(e, t) {
42
+ function ge(e, t) {
43
43
  d.providers[e] = t;
44
44
  }
45
- function P() {
45
+ function E() {
46
46
  return { ...d };
47
47
  }
48
- function k() {
49
- return d.baseUrl || ne() || (typeof window < "u" ? window.location.origin : "");
48
+ function x() {
49
+ return d.baseUrl || oe() || (typeof window < "u" ? window.location.origin : "");
50
50
  }
51
- function M(e) {
51
+ function V(e) {
52
52
  return d.providers[e];
53
53
  }
54
- function ge() {
55
- d = { ...H };
54
+ function we() {
55
+ d = { ...M };
56
56
  }
57
- class $ extends Error {
57
+ class k extends Error {
58
58
  constructor(r, n) {
59
59
  super(r);
60
60
  _(this, "statusCode");
61
61
  this.name = "AuthenticationError", this.statusCode = n;
62
62
  }
63
63
  }
64
- async function se() {
65
- const e = P(), t = k(), r = G(), n = await fetch(`${t}${e.sessionEndpoint}`, {
64
+ async function ae() {
65
+ const e = E(), t = x(), r = H(), n = await fetch(`${t}${e.sessionEndpoint}`, {
66
66
  method: "GET",
67
67
  headers: r,
68
68
  credentials: "include"
69
69
  });
70
70
  if (!n.ok)
71
- throw n.status === 401 || n.status === 403 ? new $("Not authenticated", n.status) : new $(
71
+ throw n.status === 401 || n.status === 403 ? new k("Not authenticated", n.status) : new k(
72
72
  `Session check failed: ${n.statusText}`,
73
73
  n.status
74
74
  );
75
75
  return await n.json();
76
76
  }
77
- function N(e, t) {
77
+ function Y(e, t) {
78
78
  return new Promise(() => {
79
- const r = P(), n = k();
79
+ const r = E(), n = x();
80
80
  if (!n)
81
81
  throw new Error(
82
82
  'Auth base URL is not configured. Call setApiBaseUrl("https://...") or configureAuth({ baseUrl: "https://..." }) first.'
83
83
  );
84
- const i = e || r.defaultProvider, c = M(i);
84
+ const a = e || r.defaultProvider, c = V(a);
85
85
  if (!c) {
86
86
  const w = Object.keys(r.providers || {}).join(", ") || "none";
87
87
  throw new Error(
88
- `Auth provider "${i}" is not configured. Available providers: ${w}`
88
+ `Auth provider "${a}" is not configured. Available providers: ${w}`
89
89
  );
90
90
  }
91
91
  if (!c.loginPath)
92
92
  throw new Error(
93
- `Login path not configured for provider "${i}". Configure it with: configureAuth({ providers: { ${i}: { loginPath: '/api/auth/...' } } })`
93
+ `Login path not configured for provider "${a}". Configure it with: configureAuth({ providers: { ${a}: { loginPath: '/api/auth/...' } } })`
94
94
  );
95
95
  let h;
96
96
  try {
@@ -103,13 +103,13 @@ function N(e, t) {
103
103
  (t != null && t.callbackUrl || r.callbackUrl) && h.searchParams.set(
104
104
  "callbackUrl",
105
105
  (t == null ? void 0 : t.callbackUrl) || r.callbackUrl || window.location.href
106
- ), t != null && t.params && Object.entries(t.params).forEach(([w, m]) => {
107
- h.searchParams.set(w, m);
106
+ ), t != null && t.params && Object.entries(t.params).forEach(([w, U]) => {
107
+ h.searchParams.set(w, U);
108
108
  }), window.location.href = h.toString();
109
109
  });
110
110
  }
111
- async function ie(e) {
112
- const t = P(), r = k(), n = G(), i = M(t.defaultProvider), c = i == null ? void 0 : i.logoutPath;
111
+ async function se(e) {
112
+ const t = E(), r = x(), n = H(), a = V(t.defaultProvider), c = a == null ? void 0 : a.logoutPath;
113
113
  if (c && (e == null ? void 0 : e.callLogoutEndpoint) !== !1)
114
114
  try {
115
115
  await fetch(`${r}${c}`, {
@@ -122,86 +122,86 @@ async function ie(e) {
122
122
  }
123
123
  e != null && e.redirectUrl ? window.location.href = e.redirectUrl : t.loginRedirectUrl && (window.location.href = t.loginRedirectUrl);
124
124
  }
125
- const V = D(null), Y = ["auth", "session"];
126
- function we({
125
+ const z = ee(null), G = ["auth", "session"];
126
+ function ye({
127
127
  children: e,
128
128
  config: t,
129
129
  onAuthChange: r,
130
130
  onError: n,
131
- loadingComponent: i,
131
+ loadingComponent: a,
132
132
  unauthenticatedComponent: c,
133
133
  skipInitialCheck: h = !1
134
134
  }) {
135
- const w = x(!1);
136
- t && !w.current && (oe(t), w.current = !0);
137
- const m = te(), u = P(), {
138
- data: s,
135
+ const w = L(!1);
136
+ t && !w.current && (ie(t), w.current = !0);
137
+ const U = re(), u = E(), {
138
+ data: i,
139
139
  isLoading: f,
140
140
  error: v,
141
141
  refetch: A,
142
- isFetching: R
143
- } = re({
144
- queryKey: Y,
145
- queryFn: se,
142
+ isFetching: m
143
+ } = ne({
144
+ queryKey: G,
145
+ queryFn: ae,
146
146
  enabled: !h,
147
- retry: (o, y) => y instanceof $ && (y.statusCode === 401 || y.statusCode === 403) ? !1 : o < u.retry.count,
147
+ retry: (o, y) => y instanceof k && (y.statusCode === 401 || y.statusCode === 403) ? !1 : o < u.retry.count,
148
148
  retryDelay: u.retry.delay,
149
149
  staleTime: u.staleTime,
150
150
  gcTime: u.staleTime * 2,
151
151
  refetchOnWindowFocus: u.refetchOnWindowFocus ?? !0,
152
152
  refetchOnReconnect: u.refetchOnReconnect ?? !0,
153
153
  refetchInterval: u.sessionCheckInterval || !1
154
- }), [S, C] = Z(null), l = p(() => f || R ? "loading" : s != null && s.userDetails ? "authenticated" : "unauthenticated", [f, R, s]), a = (s == null ? void 0 : s.userDetails) || null, j = (s == null ? void 0 : s.staticBaseUrl) || null, B = (s == null ? void 0 : s.buildId) || null, I = l === "authenticated", b = x(r);
154
+ }), [S, P] = D(null), l = $(() => f || m ? "loading" : i != null && i.userDetails ? "authenticated" : "unauthenticated", [f, m, i]), s = (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 = L(r);
155
155
  b.current = r;
156
- const E = x(n);
157
- E.current = n, L(() => {
156
+ const R = L(n);
157
+ R.current = n, p(() => {
158
158
  var o;
159
- f || (o = b.current) == null || o.call(b, l, a);
160
- }, [l, a, f]), L(() => {
159
+ f || (o = b.current) == null || o.call(b, l, s);
160
+ }, [l, s, f]), p(() => {
161
161
  var o;
162
- v && (C(v), (o = E.current) == null || o.call(E, v));
163
- }, [v]), L(() => {
164
- l === "unauthenticated" && u.autoRedirect && !f && N();
162
+ v && (P(v), (o = R.current) == null || o.call(R, v));
163
+ }, [v]), p(() => {
164
+ l === "unauthenticated" && u.autoRedirect && !f && Y();
165
165
  }, [l, f, u.autoRedirect]);
166
- const O = g(
166
+ const T = g(
167
167
  (o, y) => {
168
- N(o, y);
168
+ Y(o, y);
169
169
  },
170
170
  []
171
171
  ), F = g(
172
172
  async (o) => {
173
- m.removeQueries({ queryKey: Y }), await ie(o);
173
+ U.removeQueries({ queryKey: G }), await se(o);
174
174
  },
175
- [m]
176
- ), T = g(async () => {
177
- if (R)
178
- return s || null;
175
+ [U]
176
+ ), j = g(async () => {
177
+ if (m)
178
+ return i || null;
179
179
  try {
180
180
  return (await A()).data || null;
181
181
  } catch (o) {
182
- return C(o), null;
182
+ return P(o), null;
183
183
  }
184
- }, [A, R, s]), q = g(
185
- (o) => (a == null ? void 0 : a.Role) === o,
186
- [a]
184
+ }, [A, m, i]), q = g(
185
+ (o) => (s == null ? void 0 : s.Role) === o,
186
+ [s]
187
187
  ), Q = g(
188
- (o) => o.includes((a == null ? void 0 : a.Role) || ""),
189
- [a]
188
+ (o) => o.includes((s == null ? void 0 : s.Role) || ""),
189
+ [s]
190
190
  ), K = g(() => {
191
- C(null);
191
+ P(null);
192
192
  }, []), W = g(() => {
193
193
  A();
194
- }, [A]), z = p(
194
+ }, [A]), J = $(
195
195
  () => ({
196
- user: a,
197
- staticBaseUrl: j,
198
- buildId: B,
196
+ user: s,
197
+ staticBaseUrl: B,
198
+ buildId: I,
199
199
  status: l,
200
- isAuthenticated: I,
200
+ isAuthenticated: O,
201
201
  isLoading: f,
202
- login: O,
202
+ login: T,
203
203
  logout: F,
204
- refreshSession: T,
204
+ refreshSession: j,
205
205
  hasRole: q,
206
206
  hasAnyRole: Q,
207
207
  error: S,
@@ -209,15 +209,15 @@ function we({
209
209
  _forceCheck: W
210
210
  }),
211
211
  [
212
- a,
213
- j,
212
+ s,
214
213
  B,
215
- l,
216
214
  I,
217
- f,
215
+ l,
218
216
  O,
219
- F,
217
+ f,
220
218
  T,
219
+ F,
220
+ j,
221
221
  q,
222
222
  Q,
223
223
  S,
@@ -225,17 +225,17 @@ function we({
225
225
  W
226
226
  ]
227
227
  );
228
- return l === "loading" && i ? /* @__PURE__ */ U.jsx(U.Fragment, { children: i }) : l === "unauthenticated" && !u.autoRedirect && c ? /* @__PURE__ */ U.jsx(U.Fragment, { children: c }) : /* @__PURE__ */ U.jsx(V.Provider, { value: z, children: e });
228
+ return l === "loading" && a ? /* @__PURE__ */ C(N, { children: a }) : l === "unauthenticated" && !u.autoRedirect && c ? /* @__PURE__ */ C(N, { children: c }) : /* @__PURE__ */ C(z.Provider, { value: J, children: e });
229
229
  }
230
- function ae() {
231
- const e = ee(V);
230
+ function ce() {
231
+ const e = te(z);
232
232
  if (!e)
233
233
  throw new Error("useAuth must be used within an AuthProvider");
234
234
  return e;
235
235
  }
236
- function ye() {
237
- const e = ae();
238
- return p(
236
+ function Ue() {
237
+ const e = ce();
238
+ return $(
239
239
  () => ({
240
240
  user: e.user,
241
241
  staticBaseUrl: e.staticBaseUrl,
@@ -269,12 +269,12 @@ function ye() {
269
269
  );
270
270
  }
271
271
  export {
272
- we as AuthProvider,
273
- $ as AuthenticationError,
274
- oe as configureAuth,
275
- k as getAuthBaseUrl,
276
- P as getAuthConfig,
277
- ge as resetAuthConfig,
278
- fe as setAuthProvider,
279
- ye as useAuth
272
+ ye as AuthProvider,
273
+ k as AuthenticationError,
274
+ ie as configureAuth,
275
+ x as getAuthBaseUrl,
276
+ E as getAuthConfig,
277
+ we as resetAuthConfig,
278
+ ge as setAuthProvider,
279
+ Ue as useAuth
280
280
  };
@@ -8,6 +8,17 @@ export declare const isConditionGroup: (item: ConditionType | ConditionGroupType
8
8
  * Type guard to check if an item is a leaf Condition (has LHSField)
9
9
  */
10
10
  export declare const isCondition: (item: ConditionType | ConditionGroupType) => item is ConditionType;
11
+ /**
12
+ * Builder interface for fluent condition group construction
13
+ */
14
+ export interface ConditionGroupBuilder {
15
+ /** The id of the created group */
16
+ readonly id: string;
17
+ /** Add a condition to this group */
18
+ addCondition(condition: Omit<ConditionType, "id">): ConditionGroupBuilder;
19
+ /** Add a nested condition group */
20
+ addConditionGroup(operator: ConditionGroupOperatorType): ConditionGroupBuilder;
21
+ }
11
22
  /**
12
23
  * Hook options (minimal configuration)
13
24
  */
@@ -30,53 +41,45 @@ export interface UseFilterReturnType {
30
41
  /** Whether any conditions exist */
31
42
  hasConditions: boolean;
32
43
  /**
33
- * Add a leaf condition at root level
34
- * @returns The id of the created condition
35
- */
36
- add: (condition: Omit<ConditionType, "id">) => string;
37
- /**
38
- * Add a condition group at root level
39
- * @returns The id of the created group
40
- */
41
- addGroup: (operator: ConditionGroupOperatorType) => string;
42
- /**
43
- * Add a leaf condition to a specific parent group
44
- * @param parentId - The id of the parent ConditionGroup
44
+ * Add a leaf condition at root level or to a specific parent group
45
+ * @param condition - The condition to add (without id)
46
+ * @param parentId - Optional id of the parent ConditionGroup. If omitted, adds at root level
45
47
  * @returns The id of the created condition
46
48
  */
47
- addTo: (parentId: string, condition: Omit<ConditionType, "id">) => string;
49
+ addCondition: (condition: Omit<ConditionType, "id">, parentId?: string) => string;
48
50
  /**
49
- * Add a condition group to a specific parent group
50
- * @param parentId - The id of the parent ConditionGroup
51
+ * Add a condition group at root level or to a specific parent group
52
+ * @param operator - The operator for the new group ("And" | "Or" | "Not")
53
+ * @param parentId - Optional id of the parent ConditionGroup. If omitted, adds at root level
51
54
  * @returns The id of the created group
52
55
  */
53
- addGroupTo: (parentId: string, operator: ConditionGroupOperatorType) => string;
56
+ addConditionGroup: (operator: ConditionGroupOperatorType, parentId?: string) => string;
54
57
  /**
55
58
  * Update a leaf condition by id
56
59
  * @param id - The id of the condition to update
57
60
  * @param updates - Partial updates to apply
58
61
  */
59
- update: (id: string, updates: Partial<Omit<ConditionType, "id">>) => void;
62
+ updateCondition: (id: string, updates: Partial<Omit<ConditionType, "id">>) => void;
60
63
  /**
61
64
  * Update a condition group's operator by id
62
65
  * @param id - The id of the group to update
63
66
  * @param operator - The new operator
64
67
  */
65
- updateOperator: (id: string, operator: ConditionGroupOperatorType) => void;
68
+ updateGroupOperator: (id: string, operator: ConditionGroupOperatorType) => void;
66
69
  /**
67
70
  * Remove a condition or group by id
68
71
  * @param id - The id of the item to remove
69
72
  */
70
- remove: (id: string) => void;
73
+ removeCondition: (id: string) => void;
71
74
  /**
72
75
  * Get a condition or group by id
73
76
  * @param id - The id to look up
74
77
  * @returns The item or undefined if not found
75
78
  */
76
- get: (id: string) => ConditionType | ConditionGroupType | undefined;
79
+ getCondition: (id: string) => ConditionType | ConditionGroupType | undefined;
77
80
  /** Clear all conditions */
78
- clear: () => void;
81
+ clearAllConditions: () => void;
79
82
  /** Set the root operator for combining conditions */
80
- setOperator: (op: ConditionGroupOperatorType) => void;
83
+ setRootOperator: (op: ConditionGroupOperatorType) => void;
81
84
  }
82
85
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../sdk/components/hooks/useFilter/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,UAAU,EACV,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAG/B,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,UAAU,EACV,iBAAiB,GAClB,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC3B,MAAM,aAAa,GAAG,kBAAkB,KACvC,IAAI,IAAI,kBAEV,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,GACtB,MAAM,aAAa,GAAG,kBAAkB,KACvC,IAAI,IAAI,aAEV,CAAC;AAMF;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,gCAAgC;IAChC,iBAAiB,CAAC,EAAE,KAAK,CAAC,aAAa,GAAG,kBAAkB,CAAC,CAAC;IAC9D,oEAAoE;IACpE,eAAe,CAAC,EAAE,0BAA0B,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAKlC,kFAAkF;IAClF,QAAQ,EAAE,0BAA0B,CAAC;IAErC,+CAA+C;IAC/C,KAAK,EAAE,KAAK,CAAC,aAAa,GAAG,kBAAkB,CAAC,CAAC;IAEjD,yEAAyE;IACzE,OAAO,EAAE,UAAU,GAAG,SAAS,CAAC;IAEhC,mCAAmC;IACnC,aAAa,EAAE,OAA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AC;IAMvF;;;;OAIG;IACH,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC;IAEnF;;;;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,GAAG,kBAAkB,GAAG,SAAS,CAAC;IAM7E,2BAA2B;IAC3B,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAE/B,qDAAqD;IACrD,eAAe,EAAE,CAAC,EAAE,EAAE,0BAA0B,KAAK,IAAI,CAAC;CAC3D"}
@@ -1 +1 @@
1
- {"version":3,"file":"useFilter.d.ts","sourceRoot":"","sources":["../../../../sdk/components/hooks/useFilter/useFilter.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AA6KzE,wBAAgB,SAAS,CAAC,OAAO,GAAE,oBAAyB,GAAG,mBAAmB,CA2JjF"}
1
+ {"version":3,"file":"useFilter.d.ts","sourceRoot":"","sources":["../../../../sdk/components/hooks/useFilter/useFilter.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AA6KzE,wBAAgB,SAAS,CAAC,OAAO,GAAE,oBAAyB,GAAG,mBAAmB,CA+IjF"}
package/dist/filter.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./useFilter-D-bCDo6Z.cjs");exports.isCondition=i.isCondition;exports.isConditionGroup=i.isConditionGroup;exports.useFilter=i.useFilter;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./useFilter-Dofowpr_.cjs");exports.isCondition=i.isCondition;exports.isConditionGroup=i.isConditionGroup;exports.useFilter=i.useFilter;
package/dist/filter.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as s, a, u as n } from "./useFilter-CXFqEHyI.js";
1
+ import { i as s, a, u as n } from "./useFilter-Dv-mr9QW.js";
2
2
  export {
3
3
  s as isCondition,
4
4
  a as isConditionGroup,