@ram_28/kf-ai-sdk 1.0.11 → 1.0.13
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 +2355 -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 +1060 -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/useQuery-BScHEo7x.cjs +1 -0
- package/dist/useQuery-KpZFg80c.js +748 -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
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// BASE TYPES MODULE - Field Type Exports
|
|
3
|
+
// @ram_28/kf-ai-sdk/types
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
export type {
|
|
7
|
+
// ID and String fields
|
|
8
|
+
IdFieldType,
|
|
9
|
+
StringFieldType,
|
|
10
|
+
TextAreaFieldType,
|
|
11
|
+
|
|
12
|
+
// Numeric fields
|
|
13
|
+
NumberFieldType,
|
|
14
|
+
LongFieldType,
|
|
15
|
+
|
|
16
|
+
// Boolean field
|
|
17
|
+
BooleanFieldType,
|
|
18
|
+
|
|
19
|
+
// Date/Time fields
|
|
20
|
+
DateFieldType,
|
|
21
|
+
DateTimeFieldType,
|
|
22
|
+
|
|
23
|
+
// Complex fields
|
|
24
|
+
CurrencyFieldType,
|
|
25
|
+
CurrencyValueType,
|
|
26
|
+
JSONFieldType,
|
|
27
|
+
ReferenceFieldType,
|
|
28
|
+
|
|
29
|
+
// JSON types
|
|
30
|
+
JSONValueType,
|
|
31
|
+
JSONObjectType,
|
|
32
|
+
JSONArrayType,
|
|
33
|
+
|
|
34
|
+
// Select/Lookup fields
|
|
35
|
+
SelectFieldType,
|
|
36
|
+
LookupFieldType,
|
|
37
|
+
|
|
38
|
+
// Container types
|
|
39
|
+
ArrayFieldType,
|
|
40
|
+
ObjectFieldType,
|
|
41
|
+
OptionalFieldType,
|
|
42
|
+
|
|
43
|
+
// Utility types
|
|
44
|
+
ExtractFieldTypeType,
|
|
45
|
+
} from './types/base-fields';
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
// Table hook
|
|
2
2
|
export { useTable } from "./useTable";
|
|
3
3
|
export type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
UseTableOptionsType,
|
|
5
|
+
UseTableReturnType,
|
|
6
|
+
ColumnDefinitionType,
|
|
7
7
|
} from "./useTable";
|
|
8
8
|
|
|
9
9
|
// Form hook
|
|
10
10
|
export { useForm } from "./useForm";
|
|
11
11
|
export type {
|
|
12
12
|
// Core types
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
UseFormOptionsType,
|
|
14
|
+
UseFormReturnType,
|
|
15
|
+
FormOperationType,
|
|
16
|
+
FormModeType,
|
|
17
17
|
|
|
18
18
|
// Form field configuration
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
FormFieldConfigType,
|
|
20
|
+
FormSchemaConfigType,
|
|
21
|
+
FormFieldTypeType,
|
|
22
|
+
SelectOptionType,
|
|
23
|
+
FieldPermissionType,
|
|
24
24
|
|
|
25
25
|
// Result types
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
FieldValidationResultType,
|
|
27
|
+
SubmissionResultType,
|
|
28
28
|
|
|
29
29
|
// BDO Schema types (advanced)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
BDOSchemaType,
|
|
31
|
+
BDOFieldDefinitionType,
|
|
32
|
+
SchemaValidationRuleType,
|
|
33
33
|
} from "./useForm";
|
|
34
34
|
|
|
35
35
|
// Error utilities
|
|
@@ -43,11 +43,11 @@ export {
|
|
|
43
43
|
// Kanban hook
|
|
44
44
|
export { useKanban } from "./useKanban";
|
|
45
45
|
export type {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
UseKanbanOptionsType,
|
|
47
|
+
UseKanbanReturnType,
|
|
48
|
+
KanbanCardType,
|
|
49
|
+
KanbanColumnType,
|
|
50
|
+
ColumnConfigType,
|
|
51
51
|
} from "./useKanban";
|
|
52
52
|
|
|
53
53
|
// Filter hook
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
// Main hook export
|
|
2
2
|
export { useFilter } from "./useFilter";
|
|
3
3
|
|
|
4
|
-
// Type exports
|
|
4
|
+
// Type exports
|
|
5
5
|
export type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// Legacy type exports
|
|
14
|
-
FilterCondition,
|
|
15
|
-
FilterOperator,
|
|
6
|
+
ConditionType,
|
|
7
|
+
ConditionGroupType,
|
|
8
|
+
ConditionGroupOperatorType,
|
|
9
|
+
FilterType,
|
|
10
|
+
FilterRHSTypeType,
|
|
11
|
+
UseFilterOptionsType,
|
|
12
|
+
UseFilterReturnType,
|
|
16
13
|
} from "./types";
|
|
17
14
|
|
|
18
15
|
// Type guard exports
|
|
19
16
|
export {
|
|
20
17
|
isCondition,
|
|
21
18
|
isConditionGroup,
|
|
22
|
-
// Legacy type guard exports
|
|
23
|
-
isFilterCondition,
|
|
24
|
-
isFilterLogical,
|
|
25
19
|
} from "./types";
|
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// Legacy types for backwards compatibility
|
|
8
|
-
FilterCondition,
|
|
9
|
-
FilterOperator,
|
|
2
|
+
ConditionType,
|
|
3
|
+
ConditionGroupType,
|
|
4
|
+
ConditionGroupOperatorType,
|
|
5
|
+
FilterType,
|
|
6
|
+
FilterRHSTypeType,
|
|
10
7
|
} from "../../../types/common";
|
|
11
8
|
|
|
12
9
|
// Re-export from common types for convenience
|
|
13
10
|
export type {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// Legacy re-exports
|
|
20
|
-
FilterCondition,
|
|
21
|
-
FilterOperator,
|
|
11
|
+
ConditionType,
|
|
12
|
+
ConditionGroupType,
|
|
13
|
+
ConditionGroupOperatorType,
|
|
14
|
+
FilterType,
|
|
15
|
+
FilterRHSTypeType,
|
|
22
16
|
};
|
|
23
17
|
|
|
24
18
|
// ============================================================
|
|
@@ -29,8 +23,8 @@ export type {
|
|
|
29
23
|
* Type guard to check if an item is a ConditionGroup (has nested Condition array)
|
|
30
24
|
*/
|
|
31
25
|
export const isConditionGroup = (
|
|
32
|
-
item:
|
|
33
|
-
): item is
|
|
26
|
+
item: ConditionType | ConditionGroupType
|
|
27
|
+
): item is ConditionGroupType => {
|
|
34
28
|
return "Condition" in item;
|
|
35
29
|
};
|
|
36
30
|
|
|
@@ -38,25 +32,11 @@ export const isConditionGroup = (
|
|
|
38
32
|
* Type guard to check if an item is a leaf Condition (has LHSField)
|
|
39
33
|
*/
|
|
40
34
|
export const isCondition = (
|
|
41
|
-
item:
|
|
42
|
-
): item is
|
|
35
|
+
item: ConditionType | ConditionGroupType
|
|
36
|
+
): item is ConditionType => {
|
|
43
37
|
return "LHSField" in item;
|
|
44
38
|
};
|
|
45
39
|
|
|
46
|
-
// ============================================================
|
|
47
|
-
// LEGACY TYPE GUARDS (for backwards compatibility)
|
|
48
|
-
// ============================================================
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @deprecated Use `isConditionGroup` instead
|
|
52
|
-
*/
|
|
53
|
-
export const isFilterLogical = isConditionGroup;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @deprecated Use `isCondition` instead
|
|
57
|
-
*/
|
|
58
|
-
export const isFilterCondition = isCondition;
|
|
59
|
-
|
|
60
40
|
// ============================================================
|
|
61
41
|
// HOOK-SPECIFIC TYPE DEFINITIONS
|
|
62
42
|
// ============================================================
|
|
@@ -64,29 +44,29 @@ export const isFilterCondition = isCondition;
|
|
|
64
44
|
/**
|
|
65
45
|
* Hook options (minimal configuration)
|
|
66
46
|
*/
|
|
67
|
-
export interface
|
|
47
|
+
export interface UseFilterOptionsType {
|
|
68
48
|
/** Initial filter conditions */
|
|
69
|
-
initialConditions?: Array<
|
|
49
|
+
initialConditions?: Array<ConditionType | ConditionGroupType>;
|
|
70
50
|
/** Initial operator for combining conditions (defaults to "And") */
|
|
71
|
-
initialOperator?:
|
|
51
|
+
initialOperator?: ConditionGroupOperatorType;
|
|
72
52
|
}
|
|
73
53
|
|
|
74
54
|
/**
|
|
75
55
|
* Hook return interface with nested filter support
|
|
76
56
|
*/
|
|
77
|
-
export interface
|
|
57
|
+
export interface UseFilterReturnType {
|
|
78
58
|
// ============================================================
|
|
79
59
|
// STATE (read-only)
|
|
80
60
|
// ============================================================
|
|
81
61
|
|
|
82
62
|
/** Current operator for combining root-level conditions ("And" | "Or" | "Not") */
|
|
83
|
-
operator:
|
|
63
|
+
operator: ConditionGroupOperatorType;
|
|
84
64
|
|
|
85
65
|
/** Current filter items (with id populated) */
|
|
86
|
-
items: Array<
|
|
66
|
+
items: Array<ConditionType | ConditionGroupType>;
|
|
87
67
|
|
|
88
68
|
/** Ready-to-use API payload (id stripped, undefined if no conditions) */
|
|
89
|
-
payload:
|
|
69
|
+
payload: FilterType | undefined;
|
|
90
70
|
|
|
91
71
|
/** Whether any conditions exist */
|
|
92
72
|
hasConditions: boolean;
|
|
@@ -99,27 +79,27 @@ export interface UseFilterReturn {
|
|
|
99
79
|
* Add a leaf condition at root level
|
|
100
80
|
* @returns The id of the created condition
|
|
101
81
|
*/
|
|
102
|
-
add: (condition: Omit<
|
|
82
|
+
add: (condition: Omit<ConditionType, "id">) => string;
|
|
103
83
|
|
|
104
84
|
/**
|
|
105
85
|
* Add a condition group at root level
|
|
106
86
|
* @returns The id of the created group
|
|
107
87
|
*/
|
|
108
|
-
addGroup: (operator:
|
|
88
|
+
addGroup: (operator: ConditionGroupOperatorType) => string;
|
|
109
89
|
|
|
110
90
|
/**
|
|
111
91
|
* Add a leaf condition to a specific parent group
|
|
112
92
|
* @param parentId - The id of the parent ConditionGroup
|
|
113
93
|
* @returns The id of the created condition
|
|
114
94
|
*/
|
|
115
|
-
addTo: (parentId: string, condition: Omit<
|
|
95
|
+
addTo: (parentId: string, condition: Omit<ConditionType, "id">) => string;
|
|
116
96
|
|
|
117
97
|
/**
|
|
118
98
|
* Add a condition group to a specific parent group
|
|
119
99
|
* @param parentId - The id of the parent ConditionGroup
|
|
120
100
|
* @returns The id of the created group
|
|
121
101
|
*/
|
|
122
|
-
addGroupTo: (parentId: string, operator:
|
|
102
|
+
addGroupTo: (parentId: string, operator: ConditionGroupOperatorType) => string;
|
|
123
103
|
|
|
124
104
|
// ============================================================
|
|
125
105
|
// UPDATE OPERATIONS
|
|
@@ -130,14 +110,14 @@ export interface UseFilterReturn {
|
|
|
130
110
|
* @param id - The id of the condition to update
|
|
131
111
|
* @param updates - Partial updates to apply
|
|
132
112
|
*/
|
|
133
|
-
update: (id: string, updates: Partial<Omit<
|
|
113
|
+
update: (id: string, updates: Partial<Omit<ConditionType, "id">>) => void;
|
|
134
114
|
|
|
135
115
|
/**
|
|
136
116
|
* Update a condition group's operator by id
|
|
137
117
|
* @param id - The id of the group to update
|
|
138
118
|
* @param operator - The new operator
|
|
139
119
|
*/
|
|
140
|
-
updateOperator: (id: string, operator:
|
|
120
|
+
updateOperator: (id: string, operator: ConditionGroupOperatorType) => void;
|
|
141
121
|
|
|
142
122
|
// ============================================================
|
|
143
123
|
// REMOVE & ACCESS
|
|
@@ -154,7 +134,7 @@ export interface UseFilterReturn {
|
|
|
154
134
|
* @param id - The id to look up
|
|
155
135
|
* @returns The item or undefined if not found
|
|
156
136
|
*/
|
|
157
|
-
get: (id: string) =>
|
|
137
|
+
get: (id: string) => ConditionType | ConditionGroupType | undefined;
|
|
158
138
|
|
|
159
139
|
// ============================================================
|
|
160
140
|
// UTILITY
|
|
@@ -164,14 +144,5 @@ export interface UseFilterReturn {
|
|
|
164
144
|
clear: () => void;
|
|
165
145
|
|
|
166
146
|
/** Set the root operator for combining conditions */
|
|
167
|
-
setOperator: (op:
|
|
168
|
-
|
|
169
|
-
// ============================================================
|
|
170
|
-
// LEGACY API (for backwards compatibility)
|
|
171
|
-
// ============================================================
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* @deprecated Use `items` instead
|
|
175
|
-
*/
|
|
176
|
-
conditions: Array<Condition | ConditionGroup>;
|
|
147
|
+
setOperator: (op: ConditionGroupOperatorType) => void;
|
|
177
148
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useState, useCallback, useMemo } from "react";
|
|
2
2
|
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
ConditionType,
|
|
4
|
+
ConditionGroupType,
|
|
5
|
+
ConditionGroupOperatorType,
|
|
6
|
+
FilterType,
|
|
7
7
|
} from "../../../types/common";
|
|
8
|
-
import type {
|
|
8
|
+
import type { UseFilterOptionsType, UseFilterReturnType } from "./types";
|
|
9
9
|
import { isConditionGroup } from "./types";
|
|
10
10
|
|
|
11
11
|
// ============================================================
|
|
@@ -24,7 +24,7 @@ const generateId = (): string => {
|
|
|
24
24
|
/**
|
|
25
25
|
* Ensure an item has an id
|
|
26
26
|
*/
|
|
27
|
-
const ensureId = <T extends
|
|
27
|
+
const ensureId = <T extends ConditionType | ConditionGroupType>(item: T): T => {
|
|
28
28
|
if (!item.id) {
|
|
29
29
|
return { ...item, id: generateId() };
|
|
30
30
|
}
|
|
@@ -35,8 +35,8 @@ const ensureId = <T extends Condition | ConditionGroup>(item: T): T => {
|
|
|
35
35
|
* Deep clone and ensure all items have ids
|
|
36
36
|
*/
|
|
37
37
|
const cloneWithIds = (
|
|
38
|
-
items: Array<
|
|
39
|
-
): Array<
|
|
38
|
+
items: Array<ConditionType | ConditionGroupType>
|
|
39
|
+
): Array<ConditionType | ConditionGroupType> => {
|
|
40
40
|
return items.map((item) => {
|
|
41
41
|
const withId = ensureId(item);
|
|
42
42
|
if (isConditionGroup(withId)) {
|
|
@@ -53,18 +53,18 @@ const cloneWithIds = (
|
|
|
53
53
|
* Strip id fields from items for API payload
|
|
54
54
|
*/
|
|
55
55
|
const stripIds = (
|
|
56
|
-
items: Array<
|
|
57
|
-
): Array<
|
|
56
|
+
items: Array<ConditionType | ConditionGroupType>
|
|
57
|
+
): Array<ConditionType | ConditionGroupType> => {
|
|
58
58
|
return items.map((item) => {
|
|
59
59
|
if (isConditionGroup(item)) {
|
|
60
60
|
const { id, ...rest } = item;
|
|
61
61
|
return {
|
|
62
62
|
...rest,
|
|
63
63
|
Condition: stripIds(item.Condition),
|
|
64
|
-
} as
|
|
64
|
+
} as ConditionGroupType;
|
|
65
65
|
}
|
|
66
66
|
const { id, ...rest } = item;
|
|
67
|
-
return rest as
|
|
67
|
+
return rest as ConditionType;
|
|
68
68
|
});
|
|
69
69
|
};
|
|
70
70
|
|
|
@@ -72,9 +72,9 @@ const stripIds = (
|
|
|
72
72
|
* Find an item by id in a tree structure
|
|
73
73
|
*/
|
|
74
74
|
const findById = (
|
|
75
|
-
items: Array<
|
|
75
|
+
items: Array<ConditionType | ConditionGroupType>,
|
|
76
76
|
id: string
|
|
77
|
-
):
|
|
77
|
+
): ConditionType | ConditionGroupType | undefined => {
|
|
78
78
|
for (const item of items) {
|
|
79
79
|
if (item.id === id) {
|
|
80
80
|
return item;
|
|
@@ -91,10 +91,10 @@ const findById = (
|
|
|
91
91
|
* Find a parent group by child id
|
|
92
92
|
*/
|
|
93
93
|
const findParentById = (
|
|
94
|
-
items: Array<
|
|
94
|
+
items: Array<ConditionType | ConditionGroupType>,
|
|
95
95
|
childId: string,
|
|
96
|
-
parent:
|
|
97
|
-
):
|
|
96
|
+
parent: ConditionGroupType | null = null
|
|
97
|
+
): ConditionGroupType | null => {
|
|
98
98
|
for (const item of items) {
|
|
99
99
|
if (item.id === childId) {
|
|
100
100
|
return parent;
|
|
@@ -111,10 +111,10 @@ const findParentById = (
|
|
|
111
111
|
* Update an item in the tree by id
|
|
112
112
|
*/
|
|
113
113
|
const updateInTree = (
|
|
114
|
-
items: Array<
|
|
114
|
+
items: Array<ConditionType | ConditionGroupType>,
|
|
115
115
|
id: string,
|
|
116
|
-
updater: (item:
|
|
117
|
-
): Array<
|
|
116
|
+
updater: (item: ConditionType | ConditionGroupType) => ConditionType | ConditionGroupType
|
|
117
|
+
): Array<ConditionType | ConditionGroupType> => {
|
|
118
118
|
return items.map((item) => {
|
|
119
119
|
if (item.id === id) {
|
|
120
120
|
return updater(item);
|
|
@@ -133,9 +133,9 @@ const updateInTree = (
|
|
|
133
133
|
* Remove an item from the tree by id
|
|
134
134
|
*/
|
|
135
135
|
const removeFromTree = (
|
|
136
|
-
items: Array<
|
|
136
|
+
items: Array<ConditionType | ConditionGroupType>,
|
|
137
137
|
id: string
|
|
138
|
-
): Array<
|
|
138
|
+
): Array<ConditionType | ConditionGroupType> => {
|
|
139
139
|
return items
|
|
140
140
|
.filter((item) => item.id !== id)
|
|
141
141
|
.map((item) => {
|
|
@@ -153,10 +153,10 @@ const removeFromTree = (
|
|
|
153
153
|
* Add an item to a specific parent in the tree
|
|
154
154
|
*/
|
|
155
155
|
const addToParent = (
|
|
156
|
-
items: Array<
|
|
156
|
+
items: Array<ConditionType | ConditionGroupType>,
|
|
157
157
|
parentId: string,
|
|
158
|
-
newItem:
|
|
159
|
-
): Array<
|
|
158
|
+
newItem: ConditionType | ConditionGroupType
|
|
159
|
+
): Array<ConditionType | ConditionGroupType> => {
|
|
160
160
|
return items.map((item) => {
|
|
161
161
|
if (item.id === parentId && isConditionGroup(item)) {
|
|
162
162
|
return {
|
|
@@ -178,18 +178,18 @@ const addToParent = (
|
|
|
178
178
|
// USE FILTER HOOK - Nested Filter Support
|
|
179
179
|
// ============================================================
|
|
180
180
|
|
|
181
|
-
export function useFilter(options:
|
|
181
|
+
export function useFilter(options: UseFilterOptionsType = {}): UseFilterReturnType {
|
|
182
182
|
// Initialize items with ids
|
|
183
|
-
const [items, setItems] = useState<Array<
|
|
183
|
+
const [items, setItems] = useState<Array<ConditionType | ConditionGroupType>>(() =>
|
|
184
184
|
cloneWithIds(options.initialConditions || [])
|
|
185
185
|
);
|
|
186
186
|
|
|
187
|
-
const [operator, setOperatorState] = useState<
|
|
187
|
+
const [operator, setOperatorState] = useState<ConditionGroupOperatorType>(
|
|
188
188
|
options.initialOperator || "And"
|
|
189
189
|
);
|
|
190
190
|
|
|
191
191
|
// Build payload for API (strip ids)
|
|
192
|
-
const payload = useMemo(():
|
|
192
|
+
const payload = useMemo((): FilterType | undefined => {
|
|
193
193
|
if (items.length === 0) return undefined;
|
|
194
194
|
return {
|
|
195
195
|
Operator: operator,
|
|
@@ -203,16 +203,16 @@ export function useFilter(options: UseFilterOptions = {}): UseFilterReturn {
|
|
|
203
203
|
// ADD OPERATIONS
|
|
204
204
|
// ============================================================
|
|
205
205
|
|
|
206
|
-
const add = useCallback((condition: Omit<
|
|
206
|
+
const add = useCallback((condition: Omit<ConditionType, "id">): string => {
|
|
207
207
|
const id = generateId();
|
|
208
|
-
const newCondition:
|
|
208
|
+
const newCondition: ConditionType = { ...condition, id };
|
|
209
209
|
setItems((prev) => [...prev, newCondition]);
|
|
210
210
|
return id;
|
|
211
211
|
}, []);
|
|
212
212
|
|
|
213
|
-
const addGroup = useCallback((groupOperator:
|
|
213
|
+
const addGroup = useCallback((groupOperator: ConditionGroupOperatorType): string => {
|
|
214
214
|
const id = generateId();
|
|
215
|
-
const newGroup:
|
|
215
|
+
const newGroup: ConditionGroupType = {
|
|
216
216
|
id,
|
|
217
217
|
Operator: groupOperator,
|
|
218
218
|
Condition: [],
|
|
@@ -222,9 +222,9 @@ export function useFilter(options: UseFilterOptions = {}): UseFilterReturn {
|
|
|
222
222
|
}, []);
|
|
223
223
|
|
|
224
224
|
const addTo = useCallback(
|
|
225
|
-
(parentId: string, condition: Omit<
|
|
225
|
+
(parentId: string, condition: Omit<ConditionType, "id">): string => {
|
|
226
226
|
const id = generateId();
|
|
227
|
-
const newCondition:
|
|
227
|
+
const newCondition: ConditionType = { ...condition, id };
|
|
228
228
|
setItems((prev) => addToParent(prev, parentId, newCondition));
|
|
229
229
|
return id;
|
|
230
230
|
},
|
|
@@ -232,9 +232,9 @@ export function useFilter(options: UseFilterOptions = {}): UseFilterReturn {
|
|
|
232
232
|
);
|
|
233
233
|
|
|
234
234
|
const addGroupTo = useCallback(
|
|
235
|
-
(parentId: string, groupOperator:
|
|
235
|
+
(parentId: string, groupOperator: ConditionGroupOperatorType): string => {
|
|
236
236
|
const id = generateId();
|
|
237
|
-
const newGroup:
|
|
237
|
+
const newGroup: ConditionGroupType = {
|
|
238
238
|
id,
|
|
239
239
|
Operator: groupOperator,
|
|
240
240
|
Condition: [],
|
|
@@ -250,7 +250,7 @@ export function useFilter(options: UseFilterOptions = {}): UseFilterReturn {
|
|
|
250
250
|
// ============================================================
|
|
251
251
|
|
|
252
252
|
const update = useCallback(
|
|
253
|
-
(id: string, updates: Partial<Omit<
|
|
253
|
+
(id: string, updates: Partial<Omit<ConditionType, "id">>): void => {
|
|
254
254
|
setItems((prev) =>
|
|
255
255
|
updateInTree(prev, id, (item) => {
|
|
256
256
|
if (!isConditionGroup(item)) {
|
|
@@ -264,7 +264,7 @@ export function useFilter(options: UseFilterOptions = {}): UseFilterReturn {
|
|
|
264
264
|
);
|
|
265
265
|
|
|
266
266
|
const updateOperator = useCallback(
|
|
267
|
-
(id: string, newOperator:
|
|
267
|
+
(id: string, newOperator: ConditionGroupOperatorType): void => {
|
|
268
268
|
setItems((prev) =>
|
|
269
269
|
updateInTree(prev, id, (item) => {
|
|
270
270
|
if (isConditionGroup(item)) {
|
|
@@ -286,7 +286,7 @@ export function useFilter(options: UseFilterOptions = {}): UseFilterReturn {
|
|
|
286
286
|
}, []);
|
|
287
287
|
|
|
288
288
|
const get = useCallback(
|
|
289
|
-
(id: string):
|
|
289
|
+
(id: string): ConditionType | ConditionGroupType | undefined => {
|
|
290
290
|
return findById(items, id);
|
|
291
291
|
},
|
|
292
292
|
[items]
|
|
@@ -300,7 +300,7 @@ export function useFilter(options: UseFilterOptions = {}): UseFilterReturn {
|
|
|
300
300
|
setItems([]);
|
|
301
301
|
}, []);
|
|
302
302
|
|
|
303
|
-
const setOperator = useCallback((op:
|
|
303
|
+
const setOperator = useCallback((op: ConditionGroupOperatorType): void => {
|
|
304
304
|
setOperatorState(op);
|
|
305
305
|
}, []);
|
|
306
306
|
|
|
@@ -332,8 +332,5 @@ export function useFilter(options: UseFilterOptions = {}): UseFilterReturn {
|
|
|
332
332
|
// Utility
|
|
333
333
|
clear,
|
|
334
334
|
setOperator,
|
|
335
|
-
|
|
336
|
-
// Legacy API
|
|
337
|
-
conditions: items,
|
|
338
335
|
};
|
|
339
336
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// Handles schema fetching and form submissions
|
|
5
5
|
|
|
6
6
|
import { api, getBdoSchema } from "../../../api";
|
|
7
|
-
import type {
|
|
7
|
+
import type { BDOSchemaType, FormOperationType, SubmissionResultType } from "./types";
|
|
8
8
|
|
|
9
9
|
// ============================================================
|
|
10
10
|
// SCHEMA FETCHING
|
|
@@ -13,7 +13,7 @@ import type { BDOSchema, FormOperation, SubmissionResult } from "./types";
|
|
|
13
13
|
/**
|
|
14
14
|
* Fetch BDO schema from backend metadata endpoint
|
|
15
15
|
*/
|
|
16
|
-
export async function fetchFormSchema(source: string): Promise<
|
|
16
|
+
export async function fetchFormSchema(source: string): Promise<BDOSchemaType> {
|
|
17
17
|
try {
|
|
18
18
|
// Use the new metadata API client to fetch BDO schema
|
|
19
19
|
const bdoResp = await getBdoSchema(source);
|
|
@@ -25,7 +25,7 @@ export async function fetchFormSchema(source: string): Promise<BDOSchema> {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// Return the full BDO schema - the form processor will extract what it needs
|
|
28
|
-
return bdoSchema as
|
|
28
|
+
return bdoSchema as BDOSchemaType;
|
|
29
29
|
} catch (error) {
|
|
30
30
|
console.error(`Schema fetch error for ${source}:`, error);
|
|
31
31
|
throw new Error(
|
|
@@ -40,7 +40,7 @@ export async function fetchFormSchema(source: string): Promise<BDOSchema> {
|
|
|
40
40
|
export async function fetchFormSchemaWithRetry(
|
|
41
41
|
source: string,
|
|
42
42
|
maxRetries: number = 3
|
|
43
|
-
): Promise<
|
|
43
|
+
): Promise<BDOSchemaType> {
|
|
44
44
|
let lastError: Error;
|
|
45
45
|
|
|
46
46
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
@@ -88,10 +88,10 @@ export async function fetchRecord<T = any>(
|
|
|
88
88
|
*/
|
|
89
89
|
export async function submitFormData<T = any>(
|
|
90
90
|
source: string,
|
|
91
|
-
operation:
|
|
91
|
+
operation: FormOperationType,
|
|
92
92
|
data: Partial<T>,
|
|
93
93
|
recordId?: string
|
|
94
|
-
): Promise<
|
|
94
|
+
): Promise<SubmissionResultType> {
|
|
95
95
|
try {
|
|
96
96
|
let result;
|
|
97
97
|
|
|
@@ -242,7 +242,7 @@ export function validateFormData<T>(
|
|
|
242
242
|
export function cleanFormData<T>(
|
|
243
243
|
data: Partial<T>,
|
|
244
244
|
computedFields: string[],
|
|
245
|
-
operation:
|
|
245
|
+
operation: FormOperationType = "create",
|
|
246
246
|
originalData?: Partial<T>
|
|
247
247
|
): Partial<T> {
|
|
248
248
|
const cleanedData: Partial<T> = {};
|
|
@@ -404,7 +404,7 @@ export function clearCache(keyPrefix?: string): void {
|
|
|
404
404
|
*/
|
|
405
405
|
export async function fetchFormSchemaWithCache(
|
|
406
406
|
source: string
|
|
407
|
-
): Promise<
|
|
407
|
+
): Promise<BDOSchemaType> {
|
|
408
408
|
const cacheKey = `schema:${source}`;
|
|
409
409
|
const cached = getCacheData(cacheKey);
|
|
410
410
|
|