Skip to content

Commit

Permalink
Revert more unnecessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
djhi committed May 11, 2023
1 parent 92806c6 commit 60f770e
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 27 deletions.
6 changes: 3 additions & 3 deletions packages/ra-core/src/controller/list/useList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const refetch = () => {
* @param {SortPayload} props.sort: Optional. The initial sort (field and order)
* @param {filterCallback} prop.filterCallback Optional. A function that allows you to make a custom filter
*/
export const useList = <RecordType extends RaRecord = RaRecord>(
export const useList = <RecordType extends RaRecord = any>(
props: UseListOptions<RecordType>
): UseListValue<RecordType> => {
const {
Expand Down Expand Up @@ -265,7 +265,7 @@ export const useList = <RecordType extends RaRecord = RaRecord>(
};
};

export interface UseListOptions<RecordType extends RaRecord = RaRecord> {
export interface UseListOptions<RecordType extends RaRecord = any> {
data?: RecordType[];
error?: any;
filter?: FilterPayload;
Expand All @@ -279,7 +279,7 @@ export interface UseListOptions<RecordType extends RaRecord = RaRecord> {
}

export type UseListValue<
RecordType extends RaRecord = RaRecord
RecordType extends RaRecord = any
> = ListControllerResult<RecordType>;

const defaultFilter = {};
2 changes: 1 addition & 1 deletion packages/ra-core/src/controller/list/useListController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ const defaultSort = {
order: SORT_ASC,
};

export interface ListControllerResult<RecordType extends RaRecord = RaRecord> {
export interface ListControllerResult<RecordType extends RaRecord = any> {
sort: SortPayload;
data: RecordType[];
defaultTitle?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/controller/list/useRecordSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { RaRecord } from '../../types';
*
* @returns {Object} Destructure as [selectedIds, { select, toggle, clearSelection }].
*/
export const useRecordSelection = <RecordType extends RaRecord = RaRecord>(
export const useRecordSelection = <RecordType extends RaRecord = any>(
resource: string
): [
RecordType['id'][],
Expand Down
6 changes: 3 additions & 3 deletions packages/ra-core/src/controller/useReference.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Identifier, RaRecord } from '../types';
import { RaRecord, Identifier } from '../types';
import { UseGetManyHookValue, useGetManyAggregate } from '../dataProvider';
import { UseQueryOptions } from 'react-query';

interface UseReferenceProps<RecordType extends RaRecord = RaRecord> {
interface UseReferenceProps<RecordType extends RaRecord = any> {
id: Identifier;
reference: string;
options?: UseQueryOptions<RecordType[], Error> & { meta?: any };
}

export interface UseReferenceResult<RecordType extends RaRecord = RaRecord> {
export interface UseReferenceResult<RecordType extends RaRecord = any> {
isLoading: boolean;
isFetching: boolean;
referenceRecord?: RecordType;
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/dataProvider/useCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ import { useEvent } from '../util';
* \-- data is Product
*/
export const useCreate = <
RecordType extends RaRecord = RaRecord,
RecordType extends RaRecord = any,
MutationError = unknown
>(
resource?: string,
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/dataProvider/useGetList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const useGetList = <RecordType extends RaRecord = any>(
};

export type UseGetListHookValue<
RecordType extends RaRecord = RaRecord
RecordType extends RaRecord = any
> = UseQueryResult<RecordType[], Error> & {
total?: number;
pageInfo?: {
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/dataProvider/useGetMany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,5 @@ export const useGetMany = <RecordType extends RaRecord = any>(
};

export type UseGetManyHookValue<
RecordType extends RaRecord = RaRecord
RecordType extends RaRecord = any
> = UseQueryResult<RecordType[], Error>;
4 changes: 2 additions & 2 deletions packages/ra-core/src/dataProvider/useGetManyAggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import union from 'lodash/union';

import { UseGetManyHookValue } from './useGetMany';
import { Identifier, GetManyParams, DataProvider, RaRecord } from '../types';
import { Identifier, RaRecord, GetManyParams, DataProvider } from '../types';
import { useDataProvider } from './useDataProvider';

/**
Expand Down Expand Up @@ -65,7 +65,7 @@ import { useDataProvider } from './useDataProvider';
* );
* };
*/
export const useGetManyAggregate = <RecordType extends RaRecord = RaRecord>(
export const useGetManyAggregate = <RecordType extends RaRecord = any>(
resource: string,
params: GetManyParams,
options: UseQueryOptions<RecordType[], Error> = {}
Expand Down
6 changes: 3 additions & 3 deletions packages/ra-core/src/dataProvider/useGetOne.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GetOneParams, RaRecord } from '../types';
import { RaRecord, GetOneParams } from '../types';
import { useQuery, UseQueryOptions, UseQueryResult } from 'react-query';
import { useDataProvider } from './useDataProvider';

Expand Down Expand Up @@ -41,7 +41,7 @@ import { useDataProvider } from './useDataProvider';
* return <div>User {data.username}</div>;
* };
*/
export const useGetOne = <RecordType extends RaRecord = RaRecord>(
export const useGetOne = <RecordType extends RaRecord = any>(
resource: string,
{ id, meta }: GetOneParams<RecordType>,
options?: UseQueryOptions<RecordType>
Expand All @@ -61,5 +61,5 @@ export const useGetOne = <RecordType extends RaRecord = RaRecord>(
};

export type UseGetOneHookValue<
RecordType extends RaRecord = RaRecord
RecordType extends RaRecord = any
> = UseQueryResult<RecordType>;
10 changes: 5 additions & 5 deletions packages/ra-core/src/dataProvider/useUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import {
import { useDataProvider } from './useDataProvider';
import undoableEventEmitter from './undoableEventEmitter';
import {
RaRecord,
UpdateParams,
MutationMode,
GetListResult as OriginalGetListResult,
GetInfiniteListResult,
RaRecord,
} from '../types';
import { useEvent } from '../util';

Expand Down Expand Up @@ -83,7 +83,7 @@ import { useEvent } from '../util';
* \-- data is Product
*/
export const useUpdate = <
RecordType extends RaRecord = RaRecord,
RecordType extends RaRecord = any,
MutationError = unknown
>(
resource?: string,
Expand Down Expand Up @@ -445,7 +445,7 @@ export const useUpdate = <

type Snapshot = [key: QueryKey, value: any][];

export interface UseUpdateMutateParams<RecordType extends RaRecord = RaRecord> {
export interface UseUpdateMutateParams<RecordType extends RaRecord = any> {
resource?: string;
id?: RecordType['id'];
data?: Partial<RecordType>;
Expand All @@ -454,7 +454,7 @@ export interface UseUpdateMutateParams<RecordType extends RaRecord = RaRecord> {
}

export type UseUpdateOptions<
RecordType extends RaRecord = RaRecord,
RecordType extends RaRecord = any,
MutationError = unknown
> = UseMutationOptions<
RecordType,
Expand All @@ -463,7 +463,7 @@ export type UseUpdateOptions<
> & { mutationMode?: MutationMode; returnPromise?: boolean };

export type UseUpdateResult<
RecordType extends RaRecord = RaRecord,
RecordType extends RaRecord = any,
TReturnPromise extends boolean = boolean,
MutationError = unknown
> = [
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/dataProvider/useUpdateMany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ import { Identifier } from '..';
* };
*/
export const useUpdateMany = <
RecordType extends RaRecord = RaRecord,
RecordType extends RaRecord = any,
MutationError = unknown
>(
resource?: string,
Expand Down
11 changes: 6 additions & 5 deletions packages/ra-core/src/dataProvider/withLifecycleCallbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ import {
* target: "post_id",
* id: params.id,
* }
* );RaRecord
* ids: comments.map((comment) => comment.id),
* );
* if (comments.length > 0) {
* await dataProvider.deleteMany("comments", { * ids: comments.map((comment) => comment.id),
* });
* }
* // update the author's nb_posts
Expand Down Expand Up @@ -165,7 +166,7 @@ export const withLifecycleCallbacks = (
},

// @ts-ignore
getOne: async function <RecordType extends RaRecord = RaRecord>(
getOne: async function <RecordType extends RaRecord = any>(
resource: string,
params: GetOneParams<RecordType>
) {
Expand Down Expand Up @@ -285,7 +286,7 @@ export const withLifecycleCallbacks = (
},

// @ts-ignore
update: async function <RecordType extends RaRecord = RaRecord>(
update: async function <RecordType extends RaRecord = any>(
resource: string,
params: UpdateParams<RecordType>
) {
Expand Down Expand Up @@ -330,7 +331,7 @@ export const withLifecycleCallbacks = (
return result;
},

create: async function <RecordType extends RaRecord = RaRecord>(
create: async function <RecordType extends RaRecord = any>(
resource: string,
params: CreateParams
) {
Expand Down

0 comments on commit 60f770e

Please sign in to comment.