Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove adapter commons type alternatives #1620

Merged
merged 2 commits into from
Oct 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions packages/adapter-commons/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface ServiceOptions {
}

export interface InternalServiceMethods<T = any> {
_find (params?: Params): Promise<T[] | Paginated<T>>;
_find (params?: Params): Promise<T | T[] | Paginated<T>>;
_get (id: Id, params?: Params): Promise<T>;
_create (data: Partial<T> | Array<Partial<T>>, params?: Params): Promise<T | T[]>;
_update (id: Id, data: T, params?: Params): Promise<T>;
Expand Down Expand Up @@ -94,9 +94,6 @@ export class AdapterService<T = any> implements ServiceMethods<T> {
return callMethod(this, '_get', id, params);
}

create (data: Partial<T>, params?: Params): Promise<T>;
create (data: Array<Partial<T>>, params?: Params): Promise<T[]>;
create (data: Partial<T> | Array<Partial<T>>, params?: Params): Promise<T | T[]>;
create (data: Partial<T> | Array<Partial<T>>, params?: Params): Promise<T | T[]> {
if (Array.isArray(data) && !this.allowsMulti('create')) {
return Promise.reject(new MethodNotAllowed(`Can not create multiple entries`));
Expand All @@ -115,9 +112,6 @@ export class AdapterService<T = any> implements ServiceMethods<T> {
return callMethod(this, '_update', id, data, params);
}

patch (id: Id, data: Partial<T>, params?: Params): Promise<T>;
patch (id: null, data: Partial<T>, params?: Params): Promise<T[]>;
patch (id: NullableId, data: Partial<T>, params?: Params): Promise<T | T[]>;
patch (id: NullableId, data: Partial<T>, params?: Params): Promise<T | T[]> {
if (id === null && !this.allowsMulti('patch')) {
return Promise.reject(new MethodNotAllowed(`Can not patch multiple entries`));
Expand All @@ -126,9 +120,6 @@ export class AdapterService<T = any> implements ServiceMethods<T> {
return callMethod(this, '_patch', id, data, params);
}

remove (id: Id, params?: Params): Promise<T>;
remove (id: null, params?: Params): Promise<T[]>;
remove (id: NullableId, params?: Params): Promise<T | T[]>;
remove (id: NullableId, params?: Params): Promise<T | T[]> {
if (id === null && !this.allowsMulti('remove')) {
return Promise.reject(new MethodNotAllowed(`Can not remove multiple entries`));
Expand Down