@@ -3,7 +3,17 @@ import { TimeSeriesDuplicatePolicies } from ".";
3
3
import { TimeSeriesAggregationType } from "./CREATERULE" ;
4
4
import { transformDoubleReply } from '@redis/client/dist/lib/commands/generic-transformers' ;
5
5
6
- export type InfoRawReply = [
6
+ export type InfoRawReplyTypes = SimpleStringReply |
7
+ NumberReply |
8
+ TimeSeriesDuplicatePolicies | null |
9
+ Array < [ name : BlobStringReply , value : BlobStringReply ] > |
10
+ BlobStringReply |
11
+ Array < [ key : BlobStringReply , timeBucket : NumberReply , aggregationType : TimeSeriesAggregationType ] > |
12
+ DoubleReply
13
+
14
+ export type InfoRawReply = Array < InfoRawReplyTypes > ;
15
+
16
+ export type InfoRawReplyOld = [
7
17
'totalSamples' ,
8
18
NumberReply ,
9
19
'memoryUsage' ,
@@ -54,8 +64,9 @@ export interface InfoReply {
54
64
timeBucket : NumberReply ;
55
65
aggregationType : TimeSeriesAggregationType
56
66
} > ;
57
- ignoreMaxTimeDiff : NumberReply ;
58
- ignoreMaxValDiff : DoubleReply ;
67
+ /* Added in 7.4 */
68
+ ignoreMaxTimeDiff : NumberReply | undefined ;
69
+ ignoreMaxValDiff : DoubleReply | undefined ;
59
70
}
60
71
61
72
export default {
@@ -66,29 +77,41 @@ export default {
66
77
} ,
67
78
transformReply : {
68
79
2 : ( reply : InfoRawReply , _ , typeMapping ?: TypeMapping ) : InfoReply => {
69
- return {
70
- totalSamples : reply [ 1 ] ,
71
- memoryUsage : reply [ 3 ] ,
72
- firstTimestamp : reply [ 5 ] ,
73
- lastTimestamp : reply [ 7 ] ,
74
- retentionTime : reply [ 9 ] ,
75
- chunkCount : reply [ 11 ] ,
76
- chunkSize : reply [ 13 ] ,
77
- chunkType : reply [ 15 ] ,
78
- duplicatePolicy : reply [ 17 ] ,
79
- labels : reply [ 19 ] . map ( ( [ name , value ] ) => ( {
80
- name,
81
- value
82
- } ) ) ,
83
- sourceKey : reply [ 21 ] ,
84
- rules : reply [ 23 ] . map ( ( [ key , timeBucket , aggregationType ] ) => ( {
85
- key,
86
- timeBucket,
87
- aggregationType
88
- } ) ) ,
89
- ignoreMaxTimeDiff : reply [ 25 ] ,
90
- ignoreMaxValDiff : transformDoubleReply [ 2 ] ( reply [ 27 ] as unknown as BlobStringReply , undefined , typeMapping )
80
+ const ret : InfoReply = {
81
+ totalSamples : reply [ 1 ] as NumberReply ,
82
+ memoryUsage : reply [ 3 ] as NumberReply ,
83
+ firstTimestamp : reply [ 5 ] as NumberReply ,
84
+ lastTimestamp : reply [ 7 ] as NumberReply ,
85
+ retentionTime : reply [ 9 ] as NumberReply ,
86
+ chunkCount : reply [ 11 ] as NumberReply ,
87
+ chunkSize : reply [ 13 ] as NumberReply ,
88
+ chunkType : reply [ 15 ] as SimpleStringReply ,
89
+ duplicatePolicy : reply [ 17 ] as TimeSeriesDuplicatePolicies | null ,
90
+ labels : ( reply [ 19 ] as Array < [ name : BlobStringReply , value : BlobStringReply ] > ) . map (
91
+ ( [ name , value ] ) => ( {
92
+ name,
93
+ value
94
+ } )
95
+ ) ,
96
+ sourceKey : reply [ 21 ] as BlobStringReply | null ,
97
+ rules : ( reply [ 23 ] as Array < [ key : BlobStringReply , timeBucket : NumberReply , aggregationType : TimeSeriesAggregationType ] > ) . map (
98
+ ( [ key , timeBucket , aggregationType ] ) => ( {
99
+ key,
100
+ timeBucket,
101
+ aggregationType
102
+ } )
103
+ ) ,
104
+ ignoreMaxTimeDiff : undefined ,
105
+ ignoreMaxValDiff : undefined
91
106
} ;
107
+
108
+ if ( reply [ 24 ] != null && reply [ 24 ] . toString ( ) == 'ignoreMaxTimeDiff' ) {
109
+ // > 7.4
110
+ ret . ignoreMaxTimeDiff = reply [ 25 ] as NumberReply ;
111
+ ret . ignoreMaxValDiff = transformDoubleReply [ 2 ] ( reply [ 27 ] as unknown as BlobStringReply , undefined , typeMapping )
112
+ }
113
+
114
+ return ret ;
92
115
} ,
93
116
3 : undefined as unknown as ( ) => InfoReply
94
117
}
0 commit comments