Skip to content

Commit ffab8e6

Browse files
committed
Improve notification filter definition by deriving from category and severity
1 parent f0f0a19 commit ffab8e6

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

packages/core/src/notification-filter.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,16 @@
1818
*/
1919
import { NotificationCategory, NotificationSeverityLevel } from './result-summary'
2020

21+
type Combine<Enum1 extends string, Enum2 extends string, Separator extends string = '.'> = `${Enum1}${Separator}${Enum2}`
2122
type ExcludeUnknown<T> = Exclude<T, 'UNKNOWN'>
2223

2324
type FilterKeys = ExcludeUnknown<NotificationSeverityLevel> | 'ALL'
2425
type FilterInnerKeys = ExcludeUnknown<NotificationCategory> | 'ALL'
26+
type CombinedFilter = Combine<FilterKeys, FilterInnerKeys>
2527

2628
type SeverityDotCategoryFilters = { [key in FilterKeys]: { [k in FilterInnerKeys]: NotificationFilter } }
2729

28-
type NotificationFilter =
29-
'NONE' | 'SERVER_DEFAULT' |
30-
'ALL.ALL' | 'ALL.DEPRECATION' | 'ALL.GENERIC' | 'ALL.HINT' |
31-
'ALL.PERFORMANCE' | 'ALL.QUERY' | 'ALL.UNRECOGNIZED' | 'ALL.UNSUPPORTED' |
32-
'INFORMATION.ALL' | 'INFORMATION.DEPRECATION' | 'INFORMATION.GENERIC' | 'INFORMATION.HINT' |
33-
'INFORMATION.PERFORMANCE' | 'INFORMATION.QUERY' | 'INFORMATION.UNRECOGNIZED' | 'INFORMATION.UNSUPPORTED' |
34-
'WARNING.ALL' | 'WARNING.DEPRECATION' | 'WARNING.GENERIC' | 'WARNING.HINT' |
35-
'WARNING.PERFORMANCE' | 'WARNING.QUERY' | 'WARNING.UNRECOGNIZED' | 'WARNING.UNSUPPORTED'
30+
type NotificationFilter = 'NONE' | 'SERVER_DEFAULT' | CombinedFilter
3631

3732
/**
3833
*

packages/neo4j-driver-deno/lib/core/notification-filter.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,17 @@
1818
*/
1919
import { NotificationCategory, NotificationSeverityLevel } from './result-summary.ts'
2020

21+
type Combine<Enum1 extends string, Enum2 extends string, Separator extends string = "."> = `${Enum1}${Separator}${Enum2}`;
2122
type ExcludeUnknown<T> = Exclude<T, 'UNKNOWN'>
2223

2324
type FilterKeys = ExcludeUnknown<NotificationSeverityLevel> | 'ALL'
2425
type FilterInnerKeys = ExcludeUnknown<NotificationCategory> | 'ALL'
26+
type CombinedFilter = Combine<FilterKeys, FilterInnerKeys>
2527

2628
type SeverityDotCategoryFilters = { [key in FilterKeys]: { [k in FilterInnerKeys]: NotificationFilter } }
2729

28-
type NotificationFilter =
29-
'NONE' | 'SERVER_DEFAULT' |
30-
'ALL.ALL' | 'ALL.DEPRECATION' | 'ALL.GENERIC' | 'ALL.HINT' |
31-
'ALL.PERFORMANCE' | 'ALL.QUERY' | 'ALL.UNRECOGNIZED' | 'ALL.UNSUPPORTED' |
32-
'INFORMATION.ALL' | 'INFORMATION.DEPRECATION' | 'INFORMATION.GENERIC' | 'INFORMATION.HINT' |
33-
'INFORMATION.PERFORMANCE' | 'INFORMATION.QUERY' | 'INFORMATION.UNRECOGNIZED' | 'INFORMATION.UNSUPPORTED' |
34-
'WARNING.ALL' | 'WARNING.DEPRECATION' | 'WARNING.GENERIC' | 'WARNING.HINT' |
35-
'WARNING.PERFORMANCE' | 'WARNING.QUERY' | 'WARNING.UNRECOGNIZED' | 'WARNING.UNSUPPORTED'
36-
30+
type NotificationFilter = 'NONE' | 'SERVER_DEFAULT' | CombinedFilter
31+
3732
/**
3833
*
3934
* Notifications filters used during the {@link Driver} and {@link Session} configuration.

0 commit comments

Comments
 (0)