@@ -115,6 +115,53 @@ export interface EnumTypeDefinition extends ProtobufTypeDefinition {
115
115
format : 'Protocol Buffer 3 EnumDescriptorProto' ;
116
116
}
117
117
118
+ enum IdempotencyLevel {
119
+ IDEMPOTENCY_UNKNOWN = 0 ,
120
+ NO_SIDE_EFFECTS = 1 ,
121
+ IDEMPOTENT = 2
122
+ }
123
+
124
+ interface NamePart {
125
+ namePart : string ;
126
+ isExtension : boolean ;
127
+ }
128
+
129
+ interface UninterpretedOption {
130
+ name ?: ( NamePart [ ] | null ) ;
131
+ identifierValue ?: ( string | null ) ;
132
+ positiveIntValue ?: ( number | Long | string | null ) ;
133
+ negativeIntValue ?: ( number | Long | string | null ) ;
134
+ doubleValue ?: ( number | null ) ;
135
+ stringValue ?: ( Uint8Array | string | null ) ;
136
+ aggregateValue ?: ( string | null ) ;
137
+ }
138
+
139
+ interface CustomHttpPattern {
140
+ kind ?: ( string | null ) ;
141
+ path ?: ( string | null ) ;
142
+ }
143
+
144
+ interface HttpRule {
145
+ selector ?: ( string | null ) ;
146
+ get ?: ( string | null ) ;
147
+ put ?: ( string | null ) ;
148
+ post ?: ( string | null ) ;
149
+ delete ?: ( string | null ) ;
150
+ patch ?: ( string | null ) ;
151
+ custom ?: ( CustomHttpPattern | null ) ;
152
+ body ?: ( string | null ) ;
153
+ responseBody ?: ( string | null ) ;
154
+ additionalBindings ?: ( HttpRule [ ] | null ) ;
155
+ }
156
+
157
+ interface MethodOptions {
158
+ deprecated ?: ( boolean | null ) ;
159
+ idempotency_level ?: ( IdempotencyLevel | keyof typeof IdempotencyLevel | null ) ;
160
+ uninterpreted_option ?: ( UninterpretedOption [ ] | null ) ;
161
+ "(google.api.http)" ?: ( HttpRule | null ) ;
162
+ "(google.api.method_signature)" ?: ( string [ ] | null ) ;
163
+ }
164
+
118
165
export interface MethodDefinition < RequestType , ResponseType , OutputRequestType = RequestType , OutputResponseType = ResponseType > {
119
166
path : string ;
120
167
requestStream : boolean ;
@@ -126,8 +173,7 @@ export interface MethodDefinition<RequestType, ResponseType, OutputRequestType=R
126
173
originalName ?: string ;
127
174
requestType : MessageTypeDefinition ;
128
175
responseType : MessageTypeDefinition ;
129
- options ?: { [ k : string ] : any } ;
130
- parsedOptions ?: { [ k : string ] : any } ;
176
+ options ?: MethodOptions ;
131
177
}
132
178
133
179
export interface ServiceDefinition {
@@ -222,6 +268,12 @@ function createSerializer(cls: Protobuf.Type): Serialize<object> {
222
268
} ;
223
269
}
224
270
271
+ function mapMethodOptions ( options : Partial < MethodOptions > [ ] | undefined ) : MethodOptions | undefined {
272
+ return Array . isArray ( options ) ?
273
+ options . reduce ( ( obj : MethodOptions , item : Partial < MethodOptions > ) => ( { ...obj , ...item } ) , { } ) :
274
+ undefined ;
275
+ }
276
+
225
277
function createMethodDefinition (
226
278
method : Protobuf . Method ,
227
279
serviceName : string ,
@@ -244,8 +296,7 @@ function createMethodDefinition(
244
296
originalName : camelCase ( method . name ) ,
245
297
requestType : createMessageDefinition ( requestType , fileDescriptors ) ,
246
298
responseType : createMessageDefinition ( responseType , fileDescriptors ) ,
247
- options : method . options ,
248
- parsedOptions : method . parsedOptions ,
299
+ options : mapMethodOptions ( method . parsedOptions ) ,
249
300
} ;
250
301
}
251
302
0 commit comments