@ram_28/kf-ai-sdk 1.0.18 → 1.0.19
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/api/client.d.ts.map +1 -1
- package/dist/api.cjs +1 -1
- package/dist/api.mjs +2 -2
- package/dist/auth.cjs +1 -1
- package/dist/auth.mjs +1 -1
- package/dist/{client-C15j4O5B.cjs → client-DgtkT50N.cjs} +1 -1
- package/dist/{client-CfvLiGfP.js → client-V-WzUb8H.js} +9 -5
- package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/context.d.ts +1 -1
- package/dist/components/hooks/useKanban/context.d.ts.map +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.mjs +740 -740
- package/dist/kanban.cjs +1 -1
- package/dist/kanban.mjs +4 -2
- package/dist/{metadata-2FLBsFcf.cjs → metadata-0lZAfuTP.cjs} +1 -1
- package/dist/{metadata-DBcoDth-.js → metadata-B88D_pVS.js} +1 -1
- package/dist/table.cjs +1 -1
- package/dist/table.mjs +1 -1
- package/package.json +1 -1
- package/sdk/api/client.ts +7 -1
- package/sdk/components/hooks/useForm/useForm.ts +12 -2
- package/sdk/components/hooks/useKanban/context.ts +5 -3
package/dist/kanban.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),A=require("@tanstack/react-query"),F=require("./client-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),A=require("@tanstack/react-query"),F=require("./client-DgtkT50N.cjs"),St=require("./useFilter-Dofowpr_.cjs"),nt=50,st=5,it=5;function ot({onCardMove:s,onError:c,columns:l,announceMove:a}){const[i,S]=u.useState({isDragging:!1,draggedCard:null,dragOverColumn:null,dragOverPosition:null,dragSourceColumn:null}),O=u.useRef(null),w=u.useRef(null),K=u.useRef(null),_=u.useCallback(()=>{S({isDragging:!1,draggedCard:null,dragOverColumn:null,dragOverPosition:null,dragSourceColumn:null}),w.current&&(clearTimeout(w.current),w.current=null)},[]),D=u.useCallback(d=>l.find(o=>o._id===d)||null,[l]),X=u.useCallback(d=>{for(const o of l){const y=o.cards.find(m=>m._id===d);if(y)return{card:y,column:o}}return null},[l]),P=u.useCallback((d,o)=>{var y,m;try{const g=d.target,f=D(o.columnId);if(!f)throw new Error("Source column not found");(y=d.dataTransfer)==null||y.setData("text/plain",o._id),(m=d.dataTransfer)==null||m.setData("application/json",JSON.stringify(o));const k=g.cloneNode(!0);k.style.cssText=`
|
|
2
2
|
position: fixed;
|
|
3
3
|
top: -1000px;
|
|
4
4
|
left: -1000px;
|
package/dist/kanban.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState as G, useRef as k, useCallback as h, useEffect as rt, useMemo as ot, createContext as qt, useContext as Qt } from "react";
|
|
2
2
|
import { useQueryClient as At, useQueries as Tt, keepPreviousData as kt, useQuery as Pt, useMutation as j } from "@tanstack/react-query";
|
|
3
|
-
import { a as F } from "./client-
|
|
3
|
+
import { a as F } from "./client-V-WzUb8H.js";
|
|
4
4
|
import { u as Et } from "./useFilter-Dv-mr9QW.js";
|
|
5
5
|
const ct = 50, dt = 5, ut = 5;
|
|
6
6
|
function Ft({
|
|
@@ -616,7 +616,9 @@ function Xt(i) {
|
|
|
616
616
|
refresh: bt
|
|
617
617
|
};
|
|
618
618
|
}
|
|
619
|
-
const $t = qt(
|
|
619
|
+
const $t = qt(
|
|
620
|
+
null
|
|
621
|
+
);
|
|
620
622
|
function Yt() {
|
|
621
623
|
const i = Qt($t);
|
|
622
624
|
if (!i)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const o=require("./client-
|
|
1
|
+
"use strict";const o=require("./client-DgtkT50N.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 a=require("react"),O=require("@tanstack/react-query"),Q=require("./client-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react"),O=require("@tanstack/react-query"),Q=require("./client-DgtkT50N.cjs"),_=require("./useFilter-Dofowpr_.cjs");function $(t){var N,m,P,k,z,T,F,M,w,E;const[o,p]=a.useState({query:""}),[n,y]=a.useState({field:((m=(N=t.initialState)==null?void 0:N.sorting)==null?void 0:m.field)||null,direction:((k=(P=t.initialState)==null?void 0:P.sorting)==null?void 0:k.direction)||null}),[i,c]=a.useState({pageNo:((T=(z=t.initialState)==null?void 0:z.pagination)==null?void 0:T.pageNo)||1,pageSize:((M=(F=t.initialState)==null?void 0:F.pagination)==null?void 0:M.pageSize)||10}),s=_.useFilter({initialConditions:(w=t.initialState)==null?void 0:w.filters,initialOperator:((E=t.initialState)==null?void 0:E.filterOperator)||"And"}),l=a.useMemo(()=>{const e={};return o.query&&(e.Search=o.query),s.payload&&(e.Filter=s.payload),e},[o.query,s.payload]),b=a.useMemo(()=>{const e={...l};return n.field&&n.direction&&(e.Sort=[{[String(n.field)]:n.direction==="asc"?"ASC":"DESC"}]),t.enablePagination&&(e.Page=i.pageNo,e.PageSize=i.pageSize),e},[l,n,i,t.enablePagination]),{data:u,isLoading:L,isFetching:R,error:x,refetch:q}=O.useQuery({queryKey:["table",t.source,b],queryFn:async()=>{try{const e=await Q.api(t.source).list(b);return t.onSuccess&&t.onSuccess(e.Data),e}catch(e){throw t.onError&&t.onError(e),e}},staleTime:0,gcTime:0}),{data:g,isLoading:A,isFetching:D,error:G,refetch:C}=O.useQuery({queryKey:["table-count",t.source,l],queryFn:async()=>{try{return await Q.api(t.source).count(l)}catch(e){throw t.onError&&t.onError(e),e}},staleTime:0,gcTime:0}),K=a.useMemo(()=>(u==null?void 0:u.Data)||[],[u]),S=a.useMemo(()=>(g==null?void 0:g.Count)||0,[g]),d=a.useMemo(()=>Math.ceil(S/i.pageSize),[S,i.pageSize]),j=a.useCallback(e=>{y(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"}})},[]),I=a.useCallback(()=>{y({field:null,direction:null})},[]),B=a.useCallback((e,r)=>{y({field:e,direction:r})},[]),H=a.useCallback(e=>{p({query:e}),c(r=>({...r,pageNo:1}))},[]),J=a.useCallback(()=>{p({query:""})},[]),f=i.pageNo<d,h=i.pageNo>1,U=a.useCallback(()=>{f&&c(e=>({...e,pageNo:e.pageNo+1}))},[f]),V=a.useCallback(()=>{h&&c(e=>({...e,pageNo:e.pageNo-1}))},[h]),W=a.useCallback(e=>{const r=Math.max(1,Math.min(e,d));c(Z=>({...Z,pageNo:r}))},[d]),X=a.useCallback(e=>{c(r=>({...r,pageSize:e,pageNo:1}))},[]),Y=a.useCallback(async()=>{const[e]=await Promise.all([q(),C()]);return e.data||{Data:[]}},[q,C]);return{rows:K,totalItems:S,isLoading:L||A,isFetching:R||D,error:x||G,search:{query:o.query,setQuery:H,clear:J},sort:{field:n.field,direction:n.direction,toggle:j,clear:I,set:B},filter:s,pagination:{currentPage:i.pageNo,pageSize:i.pageSize,totalPages:d,totalItems:S,canGoNext:f,canGoPrevious:h,goToNext:U,goToPrevious:V,goToPage:W,setPageSize:X},refetch:Y}}exports.useTable=$;
|
package/dist/table.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState as m, useMemo as c, useCallback as i } from "react";
|
|
2
2
|
import { useQuery as A } from "@tanstack/react-query";
|
|
3
|
-
import { a as D } from "./client-
|
|
3
|
+
import { a as D } from "./client-V-WzUb8H.js";
|
|
4
4
|
import { u as v } from "./useFilter-Dv-mr9QW.js";
|
|
5
5
|
function ae(t) {
|
|
6
6
|
var F, T, C, b, w, E, x, L, M, O;
|
package/package.json
CHANGED
package/sdk/api/client.ts
CHANGED
|
@@ -379,7 +379,13 @@ export function api<T = any>(bo_id: string): ResourceClient<T> {
|
|
|
379
379
|
);
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
|
|
382
|
+
const json = await response.json();
|
|
383
|
+
// API returns {"Data":{"_id":"..."},"ValidationFailures":[]}
|
|
384
|
+
// Extract _id from Data wrapper and return flat structure
|
|
385
|
+
return {
|
|
386
|
+
...json.Data,
|
|
387
|
+
_id: json.Data._id,
|
|
388
|
+
};
|
|
383
389
|
},
|
|
384
390
|
|
|
385
391
|
// ============================================================
|
|
@@ -81,6 +81,9 @@ export function useForm<T extends Record<string, any> = Record<string, any>>(
|
|
|
81
81
|
// This allows us to detect changes since the last draft, not since form init
|
|
82
82
|
const lastSyncedValuesRef = useRef<Partial<T> | null>(null);
|
|
83
83
|
|
|
84
|
+
// Track if draft creation has started (prevents duplicate calls in React strict mode)
|
|
85
|
+
const draftCreationStartedRef = useRef(false);
|
|
86
|
+
|
|
84
87
|
// Stable callback ref to prevent dependency loops
|
|
85
88
|
const onSchemaErrorRef = useRef(onSchemaError);
|
|
86
89
|
|
|
@@ -209,11 +212,15 @@ export function useForm<T extends Record<string, any> = Record<string, any>>(
|
|
|
209
212
|
operation !== "create" ||
|
|
210
213
|
!schemaConfig ||
|
|
211
214
|
!enabled ||
|
|
212
|
-
draftId
|
|
215
|
+
draftId ||
|
|
216
|
+
draftCreationStartedRef.current // Prevent duplicate calls in React strict mode
|
|
213
217
|
) {
|
|
214
218
|
return;
|
|
215
219
|
}
|
|
216
220
|
|
|
221
|
+
// Mark as started immediately to prevent duplicate calls
|
|
222
|
+
draftCreationStartedRef.current = true;
|
|
223
|
+
|
|
217
224
|
const createInitialDraft = async () => {
|
|
218
225
|
setIsCreatingDraft(true);
|
|
219
226
|
setDraftError(null);
|
|
@@ -244,13 +251,16 @@ export function useForm<T extends Record<string, any> = Record<string, any>>(
|
|
|
244
251
|
} catch (error) {
|
|
245
252
|
console.error("Failed to create initial draft:", error);
|
|
246
253
|
setDraftError(error as Error);
|
|
254
|
+
// Reset the ref on error so it can be retried
|
|
255
|
+
draftCreationStartedRef.current = false;
|
|
247
256
|
} finally {
|
|
248
257
|
setIsCreatingDraft(false);
|
|
249
258
|
}
|
|
250
259
|
};
|
|
251
260
|
|
|
252
261
|
createInitialDraft();
|
|
253
|
-
}, [isInteractiveMode, operation, schemaConfig, enabled, draftId, source
|
|
262
|
+
}, [isInteractiveMode, operation, schemaConfig, enabled, draftId, source]);
|
|
263
|
+
// Note: rhfForm removed from deps - we use ref pattern to avoid dependency loops
|
|
254
264
|
|
|
255
265
|
// ============================================================
|
|
256
266
|
// COMPUTED FIELD DEPENDENCY TRACKING AND OPTIMIZATION
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
|
-
import { UseKanbanReturnType } from "./types";
|
|
2
|
+
import type { UseKanbanReturnType } from "./types";
|
|
3
3
|
|
|
4
|
-
export const KanbanContext = createContext<UseKanbanReturnType<any> | null>(
|
|
4
|
+
export const KanbanContext = createContext<UseKanbanReturnType<any> | null>(
|
|
5
|
+
null,
|
|
6
|
+
);
|
|
5
7
|
|
|
6
8
|
export function useKanbanContext<T extends Record<string, any> = any>() {
|
|
7
9
|
const context = useContext(KanbanContext);
|
|
8
10
|
if (!context) {
|
|
9
11
|
throw new Error(
|
|
10
|
-
"Kanban components must be used within a KanbanBoard component"
|
|
12
|
+
"Kanban components must be used within a KanbanBoard component",
|
|
11
13
|
);
|
|
12
14
|
}
|
|
13
15
|
return context as UseKanbanReturnType<T>;
|