@ram_28/kf-ai-sdk 1.0.0

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.
Files changed (126) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +840 -0
  3. package/dist/api/client.d.ts +78 -0
  4. package/dist/api/client.d.ts.map +1 -0
  5. package/dist/api/datetime.d.ts +21 -0
  6. package/dist/api/datetime.d.ts.map +1 -0
  7. package/dist/api/index.d.ts +7 -0
  8. package/dist/api/index.d.ts.map +1 -0
  9. package/dist/api/metadata.d.ts +75 -0
  10. package/dist/api/metadata.d.ts.map +1 -0
  11. package/dist/components/hooks/index.d.ts +8 -0
  12. package/dist/components/hooks/index.d.ts.map +1 -0
  13. package/dist/components/hooks/useFilter/index.d.ts +5 -0
  14. package/dist/components/hooks/useFilter/index.d.ts.map +1 -0
  15. package/dist/components/hooks/useFilter/payloadBuilder.utils.d.ts +33 -0
  16. package/dist/components/hooks/useFilter/payloadBuilder.utils.d.ts.map +1 -0
  17. package/dist/components/hooks/useFilter/types.d.ts +137 -0
  18. package/dist/components/hooks/useFilter/types.d.ts.map +1 -0
  19. package/dist/components/hooks/useFilter/useFilter.d.ts +3 -0
  20. package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -0
  21. package/dist/components/hooks/useFilter/validation.utils.d.ts +38 -0
  22. package/dist/components/hooks/useFilter/validation.utils.d.ts.map +1 -0
  23. package/dist/components/hooks/useForm/apiClient.d.ts +71 -0
  24. package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -0
  25. package/dist/components/hooks/useForm/expressionValidator.utils.d.ts +28 -0
  26. package/dist/components/hooks/useForm/expressionValidator.utils.d.ts.map +1 -0
  27. package/dist/components/hooks/useForm/index.d.ts +6 -0
  28. package/dist/components/hooks/useForm/index.d.ts.map +1 -0
  29. package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts +88 -0
  30. package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts.map +1 -0
  31. package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts +28 -0
  32. package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts.map +1 -0
  33. package/dist/components/hooks/useForm/schemaParser.utils.d.ts +29 -0
  34. package/dist/components/hooks/useForm/schemaParser.utils.d.ts.map +1 -0
  35. package/dist/components/hooks/useForm/types.d.ts +412 -0
  36. package/dist/components/hooks/useForm/types.d.ts.map +1 -0
  37. package/dist/components/hooks/useForm/useForm.d.ts +3 -0
  38. package/dist/components/hooks/useForm/useForm.d.ts.map +1 -0
  39. package/dist/components/hooks/useKanban/apiClient.d.ts +99 -0
  40. package/dist/components/hooks/useKanban/apiClient.d.ts.map +1 -0
  41. package/dist/components/hooks/useKanban/context.d.ts +4 -0
  42. package/dist/components/hooks/useKanban/context.d.ts.map +1 -0
  43. package/dist/components/hooks/useKanban/dragDropManager.d.ts +27 -0
  44. package/dist/components/hooks/useKanban/dragDropManager.d.ts.map +1 -0
  45. package/dist/components/hooks/useKanban/index.d.ts +6 -0
  46. package/dist/components/hooks/useKanban/index.d.ts.map +1 -0
  47. package/dist/components/hooks/useKanban/types.d.ts +438 -0
  48. package/dist/components/hooks/useKanban/types.d.ts.map +1 -0
  49. package/dist/components/hooks/useKanban/useKanban.d.ts +3 -0
  50. package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -0
  51. package/dist/components/hooks/useKanban/useKanbanSimple.d.ts +62 -0
  52. package/dist/components/hooks/useKanban/useKanbanSimple.d.ts.map +1 -0
  53. package/dist/components/hooks/useTable/index.d.ts +3 -0
  54. package/dist/components/hooks/useTable/index.d.ts.map +1 -0
  55. package/dist/components/hooks/useTable/types.d.ts +107 -0
  56. package/dist/components/hooks/useTable/types.d.ts.map +1 -0
  57. package/dist/components/hooks/useTable/useTable.d.ts +8 -0
  58. package/dist/components/hooks/useTable/useTable.d.ts.map +1 -0
  59. package/dist/components/index.d.ts +3 -0
  60. package/dist/components/index.d.ts.map +1 -0
  61. package/dist/components/ui/index.d.ts +2 -0
  62. package/dist/components/ui/index.d.ts.map +1 -0
  63. package/dist/components/ui/kanban/Kanban.d.ts +12 -0
  64. package/dist/components/ui/kanban/Kanban.d.ts.map +1 -0
  65. package/dist/components/ui/kanban/index.d.ts +2 -0
  66. package/dist/components/ui/kanban/index.d.ts.map +1 -0
  67. package/dist/index.cjs +45 -0
  68. package/dist/index.d.ts +5 -0
  69. package/dist/index.d.ts.map +1 -0
  70. package/dist/index.mjs +6522 -0
  71. package/dist/types/base-fields.d.ts +182 -0
  72. package/dist/types/base-fields.d.ts.map +1 -0
  73. package/dist/types/common.d.ts +238 -0
  74. package/dist/types/common.d.ts.map +1 -0
  75. package/dist/types/index.d.ts +3 -0
  76. package/dist/types/index.d.ts.map +1 -0
  77. package/dist/utils/cn.d.ts +7 -0
  78. package/dist/utils/cn.d.ts.map +1 -0
  79. package/dist/utils/formatting.d.ts +52 -0
  80. package/dist/utils/formatting.d.ts.map +1 -0
  81. package/dist/utils/index.d.ts +3 -0
  82. package/dist/utils/index.d.ts.map +1 -0
  83. package/package.json +98 -0
  84. package/sdk/api/client.ts +447 -0
  85. package/sdk/api/datetime.ts +33 -0
  86. package/sdk/api/index.ts +61 -0
  87. package/sdk/api/metadata.ts +148 -0
  88. package/sdk/components/hooks/index.ts +34 -0
  89. package/sdk/components/hooks/useFilter/index.ts +37 -0
  90. package/sdk/components/hooks/useFilter/payloadBuilder.utils.ts +298 -0
  91. package/sdk/components/hooks/useFilter/types.ts +158 -0
  92. package/sdk/components/hooks/useFilter/useFilter.llm.txt +497 -0
  93. package/sdk/components/hooks/useFilter/useFilter.ts +494 -0
  94. package/sdk/components/hooks/useFilter/validation.utils.ts +401 -0
  95. package/sdk/components/hooks/useForm/apiClient.ts +441 -0
  96. package/sdk/components/hooks/useForm/expressionValidator.utils.ts +444 -0
  97. package/sdk/components/hooks/useForm/index.ts +64 -0
  98. package/sdk/components/hooks/useForm/optimizedExpressionValidator.utils.ts +482 -0
  99. package/sdk/components/hooks/useForm/ruleClassifier.utils.ts +424 -0
  100. package/sdk/components/hooks/useForm/schemaParser.utils.ts +519 -0
  101. package/sdk/components/hooks/useForm/types.ts +630 -0
  102. package/sdk/components/hooks/useForm/useForm.llm.txt +340 -0
  103. package/sdk/components/hooks/useForm/useForm.ts +821 -0
  104. package/sdk/components/hooks/useKanban/apiClient.ts +494 -0
  105. package/sdk/components/hooks/useKanban/context.ts +14 -0
  106. package/sdk/components/hooks/useKanban/dragDropManager.ts +529 -0
  107. package/sdk/components/hooks/useKanban/index.ts +63 -0
  108. package/sdk/components/hooks/useKanban/types.ts +606 -0
  109. package/sdk/components/hooks/useKanban/useKanban.llm.txt +482 -0
  110. package/sdk/components/hooks/useKanban/useKanban.ts +725 -0
  111. package/sdk/components/hooks/useKanban/useKanbanSimple.ts +389 -0
  112. package/sdk/components/hooks/useTable/index.ts +5 -0
  113. package/sdk/components/hooks/useTable/types.ts +154 -0
  114. package/sdk/components/hooks/useTable/useTable.llm.txt +344 -0
  115. package/sdk/components/hooks/useTable/useTable.ts +413 -0
  116. package/sdk/components/index.ts +15 -0
  117. package/sdk/components/ui/index.ts +2 -0
  118. package/sdk/components/ui/kanban/Kanban.tsx +134 -0
  119. package/sdk/components/ui/kanban/index.ts +11 -0
  120. package/sdk/index.ts +13 -0
  121. package/sdk/types/base-fields.ts +221 -0
  122. package/sdk/types/common.ts +306 -0
  123. package/sdk/types/index.ts +5 -0
  124. package/sdk/utils/cn.ts +10 -0
  125. package/sdk/utils/formatting.ts +212 -0
  126. package/sdk/utils/index.ts +5 -0
@@ -0,0 +1,606 @@
1
+ // ============================================================
2
+ // KANBAN SDK - TYPE DEFINITIONS
3
+ // ============================================================
4
+ // Core TypeScript interfaces for the kanban board functionality
5
+ // Following patterns from useTable and useForm
6
+
7
+ import type {
8
+ FilterConditionWithId,
9
+ ValidationError,
10
+ FieldDefinition,
11
+ } from "../useFilter";
12
+ import type { LogicalOperator } from "../../../types/common";
13
+
14
+ // ============================================================
15
+ // CORE DATA STRUCTURES
16
+ // ============================================================
17
+
18
+ /**
19
+ * Static column configuration (no CRUD operations)
20
+ * Columns are defined once in the hook configuration
21
+ */
22
+ export interface ColumnConfig {
23
+ /** Unique column identifier */
24
+ id: string;
25
+ /** Display title */
26
+ title: string;
27
+ /** Display order (0-indexed) */
28
+ position: number;
29
+ /** Optional color for the column header */
30
+ color?: string;
31
+ /** Optional WIP limit */
32
+ limit?: number;
33
+ }
34
+
35
+ /**
36
+ * Base kanban card interface
37
+ * @template T - Custom fields for the card
38
+ */
39
+ export type KanbanCard<T = Record<string, any>> = {
40
+ /** Unique identifier */
41
+ _id: string;
42
+ /** Card title */
43
+ title: string;
44
+ /** Column this card belongs to */
45
+ columnId: string;
46
+ /** Position within the column (0-indexed) */
47
+ position: number;
48
+ /** When the card was created */
49
+ _created_at?: Date;
50
+ /** When the card was last modified */
51
+ _modified_at?: Date;
52
+ } & T;
53
+
54
+ /**
55
+ * Kanban card with custom fields
56
+ */
57
+ export type KanbanCardWithData<T> = KanbanCard<Record<string, never>> & T;
58
+
59
+ /**
60
+ * Base kanban card without custom fields
61
+ */
62
+ export interface BaseKanbanCard {
63
+ /** Unique identifier */
64
+ _id: string;
65
+ /** Card title */
66
+ title: string;
67
+ /** Column this card belongs to */
68
+ columnId: string;
69
+ /** Position within the column (0-indexed) */
70
+ position: number;
71
+ /** When the card was created */
72
+ _created_at?: Date;
73
+ /** When the card was last modified */
74
+ _modified_at?: Date;
75
+ }
76
+
77
+ /**
78
+ * Kanban column interface
79
+ * @template T - Custom fields for cards in this column
80
+ */
81
+ export interface KanbanColumn<T = Record<string, any>> {
82
+ /** Unique identifier */
83
+ _id: string;
84
+ /** Column title */
85
+ title: string;
86
+ /** Position among columns (0-indexed) */
87
+ position: number;
88
+ /** Cards in this column */
89
+ cards: KanbanCard<T>[];
90
+ /** Optional color for the column header */
91
+ color?: string;
92
+ /** Optional limit on number of cards (WIP limit) */
93
+ limit?: number;
94
+ /** Optional board identifier if supporting multiple boards */
95
+ boardId?: string;
96
+ /** When the column was created */
97
+ _created_at?: Date;
98
+ /** When the column was last modified */
99
+ _modified_at?: Date;
100
+ }
101
+
102
+ /**
103
+ * Column definition for display and behavior
104
+ * Similar to ColumnDefinition in useTable
105
+ */
106
+ export interface ColumnDefinition<T> {
107
+ /** Field name from the card type */
108
+ fieldId: keyof T;
109
+ /** Display label (optional, defaults to fieldId) */
110
+ label?: string;
111
+ /** Enable sorting for this field */
112
+ enableSorting?: boolean;
113
+ /** Enable filtering for this field */
114
+ enableFiltering?: boolean;
115
+ /** Custom transform function (overrides auto-formatting) */
116
+ transform?: (value: any, card: T) => React.ReactNode;
117
+ }
118
+
119
+ // ============================================================
120
+ // DRAG & DROP TYPES
121
+ // ============================================================
122
+
123
+ /**
124
+ * Drag and drop state management
125
+ */
126
+ export interface DragDropState<T> {
127
+ /** Whether a drag operation is in progress */
128
+ isDragging: boolean;
129
+ /** The card currently being dragged */
130
+ draggedCard: KanbanCard<T> | null;
131
+ /** The column currently being hovered over */
132
+ dragOverColumn: string | null;
133
+ /** The position within the column being hovered over */
134
+ dragOverPosition: number | null;
135
+ /** Source column of the drag operation */
136
+ dragSourceColumn: string | null;
137
+ }
138
+
139
+ /**
140
+ * Drag event handlers
141
+ */
142
+ export interface DragDropHandlers<T> {
143
+ /** Handle drag start event */
144
+ handleDragStart: (event: DragEvent, card: KanbanCard<T>) => void;
145
+ /** Handle drag over event */
146
+ handleDragOver: (event: DragEvent, columnId?: string) => void;
147
+ /** Handle drop event */
148
+ handleDrop: (event: DragEvent, columnId: string) => void;
149
+ /** Handle drag end event */
150
+ handleDragEnd: () => void;
151
+ /** Handle keyboard navigation */
152
+ handleKeyDown: (event: KeyboardEvent, card: KanbanCard<T>) => void;
153
+ /** Handle touch start for mobile */
154
+ handleTouchStart: (event: TouchEvent, card: KanbanCard<T>) => void;
155
+ /** Handle touch move for mobile */
156
+ handleTouchMove: (event: TouchEvent) => void;
157
+ /** Handle touch end for mobile */
158
+ handleTouchEnd: (event: TouchEvent) => void;
159
+ }
160
+
161
+ /**
162
+ * Combined drag and drop interface
163
+ */
164
+ export interface DragDropManager<T>
165
+ extends DragDropState<T>,
166
+ DragDropHandlers<T> {
167
+ /** Announce moves for accessibility */
168
+ announceMove: (
169
+ card: KanbanCard<T>,
170
+ fromColumn: string,
171
+ toColumn: string
172
+ ) => void;
173
+ /** Reset drag state */
174
+ reset: () => void;
175
+ }
176
+
177
+ // ============================================================
178
+ // HOOK CONFIGURATION
179
+ // ============================================================
180
+
181
+ /**
182
+ * Configuration options for the useKanban hook
183
+ */
184
+ export interface UseKanbanOptions<T> {
185
+ /** Card data source identifier */
186
+ cardSource?: string;
187
+ /** Card data source identifier (alias for cardSource) */
188
+ source?: string;
189
+
190
+ /** Static column definitions (required) */
191
+ columns: ColumnConfig[];
192
+
193
+ /** Enable drag and drop functionality */
194
+ enableDragDrop?: boolean;
195
+
196
+ /** Enable filtering functionality */
197
+ enableFiltering?: boolean;
198
+
199
+ /** Enable search functionality */
200
+ enableSearch?: boolean;
201
+
202
+ /** Field definitions for card validation */
203
+ cardFieldDefinitions?: Record<keyof T, FieldDefinition>;
204
+
205
+ /** Initial state */
206
+ initialState?: {
207
+ /** Initial filter conditions */
208
+ filters?: FilterConditionWithId[];
209
+ /** Initial filter operator */
210
+ filterOperator?: LogicalOperator;
211
+ /** Initial search query */
212
+ search?: string;
213
+ /** Initial column order */
214
+ columnOrder?: string[];
215
+ /** Initial sort configuration */
216
+ sorting?: {
217
+ field: keyof T;
218
+ direction: "asc" | "desc";
219
+ };
220
+ };
221
+
222
+ /** Event callbacks */
223
+ onCardMove?: (
224
+ card: KanbanCard<T>,
225
+ fromColumnId: string,
226
+ toColumnId: string
227
+ ) => void;
228
+ onCardCreate?: (card: KanbanCard<T>) => void;
229
+ onCardUpdate?: (card: KanbanCard<T>) => void;
230
+ onCardDelete?: (cardId: string) => void;
231
+ onSuccess?: (data: any) => void;
232
+ onError?: (error: Error) => void;
233
+ onFilterError?: (errors: ValidationError[]) => void;
234
+ }
235
+
236
+ // ============================================================
237
+ // HOOK RETURN INTERFACE
238
+ // ============================================================
239
+
240
+ /**
241
+ * Card operations interface
242
+ */
243
+ export interface CardOperations<T> {
244
+ /** Create a new card */
245
+ create: (
246
+ card: Partial<KanbanCard<T>> & { columnId: string }
247
+ ) => Promise<string>;
248
+ /** Update an existing card */
249
+ update: (id: string, updates: Partial<KanbanCard<T>>) => Promise<void>;
250
+ /** Delete a card */
251
+ delete: (id: string) => Promise<void>;
252
+ /** Move a card to a different column */
253
+ move: (
254
+ cardId: string,
255
+ toColumnId: string,
256
+ position?: number,
257
+ fromColumnId?: string
258
+ ) => Promise<void>;
259
+ /** Reorder cards within a column */
260
+ reorder: (cardIds: string[], columnId: string) => Promise<void>;
261
+ }
262
+
263
+ /**
264
+ * Search functionality interface
265
+ */
266
+ export interface SearchOperations {
267
+ /** Current search query */
268
+ query: string;
269
+ /** Set search query */
270
+ setQuery: (value: string) => void;
271
+ /** Clear search query */
272
+ clear: () => void;
273
+ }
274
+
275
+ /**
276
+ * Filter functionality interface (reusing from useFilter)
277
+ */
278
+ export interface FilterOperations {
279
+ /** Current filter conditions */
280
+ conditions: FilterConditionWithId[];
281
+ /** Logical operator for combining conditions */
282
+ logicalOperator: LogicalOperator;
283
+ /** Whether all conditions are valid */
284
+ isValid: boolean;
285
+ /** Current validation errors */
286
+ validationErrors: ValidationError[];
287
+ /** Whether there are any conditions */
288
+ hasConditions: boolean;
289
+
290
+ /** Add a new filter condition */
291
+ addCondition: (
292
+ condition: Omit<FilterConditionWithId, "id" | "isValid">
293
+ ) => string;
294
+ /** Update an existing condition */
295
+ updateCondition: (
296
+ id: string,
297
+ updates: Partial<FilterConditionWithId>
298
+ ) => boolean;
299
+ /** Remove a condition */
300
+ removeCondition: (id: string) => boolean;
301
+ /** Clear all conditions */
302
+ clearConditions: () => void;
303
+ /** Get a specific condition */
304
+ getCondition: (id: string) => FilterConditionWithId | undefined;
305
+
306
+ /** Set logical operator */
307
+ setLogicalOperator: (operator: LogicalOperator) => void;
308
+
309
+ /** Bulk operations */
310
+ setConditions: (conditions: FilterConditionWithId[]) => void;
311
+ replaceCondition: (
312
+ id: string,
313
+ newCondition: Omit<FilterConditionWithId, "id" | "isValid">
314
+ ) => boolean;
315
+
316
+ /** Validation */
317
+ validateCondition: (condition: Partial<FilterConditionWithId>) => any;
318
+ validateAllConditions: () => any;
319
+
320
+ /** State management */
321
+ exportState: () => any;
322
+ importState: (state: any) => void;
323
+ resetToInitial: () => void;
324
+
325
+ /** Utilities */
326
+ getConditionCount: () => number;
327
+ }
328
+
329
+ /**
330
+ * Main return interface for useKanban hook
331
+ * Follows useTable pattern with flat access
332
+ */
333
+ export interface UseKanbanReturn<T> {
334
+ // ============================================================
335
+ // DATA
336
+ // ============================================================
337
+
338
+ /** All columns with their cards */
339
+ columns: KanbanColumn<T>[];
340
+ /** Total number of cards across all columns */
341
+ totalCards: number;
342
+
343
+ // ============================================================
344
+ // LOADING STATES
345
+ // ============================================================
346
+
347
+ /** Initial data loading */
348
+ isLoading: boolean;
349
+ /** Background refetching */
350
+ isFetching: boolean;
351
+ /** Any mutation in progress */
352
+ isUpdating: boolean;
353
+
354
+ // ============================================================
355
+ // ERROR HANDLING
356
+ // ============================================================
357
+
358
+ /** Current error state */
359
+ error: Error | null;
360
+
361
+ // ============================================================
362
+ // CARD OPERATIONS (Flat Access)
363
+ // ============================================================
364
+
365
+ /** Create a new card */
366
+ createCard: (
367
+ card: Partial<KanbanCard<T>> & { columnId: string }
368
+ ) => Promise<string>;
369
+ /** Update an existing card */
370
+ updateCard: (id: string, updates: Partial<KanbanCard<T>>) => Promise<void>;
371
+ /** Delete a card */
372
+ deleteCard: (id: string) => Promise<void>;
373
+ /** Move a card to a different column */
374
+ moveCard: (
375
+ cardId: string,
376
+ toColumnId: string,
377
+ position?: number,
378
+ fromColumnId?: string
379
+ ) => Promise<void>;
380
+ /** Reorder cards within a column */
381
+ reorderCards: (cardIds: string[], columnId: string) => Promise<void>;
382
+
383
+ // ============================================================
384
+ // SEARCH (Flat Access)
385
+ // ============================================================
386
+
387
+ /** Current search query */
388
+ searchQuery: string;
389
+ /** Set search query */
390
+ setSearchQuery: (value: string) => void;
391
+ /** Clear search query */
392
+ clearSearch: () => void;
393
+
394
+ // ============================================================
395
+ // FILTER (Nested - following useTable pattern)
396
+ // ============================================================
397
+
398
+ /** Filter functionality */
399
+ filter: FilterOperations;
400
+
401
+ // ============================================================
402
+ // DRAG DROP (Flat Access)
403
+ // ============================================================
404
+
405
+ /** Whether a drag operation is in progress */
406
+ isDragging: boolean;
407
+ /** The card currently being dragged */
408
+ draggedCard: KanbanCard<T> | null;
409
+ /** The column currently being hovered over during drag */
410
+ dragOverColumn: string | null;
411
+ /** Handle drag start event */
412
+ handleDragStart: (event: DragEvent, card: KanbanCard<T>) => void;
413
+ /** Handle drag over event */
414
+ handleDragOver: (event: DragEvent, columnId?: string) => void;
415
+ /** Handle drop event */
416
+ handleDrop: (event: DragEvent, columnId: string) => void;
417
+ /** Handle drag end event */
418
+ handleDragEnd: () => void;
419
+ /** Handle keyboard navigation */
420
+ handleKeyDown: (event: KeyboardEvent, card: KanbanCard<T>) => void;
421
+
422
+ // ============================================================
423
+ // PROP GETTERS
424
+ // ============================================================
425
+
426
+ /**
427
+ * Get props for a draggable card
428
+ */
429
+ getCardProps: (card: KanbanCard<T>) => {
430
+ draggable: boolean;
431
+ role: string;
432
+ "aria-selected": boolean;
433
+ "aria-grabbed": boolean;
434
+ onDragStart: (e: any) => void;
435
+ onDragEnd: () => void;
436
+ onKeyDown: (e: any) => void;
437
+ };
438
+
439
+ /**
440
+ * Get props for a droppable column
441
+ */
442
+ getColumnProps: (columnId: string) => {
443
+ "data-column-id": string;
444
+ role: string;
445
+ onDragOver: (e: any) => void;
446
+ onDrop: (e: any) => void;
447
+ };
448
+
449
+ // ============================================================
450
+ // UTILITIES
451
+ // ============================================================
452
+
453
+ /** Refetch all data */
454
+ refetch: () => Promise<void>;
455
+ /** Refresh data (invalidate cache) */
456
+ refresh: () => Promise<void>;
457
+
458
+ /** Load more cards for a specific column (Pagination) */
459
+ loadMore: (columnId: string) => void;
460
+ }
461
+
462
+ // ============================================================
463
+ // API INTEGRATION TYPES
464
+ // ============================================================
465
+
466
+ /**
467
+ * API response for card operations
468
+ */
469
+ export interface CardApiResponse<T> {
470
+ Data: KanbanCard<T>[];
471
+ }
472
+
473
+ /**
474
+ * API response for column operations
475
+ */
476
+ export interface ColumnApiResponse<T> {
477
+ Data: KanbanColumn<T>[];
478
+ }
479
+
480
+ /**
481
+ * Request payload for moving a card
482
+ */
483
+ export interface MoveCardRequest {
484
+ cardId: string;
485
+ toColumnId: string;
486
+ position?: number;
487
+ }
488
+
489
+ /**
490
+ * Request payload for reordering items
491
+ */
492
+ export interface ReorderRequest {
493
+ itemIds: string[];
494
+ containerId?: string; // for cards, this would be columnId
495
+ }
496
+
497
+ /**
498
+ * Bulk card update request
499
+ */
500
+ export interface BulkCardUpdateRequest<T> {
501
+ updates: Array<{
502
+ cardId: string;
503
+ data: Partial<KanbanCard<T>>;
504
+ }>;
505
+ }
506
+
507
+ /**
508
+ * Bulk column update request
509
+ */
510
+ export interface BulkColumnUpdateRequest<T> {
511
+ updates: Array<{
512
+ columnId: string;
513
+ data: Partial<KanbanColumn<T>>;
514
+ }>;
515
+ }
516
+
517
+ // ============================================================
518
+ // VALIDATION TYPES
519
+ // ============================================================
520
+
521
+ /**
522
+ * Validation result interface
523
+ */
524
+ export interface ValidationResult {
525
+ isValid: boolean;
526
+ message?: string;
527
+ errors?: Array<{
528
+ field: string;
529
+ message: string;
530
+ }>;
531
+ }
532
+
533
+ /**
534
+ * Card validation context
535
+ */
536
+ export interface CardValidationContext<T> {
537
+ card: Partial<KanbanCard<T>>;
538
+ column?: KanbanColumn<T>;
539
+ allColumns: KanbanColumn<T>[];
540
+ fieldDefinitions?: Record<keyof T, FieldDefinition>;
541
+ }
542
+
543
+ /**
544
+ * Column validation context
545
+ */
546
+ export interface ColumnValidationContext<T> {
547
+ column: Partial<KanbanColumn<T>>;
548
+ allColumns: KanbanColumn<T>[];
549
+ }
550
+
551
+ // ============================================================
552
+ // EVENT TYPES
553
+ // ============================================================
554
+
555
+ /**
556
+ * Kanban event types for callbacks
557
+ */
558
+ export type KanbanEventType =
559
+ | "card-created"
560
+ | "card-updated"
561
+ | "card-deleted"
562
+ | "card-moved"
563
+ | "cards-reordered";
564
+
565
+ /**
566
+ * Kanban event data
567
+ */
568
+ export interface KanbanEvent<T> {
569
+ type: KanbanEventType;
570
+ timestamp: Date;
571
+ data: any;
572
+ card?: KanbanCard<T>;
573
+ column?: KanbanColumn<T>;
574
+ fromColumnId?: string;
575
+ toColumnId?: string;
576
+ }
577
+
578
+ // ============================================================
579
+ // UTILITY TYPES
580
+ // ============================================================
581
+
582
+ /**
583
+ * Utility type for extracting card type from column
584
+ */
585
+ export type ExtractCardType<C> = C extends KanbanColumn<infer T> ? T : never;
586
+
587
+ /**
588
+ * Utility type for making certain fields optional
589
+ */
590
+ export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
591
+
592
+ /**
593
+ * Utility type for card creation (auto-generated fields optional)
594
+ */
595
+ export type CreateCardInput<T> = PartialBy<
596
+ KanbanCard<T>,
597
+ "_id" | "position" | "_created_at" | "_modified_at"
598
+ >;
599
+
600
+ /**
601
+ * Utility type for column creation (auto-generated fields optional)
602
+ */
603
+ export type CreateColumnInput<T> = PartialBy<
604
+ KanbanColumn<T>,
605
+ "_id" | "position" | "cards" | "_created_at" | "_modified_at"
606
+ >;