@@ -49,7 +49,7 @@ export interface AdapterParams<M = any> extends Params {
4949 *
5050 * @see {@link https://docs.feathersjs.com/guides/migrating.html#hook-less-service-methods }
5151 */
52- export interface InternalServiceMethods < T = any > {
52+ export interface InternalServiceMethods < T = any , D = Partial < T > > {
5353
5454 /**
5555 * Retrieve all resources from this service, skipping any service-level hooks.
@@ -78,7 +78,7 @@ export interface InternalServiceMethods<T = any> {
7878 * @see {@link HookLessServiceMethods }
7979 * @see {@link https://docs.feathersjs.com/api/services.html#create-data-params|Feathers API Documentation: .create(data, params) }
8080 */
81- _create ( data : Partial < T > | Partial < T > [ ] , params ?: AdapterParams ) : Promise < T | T [ ] > ;
81+ _create ( data : D | D [ ] , params ?: AdapterParams ) : Promise < T | T [ ] > ;
8282
8383 /**
8484 * Replace any resources matching the given ID with the given data, skipping any service-level hooks.
@@ -89,7 +89,7 @@ export interface InternalServiceMethods<T = any> {
8989 * @see {@link HookLessServiceMethods }
9090 * @see {@link https://docs.feathersjs.com/api/services.html#update-id-data-params|Feathers API Documentation: .update(id, data, params) }
9191 */
92- _update ( id : Id , data : T , params ?: AdapterParams ) : Promise < T > ;
92+ _update ( id : Id , data : D , params ?: AdapterParams ) : Promise < T > ;
9393
9494 /**
9595 * Merge any resources matching the given ID with the given data, skipping any service-level hooks.
@@ -100,7 +100,7 @@ export interface InternalServiceMethods<T = any> {
100100 * @see {@link HookLessServiceMethods }
101101 * @see {@link https://docs.feathersjs.com/api/services.html#patch-id-data-params|Feathers API Documentation: .patch(id, data, params) }
102102 */
103- _patch ( id : NullableId , data : Partial < T > , params ?: AdapterParams ) : Promise < T | T [ ] > ;
103+ _patch ( id : NullableId , data : D , params ?: AdapterParams ) : Promise < T | T [ ] > ;
104104
105105 /**
106106 * Remove resources matching the given ID from the this service, skipping any service-level hooks.
@@ -113,10 +113,14 @@ export interface InternalServiceMethods<T = any> {
113113 _remove ( id : NullableId , params ?: AdapterParams ) : Promise < T | T [ ] > ;
114114}
115115
116- export class AdapterService < T = any > implements ServiceMethods < T | Paginated < T > > {
117- options : ServiceOptions ;
116+ export class AdapterService <
117+ T = any ,
118+ D = Partial < T > ,
119+ O extends Partial < ServiceOptions > = Partial < ServiceOptions >
120+ > implements ServiceMethods < T | Paginated < T > , D > {
121+ options : ServiceOptions & O ;
118122
119- constructor ( options : Partial < ServiceOptions > ) {
123+ constructor ( options : O ) {
120124 this . options = Object . assign ( {
121125 id : 'id' ,
122126 events : [ ] ,
@@ -191,7 +195,7 @@ export class AdapterService<T = any> implements ServiceMethods<T|Paginated<T>> {
191195 return callMethod ( this , '_create' , data , params ) ;
192196 }
193197
194- update ( id : Id , data : T , params ?: AdapterParams ) : Promise < T > {
198+ update ( id : Id , data : D , params ?: AdapterParams ) : Promise < T > {
195199 if ( id === null || Array . isArray ( data ) ) {
196200 return Promise . reject ( new BadRequest (
197201 'You can not replace multiple instances. Did you mean \'patch\'?'
0 commit comments