ag-grid-url-sync 0.2.2 → 0.2.4
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 +45 -22
- package/dist/core/grid-integration.d.ts +1 -1
- package/dist/core/grid-integration.js +141 -9
- package/dist/core/grid-integration.js.map +1 -1
- package/dist/core/types.d.ts +174 -36
- package/dist/core/types.js +179 -37
- package/dist/core/types.js.map +1 -1
- package/dist/core/url-generator.js +53 -15
- package/dist/core/url-generator.js.map +1 -1
- package/dist/core/url-parser.js +164 -35
- package/dist/core/url-parser.js.map +1 -1
- package/dist/core/validation.d.ts +38 -5
- package/dist/core/validation.js +115 -3
- package/dist/core/validation.js.map +1 -1
- package/dist/react/types.d.ts +5 -0
- package/dist/react/use-ag-grid-url-sync.js +42 -27
- package/dist/react/use-ag-grid-url-sync.js.map +1 -1
- package/package.json +2 -2
package/dist/core/types.d.ts
CHANGED
|
@@ -1,33 +1,73 @@
|
|
|
1
|
-
import type { GridApi as AGGridApi, TextFilterModel, NumberFilterModel } from 'ag-grid-community';
|
|
1
|
+
import type { GridApi as AGGridApi, TextFilterModel, NumberFilterModel, DateFilterModel } from 'ag-grid-community';
|
|
2
2
|
/**
|
|
3
3
|
* Configuration options for AG Grid URL Sync
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const config: AGGridUrlSyncConfig = {
|
|
8
|
+
* paramPrefix: 'filter_',
|
|
9
|
+
* maxValueLength: 500,
|
|
10
|
+
* onParseError: (error) => console.warn('Filter parse error:', error)
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
4
13
|
*/
|
|
5
14
|
export interface AGGridUrlSyncConfig {
|
|
6
15
|
/**
|
|
7
|
-
* Prefix for URL parameters
|
|
16
|
+
* Prefix for URL parameters
|
|
17
|
+
* @default 'f_'
|
|
18
|
+
* @example 'filter_' results in URLs like '?filter_name_contains=john'
|
|
8
19
|
*/
|
|
9
20
|
paramPrefix?: string;
|
|
10
21
|
/**
|
|
11
|
-
* Maximum length for filter values
|
|
22
|
+
* Maximum length for filter values to prevent URL length issues
|
|
23
|
+
* @default 200
|
|
12
24
|
*/
|
|
13
25
|
maxValueLength?: number;
|
|
14
26
|
/**
|
|
15
|
-
* Optional error handler for parsing errors
|
|
27
|
+
* Optional error handler for parsing errors.
|
|
28
|
+
* Allows graceful error handling without breaking the application.
|
|
16
29
|
*/
|
|
17
30
|
onParseError?: (error: Error) => void;
|
|
18
31
|
}
|
|
19
32
|
/**
|
|
20
|
-
*
|
|
33
|
+
* Internal configuration with all required fields and runtime dependencies
|
|
21
34
|
*/
|
|
22
|
-
export
|
|
35
|
+
export interface InternalConfig extends Required<AGGridUrlSyncConfig> {
|
|
36
|
+
/** AG Grid API instance for filter operations */
|
|
37
|
+
gridApi: AGGridApi;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Text-only filter operations for string-based filtering
|
|
41
|
+
*/
|
|
42
|
+
export declare const TEXT_ONLY_OPERATIONS: readonly ["contains", "notContains", "startsWith", "endsWith"];
|
|
43
|
+
/**
|
|
44
|
+
* Number-only filter operations for numeric comparisons
|
|
45
|
+
*/
|
|
46
|
+
export declare const NUMBER_ONLY_OPERATIONS: readonly ["lessThan", "lessThanOrEqual", "greaterThan", "greaterThanOrEqual", "inRange"];
|
|
47
|
+
/**
|
|
48
|
+
* Date-specific filter operations for temporal comparisons
|
|
49
|
+
*/
|
|
50
|
+
export declare const DATE_ONLY_OPERATIONS: readonly ["dateBefore", "dateBeforeOrEqual", "dateAfter", "dateAfterOrEqual", "dateRange"];
|
|
23
51
|
/**
|
|
24
|
-
*
|
|
52
|
+
* Operations shared across multiple filter types
|
|
25
53
|
*/
|
|
26
|
-
export declare const
|
|
54
|
+
export declare const SHARED_OPERATIONS: readonly ["eq", "notEqual", "blank", "notBlank"];
|
|
27
55
|
/**
|
|
28
|
-
*
|
|
56
|
+
* All supported filter operations across text, number, and date filters
|
|
29
57
|
*/
|
|
30
|
-
export
|
|
58
|
+
export type FilterOperation = (typeof TEXT_ONLY_OPERATIONS)[number] | (typeof NUMBER_ONLY_OPERATIONS)[number] | (typeof DATE_ONLY_OPERATIONS)[number] | (typeof SHARED_OPERATIONS)[number];
|
|
59
|
+
/**
|
|
60
|
+
* Complete list of valid text filter operations
|
|
61
|
+
*/
|
|
62
|
+
export declare const TEXT_FILTER_OPERATIONS: readonly ["contains", "notContains", "startsWith", "endsWith", "eq", "notEqual", "blank", "notBlank"];
|
|
63
|
+
/**
|
|
64
|
+
* Complete list of valid number filter operations
|
|
65
|
+
*/
|
|
66
|
+
export declare const NUMBER_FILTER_OPERATIONS: readonly ["lessThan", "lessThanOrEqual", "greaterThan", "greaterThanOrEqual", "inRange", "eq", "notEqual", "blank", "notBlank"];
|
|
67
|
+
/**
|
|
68
|
+
* Valid date filter operations as const array
|
|
69
|
+
*/
|
|
70
|
+
export declare const DATE_FILTER_OPERATIONS: readonly ["dateBefore", "dateBeforeOrEqual", "dateAfter", "dateAfterOrEqual", "dateRange", "eq", "notEqual", "blank", "notBlank"];
|
|
31
71
|
/**
|
|
32
72
|
* Text-specific filter operations
|
|
33
73
|
*/
|
|
@@ -37,71 +77,169 @@ export type TextFilterOperation = (typeof TEXT_FILTER_OPERATIONS)[number];
|
|
|
37
77
|
*/
|
|
38
78
|
export type NumberFilterOperation = (typeof NUMBER_FILTER_OPERATIONS)[number];
|
|
39
79
|
/**
|
|
40
|
-
*
|
|
80
|
+
* Date-specific filter operations
|
|
81
|
+
*/
|
|
82
|
+
export type DateFilterOperation = (typeof DATE_FILTER_OPERATIONS)[number];
|
|
83
|
+
/**
|
|
84
|
+
* Range operations that require two values (from/to)
|
|
41
85
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
86
|
+
export type RangeOperation = 'inRange' | 'dateRange';
|
|
87
|
+
/**
|
|
88
|
+
* Operations that don't require a filter value
|
|
89
|
+
*/
|
|
90
|
+
export type BlankOperation = 'blank' | 'notBlank';
|
|
91
|
+
/**
|
|
92
|
+
* Supported filter types
|
|
93
|
+
*/
|
|
94
|
+
export type FilterType = 'text' | 'number' | 'date';
|
|
95
|
+
/**
|
|
96
|
+
* Base interface for all column filters with common properties
|
|
97
|
+
*/
|
|
98
|
+
interface BaseColumnFilter<T extends FilterOperation = FilterOperation> {
|
|
99
|
+
/** The filter operation type */
|
|
100
|
+
type: T;
|
|
44
101
|
}
|
|
45
102
|
/**
|
|
46
|
-
* Text filter configuration
|
|
103
|
+
* Text filter configuration for string-based filtering
|
|
47
104
|
*/
|
|
48
|
-
export interface TextColumnFilter extends BaseColumnFilter {
|
|
105
|
+
export interface TextColumnFilter extends BaseColumnFilter<TextFilterOperation> {
|
|
49
106
|
filterType: 'text';
|
|
50
|
-
|
|
107
|
+
/** The text value to filter by */
|
|
51
108
|
filter: string;
|
|
52
109
|
}
|
|
53
110
|
/**
|
|
54
|
-
* Number filter configuration
|
|
111
|
+
* Number filter configuration for numeric filtering
|
|
55
112
|
*/
|
|
56
|
-
export interface NumberColumnFilter extends BaseColumnFilter {
|
|
113
|
+
export interface NumberColumnFilter extends BaseColumnFilter<NumberFilterOperation> {
|
|
57
114
|
filterType: 'number';
|
|
58
|
-
|
|
115
|
+
/** The numeric value to filter by */
|
|
59
116
|
filter: number;
|
|
117
|
+
/** Optional second value for range operations */
|
|
60
118
|
filterTo?: number;
|
|
61
119
|
}
|
|
62
120
|
/**
|
|
63
|
-
*
|
|
121
|
+
* Date filter configuration for temporal filtering.
|
|
122
|
+
* Uses ISO date format (YYYY-MM-DD) for consistency and parseability.
|
|
64
123
|
*/
|
|
65
|
-
export
|
|
124
|
+
export interface DateColumnFilter extends BaseColumnFilter<DateFilterOperation> {
|
|
125
|
+
filterType: 'date';
|
|
126
|
+
/** ISO date string (YYYY-MM-DD) */
|
|
127
|
+
filter: string;
|
|
128
|
+
/** Optional end date for range operations (ISO format) */
|
|
129
|
+
filterTo?: string;
|
|
130
|
+
}
|
|
66
131
|
/**
|
|
67
|
-
*
|
|
132
|
+
* Union type for all possible column filters
|
|
133
|
+
*/
|
|
134
|
+
export type ColumnFilter = TextColumnFilter | NumberColumnFilter | DateColumnFilter;
|
|
135
|
+
/**
|
|
136
|
+
* Complete filter state mapping column IDs to their filters
|
|
68
137
|
*/
|
|
69
138
|
export interface FilterState {
|
|
70
139
|
[columnId: string]: ColumnFilter;
|
|
71
140
|
}
|
|
72
141
|
/**
|
|
73
|
-
*
|
|
142
|
+
* Type guard to check if an operation is text-specific
|
|
74
143
|
*/
|
|
75
|
-
export
|
|
76
|
-
|
|
77
|
-
|
|
144
|
+
export declare function isTextFilterOperation(op: FilterOperation): op is TextFilterOperation;
|
|
145
|
+
/**
|
|
146
|
+
* Type guard to check if an operation is number-specific
|
|
147
|
+
*/
|
|
148
|
+
export declare function isNumberFilterOperation(op: FilterOperation): op is NumberFilterOperation;
|
|
149
|
+
/**
|
|
150
|
+
* Type guard to check if an operation is date-specific
|
|
151
|
+
*/
|
|
152
|
+
export declare function isDateFilterOperation(op: FilterOperation): op is DateFilterOperation;
|
|
78
153
|
/**
|
|
79
|
-
*
|
|
154
|
+
* Type guard to check if an operation requires a range (two values)
|
|
155
|
+
*/
|
|
156
|
+
export declare function isRangeOperation(op: FilterOperation): op is RangeOperation;
|
|
157
|
+
/**
|
|
158
|
+
* Type guard to check if an operation is a blank operation
|
|
159
|
+
*/
|
|
160
|
+
export declare function isBlankOperation(op: FilterOperation): op is BlankOperation;
|
|
161
|
+
/**
|
|
162
|
+
* Type guard to check if a filter is a text filter
|
|
163
|
+
*/
|
|
164
|
+
export declare function isTextFilter(filter: ColumnFilter): filter is TextColumnFilter;
|
|
165
|
+
/**
|
|
166
|
+
* Type guard to check if a filter is a number filter
|
|
167
|
+
*/
|
|
168
|
+
export declare function isNumberFilter(filter: ColumnFilter): filter is NumberColumnFilter;
|
|
169
|
+
/**
|
|
170
|
+
* Type guard to check if a filter is a date filter
|
|
171
|
+
*/
|
|
172
|
+
export declare function isDateFilter(filter: ColumnFilter): filter is DateColumnFilter;
|
|
173
|
+
/**
|
|
174
|
+
* Base error class for all URL sync operations
|
|
80
175
|
*/
|
|
81
176
|
export declare class URLSyncError extends Error {
|
|
82
|
-
|
|
177
|
+
readonly cause?: Error | undefined;
|
|
178
|
+
constructor(message: string, cause?: Error | undefined);
|
|
83
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Error thrown when filter validation fails
|
|
182
|
+
*/
|
|
84
183
|
export declare class InvalidFilterError extends URLSyncError {
|
|
85
|
-
constructor(message: string);
|
|
184
|
+
constructor(message: string, cause?: Error);
|
|
86
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* Error thrown when URL parsing fails
|
|
188
|
+
*/
|
|
87
189
|
export declare class InvalidURLError extends URLSyncError {
|
|
88
|
-
constructor(message: string);
|
|
190
|
+
constructor(message: string, cause?: Error);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Error thrown when date validation fails
|
|
194
|
+
*/
|
|
195
|
+
export declare class InvalidDateError extends InvalidFilterError {
|
|
196
|
+
constructor(message: string, cause?: Error);
|
|
89
197
|
}
|
|
90
|
-
|
|
198
|
+
/**
|
|
199
|
+
* Parsed filter parameter information for internal processing
|
|
200
|
+
*/
|
|
201
|
+
export interface ParsedFilterParam {
|
|
91
202
|
columnName: string;
|
|
92
203
|
operation: FilterOperation;
|
|
93
|
-
filterType:
|
|
204
|
+
filterType: FilterType | 'auto';
|
|
94
205
|
value: string | number;
|
|
95
|
-
filterTo?: number;
|
|
206
|
+
filterTo?: number | string;
|
|
96
207
|
action: 'apply' | 'remove';
|
|
97
|
-
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Re-export GridApi for convenience
|
|
211
|
+
*/
|
|
98
212
|
export type GridApi = AGGridApi;
|
|
99
213
|
/**
|
|
100
214
|
* Union type for AG Grid filters using official AG Grid types
|
|
101
215
|
*/
|
|
102
|
-
export type AGGridFilter = TextFilterModel | NumberFilterModel;
|
|
216
|
+
export type AGGridFilter = TextFilterModel | NumberFilterModel | DateFilterModel;
|
|
217
|
+
/**
|
|
218
|
+
* Raw AG Grid filter object structure from getFilterModel()
|
|
219
|
+
* Used for type-safe destructuring of filter objects
|
|
220
|
+
*/
|
|
221
|
+
export interface RawAGGridFilter {
|
|
222
|
+
filterType?: string;
|
|
223
|
+
type?: string;
|
|
224
|
+
filter?: string | number;
|
|
225
|
+
filterTo?: string | number;
|
|
226
|
+
dateFrom?: string;
|
|
227
|
+
dateTo?: string;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Maps URL operation names to internal operation types
|
|
231
|
+
*/
|
|
103
232
|
export declare const OPERATION_MAP: Record<string, FilterOperation>;
|
|
233
|
+
/**
|
|
234
|
+
* Maps internal operation types to URL operation names
|
|
235
|
+
*/
|
|
104
236
|
export declare const INTERNAL_TO_URL_OPERATION_MAP: Record<FilterOperation, string>;
|
|
105
|
-
|
|
237
|
+
/**
|
|
238
|
+
* Maps internal operation types to AG Grid operation names
|
|
239
|
+
*/
|
|
240
|
+
export declare const AG_GRID_OPERATION_NAMES: Record<string, string>;
|
|
241
|
+
/**
|
|
242
|
+
* Maps AG Grid operation names to internal operation types
|
|
243
|
+
*/
|
|
106
244
|
export declare const REVERSE_AG_GRID_OPERATION_NAMES: Record<string, FilterOperation>;
|
|
107
245
|
export {};
|
package/dist/core/types.js
CHANGED
|
@@ -1,89 +1,220 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// FILTER OPERATION DEFINITIONS
|
|
3
|
+
// ============================================================================
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
5
|
+
* Text-only filter operations for string-based filtering
|
|
3
6
|
*/
|
|
4
|
-
export const
|
|
7
|
+
export const TEXT_ONLY_OPERATIONS = [
|
|
5
8
|
'contains',
|
|
6
|
-
'eq',
|
|
7
9
|
'notContains',
|
|
8
|
-
'notEqual',
|
|
9
10
|
'startsWith',
|
|
10
|
-
'endsWith'
|
|
11
|
-
'blank',
|
|
12
|
-
'notBlank'
|
|
11
|
+
'endsWith'
|
|
13
12
|
];
|
|
14
13
|
/**
|
|
15
|
-
*
|
|
14
|
+
* Number-only filter operations for numeric comparisons
|
|
16
15
|
*/
|
|
17
|
-
export const
|
|
18
|
-
'eq',
|
|
19
|
-
'notEqual',
|
|
16
|
+
export const NUMBER_ONLY_OPERATIONS = [
|
|
20
17
|
'lessThan',
|
|
21
18
|
'lessThanOrEqual',
|
|
22
19
|
'greaterThan',
|
|
23
20
|
'greaterThanOrEqual',
|
|
24
|
-
'inRange'
|
|
21
|
+
'inRange'
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* Date-specific filter operations for temporal comparisons
|
|
25
|
+
*/
|
|
26
|
+
export const DATE_ONLY_OPERATIONS = [
|
|
27
|
+
'dateBefore',
|
|
28
|
+
'dateBeforeOrEqual',
|
|
29
|
+
'dateAfter',
|
|
30
|
+
'dateAfterOrEqual',
|
|
31
|
+
'dateRange'
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* Operations shared across multiple filter types
|
|
35
|
+
*/
|
|
36
|
+
export const SHARED_OPERATIONS = [
|
|
37
|
+
'eq',
|
|
38
|
+
'notEqual',
|
|
25
39
|
'blank',
|
|
26
40
|
'notBlank'
|
|
27
41
|
];
|
|
28
42
|
/**
|
|
29
|
-
*
|
|
43
|
+
* Complete list of valid text filter operations
|
|
44
|
+
*/
|
|
45
|
+
export const TEXT_FILTER_OPERATIONS = [
|
|
46
|
+
...TEXT_ONLY_OPERATIONS,
|
|
47
|
+
...SHARED_OPERATIONS
|
|
48
|
+
];
|
|
49
|
+
/**
|
|
50
|
+
* Complete list of valid number filter operations
|
|
51
|
+
*/
|
|
52
|
+
export const NUMBER_FILTER_OPERATIONS = [
|
|
53
|
+
...NUMBER_ONLY_OPERATIONS,
|
|
54
|
+
...SHARED_OPERATIONS
|
|
55
|
+
];
|
|
56
|
+
/**
|
|
57
|
+
* Valid date filter operations as const array
|
|
58
|
+
*/
|
|
59
|
+
export const DATE_FILTER_OPERATIONS = [
|
|
60
|
+
...DATE_ONLY_OPERATIONS,
|
|
61
|
+
...SHARED_OPERATIONS
|
|
62
|
+
];
|
|
63
|
+
// ============================================================================
|
|
64
|
+
// TYPE GUARDS
|
|
65
|
+
// ============================================================================
|
|
66
|
+
/**
|
|
67
|
+
* Type guard to check if an operation is text-specific
|
|
68
|
+
*/
|
|
69
|
+
export function isTextFilterOperation(op) {
|
|
70
|
+
return TEXT_FILTER_OPERATIONS.includes(op);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Type guard to check if an operation is number-specific
|
|
74
|
+
*/
|
|
75
|
+
export function isNumberFilterOperation(op) {
|
|
76
|
+
return NUMBER_FILTER_OPERATIONS.includes(op);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Type guard to check if an operation is date-specific
|
|
80
|
+
*/
|
|
81
|
+
export function isDateFilterOperation(op) {
|
|
82
|
+
return DATE_FILTER_OPERATIONS.includes(op);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Type guard to check if an operation requires a range (two values)
|
|
86
|
+
*/
|
|
87
|
+
export function isRangeOperation(op) {
|
|
88
|
+
return op === 'inRange' || op === 'dateRange';
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Type guard to check if an operation is a blank operation
|
|
92
|
+
*/
|
|
93
|
+
export function isBlankOperation(op) {
|
|
94
|
+
return op === 'blank' || op === 'notBlank';
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Type guard to check if a filter is a text filter
|
|
98
|
+
*/
|
|
99
|
+
export function isTextFilter(filter) {
|
|
100
|
+
return filter.filterType === 'text';
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Type guard to check if a filter is a number filter
|
|
104
|
+
*/
|
|
105
|
+
export function isNumberFilter(filter) {
|
|
106
|
+
return filter.filterType === 'number';
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Type guard to check if a filter is a date filter
|
|
110
|
+
*/
|
|
111
|
+
export function isDateFilter(filter) {
|
|
112
|
+
return filter.filterType === 'date';
|
|
113
|
+
}
|
|
114
|
+
// ============================================================================
|
|
115
|
+
// ERROR TYPES
|
|
116
|
+
// ============================================================================
|
|
117
|
+
/**
|
|
118
|
+
* Base error class for all URL sync operations
|
|
30
119
|
*/
|
|
31
120
|
export class URLSyncError extends Error {
|
|
32
|
-
|
|
121
|
+
cause;
|
|
122
|
+
constructor(message, cause) {
|
|
33
123
|
super(message);
|
|
124
|
+
this.cause = cause;
|
|
34
125
|
this.name = 'URLSyncError';
|
|
35
126
|
}
|
|
36
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Error thrown when filter validation fails
|
|
130
|
+
*/
|
|
37
131
|
export class InvalidFilterError extends URLSyncError {
|
|
38
|
-
constructor(message) {
|
|
39
|
-
super(message);
|
|
132
|
+
constructor(message, cause) {
|
|
133
|
+
super(message, cause);
|
|
40
134
|
this.name = 'InvalidFilterError';
|
|
41
135
|
}
|
|
42
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Error thrown when URL parsing fails
|
|
139
|
+
*/
|
|
43
140
|
export class InvalidURLError extends URLSyncError {
|
|
44
|
-
constructor(message) {
|
|
45
|
-
super(message);
|
|
141
|
+
constructor(message, cause) {
|
|
142
|
+
super(message, cause);
|
|
46
143
|
this.name = 'InvalidURLError';
|
|
47
144
|
}
|
|
48
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Error thrown when date validation fails
|
|
148
|
+
*/
|
|
149
|
+
export class InvalidDateError extends InvalidFilterError {
|
|
150
|
+
constructor(message, cause) {
|
|
151
|
+
super(message, cause);
|
|
152
|
+
this.name = 'InvalidDateError';
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// ============================================================================
|
|
156
|
+
// OPERATION MAPPINGS
|
|
157
|
+
// ============================================================================
|
|
49
158
|
/**
|
|
50
159
|
* Operation Mapping Strategy:
|
|
51
160
|
*
|
|
52
161
|
* We use three different naming conventions for better user experience:
|
|
53
162
|
*
|
|
54
|
-
* 1. URL Parameters: Short, clean names for URLs (e.g., 'eq', 'neq', '
|
|
163
|
+
* 1. URL Parameters: Short, clean names for URLs (e.g., 'eq', 'neq', 'before', 'after')
|
|
55
164
|
* 2. Internal Types: Consistent naming for our FilterOperation type
|
|
56
|
-
* 3. AG Grid Operations: Exact names expected by AG Grid API (e.g., 'equals', 'notEqual')
|
|
165
|
+
* 3. AG Grid Operations: Exact names expected by AG Grid API (e.g., 'equals', 'notEqual', 'lessThan')
|
|
57
166
|
*
|
|
58
167
|
* This approach keeps URLs readable while maintaining compatibility with AG Grid.
|
|
59
168
|
*/
|
|
60
169
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
170
|
+
* URL shorthand mappings for cleaner URLs.
|
|
171
|
+
* Maps internal operation names to shorter URL parameter names.
|
|
172
|
+
* Operations not listed here use their internal name as URL param.
|
|
63
173
|
*/
|
|
64
174
|
const URL_SHORTHAND_MAPPINGS = {
|
|
175
|
+
// Shared operations
|
|
65
176
|
notEqual: 'neq',
|
|
177
|
+
// Number operations
|
|
66
178
|
lessThan: 'lt',
|
|
67
179
|
lessThanOrEqual: 'lte',
|
|
68
180
|
greaterThan: 'gt',
|
|
69
181
|
greaterThanOrEqual: 'gte',
|
|
70
|
-
inRange: 'range'
|
|
182
|
+
inRange: 'range',
|
|
183
|
+
// Date operations
|
|
184
|
+
dateBefore: 'before',
|
|
185
|
+
dateBeforeOrEqual: 'beforeEq',
|
|
186
|
+
dateAfter: 'after',
|
|
187
|
+
dateAfterOrEqual: 'afterEq',
|
|
188
|
+
dateRange: 'daterange'
|
|
71
189
|
};
|
|
72
190
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
191
|
+
* AG Grid operation name mappings.
|
|
192
|
+
* Maps internal operation names to AG Grid API operation names.
|
|
193
|
+
* Operations not listed here use their internal name for AG Grid.
|
|
75
194
|
*/
|
|
76
195
|
const AG_GRID_NAME_MAPPINGS = {
|
|
77
|
-
|
|
196
|
+
// Shared operations
|
|
197
|
+
eq: 'equals',
|
|
198
|
+
// Date operations (AG Grid uses generic names)
|
|
199
|
+
dateBefore: 'lessThan',
|
|
200
|
+
dateBeforeOrEqual: 'lessThanOrEqual',
|
|
201
|
+
dateAfter: 'greaterThan',
|
|
202
|
+
dateAfterOrEqual: 'greaterThanOrEqual',
|
|
203
|
+
dateRange: 'inRange'
|
|
78
204
|
};
|
|
79
205
|
/**
|
|
80
|
-
*
|
|
206
|
+
* Creates operation mapping tables for URL and AG Grid integration
|
|
81
207
|
*/
|
|
82
208
|
function createOperationMaps() {
|
|
83
|
-
|
|
84
|
-
|
|
209
|
+
// Get all unique operations across filter types
|
|
210
|
+
const allOperations = [
|
|
211
|
+
...TEXT_FILTER_OPERATIONS,
|
|
212
|
+
...NUMBER_FILTER_OPERATIONS,
|
|
213
|
+
...DATE_FILTER_OPERATIONS
|
|
214
|
+
];
|
|
215
|
+
// Remove duplicates (operations like 'eq', 'blank' appear in multiple arrays)
|
|
85
216
|
const uniqueOperations = [...new Set(allOperations)];
|
|
86
|
-
// Generate URL mappings
|
|
217
|
+
// Generate URL mappings (bidirectional)
|
|
87
218
|
const operationMap = {};
|
|
88
219
|
const internalToUrlMap = {};
|
|
89
220
|
uniqueOperations.forEach(operation => {
|
|
@@ -91,7 +222,7 @@ function createOperationMaps() {
|
|
|
91
222
|
operationMap[urlName] = operation;
|
|
92
223
|
internalToUrlMap[operation] = urlName;
|
|
93
224
|
});
|
|
94
|
-
// Generate AG Grid mappings
|
|
225
|
+
// Generate AG Grid mappings (bidirectional)
|
|
95
226
|
const agGridMap = {};
|
|
96
227
|
const reverseAgGridMap = {};
|
|
97
228
|
uniqueOperations.forEach(operation => {
|
|
@@ -108,10 +239,21 @@ function createOperationMaps() {
|
|
|
108
239
|
};
|
|
109
240
|
}
|
|
110
241
|
// Generate all mappings dynamically
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
export const
|
|
116
|
-
|
|
242
|
+
const mappings = createOperationMaps();
|
|
243
|
+
/**
|
|
244
|
+
* Maps URL operation names to internal operation types
|
|
245
|
+
*/
|
|
246
|
+
export const OPERATION_MAP = mappings.operationMap;
|
|
247
|
+
/**
|
|
248
|
+
* Maps internal operation types to URL operation names
|
|
249
|
+
*/
|
|
250
|
+
export const INTERNAL_TO_URL_OPERATION_MAP = mappings.internalToUrlMap;
|
|
251
|
+
/**
|
|
252
|
+
* Maps internal operation types to AG Grid operation names
|
|
253
|
+
*/
|
|
254
|
+
export const AG_GRID_OPERATION_NAMES = mappings.agGridMap;
|
|
255
|
+
/**
|
|
256
|
+
* Maps AG Grid operation names to internal operation types
|
|
257
|
+
*/
|
|
258
|
+
export const REVERSE_AG_GRID_OPERATION_NAMES = mappings.reverseAgGridMap;
|
|
117
259
|
//# sourceMappingURL=types.js.map
|
package/dist/core/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAoDA,+EAA+E;AAC/E,+BAA+B;AAC/B,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,UAAU;IACV,aAAa;IACb,YAAY;IACZ,UAAU;CACF,CAAA;AAEV;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,UAAU;IACV,iBAAiB;IACjB,aAAa;IACb,oBAAoB;IACpB,SAAS;CACD,CAAA;AAEV;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,YAAY;IACZ,mBAAmB;IACnB,WAAW;IACX,kBAAkB;IAClB,WAAW;CACH,CAAA;AAEV;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI;IACJ,UAAU;IACV,OAAO;IACP,UAAU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