@ram_28/kf-ai-sdk 1.0.11 → 1.0.12
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 +55 -48
- package/dist/api/client.d.ts +14 -14
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/datetime.d.ts +5 -5
- package/dist/api/datetime.d.ts.map +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/metadata.d.ts +2 -2
- package/dist/api/metadata.d.ts.map +1 -1
- package/dist/api.cjs +1 -0
- package/dist/api.d.ts +4 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.mjs +27 -0
- package/dist/api.types.cjs +1 -0
- package/dist/api.types.d.ts +4 -0
- package/dist/api.types.d.ts.map +1 -0
- package/dist/api.types.mjs +1 -0
- package/dist/auth/AuthProvider.d.ts +3 -3
- package/dist/auth/AuthProvider.d.ts.map +1 -1
- package/dist/auth/authClient.d.ts +4 -4
- package/dist/auth/authClient.d.ts.map +1 -1
- package/dist/auth/authConfig.d.ts +5 -5
- package/dist/auth/authConfig.d.ts.map +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/types.d.ts +21 -21
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/useAuth.d.ts +2 -2
- package/dist/auth/useAuth.d.ts.map +1 -1
- package/dist/auth.cjs +1 -0
- package/dist/auth.d.ts +5 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.mjs +280 -0
- package/dist/auth.types.cjs +1 -0
- package/dist/auth.types.d.ts +2 -0
- package/dist/auth.types.d.ts.map +1 -0
- package/dist/auth.types.mjs +1 -0
- package/dist/base-types.d.ts +2 -0
- package/dist/base-types.d.ts.map +1 -0
- package/dist/client-C15j4O5B.cjs +1 -0
- package/dist/client-CfvLiGfP.js +233 -0
- package/dist/cn-Dr87sK3i.js +2775 -0
- package/dist/cn-mXUIg4vp.cjs +1 -0
- package/dist/components/hooks/index.d.ts +3 -3
- package/dist/components/hooks/index.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/index.d.ts +2 -2
- package/dist/components/hooks/useFilter/index.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/types.d.ts +19 -31
- package/dist/components/hooks/useFilter/types.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/useFilter.d.ts +2 -2
- package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -1
- package/dist/components/hooks/useForm/apiClient.d.ts +6 -6
- package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
- package/dist/components/hooks/useForm/expressionValidator.utils.d.ts +7 -7
- package/dist/components/hooks/useForm/expressionValidator.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/index.d.ts +5 -5
- package/dist/components/hooks/useForm/index.d.ts.map +1 -1
- package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts +10 -10
- package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts +7 -12
- package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/schemaParser.utils.d.ts +7 -7
- package/dist/components/hooks/useForm/schemaParser.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/types.d.ts +67 -76
- package/dist/components/hooks/useForm/types.d.ts.map +1 -1
- package/dist/components/hooks/useForm/useForm.d.ts +2 -2
- package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/apiClient.d.ts +16 -16
- package/dist/components/hooks/useKanban/apiClient.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/context.d.ts +3 -3
- package/dist/components/hooks/useKanban/context.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/dragDropManager.d.ts +7 -7
- package/dist/components/hooks/useKanban/dragDropManager.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/index.d.ts +1 -1
- package/dist/components/hooks/useKanban/index.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/types.d.ts +65 -67
- package/dist/components/hooks/useKanban/types.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/useKanban.d.ts +2 -2
- package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -1
- package/dist/components/hooks/useTable/index.d.ts +1 -1
- package/dist/components/hooks/useTable/index.d.ts.map +1 -1
- package/dist/components/hooks/useTable/types.d.ts +10 -10
- package/dist/components/hooks/useTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useTable/useTable.d.ts +2 -2
- package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
- package/dist/filter.cjs +1 -0
- package/dist/filter.d.ts +3 -0
- package/dist/filter.d.ts.map +1 -0
- package/dist/filter.mjs +6 -0
- package/dist/filter.types.cjs +1 -0
- package/dist/filter.types.d.ts +2 -0
- package/dist/filter.types.d.ts.map +1 -0
- package/dist/filter.types.mjs +1 -0
- package/dist/form.cjs +1 -0
- package/dist/form.d.ts +3 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.mjs +1346 -0
- package/dist/form.types.cjs +1 -0
- package/dist/form.types.d.ts +2 -0
- package/dist/form.types.d.ts.map +1 -0
- package/dist/form.types.mjs +1 -0
- package/dist/jsx-runtime-BYECrxsp.cjs +30 -0
- package/dist/jsx-runtime-DGlMoOmv.js +630 -0
- package/dist/kanban.cjs +13 -0
- package/dist/kanban.d.ts +5 -0
- package/dist/kanban.d.ts.map +1 -0
- package/dist/kanban.mjs +694 -0
- package/dist/kanban.types.cjs +1 -0
- package/dist/kanban.types.d.ts +2 -0
- package/dist/kanban.types.d.ts.map +1 -0
- package/dist/kanban.types.mjs +1 -0
- package/dist/kanban.ui.cjs +1 -0
- package/dist/kanban.ui.d.ts +2 -0
- package/dist/kanban.ui.d.ts.map +1 -0
- package/dist/kanban.ui.mjs +104 -0
- package/dist/metadata-2FLBsFcf.cjs +1 -0
- package/dist/metadata-DBcoDth-.js +43 -0
- package/dist/table.cjs +1 -0
- package/dist/table.d.ts +2 -0
- package/dist/table.d.ts.map +1 -0
- package/dist/table.mjs +148 -0
- package/dist/table.types.cjs +1 -0
- package/dist/table.types.d.ts +2 -0
- package/dist/table.types.d.ts.map +1 -0
- package/dist/table.types.mjs +1 -0
- package/dist/types/base-fields.d.ts +45 -45
- package/dist/types/base-fields.d.ts.map +1 -1
- package/dist/types/common.d.ts +45 -61
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types.cjs +1 -0
- package/dist/types.mjs +1 -0
- package/dist/useFilter-CXFqEHyI.js +129 -0
- package/dist/useFilter-D-bCDo6Z.cjs +1 -0
- package/dist/utils/formatting.d.ts +4 -4
- package/dist/utils/formatting.d.ts.map +1 -1
- package/dist/utils.cjs +4 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.mjs +105 -0
- package/package.json +147 -9
- package/sdk/api/client.ts +51 -51
- package/sdk/api/datetime.ts +5 -5
- package/sdk/api/index.ts +28 -33
- package/sdk/api/metadata.ts +4 -4
- package/sdk/api.ts +24 -0
- package/sdk/api.types.ts +58 -0
- package/sdk/auth/AuthProvider.tsx +18 -18
- package/sdk/auth/authClient.ts +9 -9
- package/sdk/auth/authConfig.ts +9 -9
- package/sdk/auth/index.ts +5 -5
- package/sdk/auth/types.ts +21 -21
- package/sdk/auth/useAuth.ts +2 -2
- package/sdk/auth.ts +22 -0
- package/sdk/auth.types.ts +28 -0
- package/sdk/base-types.ts +45 -0
- package/sdk/components/hooks/index.ts +22 -22
- package/sdk/components/hooks/useFilter/index.ts +8 -14
- package/sdk/components/hooks/useFilter/types.ts +29 -58
- package/sdk/components/hooks/useFilter/useFilter.ts +41 -44
- package/sdk/components/hooks/useForm/apiClient.ts +8 -8
- package/sdk/components/hooks/useForm/expressionValidator.utils.ts +18 -18
- package/sdk/components/hooks/useForm/index.ts +24 -24
- package/sdk/components/hooks/useForm/optimizedExpressionValidator.utils.ts +22 -22
- package/sdk/components/hooks/useForm/ruleClassifier.utils.ts +26 -62
- package/sdk/components/hooks/useForm/schemaParser.utils.ts +24 -24
- package/sdk/components/hooks/useForm/types.ts +66 -82
- package/sdk/components/hooks/useForm/useForm.ts +15 -21
- package/sdk/components/hooks/useKanban/apiClient.ts +54 -54
- package/sdk/components/hooks/useKanban/context.ts +3 -3
- package/sdk/components/hooks/useKanban/dragDropManager.ts +19 -19
- package/sdk/components/hooks/useKanban/index.ts +26 -26
- package/sdk/components/hooks/useKanban/types.ts +69 -71
- package/sdk/components/hooks/useKanban/useKanban.ts +43 -51
- package/sdk/components/hooks/useKanban/useKanbanSimple.ts +4 -4
- package/sdk/components/hooks/useTable/index.ts +5 -1
- package/sdk/components/hooks/useTable/types.ts +10 -10
- package/sdk/components/hooks/useTable/useTable.ts +10 -10
- package/sdk/filter.ts +13 -0
- package/sdk/filter.types.ts +17 -0
- package/sdk/form.ts +15 -0
- package/sdk/form.types.ts +46 -0
- package/sdk/kanban.ts +23 -0
- package/sdk/kanban.types.ts +50 -0
- package/sdk/kanban.ui.ts +16 -0
- package/sdk/table.ts +7 -0
- package/sdk/table.types.ts +13 -0
- package/sdk/types/base-fields.ts +47 -47
- package/sdk/types/common.ts +47 -71
- package/sdk/types/index.ts +1 -1
- package/sdk/utils/formatting.ts +4 -4
- package/sdk/utils.ts +10 -0
- package/dist/index.cjs +0 -45
- package/dist/index.mjs +0 -6387
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
import { useState, useMemo, useCallback, useRef, useEffect } from "react";
|
|
7
7
|
import { useQuery, useMutation, useQueryClient, useQueries, keepPreviousData } from "@tanstack/react-query";
|
|
8
8
|
import { api } from "../../../api";
|
|
9
|
-
import type {
|
|
9
|
+
import type { ListOptionsType, ListResponseType } from "../../../types/common";
|
|
10
10
|
import { useFilter } from "../useFilter";
|
|
11
11
|
|
|
12
12
|
import type {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
UseKanbanOptionsType,
|
|
14
|
+
UseKanbanReturnType,
|
|
15
|
+
KanbanCardType,
|
|
16
16
|
} from "./types";
|
|
17
17
|
import { useDragDropManager } from "./dragDropManager";
|
|
18
18
|
|
|
@@ -21,11 +21,10 @@ import { useDragDropManager } from "./dragDropManager";
|
|
|
21
21
|
// ============================================================
|
|
22
22
|
|
|
23
23
|
export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
24
|
-
options:
|
|
25
|
-
):
|
|
24
|
+
options: UseKanbanOptionsType<T>
|
|
25
|
+
): UseKanbanReturnType<T> {
|
|
26
26
|
const {
|
|
27
27
|
columns: columnConfigs,
|
|
28
|
-
cardSource,
|
|
29
28
|
source,
|
|
30
29
|
enableDragDrop = true,
|
|
31
30
|
initialState,
|
|
@@ -36,13 +35,6 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
36
35
|
onError,
|
|
37
36
|
} = options;
|
|
38
37
|
|
|
39
|
-
// Use source or cardSource (backwards compatibility)
|
|
40
|
-
const dataSource = source || cardSource;
|
|
41
|
-
|
|
42
|
-
if (!dataSource) {
|
|
43
|
-
throw new Error('useKanban requires either "source" or "cardSource" parameter');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
38
|
// ============================================================
|
|
47
39
|
// STATE MANAGEMENT
|
|
48
40
|
// ============================================================
|
|
@@ -95,7 +87,7 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
95
87
|
|
|
96
88
|
// Helper to generate API options for a specific column
|
|
97
89
|
// This is used for both initial fetching and mutation updates
|
|
98
|
-
const getColumnApiOptions = useCallback((columnId: string):
|
|
90
|
+
const getColumnApiOptions = useCallback((columnId: string): ListOptionsType => {
|
|
99
91
|
// 1. Construct Compound Filter Payload
|
|
100
92
|
const columnFilterObject = {
|
|
101
93
|
LHSField: "columnId",
|
|
@@ -128,7 +120,7 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
128
120
|
}
|
|
129
121
|
|
|
130
122
|
// 2. Construct API Options
|
|
131
|
-
const opts:
|
|
123
|
+
const opts: ListOptionsType = {
|
|
132
124
|
Page: 1, // Always page 1 due to expanding PageSize strategy
|
|
133
125
|
PageSize: columnPagination[columnId] || 10,
|
|
134
126
|
Filter: combinedPayload,
|
|
@@ -163,10 +155,10 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
163
155
|
queries: columnConfigs.map((column) => {
|
|
164
156
|
const opts = getColumnApiOptions(column.id);
|
|
165
157
|
return {
|
|
166
|
-
queryKey: ["kanban-cards",
|
|
167
|
-
queryFn: async (): Promise<
|
|
158
|
+
queryKey: ["kanban-cards", source, column.id, opts],
|
|
159
|
+
queryFn: async (): Promise<ListResponseType<KanbanCardType<T>>> => {
|
|
168
160
|
try {
|
|
169
|
-
return await api<
|
|
161
|
+
return await api<KanbanCardType<T>>(source).list(opts);
|
|
170
162
|
} catch (err) {
|
|
171
163
|
throw err;
|
|
172
164
|
}
|
|
@@ -185,9 +177,9 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
185
177
|
await Promise.all(columnQueries.map(q => q.refetch()));
|
|
186
178
|
};
|
|
187
179
|
|
|
188
|
-
const cardApiOptions = useMemo(():
|
|
180
|
+
const cardApiOptions = useMemo((): ListOptionsType => {
|
|
189
181
|
// This is for the GLOBAL count (ignoring column split)
|
|
190
|
-
const opts:
|
|
182
|
+
const opts: ListOptionsType = {};
|
|
191
183
|
if (search.query) opts.Search = search.query;
|
|
192
184
|
if (filter.payload) opts.Filter = filter.payload;
|
|
193
185
|
return opts;
|
|
@@ -198,10 +190,10 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
198
190
|
isLoading: isLoadingCount,
|
|
199
191
|
error: countError,
|
|
200
192
|
} = useQuery({
|
|
201
|
-
queryKey: ["kanban-count",
|
|
193
|
+
queryKey: ["kanban-count", source, cardApiOptions],
|
|
202
194
|
queryFn: async () => {
|
|
203
195
|
try {
|
|
204
|
-
return await api<
|
|
196
|
+
return await api<KanbanCardType<T>>(source).count(cardApiOptions);
|
|
205
197
|
} catch (err) {
|
|
206
198
|
if (onErrorRef.current) {
|
|
207
199
|
onErrorRef.current(err as Error);
|
|
@@ -218,19 +210,19 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
218
210
|
// ============================================================
|
|
219
211
|
|
|
220
212
|
const createCardMutation = useMutation({
|
|
221
|
-
mutationFn: async (card: Partial<
|
|
213
|
+
mutationFn: async (card: Partial<KanbanCardType<T>> & { columnId: string }) => {
|
|
222
214
|
const position = card.position ?? 999999;
|
|
223
|
-
const response = await api<
|
|
215
|
+
const response = await api<KanbanCardType<T>>(source).create({ ...card, position });
|
|
224
216
|
return response._id;
|
|
225
217
|
},
|
|
226
218
|
onMutate: async (newCardVariables) => {
|
|
227
219
|
const columnId = newCardVariables.columnId;
|
|
228
220
|
const opts = getColumnApiOptions(columnId);
|
|
229
|
-
const queryKey = ["kanban-cards",
|
|
221
|
+
const queryKey = ["kanban-cards", source, columnId, opts];
|
|
230
222
|
|
|
231
223
|
await queryClient.cancelQueries({ queryKey });
|
|
232
224
|
|
|
233
|
-
const previousCards = queryClient.getQueryData<
|
|
225
|
+
const previousCards = queryClient.getQueryData<ListResponseType<KanbanCardType<T>>>(queryKey);
|
|
234
226
|
|
|
235
227
|
if (previousCards) {
|
|
236
228
|
const currentCards = previousCards.Data;
|
|
@@ -243,9 +235,9 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
243
235
|
position,
|
|
244
236
|
_created_at: new Date(),
|
|
245
237
|
_modified_at: new Date(),
|
|
246
|
-
} as
|
|
238
|
+
} as KanbanCardType<T>;
|
|
247
239
|
|
|
248
|
-
queryClient.setQueryData<
|
|
240
|
+
queryClient.setQueryData<ListResponseType<KanbanCardType<T>>>(queryKey, {
|
|
249
241
|
...previousCards,
|
|
250
242
|
Data: [...previousCards.Data, newCard],
|
|
251
243
|
});
|
|
@@ -260,7 +252,7 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
260
252
|
onCardCreateRef.current?.({
|
|
261
253
|
_id: cardId,
|
|
262
254
|
..._variables,
|
|
263
|
-
} as
|
|
255
|
+
} as KanbanCardType<T>);
|
|
264
256
|
},
|
|
265
257
|
onError: (error, _variables, context) => {
|
|
266
258
|
if (context?.previousCards && context?.queryKey) {
|
|
@@ -271,17 +263,17 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
271
263
|
onSettled: (_data, _error, variables) => {
|
|
272
264
|
const columnId = variables.columnId;
|
|
273
265
|
const opts = getColumnApiOptions(columnId);
|
|
274
|
-
queryClient.invalidateQueries({ queryKey: ["kanban-cards",
|
|
266
|
+
queryClient.invalidateQueries({ queryKey: ["kanban-cards", source, columnId, opts] });
|
|
275
267
|
}
|
|
276
268
|
});
|
|
277
269
|
|
|
278
270
|
const updateCardMutation = useMutation({
|
|
279
|
-
mutationFn: async ({ id, updates }: { id: string; updates: Partial<
|
|
280
|
-
await api<
|
|
271
|
+
mutationFn: async ({ id, updates }: { id: string; updates: Partial<KanbanCardType<T>> }) => {
|
|
272
|
+
await api<KanbanCardType<T>>(source).update(id, updates);
|
|
281
273
|
return { id, updates };
|
|
282
274
|
},
|
|
283
275
|
onMutate: async () => {
|
|
284
|
-
await queryClient.cancelQueries({ queryKey: ["kanban-cards",
|
|
276
|
+
await queryClient.cancelQueries({ queryKey: ["kanban-cards", source] });
|
|
285
277
|
return {};
|
|
286
278
|
},
|
|
287
279
|
onSuccess: async (result) => {
|
|
@@ -291,17 +283,17 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
291
283
|
onErrorRef.current?.(error as Error);
|
|
292
284
|
},
|
|
293
285
|
onSettled: () => {
|
|
294
|
-
queryClient.invalidateQueries({ queryKey: ["kanban-cards",
|
|
286
|
+
queryClient.invalidateQueries({ queryKey: ["kanban-cards", source] });
|
|
295
287
|
}
|
|
296
288
|
});
|
|
297
289
|
|
|
298
290
|
const deleteCardMutation = useMutation({
|
|
299
291
|
mutationFn: async (id: string) => {
|
|
300
|
-
await api(
|
|
292
|
+
await api(source).delete(id);
|
|
301
293
|
return id;
|
|
302
294
|
},
|
|
303
295
|
onMutate: async () => {
|
|
304
|
-
await queryClient.cancelQueries({ queryKey: ["kanban-cards",
|
|
296
|
+
await queryClient.cancelQueries({ queryKey: ["kanban-cards", source] });
|
|
305
297
|
return {};
|
|
306
298
|
},
|
|
307
299
|
onSuccess: async (id) => {
|
|
@@ -311,27 +303,27 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
311
303
|
onErrorRef.current?.(error as Error);
|
|
312
304
|
},
|
|
313
305
|
onSettled: () => {
|
|
314
|
-
queryClient.invalidateQueries({ queryKey: ["kanban-cards",
|
|
306
|
+
queryClient.invalidateQueries({ queryKey: ["kanban-cards", source] });
|
|
315
307
|
}
|
|
316
308
|
});
|
|
317
309
|
|
|
318
310
|
const moveCardMutation = useMutation({
|
|
319
311
|
mutationFn: async ({ cardId, fromColumnId, toColumnId, position }: { cardId: string; fromColumnId: string; toColumnId: string; position?: number }) => {
|
|
320
312
|
const updates: any = { columnId: toColumnId, ...(position !== undefined && { position }) };
|
|
321
|
-
await api<
|
|
313
|
+
await api<KanbanCardType<T>>(source).update(cardId, updates);
|
|
322
314
|
return { cardId, fromColumnId, toColumnId, position };
|
|
323
315
|
},
|
|
324
316
|
onMutate: async ({ cardId, fromColumnId, toColumnId, position }) => {
|
|
325
317
|
const fromOpts = getColumnApiOptions(fromColumnId);
|
|
326
318
|
const toOpts = getColumnApiOptions(toColumnId);
|
|
327
|
-
const fromQueryKey = ["kanban-cards",
|
|
328
|
-
const toQueryKey = ["kanban-cards",
|
|
319
|
+
const fromQueryKey = ["kanban-cards", source, fromColumnId, fromOpts];
|
|
320
|
+
const toQueryKey = ["kanban-cards", source, toColumnId, toOpts];
|
|
329
321
|
|
|
330
322
|
await queryClient.cancelQueries({ queryKey: fromQueryKey });
|
|
331
323
|
await queryClient.cancelQueries({ queryKey: toQueryKey });
|
|
332
324
|
|
|
333
|
-
const previousFromData = queryClient.getQueryData<
|
|
334
|
-
const previousToData = queryClient.getQueryData<
|
|
325
|
+
const previousFromData = queryClient.getQueryData<ListResponseType<KanbanCardType<T>>>(fromQueryKey);
|
|
326
|
+
const previousToData = queryClient.getQueryData<ListResponseType<KanbanCardType<T>>>(toQueryKey);
|
|
335
327
|
|
|
336
328
|
if (previousFromData && previousToData) {
|
|
337
329
|
const cardToMove = previousFromData.Data.find(c => c._id === cardId);
|
|
@@ -387,8 +379,8 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
387
379
|
onSettled: (_data, _error, variables) => {
|
|
388
380
|
const fromOpts = getColumnApiOptions(variables.fromColumnId);
|
|
389
381
|
const toOpts = getColumnApiOptions(variables.toColumnId);
|
|
390
|
-
queryClient.invalidateQueries({ queryKey: ["kanban-cards",
|
|
391
|
-
queryClient.invalidateQueries({ queryKey: ["kanban-cards",
|
|
382
|
+
queryClient.invalidateQueries({ queryKey: ["kanban-cards", source, variables.fromColumnId, fromOpts] });
|
|
383
|
+
queryClient.invalidateQueries({ queryKey: ["kanban-cards", source, variables.toColumnId, toOpts] });
|
|
392
384
|
}
|
|
393
385
|
});
|
|
394
386
|
|
|
@@ -397,13 +389,13 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
397
389
|
const updates = cardIds.map((id, index) => ({ id, position: index, columnId }));
|
|
398
390
|
await Promise.all(
|
|
399
391
|
updates.map((update) =>
|
|
400
|
-
api<
|
|
392
|
+
api<KanbanCardType<T>>(source).update(update.id, { position: update.position, columnId: update.columnId } as Partial<KanbanCardType<T>>)
|
|
401
393
|
)
|
|
402
394
|
);
|
|
403
395
|
},
|
|
404
396
|
onMutate: async ({ columnId }) => {
|
|
405
397
|
const opts = getColumnApiOptions(columnId);
|
|
406
|
-
const queryKey = ["kanban-cards",
|
|
398
|
+
const queryKey = ["kanban-cards", source, columnId, opts];
|
|
407
399
|
await queryClient.cancelQueries({ queryKey });
|
|
408
400
|
return {};
|
|
409
401
|
},
|
|
@@ -413,7 +405,7 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
413
405
|
},
|
|
414
406
|
onSettled: (_data, _error, variables) => {
|
|
415
407
|
const opts = getColumnApiOptions(variables.columnId);
|
|
416
|
-
queryClient.invalidateQueries({ queryKey: ["kanban-cards",
|
|
408
|
+
queryClient.invalidateQueries({ queryKey: ["kanban-cards", source, variables.columnId, opts] });
|
|
417
409
|
}
|
|
418
410
|
});
|
|
419
411
|
|
|
@@ -422,7 +414,7 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
422
414
|
// ============================================================
|
|
423
415
|
|
|
424
416
|
const handleCardMove = useCallback(
|
|
425
|
-
async (card:
|
|
417
|
+
async (card: KanbanCardType<T>, fromColumnId: string, toColumnId: string) => {
|
|
426
418
|
try {
|
|
427
419
|
await moveCardMutation.mutateAsync({
|
|
428
420
|
cardId: card._id,
|
|
@@ -477,7 +469,7 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
477
469
|
// ============================================================
|
|
478
470
|
|
|
479
471
|
const getCardProps = useCallback(
|
|
480
|
-
(card:
|
|
472
|
+
(card: KanbanCardType<T>) => ({
|
|
481
473
|
draggable: true,
|
|
482
474
|
role: "option",
|
|
483
475
|
"aria-selected": enableDragDrop && dragDropManager.draggedCard?._id === card._id,
|
|
@@ -587,7 +579,7 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
587
579
|
// Card Operations (Flat Access)
|
|
588
580
|
createCard: createCardMutation.mutateAsync,
|
|
589
581
|
updateCard: useCallback(
|
|
590
|
-
async (id: string, updates: Partial<
|
|
582
|
+
async (id: string, updates: Partial<KanbanCardType<T>>) => {
|
|
591
583
|
await updateCardMutation.mutateAsync({ id, updates });
|
|
592
584
|
},
|
|
593
585
|
[updateCardMutation]
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { useState, useMemo, useCallback, useRef } from "react";
|
|
7
7
|
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
|
8
8
|
import { api } from "../../../api";
|
|
9
|
-
import type {
|
|
9
|
+
import type { ListOptionsType, ListResponseType } from "../../../types/common";
|
|
10
10
|
|
|
11
11
|
// ============================================================
|
|
12
12
|
// TYPE DEFINITIONS
|
|
@@ -121,8 +121,8 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
121
121
|
// API OPTIONS
|
|
122
122
|
// ============================================================
|
|
123
123
|
|
|
124
|
-
const apiOptions = useMemo(():
|
|
125
|
-
const opts:
|
|
124
|
+
const apiOptions = useMemo((): ListOptionsType => {
|
|
125
|
+
const opts: ListOptionsType = {};
|
|
126
126
|
|
|
127
127
|
// Default sorting by column and position - using correct API format
|
|
128
128
|
opts.Sort = [
|
|
@@ -151,7 +151,7 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
151
151
|
refetch: refetchCards,
|
|
152
152
|
} = useQuery({
|
|
153
153
|
queryKey: ["kanban-cards", source, apiOptions],
|
|
154
|
-
queryFn: async (): Promise<
|
|
154
|
+
queryFn: async (): Promise<ListResponseType<KanbanCard<T>>> => {
|
|
155
155
|
try {
|
|
156
156
|
return await api<KanbanCard<T>>(source).list(apiOptions);
|
|
157
157
|
} catch (err) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ListResponseType, ConditionGroupOperatorType } from "../../../types/common";
|
|
2
|
+
import type { ConditionType, ConditionGroupType, UseFilterReturnType } from "../useFilter";
|
|
3
3
|
|
|
4
4
|
// ============================================================
|
|
5
5
|
// TYPE DEFINITIONS
|
|
6
6
|
// ============================================================
|
|
7
7
|
|
|
8
|
-
export interface
|
|
8
|
+
export interface ColumnDefinitionType<T> {
|
|
9
9
|
/** Field name from the data type */
|
|
10
10
|
fieldId: keyof T;
|
|
11
11
|
/** Display label (optional, defaults to fieldId) */
|
|
@@ -18,11 +18,11 @@ export interface ColumnDefinition<T> {
|
|
|
18
18
|
transform?: (value: any, row: T) => React.ReactNode;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export interface
|
|
21
|
+
export interface UseTableOptionsType<T> {
|
|
22
22
|
/** Data source identifier */
|
|
23
23
|
source: string;
|
|
24
24
|
/** Column configurations */
|
|
25
|
-
columns:
|
|
25
|
+
columns: ColumnDefinitionType<T>[];
|
|
26
26
|
/** Enable sorting functionality */
|
|
27
27
|
enableSorting?: boolean;
|
|
28
28
|
/** Enable filtering functionality */
|
|
@@ -39,8 +39,8 @@ export interface UseTableOptions<T> {
|
|
|
39
39
|
field: keyof T;
|
|
40
40
|
direction: "asc" | "desc";
|
|
41
41
|
};
|
|
42
|
-
filters?: Array<
|
|
43
|
-
filterOperator?:
|
|
42
|
+
filters?: Array<ConditionType | ConditionGroupType>;
|
|
43
|
+
filterOperator?: ConditionGroupOperatorType;
|
|
44
44
|
};
|
|
45
45
|
/** Error callback */
|
|
46
46
|
onError?: (error: Error) => void;
|
|
@@ -48,7 +48,7 @@ export interface UseTableOptions<T> {
|
|
|
48
48
|
onSuccess?: (data: T[]) => void;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
export interface
|
|
51
|
+
export interface UseTableReturnType<T> {
|
|
52
52
|
// Data
|
|
53
53
|
rows: T[];
|
|
54
54
|
totalItems: number;
|
|
@@ -77,7 +77,7 @@ export interface UseTableReturn<T> {
|
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
// Filter (Simplified chainable API)
|
|
80
|
-
filter:
|
|
80
|
+
filter: UseFilterReturnType;
|
|
81
81
|
|
|
82
82
|
// Pagination (Flat Access)
|
|
83
83
|
pagination: {
|
|
@@ -94,5 +94,5 @@ export interface UseTableReturn<T> {
|
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
// Operations
|
|
97
|
-
refetch: () => Promise<
|
|
97
|
+
refetch: () => Promise<ListResponseType<T>>;
|
|
98
98
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useState, useMemo, useCallback } from "react";
|
|
2
2
|
import { useQuery } from "@tanstack/react-query";
|
|
3
3
|
import { api } from "../../../api";
|
|
4
|
-
import type {
|
|
4
|
+
import type { ListResponseType, ListOptionsType } from "../../../types/common";
|
|
5
5
|
import { useFilter } from "../useFilter";
|
|
6
|
-
import type {
|
|
6
|
+
import type { UseTableOptionsType, UseTableReturnType } from "./types";
|
|
7
7
|
|
|
8
8
|
// ============================================================
|
|
9
9
|
// INTERNAL STATE TYPES
|
|
@@ -28,8 +28,8 @@ interface PaginationState {
|
|
|
28
28
|
// ============================================================
|
|
29
29
|
|
|
30
30
|
export function useTable<T = any>(
|
|
31
|
-
options:
|
|
32
|
-
):
|
|
31
|
+
options: UseTableOptionsType<T>
|
|
32
|
+
): UseTableReturnType<T> {
|
|
33
33
|
// ============================================================
|
|
34
34
|
// STATE MANAGEMENT
|
|
35
35
|
// ============================================================
|
|
@@ -62,8 +62,8 @@ export function useTable<T = any>(
|
|
|
62
62
|
// ============================================================
|
|
63
63
|
|
|
64
64
|
// Options for count query - excludes sorting and pagination (they don't affect count)
|
|
65
|
-
const countApiOptions = useMemo(():
|
|
66
|
-
const opts:
|
|
65
|
+
const countApiOptions = useMemo((): ListOptionsType => {
|
|
66
|
+
const opts: ListOptionsType = {};
|
|
67
67
|
|
|
68
68
|
// Add search query (affects count)
|
|
69
69
|
if (search.query) {
|
|
@@ -79,8 +79,8 @@ export function useTable<T = any>(
|
|
|
79
79
|
}, [search.query, filter.payload]);
|
|
80
80
|
|
|
81
81
|
// Options for list query - includes all options
|
|
82
|
-
const apiOptions = useMemo(():
|
|
83
|
-
const opts:
|
|
82
|
+
const apiOptions = useMemo((): ListOptionsType => {
|
|
83
|
+
const opts: ListOptionsType = { ...countApiOptions };
|
|
84
84
|
|
|
85
85
|
// Add sorting - using correct API format: [{ "fieldName": "ASC" }]
|
|
86
86
|
if (sorting.field && sorting.direction) {
|
|
@@ -112,7 +112,7 @@ export function useTable<T = any>(
|
|
|
112
112
|
refetch: queryRefetch,
|
|
113
113
|
} = useQuery({
|
|
114
114
|
queryKey: ["table", options.source, apiOptions],
|
|
115
|
-
queryFn: async (): Promise<
|
|
115
|
+
queryFn: async (): Promise<ListResponseType<T>> => {
|
|
116
116
|
try {
|
|
117
117
|
const response = await api<T>(options.source).list(apiOptions);
|
|
118
118
|
if (options.onSuccess) {
|
|
@@ -244,7 +244,7 @@ export function useTable<T = any>(
|
|
|
244
244
|
// REFETCH OPERATION
|
|
245
245
|
// ============================================================
|
|
246
246
|
|
|
247
|
-
const refetch = useCallback(async (): Promise<
|
|
247
|
+
const refetch = useCallback(async (): Promise<ListResponseType<T>> => {
|
|
248
248
|
const [listResult] = await Promise.all([queryRefetch(), countRefetch()]);
|
|
249
249
|
return listResult.data || { Data: [] };
|
|
250
250
|
}, [queryRefetch, countRefetch]);
|
package/sdk/filter.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// FILTER MODULE - Main Entry Point
|
|
3
|
+
// @ram_28/kf-ai-sdk/filter
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
// Main hook
|
|
7
|
+
export { useFilter } from './components/hooks/useFilter/useFilter';
|
|
8
|
+
|
|
9
|
+
// Type guards
|
|
10
|
+
export {
|
|
11
|
+
isCondition,
|
|
12
|
+
isConditionGroup,
|
|
13
|
+
} from './components/hooks/useFilter/types';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// FILTER MODULE - Type Exports
|
|
3
|
+
// @ram_28/kf-ai-sdk/filter/types
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
export type {
|
|
7
|
+
// Core hook types
|
|
8
|
+
UseFilterOptionsType,
|
|
9
|
+
UseFilterReturnType,
|
|
10
|
+
|
|
11
|
+
// Filter condition types (re-exported from common)
|
|
12
|
+
ConditionType,
|
|
13
|
+
ConditionGroupType,
|
|
14
|
+
ConditionGroupOperatorType,
|
|
15
|
+
FilterType,
|
|
16
|
+
FilterRHSTypeType,
|
|
17
|
+
} from './components/hooks/useFilter/types';
|
package/sdk/form.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// FORM MODULE - Main Entry Point
|
|
3
|
+
// @ram_28/kf-ai-sdk/form
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
// Main hook
|
|
7
|
+
export { useForm } from './components/hooks/useForm/useForm';
|
|
8
|
+
|
|
9
|
+
// Error handling utilities
|
|
10
|
+
export {
|
|
11
|
+
parseApiError,
|
|
12
|
+
isNetworkError,
|
|
13
|
+
isValidationError,
|
|
14
|
+
clearCache as clearFormCache,
|
|
15
|
+
} from './components/hooks/useForm/apiClient';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// FORM MODULE - Type Exports
|
|
3
|
+
// @ram_28/kf-ai-sdk/form/types
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
export type {
|
|
7
|
+
// Core hook types
|
|
8
|
+
UseFormOptionsType,
|
|
9
|
+
UseFormReturnType,
|
|
10
|
+
HandleSubmitType,
|
|
11
|
+
|
|
12
|
+
// Form operation types
|
|
13
|
+
FormOperationType,
|
|
14
|
+
FormModeType,
|
|
15
|
+
InteractionModeType,
|
|
16
|
+
|
|
17
|
+
// Form field configuration
|
|
18
|
+
FormFieldConfigType,
|
|
19
|
+
FormSchemaConfigType,
|
|
20
|
+
FormFieldTypeType,
|
|
21
|
+
SelectOptionType,
|
|
22
|
+
FieldPermissionType,
|
|
23
|
+
FieldRuleIdsType,
|
|
24
|
+
|
|
25
|
+
// Result types
|
|
26
|
+
FieldValidationResultType,
|
|
27
|
+
SubmissionResultType,
|
|
28
|
+
|
|
29
|
+
// BDO Schema types
|
|
30
|
+
BDOSchemaType,
|
|
31
|
+
BDOFieldDefinitionType,
|
|
32
|
+
SchemaValidationRuleType,
|
|
33
|
+
ComputedFieldFormulaType,
|
|
34
|
+
DefaultValueExpressionType,
|
|
35
|
+
ReferenceFieldConfigType,
|
|
36
|
+
FieldOptionsConfigType,
|
|
37
|
+
BusinessObjectRulesType,
|
|
38
|
+
RolePermissionType,
|
|
39
|
+
|
|
40
|
+
// Expression types
|
|
41
|
+
ExpressionTreeType,
|
|
42
|
+
ExpressionContextType,
|
|
43
|
+
|
|
44
|
+
// Rule types
|
|
45
|
+
RuleTypeType,
|
|
46
|
+
} from "./components/hooks/useForm/types";
|
package/sdk/kanban.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// KANBAN MODULE - Main Entry Point
|
|
3
|
+
// @ram_28/kf-ai-sdk/kanban
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
// Main hook
|
|
7
|
+
export { useKanban } from './components/hooks/useKanban/useKanban';
|
|
8
|
+
|
|
9
|
+
// Context
|
|
10
|
+
export { KanbanContext, useKanbanContext } from './components/hooks/useKanban/context';
|
|
11
|
+
|
|
12
|
+
// Utilities
|
|
13
|
+
export {
|
|
14
|
+
mergeCardsIntoColumns,
|
|
15
|
+
calculateCardPosition,
|
|
16
|
+
calculateColumnPosition,
|
|
17
|
+
normalizePositions,
|
|
18
|
+
handleKanbanApiError,
|
|
19
|
+
validateApiResponse,
|
|
20
|
+
} from './components/hooks/useKanban/apiClient';
|
|
21
|
+
|
|
22
|
+
// Drag drop manager
|
|
23
|
+
export { useDragDropManager } from './components/hooks/useKanban/dragDropManager';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// KANBAN MODULE - Type Exports
|
|
3
|
+
// @ram_28/kf-ai-sdk/kanban/types
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
export type {
|
|
7
|
+
// Core hook types
|
|
8
|
+
UseKanbanOptionsType,
|
|
9
|
+
UseKanbanReturnType,
|
|
10
|
+
|
|
11
|
+
// Data structures
|
|
12
|
+
KanbanCardType,
|
|
13
|
+
KanbanColumnType,
|
|
14
|
+
ColumnConfigType,
|
|
15
|
+
ColumnDefinitionType,
|
|
16
|
+
BaseKanbanCardType,
|
|
17
|
+
KanbanCardWithDataType,
|
|
18
|
+
|
|
19
|
+
// Operations
|
|
20
|
+
CardOperationsType,
|
|
21
|
+
SearchOperationsType,
|
|
22
|
+
|
|
23
|
+
// Drag & Drop
|
|
24
|
+
DragDropStateType,
|
|
25
|
+
DragDropHandlersType,
|
|
26
|
+
DragDropManagerType,
|
|
27
|
+
|
|
28
|
+
// API Types
|
|
29
|
+
CardApiResponseType,
|
|
30
|
+
ColumnApiResponseType,
|
|
31
|
+
MoveCardRequestType,
|
|
32
|
+
ReorderRequestType,
|
|
33
|
+
BulkCardUpdateRequestType,
|
|
34
|
+
BulkColumnUpdateRequestType,
|
|
35
|
+
|
|
36
|
+
// Validation
|
|
37
|
+
ValidationResultType,
|
|
38
|
+
CardValidationContextType,
|
|
39
|
+
ColumnValidationContextType,
|
|
40
|
+
|
|
41
|
+
// Events
|
|
42
|
+
KanbanEventTypeType,
|
|
43
|
+
KanbanEventType,
|
|
44
|
+
|
|
45
|
+
// Utility Types
|
|
46
|
+
ExtractCardTypeType,
|
|
47
|
+
PartialByType,
|
|
48
|
+
CreateCardInputType,
|
|
49
|
+
CreateColumnInputType,
|
|
50
|
+
} from './components/hooks/useKanban/types';
|
package/sdk/kanban.ui.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// KANBAN UI MODULE - Component Exports
|
|
3
|
+
// @ram_28/kf-ai-sdk/kanban/ui
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
Kanban,
|
|
8
|
+
KanbanColumn,
|
|
9
|
+
KanbanColumnHeader,
|
|
10
|
+
KanbanColumnTitle,
|
|
11
|
+
KanbanColumnContent,
|
|
12
|
+
KanbanCard,
|
|
13
|
+
KanbanCardTitle,
|
|
14
|
+
KanbanCardDescription,
|
|
15
|
+
KanbanColumnFooter,
|
|
16
|
+
} from './components/ui/kanban/Kanban';
|
package/sdk/table.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// TABLE MODULE - Main Entry Point
|
|
3
|
+
// @ram_28/kf-ai-sdk/table
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
// Main hook
|
|
7
|
+
export { useTable } from './components/hooks/useTable/useTable';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// TABLE MODULE - Type Exports
|
|
3
|
+
// @ram_28/kf-ai-sdk/table/types
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
export type {
|
|
7
|
+
// Core hook types
|
|
8
|
+
UseTableOptionsType,
|
|
9
|
+
UseTableReturnType,
|
|
10
|
+
|
|
11
|
+
// Column definition
|
|
12
|
+
ColumnDefinitionType,
|
|
13
|
+
} from './components/hooks/useTable/types';
|