@@ -22,7 +22,9 @@ interface RestClientSettings {
2222 options : any
2323}
2424
25- export abstract class Base < T = any , D = Partial < T > > implements ServiceInterface < T , D > {
25+ export abstract class Base < T = any , D = Partial < T > , P extends Params = RestClientParams >
26+ implements ServiceInterface < T , D , P >
27+ {
2628 name : string
2729 base : string
2830 connection : any
@@ -57,7 +59,7 @@ export abstract class Base<T = any, D = Partial<T>> implements ServiceInterface<
5759 return ''
5860 }
5961
60- abstract request ( options : any , params : Params ) : any
62+ abstract request ( options : any , params : P ) : any
6163
6264 methods ( this : any , ...names : string [ ] ) {
6365 names . forEach ( ( method ) => {
@@ -83,7 +85,7 @@ export abstract class Base<T = any, D = Partial<T>> implements ServiceInterface<
8385 return this
8486 }
8587
86- find ( params : RestClientParams = { } ) {
88+ find ( params ?: P ) {
8789 return this . request (
8890 {
8991 url : this . makeUrl ( params . query ) ,
@@ -94,7 +96,7 @@ export abstract class Base<T = any, D = Partial<T>> implements ServiceInterface<
9496 ) . catch ( toError )
9597 }
9698
97- get ( id : Id , params : RestClientParams = { } ) {
99+ get ( id : Id , params ?: P ) {
98100 if ( typeof id === 'undefined' ) {
99101 return Promise . reject ( new Error ( "id for 'get' can not be undefined" ) )
100102 }
@@ -109,7 +111,7 @@ export abstract class Base<T = any, D = Partial<T>> implements ServiceInterface<
109111 ) . catch ( toError )
110112 }
111113
112- create ( body : D , params : RestClientParams = { } ) {
114+ create ( body : D , params ?: P ) {
113115 return this . request (
114116 {
115117 url : this . makeUrl ( params . query ) ,
@@ -121,7 +123,7 @@ export abstract class Base<T = any, D = Partial<T>> implements ServiceInterface<
121123 ) . catch ( toError )
122124 }
123125
124- update ( id : NullableId , body : D , params : RestClientParams = { } ) {
126+ update ( id : NullableId , body : D , params ?: P ) {
125127 if ( typeof id === 'undefined' ) {
126128 return Promise . reject (
127129 new Error ( "id for 'update' can not be undefined, only 'null' when updating multiple entries" )
@@ -139,7 +141,7 @@ export abstract class Base<T = any, D = Partial<T>> implements ServiceInterface<
139141 ) . catch ( toError )
140142 }
141143
142- patch ( id : NullableId , body : D , params : RestClientParams = { } ) {
144+ patch ( id : NullableId , body : D , params ?: P ) {
143145 if ( typeof id === 'undefined' ) {
144146 return Promise . reject (
145147 new Error ( "id for 'patch' can not be undefined, only 'null' when updating multiple entries" )
@@ -157,7 +159,7 @@ export abstract class Base<T = any, D = Partial<T>> implements ServiceInterface<
157159 ) . catch ( toError )
158160 }
159161
160- remove ( id : NullableId , params : RestClientParams = { } ) {
162+ remove ( id : NullableId , params ?: P ) {
161163 if ( typeof id === 'undefined' ) {
162164 return Promise . reject (
163165 new Error ( "id for 'remove' can not be undefined, only 'null' when removing multiple entries" )
0 commit comments