1
- import { BlobStringReply , Command , DoubleReply , NumberReply , SimpleStringReply , TypeMapping } from "@redis/client/dist /lib/RESP/types" ;
1
+ import { ArrayReply , BlobStringReply , Command , DoubleReply , NumberReply , ReplyUnion , SimpleStringReply , TypeMapping } from "@redis/client/lib/RESP/types" ;
2
2
import { TimeSeriesDuplicatePolicies } from "." ;
3
3
import { TimeSeriesAggregationType } from "./CREATERULE" ;
4
4
import { transformDoubleReply } from '@redis/client/dist/lib/commands/generic-transformers' ;
@@ -33,11 +33,11 @@ export type InfoRawReplyOld = [
33
33
'duplicatePolicy' ,
34
34
TimeSeriesDuplicatePolicies | null ,
35
35
'labels' ,
36
- Array < [ name : BlobStringReply , value : BlobStringReply ] > ,
36
+ ArrayReply < [ name : BlobStringReply , value : BlobStringReply ] > ,
37
37
'sourceKey' ,
38
38
BlobStringReply | null ,
39
39
'rules' ,
40
- Array < [ key : BlobStringReply , timeBucket : NumberReply , aggregationType : TimeSeriesAggregationType ] > ,
40
+ ArrayReply < [ key : BlobStringReply , timeBucket : NumberReply , aggregationType : TimeSeriesAggregationType ] > ,
41
41
'ignoreMaxTimeDiff' ,
42
42
NumberReply ,
43
43
'ignoreMaxValDiff' ,
@@ -77,42 +77,51 @@ export default {
77
77
} ,
78
78
transformReply : {
79
79
2 : ( reply : InfoRawReply , _ , typeMapping ?: TypeMapping ) : InfoReply => {
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
106
- } ;
80
+ const ret = { } as any ;
107
81
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 )
82
+ for ( let i = 0 ; i < reply . length ; i += 2 ) {
83
+ const key = ( reply [ i ] as any ) . toString ( ) ;
84
+
85
+ switch ( key ) {
86
+ case 'totalSamples' :
87
+ case 'memoryUsage' :
88
+ case 'firstTimestamp' :
89
+ case 'lastTimestamp' :
90
+ case 'retentionTime' :
91
+ case 'chunkCount' :
92
+ case 'chunkSize' :
93
+ case 'chunkType' :
94
+ case 'duplicatePolicy' :
95
+ case 'sourceKey' :
96
+ case 'ignoreMaxTimeDiff' :
97
+ ret [ key ] = reply [ i + 1 ] ;
98
+ break ;
99
+ case 'labels' :
100
+ ret [ key ] = ( reply [ i + 1 ] as Array < [ name : BlobStringReply , value : BlobStringReply ] > ) . map (
101
+ ( [ name , value ] ) => ( {
102
+ name,
103
+ value
104
+ } )
105
+ )
106
+ break ;
107
+ case 'rules' :
108
+ ret [ key ] = ( reply [ i + 1 ] as Array < [ key : BlobStringReply , timeBucket : NumberReply , aggregationType : TimeSeriesAggregationType ] > ) . map (
109
+ ( [ key , timeBucket , aggregationType ] ) => ( {
110
+ key,
111
+ timeBucket,
112
+ aggregationType
113
+ } )
114
+ )
115
+ break ;
116
+ case 'ignoreMaxValDiff' :
117
+ ret [ key ] = transformDoubleReply [ 2 ] ( reply [ 27 ] as unknown as BlobStringReply , undefined , typeMapping )
118
+ break ;
119
+ }
112
120
}
113
121
114
122
return ret ;
115
123
} ,
116
- 3 : undefined as unknown as ( ) => InfoReply
117
- }
124
+ 3 : undefined as unknown as ( ) => ReplyUnion
125
+ } ,
126
+ unstableResp3 : true
118
127
} as const satisfies Command ;
0 commit comments