ag-grid-url-sync 0.5.0 → 0.5.1

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 (58) hide show
  1. package/README.md +110 -55
  2. package/dist/core/ag-grid-url-sync.d.ts +10 -9
  3. package/dist/core/ag-grid-url-sync.js +23 -19
  4. package/dist/core/ag-grid-url-sync.js.map +1 -1
  5. package/dist/core/grid-integration.d.ts +27 -1
  6. package/dist/core/grid-integration.js +161 -129
  7. package/dist/core/grid-integration.js.map +1 -1
  8. package/dist/core/index.d.ts +2 -1
  9. package/dist/core/index.js +2 -1
  10. package/dist/core/index.js.map +1 -1
  11. package/dist/core/individual-params.d.ts +12 -5
  12. package/dist/core/individual-params.js +38 -62
  13. package/dist/core/individual-params.js.map +1 -1
  14. package/dist/core/issue-columns.d.ts +2 -0
  15. package/dist/core/issue-columns.js +11 -0
  16. package/dist/core/issue-columns.js.map +1 -0
  17. package/dist/core/issues.d.ts +34 -0
  18. package/dist/core/issues.js +58 -0
  19. package/dist/core/issues.js.map +1 -0
  20. package/dist/core/operators.d.ts +189 -0
  21. package/dist/core/operators.js +60 -0
  22. package/dist/core/operators.js.map +1 -0
  23. package/dist/core/options.d.ts +21 -0
  24. package/dist/core/options.js +21 -0
  25. package/dist/core/options.js.map +1 -0
  26. package/dist/core/schemas.d.ts +51 -0
  27. package/dist/core/schemas.js +59 -0
  28. package/dist/core/schemas.js.map +1 -0
  29. package/dist/core/serialization/formats.d.ts +7 -7
  30. package/dist/core/serialization/formats.js +34 -28
  31. package/dist/core/serialization/formats.js.map +1 -1
  32. package/dist/core/serialization/grouped.d.ts +9 -12
  33. package/dist/core/serialization/grouped.js +24 -17
  34. package/dist/core/serialization/grouped.js.map +1 -1
  35. package/dist/core/to-error.d.ts +5 -0
  36. package/dist/core/to-error.js +4 -0
  37. package/dist/core/to-error.js.map +1 -0
  38. package/dist/core/types.d.ts +149 -43
  39. package/dist/core/types.js +35 -108
  40. package/dist/core/types.js.map +1 -1
  41. package/dist/core/url-generator.d.ts +4 -4
  42. package/dist/core/url-generator.js +9 -7
  43. package/dist/core/url-generator.js.map +1 -1
  44. package/dist/core/url-parser.d.ts +4 -4
  45. package/dist/core/url-parser.js +6 -4
  46. package/dist/core/url-parser.js.map +1 -1
  47. package/dist/core/validation.d.ts +21 -14
  48. package/dist/core/validation.js +58 -54
  49. package/dist/core/validation.js.map +1 -1
  50. package/dist/core/view-storage.js +21 -19
  51. package/dist/core/view-storage.js.map +1 -1
  52. package/dist/index.d.ts +2 -1
  53. package/dist/index.js +2 -1
  54. package/dist/index.js.map +1 -1
  55. package/dist/react/types.d.ts +31 -12
  56. package/dist/react/use-ag-grid-url-sync.js +148 -87
  57. package/dist/react/use-ag-grid-url-sync.js.map +1 -1
  58. package/package.json +22 -15
@@ -1,4 +1,5 @@
1
1
  import type { GridApi as AGGridApi, TextFilterModel, NumberFilterModel, DateFilterModel } from 'ag-grid-community';
2
+ import { type Operator, type OperationsFor } from './operators.js';
2
3
  /**
3
4
  * Serialization modes for URL parameters
4
5
  */
@@ -29,62 +30,99 @@ export type SerializationFormat = 'querystring' | 'json' | 'base64';
29
30
  */
30
31
  export interface AGGridUrlSyncConfig {
31
32
  /**
32
- * Prefix for URL parameters (only used in individual mode)
33
+ * Prefix for URL parameters (only used in individual mode).
34
+ * A prefix without a trailing `_` gets one, so 'filter' and 'filter_' both
35
+ * give `?filter_name_contains=john`. An empty prefix means the default.
33
36
  * @default 'f_'
34
37
  * @example 'filter_' results in URLs like '?filter_name_contains=john'
35
38
  */
36
- paramPrefix?: string;
39
+ paramPrefix?: string | undefined;
37
40
  /**
38
41
  * Maximum length for filter values to prevent URL length issues
39
42
  * @default 200
40
43
  */
41
- maxValueLength?: number;
44
+ maxValueLength?: number | undefined;
42
45
  /**
43
- * Optional error handler for parsing errors.
44
- * Allows graceful error handling without breaking the application.
46
+ * Optional handler for issues: a filter that is dropped or not valid, in a
47
+ * URL, a value, or the grid model. The filter is skipped and the others are
48
+ * kept. Each error is a `URLSyncError` with a `code` (for example
49
+ * `VALUE_TOO_LONG`) and, when it is known, a `column`. In the core, an error
50
+ * from the grid API also comes here, as `GRID_ERROR` (the React hook sends it
51
+ * to `onError`). A URL that cannot be read is thrown as `INVALID_URL`, not
52
+ * sent here. The library never writes to the console, so an issue with no
53
+ * handler is silent (#220).
45
54
  *
46
55
  * In grouped mode, an error that comes from the grouped URL value is an
47
56
  * `InvalidSerializationError`, and the original error is in `error.cause`.
48
- * In individual mode, the same failure arrives with no wrapper.
57
+ * The wrapper has the code and the column of the original issue, so a check
58
+ * on `error.code` works the same in both modes.
49
59
  */
50
- onParseError?: (error: Error) => void;
60
+ onParseError?: ((error: Error) => void) | undefined;
51
61
  /**
52
62
  * Serialization mode for URL parameters
53
63
  * @default 'individual'
54
64
  */
55
- serialization?: SerializationMode;
65
+ serialization?: SerializationMode | undefined;
56
66
  /**
57
67
  * Parameter name for grouped serialization
58
68
  * @default 'grid_filters'
59
69
  */
60
- groupedParam?: string;
70
+ groupedParam?: string | undefined;
61
71
  /**
62
72
  * Serialization format for grouped mode
63
73
  * @default 'querystring'
64
74
  */
65
- format?: SerializationFormat;
75
+ format?: SerializationFormat | undefined;
76
+ /**
77
+ * Throw an issue instead of reporting it (#229), like TanStack Query's
78
+ * `throwOnError`. `true` throws every issue, and a function throws the
79
+ * issues for which it gives `true`. In the core, a thrown issue is not sent
80
+ * to `onParseError`, and the first one stops the call. In the React hook,
81
+ * each issue is still sent to `onParseError` one time, and the picked issue
82
+ * is thrown during render, so an error boundary catches it. The library does
83
+ * not change the address bar, so remove the bad param before the boundary
84
+ * resets, or the same issue is thrown again.
85
+ *
86
+ * A function that throws makes the library throw that error.
87
+ * @default false
88
+ */
89
+ throwOnError?: boolean | ((issue: URLSyncError) => boolean) | undefined;
66
90
  }
91
+ /**
92
+ * The options with a value for each one: the config after the defaults are
93
+ * filled in. It has no `gridApi`: the grid is an argument of the functions
94
+ * that read it (#219).
95
+ *
96
+ * A caller can set an option to undefined (#258), so `Required` is not enough:
97
+ * it keeps the undefined.
98
+ */
99
+ export type ResolvedOptions = {
100
+ [K in Exclude<keyof AGGridUrlSyncConfig, 'throwOnError'>]-?: Exclude<AGGridUrlSyncConfig[K], undefined>;
101
+ } & {
102
+ /**
103
+ * Optional, so that ParseConfig and InternalConfig, which extend this type,
104
+ * get no new required key (#229). resolveOptions always sets it.
105
+ */
106
+ throwOnError?: Exclude<AGGridUrlSyncConfig['throwOnError'], undefined>;
107
+ };
67
108
  /**
68
109
  * Configuration for URL parsing and serialization operations that don't require GridApi.
69
- * Use this type when you only need to parse filters from URLs or serialize filters to URLs
70
- * without actually applying them to a grid.
71
110
  *
72
- * @example
73
- * ```typescript
74
- * // Parse filters without a grid instance
75
- * const config: ParseConfig = {
76
- * ...DEFAULT_CONFIG,
77
- * onParseError: (error) => console.error(error)
78
- * }
79
- * const filters = parseUrlFilters(url, config)
80
- * ```
111
+ * @deprecated The parse and serialize functions take a partial
112
+ * `AGGridUrlSyncConfig` and fill in the defaults, so you do not need this
113
+ * type. Use `ResolvedOptions` for a config with every option set. This type
114
+ * will be removed in 0.6.0.
81
115
  */
82
- export interface ParseConfig extends Required<AGGridUrlSyncConfig> {
116
+ export interface ParseConfig extends ResolvedOptions {
83
117
  /** AG Grid API instance - not read by parsing/serialization operations */
84
118
  gridApi?: AGGridApi | null;
85
119
  }
86
120
  /**
87
121
  * Internal configuration with all required fields and runtime dependencies
122
+ *
123
+ * @deprecated Give the grid API to `getFilterModel(gridApi, options)` and
124
+ * `applyFilterModel(filterState, gridApi, options)` as an argument. This type
125
+ * will be removed in 0.6.0.
88
126
  */
89
127
  export interface InternalConfig extends ParseConfig {
90
128
  /** AG Grid API instance for filter operations */
@@ -93,23 +131,23 @@ export interface InternalConfig extends ParseConfig {
93
131
  /**
94
132
  * Text-only filter operations for string-based filtering
95
133
  */
96
- export declare const TEXT_ONLY_OPERATIONS: readonly ['contains', 'notContains', 'startsWith', 'endsWith'];
134
+ export declare const TEXT_ONLY_OPERATIONS: readonly ["contains", "notContains", "startsWith", "endsWith"];
97
135
  /**
98
136
  * Number-only filter operations for numeric comparisons
99
137
  */
100
- export declare const NUMBER_ONLY_OPERATIONS: readonly ['lessThan', 'lessThanOrEqual', 'greaterThan', 'greaterThanOrEqual', 'inRange'];
138
+ export declare const NUMBER_ONLY_OPERATIONS: readonly ["lessThan", "lessThanOrEqual", "greaterThan", "greaterThanOrEqual", "inRange"];
101
139
  /**
102
140
  * Date-specific filter operations for temporal comparisons
103
141
  */
104
- export declare const DATE_ONLY_OPERATIONS: readonly ['dateBefore', 'dateBeforeOrEqual', 'dateAfter', 'dateAfterOrEqual', 'dateRange'];
142
+ export declare const DATE_ONLY_OPERATIONS: readonly ["dateBefore", "dateBeforeOrEqual", "dateAfter", "dateAfterOrEqual", "dateRange"];
105
143
  /**
106
144
  * Operations shared across multiple filter types
107
145
  */
108
- export declare const SHARED_OPERATIONS: readonly ['eq', 'notEqual', 'blank', 'notBlank'];
146
+ export declare const SHARED_OPERATIONS: readonly ["eq", "notEqual", "blank", "notBlank"];
109
147
  /**
110
148
  * All supported filter operations across text, number, and date filters
111
149
  */
112
- export type FilterOperation = (typeof TEXT_ONLY_OPERATIONS)[number] | (typeof NUMBER_ONLY_OPERATIONS)[number] | (typeof DATE_ONLY_OPERATIONS)[number] | (typeof SHARED_OPERATIONS)[number];
150
+ export type FilterOperation = Operator['id'];
113
151
  /**
114
152
  * Complete list of valid text filter operations
115
153
  */
@@ -119,29 +157,33 @@ export declare const TEXT_FILTER_OPERATIONS: readonly ["contains", "notContains"
119
157
  */
120
158
  export declare const NUMBER_FILTER_OPERATIONS: readonly ["lessThan", "lessThanOrEqual", "greaterThan", "greaterThanOrEqual", "inRange", "eq", "notEqual", "blank", "notBlank"];
121
159
  /**
122
- * Valid date filter operations as const array
160
+ * Valid date filter operations
123
161
  */
124
162
  export declare const DATE_FILTER_OPERATIONS: readonly ["dateBefore", "dateBeforeOrEqual", "dateAfter", "dateAfterOrEqual", "dateRange", "eq", "notEqual", "blank", "notBlank"];
125
163
  /**
126
164
  * Text-specific filter operations
127
165
  */
128
- export type TextFilterOperation = (typeof TEXT_FILTER_OPERATIONS)[number];
166
+ export type TextFilterOperation = OperationsFor<'text'>;
129
167
  /**
130
168
  * Number-specific filter operations
131
169
  */
132
- export type NumberFilterOperation = (typeof NUMBER_FILTER_OPERATIONS)[number];
170
+ export type NumberFilterOperation = OperationsFor<'number'>;
133
171
  /**
134
172
  * Date-specific filter operations
135
173
  */
136
- export type DateFilterOperation = (typeof DATE_FILTER_OPERATIONS)[number];
174
+ export type DateFilterOperation = OperationsFor<'date'>;
137
175
  /**
138
176
  * Range operations that require two values (from/to)
139
177
  */
140
- export type RangeOperation = 'inRange' | 'dateRange';
178
+ export type RangeOperation = Extract<Operator, {
179
+ arity: 2;
180
+ }>['id'];
141
181
  /**
142
182
  * Operations that don't require a filter value
143
183
  */
144
- export type BlankOperation = 'blank' | 'notBlank';
184
+ export type BlankOperation = Extract<Operator, {
185
+ arity: 0;
186
+ }>['id'];
145
187
  /**
146
188
  * Supported filter types
147
189
  */
@@ -224,35 +266,56 @@ export declare function isNumberFilter(filter: ColumnFilter): filter is NumberCo
224
266
  * Type guard to check if a filter is a date filter
225
267
  */
226
268
  export declare function isDateFilter(filter: ColumnFilter): filter is DateColumnFilter;
269
+ /**
270
+ * The reason for an issue (#220). Data issues are a filter that is dropped or
271
+ * not valid. The other codes are failures of an operation.
272
+ */
273
+ export type IssueCode = 'INVALID_PARAM' | 'INVALID_NUMBER' | 'INVALID_DATE' | 'VALUE_TOO_LONG' | 'INVALID_GROUPED' | 'TYPE_MISMATCH' | 'INVALID_URL' | 'GRID_ERROR' | 'NOT_READY' | 'VIEW_NOT_FOUND' | 'VIEW_NAME_REQUIRED' | 'STORAGE_UNAVAILABLE' | 'STORAGE_FULL' | 'STORAGE_WRITE_FAILED' | 'UNKNOWN';
274
+ /** The code and the column of an issue, when the default is not right */
275
+ export interface IssueDetails {
276
+ code?: IssueCode | undefined;
277
+ column?: string | undefined;
278
+ }
227
279
  /**
228
280
  * Base error class for all URL sync operations
229
281
  */
230
282
  export declare class URLSyncError extends Error {
231
283
  readonly cause?: Error | undefined;
232
- constructor(message: string, cause?: Error | undefined);
284
+ /** The reason for the error */
285
+ readonly code: IssueCode;
286
+ /** The column of the filter, when it is known */
287
+ readonly column?: string;
288
+ constructor(message: string, cause?: Error | undefined, details?: IssueDetails);
233
289
  }
234
290
  /**
235
291
  * Error thrown when filter validation fails
236
292
  */
237
293
  export declare class InvalidFilterError extends URLSyncError {
238
- constructor(message: string, cause?: Error);
294
+ constructor(message: string, cause?: Error, details?: IssueDetails);
239
295
  }
240
296
  /**
241
297
  * Error thrown when URL parsing fails
242
298
  */
243
299
  export declare class InvalidURLError extends URLSyncError {
244
- constructor(message: string, cause?: Error);
300
+ constructor(message: string, cause?: Error, details?: IssueDetails);
245
301
  }
246
302
  /**
247
303
  * Error thrown when date validation fails
248
304
  */
249
305
  export declare class InvalidDateError extends InvalidFilterError {
250
- constructor(message: string, cause?: Error);
306
+ constructor(message: string, cause?: Error, details?: IssueDetails);
251
307
  }
252
308
  /**
253
- * Error thrown when serialization/deserialization fails
254
- */
255
- export declare class InvalidSerializationError extends Error {
309
+ * Error thrown when serialization/deserialization fails.
310
+ *
311
+ * When the cause is an issue inside the grouped value (for example a value
312
+ * over maxValueLength), this error has the same code and column, so a filter
313
+ * gives the same code in both modes. `INVALID_GROUPED` means that the grouped
314
+ * value itself does not decode.
315
+ */
316
+ export declare class InvalidSerializationError extends URLSyncError {
317
+ /** The grouped format: querystring, json or base64 */
318
+ readonly format: string;
256
319
  constructor(format: string, cause: Error);
257
320
  }
258
321
  /**
@@ -286,6 +349,28 @@ export interface RawAGGridFilter {
286
349
  dateFrom?: string;
287
350
  dateTo?: string;
288
351
  }
352
+ /**
353
+ * The URL with the current filter state, and whether the grid has filters
354
+ */
355
+ export interface UrlState {
356
+ /** The URL with the current filter state and the page's own params */
357
+ url: string;
358
+ /** Whether the grid has filters that the library supports */
359
+ hasFilters: boolean;
360
+ /**
361
+ * The issues of this call (#229): filters that the grid read or the URL
362
+ * leaves out. The same objects also go to `onParseError`.
363
+ */
364
+ issues: readonly URLSyncError[];
365
+ }
366
+ /** The result of an apply method (#229) */
367
+ export interface ApplyResult {
368
+ /**
369
+ * The issues of this call: filters that were dropped. The same objects
370
+ * also go to `onParseError`.
371
+ */
372
+ issues: readonly URLSyncError[];
373
+ }
289
374
  /**
290
375
  * Grouped serialization result
291
376
  */
@@ -305,14 +390,14 @@ export interface FormatSerializer {
305
390
  * maxValueLength and onParseError. JSON and Base64 drop over-length text
306
391
  * values and report them through onParseError (see #213, #207).
307
392
  */
308
- serialize(filterState: FilterState, config?: ParseConfig): string;
393
+ serialize(filterState: FilterState, config?: ResolvedOptions): string;
309
394
  /**
310
395
  * Deserialize string to filter state
311
396
  * @param config - Caller's configuration. All serializers honour
312
397
  * maxValueLength and onParseError. JSON and Base64 drop over-length text
313
398
  * values and report them through onParseError (see #213, #207).
314
399
  */
315
- deserialize(value: string, config?: ParseConfig): FilterState;
400
+ deserialize(value: string, config?: ResolvedOptions): FilterState;
316
401
  /** Format identifier */
317
402
  format: SerializationFormat;
318
403
  }
@@ -329,20 +414,41 @@ export interface GroupedDetectionResult {
329
414
  /** The raw value if grouped */
330
415
  value?: string;
331
416
  }
417
+ /**
418
+ * Operation Mapping Strategy:
419
+ *
420
+ * We use three different naming conventions for better user experience:
421
+ *
422
+ * 1. URL Parameters: Short, clean names for URLs (e.g., 'eq', 'neq', 'before', 'after')
423
+ * 2. Internal Types: Consistent naming for our FilterOperation type
424
+ * 3. AG Grid Operations: Exact names expected by AG Grid API (e.g., 'equals', 'notEqual', 'lessThan')
425
+ *
426
+ * The operator table in `operators.ts` holds all three names for each
427
+ * operation (#217). The maps below are derived from it and kept only for
428
+ * callers that use them.
429
+ */
332
430
  /**
333
431
  * Maps URL operation names to internal operation types
432
+ * @deprecated Derived from the operator table. Will be removed in 0.6.0.
334
433
  */
335
434
  export declare const OPERATION_MAP: Record<string, FilterOperation>;
336
435
  /**
337
436
  * Maps internal operation types to URL operation names
437
+ * @deprecated Derived from the operator table. Will be removed in 0.6.0.
338
438
  */
339
439
  export declare const INTERNAL_TO_URL_OPERATION_MAP: Record<FilterOperation, string>;
340
440
  /**
341
441
  * Maps internal operation types to AG Grid operation names
442
+ * @deprecated Derived from the operator table. Will be removed in 0.6.0.
342
443
  */
343
444
  export declare const AG_GRID_OPERATION_NAMES: Record<string, string>;
344
445
  /**
345
- * Maps AG Grid operation names to internal operation types
446
+ * Maps AG Grid operation names to internal operation types.
447
+ *
448
+ * AG Grid uses one name for a number and a date operation, so this map is
449
+ * wrong for one of them: `lessThan` gives `dateBefore`. The last row in the
450
+ * operator table wins, as before.
451
+ * @deprecated The key needs the filter type too. Will be removed in 0.6.0.
346
452
  */
347
453
  export declare const REVERSE_AG_GRID_OPERATION_NAMES: Record<string, FilterOperation>;
348
454
  export {};
@@ -1,55 +1,26 @@
1
- export const TEXT_ONLY_OPERATIONS = [
2
- 'contains',
3
- 'notContains',
4
- 'startsWith',
5
- 'endsWith'
6
- ];
7
- export const NUMBER_ONLY_OPERATIONS = [
8
- 'lessThan',
9
- 'lessThanOrEqual',
10
- 'greaterThan',
11
- 'greaterThanOrEqual',
12
- 'inRange'
13
- ];
14
- export const DATE_ONLY_OPERATIONS = [
15
- 'dateBefore',
16
- 'dateBeforeOrEqual',
17
- 'dateAfter',
18
- 'dateAfterOrEqual',
19
- 'dateRange'
20
- ];
21
- export const SHARED_OPERATIONS = [
22
- 'eq',
23
- 'notEqual',
24
- 'blank',
25
- 'notBlank'
26
- ];
27
- export const TEXT_FILTER_OPERATIONS = [
28
- ...TEXT_ONLY_OPERATIONS,
29
- ...SHARED_OPERATIONS
30
- ];
31
- export const NUMBER_FILTER_OPERATIONS = [
32
- ...NUMBER_ONLY_OPERATIONS,
33
- ...SHARED_OPERATIONS
34
- ];
35
- export const DATE_FILTER_OPERATIONS = [
36
- ...DATE_ONLY_OPERATIONS,
37
- ...SHARED_OPERATIONS
38
- ];
1
+ import { attachColumn } from './issue-columns.js';
2
+ import { OPERATORS, operationsFor, operationsOnlyFor, sharedOperations, isOperationFor, operatorById } from './operators.js';
3
+ export const TEXT_ONLY_OPERATIONS = operationsOnlyFor('text');
4
+ export const NUMBER_ONLY_OPERATIONS = operationsOnlyFor('number');
5
+ export const DATE_ONLY_OPERATIONS = operationsOnlyFor('date');
6
+ export const SHARED_OPERATIONS = sharedOperations();
7
+ export const TEXT_FILTER_OPERATIONS = operationsFor('text');
8
+ export const NUMBER_FILTER_OPERATIONS = operationsFor('number');
9
+ export const DATE_FILTER_OPERATIONS = operationsFor('date');
39
10
  export function isTextFilterOperation(op) {
40
- return TEXT_FILTER_OPERATIONS.includes(op);
11
+ return isOperationFor(op, 'text');
41
12
  }
42
13
  export function isNumberFilterOperation(op) {
43
- return NUMBER_FILTER_OPERATIONS.includes(op);
14
+ return isOperationFor(op, 'number');
44
15
  }
45
16
  export function isDateFilterOperation(op) {
46
- return DATE_FILTER_OPERATIONS.includes(op);
17
+ return isOperationFor(op, 'date');
47
18
  }
48
19
  export function isRangeOperation(op) {
49
- return op === 'inRange' || op === 'dateRange';
20
+ return operatorById(op)?.arity === 2;
50
21
  }
51
22
  export function isBlankOperation(op) {
52
- return op === 'blank' || op === 'notBlank';
23
+ return operatorById(op)?.arity === 0;
53
24
  }
54
25
  export function isTextFilter(filter) {
55
26
  return filter.filterType === 'text';
@@ -62,90 +33,46 @@ export function isDateFilter(filter) {
62
33
  }
63
34
  export class URLSyncError extends Error {
64
35
  cause;
65
- constructor(message, cause) {
36
+ code;
37
+ constructor(message, cause, details = {}) {
66
38
  super(message);
67
39
  this.cause = cause;
68
40
  this.name = 'URLSyncError';
41
+ this.code = details.code ?? 'UNKNOWN';
42
+ if (details.column !== undefined)
43
+ attachColumn(this, details.column);
69
44
  }
70
45
  }
71
46
  export class InvalidFilterError extends URLSyncError {
72
- constructor(message, cause) {
73
- super(message, cause);
47
+ constructor(message, cause, details = {}) {
48
+ super(message, cause, { ...details, code: details.code ?? 'INVALID_PARAM' });
74
49
  this.name = 'InvalidFilterError';
75
50
  }
76
51
  }
77
52
  export class InvalidURLError extends URLSyncError {
78
- constructor(message, cause) {
79
- super(message, cause);
53
+ constructor(message, cause, details = {}) {
54
+ super(message, cause, { ...details, code: details.code ?? 'INVALID_URL' });
80
55
  this.name = 'InvalidURLError';
81
56
  }
82
57
  }
83
58
  export class InvalidDateError extends InvalidFilterError {
84
- constructor(message, cause) {
85
- super(message, cause);
59
+ constructor(message, cause, details = {}) {
60
+ super(message, cause, { ...details, code: details.code ?? 'INVALID_DATE' });
86
61
  this.name = 'InvalidDateError';
87
62
  }
88
63
  }
89
- export class InvalidSerializationError extends Error {
64
+ export class InvalidSerializationError extends URLSyncError {
65
+ format;
90
66
  constructor(format, cause) {
91
- super(`Invalid ${format} serialization: ${cause.message}`);
67
+ super(`Invalid ${format} serialization: ${cause.message}`, cause, cause instanceof URLSyncError
68
+ ? { code: cause.code, column: cause.column }
69
+ : { code: 'INVALID_GROUPED' });
92
70
  this.name = 'InvalidSerializationError';
93
- this.cause = cause;
71
+ this.format = format;
94
72
  }
95
73
  }
96
- const URL_SHORTHAND_MAPPINGS = {
97
- notEqual: 'neq',
98
- lessThan: 'lt',
99
- lessThanOrEqual: 'lte',
100
- greaterThan: 'gt',
101
- greaterThanOrEqual: 'gte',
102
- inRange: 'range',
103
- dateBefore: 'before',
104
- dateBeforeOrEqual: 'beforeEq',
105
- dateAfter: 'after',
106
- dateAfterOrEqual: 'afterEq',
107
- dateRange: 'daterange'
108
- };
109
- const AG_GRID_NAME_MAPPINGS = {
110
- eq: 'equals',
111
- dateBefore: 'lessThan',
112
- dateBeforeOrEqual: 'lessThanOrEqual',
113
- dateAfter: 'greaterThan',
114
- dateAfterOrEqual: 'greaterThanOrEqual',
115
- dateRange: 'inRange'
116
- };
117
- function createOperationMaps() {
118
- const allOperations = [
119
- ...TEXT_FILTER_OPERATIONS,
120
- ...NUMBER_FILTER_OPERATIONS,
121
- ...DATE_FILTER_OPERATIONS
122
- ];
123
- const uniqueOperations = [...new Set(allOperations)];
124
- const operationMap = {};
125
- const internalToUrlMap = {};
126
- uniqueOperations.forEach(operation => {
127
- const urlName = URL_SHORTHAND_MAPPINGS[operation] || operation;
128
- operationMap[urlName] = operation;
129
- internalToUrlMap[operation] = urlName;
130
- });
131
- const agGridMap = {};
132
- const reverseAgGridMap = {};
133
- uniqueOperations.forEach(operation => {
134
- const agGridName = AG_GRID_NAME_MAPPINGS[operation] ||
135
- operation;
136
- agGridMap[operation] = agGridName;
137
- reverseAgGridMap[agGridName] = operation;
138
- });
139
- return {
140
- operationMap,
141
- internalToUrlMap,
142
- agGridMap,
143
- reverseAgGridMap
144
- };
145
- }
146
- const mappings = createOperationMaps();
147
- export const OPERATION_MAP = mappings.operationMap;
148
- export const INTERNAL_TO_URL_OPERATION_MAP = mappings.internalToUrlMap;
149
- export const AG_GRID_OPERATION_NAMES = mappings.agGridMap;
150
- export const REVERSE_AG_GRID_OPERATION_NAMES = mappings.reverseAgGridMap;
74
+ export const OPERATION_MAP = Object.fromEntries(OPERATORS.map(op => [op.url, op.id]));
75
+ export const INTERNAL_TO_URL_OPERATION_MAP = Object.fromEntries(OPERATORS.map(op => [op.id, op.url]));
76
+ export const AG_GRID_OPERATION_NAMES = Object.fromEntries(OPERATORS.map(op => [op.id, op.agGrid]));
77
+ export const REVERSE_AG_GRID_OPERATION_NAMES = Object.fromEntries(OPERATORS.map(op => [op.agGrid, op.id]));
151
78
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAuHA,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,UAAU;IACV,aAAa;IACb,YAAY;IACZ,UAAU;CACF,CAAA;AAKV,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,UAAU;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AG,MAAM,CAAA;IACtB,CAAC;CACF;AAqID,MAAM,CAAC,MAAM,aAAa,GACxB,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAM1D,MAAM,CAAC,MAAM,6BAA6B,GAGxC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAGtD,CAAA;AAMH,MAAM,CAAC,MAAM,uBAAuB,GAClC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AAU7D,MAAM,CAAC,MAAM,+BAA+B,GAC1C,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA"}
@@ -1,12 +1,12 @@
1
- import type { FilterState, ParseConfig } from './types.js';
1
+ import type { AGGridUrlSyncConfig, FilterState } from './types.js';
2
2
  import { serializeFilters } from './individual-params.js';
3
3
  export { serializeFilters };
4
4
  /**
5
5
  * Generates a URL with the current filter state.
6
- * This function does not require a GridApi instance: leave `config.gridApi` out
7
- * (or set it to `null`) when you only need to generate URLs without a grid.
6
+ * This function does not need a grid. An option that the config leaves out
7
+ * gets its default.
8
8
  *
9
9
  * The host app's own params are kept, including repeated keys. Filter params
10
10
  * from either mode are replaced.
11
11
  */
12
- export declare function generateUrl(baseUrl: string, filterState: FilterState, config: ParseConfig): string;
12
+ export declare function generateUrl(baseUrl: string, filterState: FilterState, config?: AGGridUrlSyncConfig): string;
@@ -1,9 +1,10 @@
1
- import { serializeFilters } from './individual-params.js';
1
+ import { serializeFilters, resolveParamPrefix } from './individual-params.js';
2
2
  import { serializeGrouped } from './serialization/grouped.js';
3
+ import { resolveOptions } from './options.js';
3
4
  export { serializeFilters };
4
5
  function isFilterParam(key, config) {
5
6
  return (key === config.groupedParam ||
6
- (Boolean(config.paramPrefix) && key.startsWith(config.paramPrefix)));
7
+ key.startsWith(resolveParamPrefix(config.paramPrefix)));
7
8
  }
8
9
  function getHostParams(url, config) {
9
10
  return [...url.searchParams].filter(([key]) => !isFilterParam(key, config));
@@ -18,18 +19,19 @@ function toUrlString(url, params) {
18
19
  const result = url.toString();
19
20
  return result === `${url.origin}/` ? result.slice(0, -1) : result;
20
21
  }
21
- export function generateUrl(baseUrl, filterState, config) {
22
+ export function generateUrl(baseUrl, filterState, config = {}) {
23
+ const options = resolveOptions(config);
22
24
  const url = new URL(baseUrl);
23
- const hostParams = getHostParams(url, config);
24
- if (config.serialization === 'grouped') {
25
+ const hostParams = getHostParams(url, options);
26
+ if (options.serialization === 'grouped') {
25
27
  const params = new URLSearchParams(hostParams);
26
- const groupedResult = serializeGrouped(filterState, config);
28
+ const groupedResult = serializeGrouped(filterState, options);
27
29
  if (groupedResult.value) {
28
30
  params.append(groupedResult.paramName, groupedResult.value);
29
31
  }
30
32
  return toUrlString(url, params);
31
33
  }
32
- const params = serializeFilters(filterState, config);
34
+ const params = serializeFilters(filterState, options);
33
35
  for (const [key, value] of hostParams) {
34
36
  params.append(key, value);
35
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"url-generator.js","sourceRoot":"","sources":["../../src/core/url-generator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAE7D,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAQ3B,SAAS,aAAa,CAAC,GAAW,EAAE,MAAmB;IACrD,O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C,IAAI,UAAU,EAAE,CAAC;QACtC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IAC3B,CAAC;IAED,OAAO,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;AACjC,CAAC"}
@@ -1,10 +1,10 @@
1
- import type { FilterState, ParseConfig } from './types.js';
1
+ import type { AGGridUrlSyncConfig, FilterState } from './types.js';
2
2
  import { parseFilterParam } from './individual-params.js';
3
3
  export { parseFilterParam };
4
4
  /**
5
5
  * Converts URL search params into a filter state object.
6
- * This function does not require a GridApi instance: leave `config.gridApi` out
7
- * (or set it to `null`) when you only need to parse filters without a grid.
6
+ * This function does not need a grid. An option that the config leaves out
7
+ * gets its default.
8
8
  *
9
9
  * Accepts an absolute URL, a relative path, a query string or a raw query
10
10
  * string (see {@link toUrl}). A param that is not valid is skipped and reported
@@ -18,4 +18,4 @@ export { parseFilterParam };
18
18
  * @throws InvalidURLError if the input is an absolute URL that is not valid,
19
19
  * or a host with no scheme
20
20
  */
21
- export declare function parseUrlFilters(url: string, config: ParseConfig): FilterState;
21
+ export declare function parseUrlFilters(url: string, config?: AGGridUrlSyncConfig): FilterState;