diff --git a/packages/adapter-commons/src/service.ts b/packages/adapter-commons/src/service.ts index 19b452f7a1..6182dbb4e8 100644 --- a/packages/adapter-commons/src/service.ts +++ b/packages/adapter-commons/src/service.ts @@ -26,12 +26,12 @@ export interface ServiceOptions { } export interface InternalServiceMethods { - _find (params?: Params): Promise>; + _find (params?: Params): Promise>; _get (id: Id, params?: Params): Promise; _create (data: Partial | Array>, params?: Params): Promise; _update (id: Id, data: T, params?: Params): Promise; - _patch (id: NullableId, data: Partial, params?: Params): Promise; - _remove (id: NullableId, params?: Params): Promise; + _patch (id: NullableId, data: Partial, params?: Params): Promise; + _remove (id: NullableId, params?: Params): Promise; } export class AdapterService implements ServiceMethods { @@ -86,7 +86,7 @@ export class AdapterService implements ServiceMethods { } } - find (params?: Params): Promise> { + find (params?: Params): Promise> { return callMethod(this, '_find', params); } @@ -94,6 +94,9 @@ export class AdapterService implements ServiceMethods { return callMethod(this, '_get', id, params); } + create (data: Partial, params?: Params): Promise; + create (data: Array>, params?: Params): Promise; + create (data: Partial | Array>, params?: Params): Promise; create (data: Partial | Array>, params?: Params): Promise { if (Array.isArray(data) && !this.allowsMulti('create')) { return Promise.reject(new MethodNotAllowed(`Can not create multiple entries`)); @@ -112,7 +115,10 @@ export class AdapterService implements ServiceMethods { return callMethod(this, '_update', id, data, params); } - patch (id: NullableId, data: Partial, params?: Params): Promise { + patch (id: Id, data: Partial, params?: Params): Promise; + patch (id: null, data: Partial, params?: Params): Promise; + patch (id: NullableId, data: Partial, params?: Params): Promise; + patch (id: NullableId, data: Partial, params?: Params): Promise { if (id === null && !this.allowsMulti('patch')) { return Promise.reject(new MethodNotAllowed(`Can not patch multiple entries`)); } @@ -120,7 +126,10 @@ export class AdapterService implements ServiceMethods { return callMethod(this, '_patch', id, data, params); } - remove (id: NullableId, params?: Params): Promise { + remove (id: Id, params?: Params): Promise; + remove (id: null, params?: Params): Promise; + remove (id: NullableId, params?: Params): Promise; + remove (id: NullableId, params?: Params): Promise { if (id === null && !this.allowsMulti('remove')) { return Promise.reject(new MethodNotAllowed(`Can not remove multiple entries`)); } diff --git a/packages/feathers/index.d.ts b/packages/feathers/index.d.ts index 25135d8f14..7f9cb6e2f8 100644 --- a/packages/feathers/index.d.ts +++ b/packages/feathers/index.d.ts @@ -149,11 +149,11 @@ declare namespace createApplication { create (data: Partial | Array>, params?: Params): Promise; - update (id: NullableId, data: T, params?: Params): Promise; + update (id: NullableId, data: T, params?: Params): Promise; - patch (id: NullableId, data: Partial, params?: Params): Promise; + patch (id: NullableId, data: Partial, params?: Params): Promise; - remove (id: NullableId, params?: Params): Promise; + remove (id: NullableId, params?: Params): Promise; } interface SetupMethod { @@ -161,11 +161,21 @@ declare namespace createApplication { } interface ServiceOverloads { + create? (data: Partial, params?: Params): Promise; + create? (data: Array>, params?: Params): Promise; - create? (data: Partial, params?: Params): Promise; + update? (id: Id, data: T, params?: Params): Promise; + + update? (id: null, data: T, params?: Params): Promise; + + patch? (id: Id, data: Partial, params?: Params): Promise; + + patch? (id: null, data: Partial, params?: Params): Promise; + + remove? (id: Id, params?: Params): Promise; - patch? (id: NullableId, data: Pick, params?: Params): Promise; + remove? (id: null, params?: Params): Promise; } interface ServiceAddons extends EventEmitter {