From 3b74f8d854c61e648498c81ac2d2bf600d8d5152 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Tue, 25 May 2021 21:54:13 -0500 Subject: [PATCH] Renamed fetchInput to fetcherInput --- framework/commerce/types/cart.ts | 8 ++++---- framework/commerce/types/customer.ts | 2 -- framework/commerce/types/login.ts | 2 +- framework/commerce/types/product.ts | 2 +- framework/commerce/types/signup.ts | 2 +- framework/commerce/types/wishlist.ts | 6 +++--- framework/commerce/utils/types.ts | 18 ++++++++++-------- framework/commerce/utils/use-data.tsx | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/framework/commerce/types/cart.ts b/framework/commerce/types/cart.ts index 3ab6eb867..4cd9d13da 100644 --- a/framework/commerce/types/cart.ts +++ b/framework/commerce/types/cart.ts @@ -101,14 +101,14 @@ export type CartHooks = { export type GetCartHook = { data: T['cart'] | null input: {} - fetchInput: { cartId?: string } + fetcherInput: { cartId?: string } swrState: { isEmpty: boolean } } export type AddItemHook = { data: T['cart'] input: T['itemBody'] - fetchInput: T['itemBody'] + fetcherInput: T['itemBody'] body: { item: T['itemBody'] } actionInput: T['itemBody'] } @@ -116,7 +116,7 @@ export type AddItemHook = { export type UpdateItemHook = { data: T['cart'] | null input: { item?: T['item']; wait?: number } - fetchInput: { itemId: string; item: T['itemBody'] } + fetcherInput: { itemId: string; item: T['itemBody'] } body: { itemId: string; item: T['itemBody'] } actionInput: T['itemBody'] & { id: string } } @@ -124,7 +124,7 @@ export type UpdateItemHook = { export type RemoveItemHook = { data: T['cart'] | null input: { item?: T['item'] } - fetchInput: { itemId: string } + fetcherInput: { itemId: string } body: { itemId: string } actionInput: { id: string } } diff --git a/framework/commerce/types/customer.ts b/framework/commerce/types/customer.ts index 4df0fade3..ba90acdf4 100644 --- a/framework/commerce/types/customer.ts +++ b/framework/commerce/types/customer.ts @@ -8,8 +8,6 @@ export type CustomerTypes = { export type CustomerHook = { data: T['customer'] | null fetchData: { customer: T['customer'] } | null - // actionInput: T['body'] - // fetchInput: T['body'] } export type CustomerSchema = { diff --git a/framework/commerce/types/login.ts b/framework/commerce/types/login.ts index 031574a33..b6ef228e0 100644 --- a/framework/commerce/types/login.ts +++ b/framework/commerce/types/login.ts @@ -10,7 +10,7 @@ export type LoginTypes = { export type LoginHook = { data: null actionInput: LoginBody - fetchInput: LoginBody + fetcherInput: LoginBody body: T['body'] } diff --git a/framework/commerce/types/product.ts b/framework/commerce/types/product.ts index 2ac45389e..782f2a31a 100644 --- a/framework/commerce/types/product.ts +++ b/framework/commerce/types/product.ts @@ -58,7 +58,7 @@ export type SearchProductsHook = { data: T['product'][] body: T['searchBody'] input: T['searchBody'] - fetchInput: T['searchBody'] + fetcherInput: T['searchBody'] } export type ProductsSchema = { diff --git a/framework/commerce/types/signup.ts b/framework/commerce/types/signup.ts index df5f9aca7..4e23da6c0 100644 --- a/framework/commerce/types/signup.ts +++ b/framework/commerce/types/signup.ts @@ -13,7 +13,7 @@ export type SignupHook = { data: null body: T['body'] actionInput: T['body'] - fetchInput: T['body'] + fetcherInput: T['body'] } export type SignupSchema = { diff --git a/framework/commerce/types/wishlist.ts b/framework/commerce/types/wishlist.ts index 7a547e9fc..e71cdc7e4 100644 --- a/framework/commerce/types/wishlist.ts +++ b/framework/commerce/types/wishlist.ts @@ -15,21 +15,21 @@ export type GetWishlistHook = { data: T['wishlist'] | null body: { includeProducts?: boolean } input: { includeProducts?: boolean } - fetchInput: { customerId: string; includeProducts?: boolean } + fetcherInput: { customerId: string; includeProducts?: boolean } swrState: { isEmpty: boolean } } export type AddItemHook = { data: T['wishlist'] body: { item: T['itemBody'] } - fetchInput: { item: T['itemBody'] } + fetcherInput: { item: T['itemBody'] } actionInput: T['itemBody'] } export type RemoveItemHook = { data: T['wishlist'] | null body: { itemId: string } - fetchInput: { itemId: string } + fetcherInput: { itemId: string } actionInput: { id: string } input: { wishlist?: { includeProducts?: boolean } } } diff --git a/framework/commerce/utils/types.ts b/framework/commerce/utils/types.ts index f95d1148a..fe1507d08 100644 --- a/framework/commerce/utils/types.ts +++ b/framework/commerce/utils/types.ts @@ -42,7 +42,7 @@ export type HookFetcherFn = ( export type HookFetcherContext = { options: HookFetcherOptions - input: H['fetchInput'] + input: H['fetcherInput'] fetch: ( options: FetcherOptions ) => Promise @@ -74,7 +74,7 @@ export type HookSchemaBase = { // Input expected by the hook input?: {} // Input expected before doing a fetch operation (aka fetch handler) - fetchInput?: {} + fetcherInput?: {} // Body object expected by the fetch operation body?: {} // Data returned by the fetch operation @@ -98,7 +98,7 @@ export type SWRHook = { useHook( context: SWRHookContext ): HookFunction< - H['input'] & { swrOptions?: SwrOptions }, + H['input'] & { swrOptions?: SwrOptions }, ResponseState & H['swrState'] > fetchOptions: HookFetcherOptions @@ -108,7 +108,7 @@ export type SWRHook = { export type SWRHookContext = { useData(context?: { input?: HookFetchInput | HookSWRInput - swrOptions?: SwrOptions + swrOptions?: SwrOptions }): ResponseState } @@ -127,11 +127,13 @@ export type MutationHook = { } export type MutationHookContext = { - fetch: keyof H['fetchInput'] extends never + fetch: keyof H['fetcherInput'] extends never ? () => H['data'] | Promise - : Partial extends H['fetchInput'] - ? (context?: { input?: H['fetchInput'] }) => H['data'] | Promise - : (context: { input: H['fetchInput'] }) => H['data'] | Promise + : Partial extends H['fetcherInput'] + ? (context?: { + input?: H['fetcherInput'] + }) => H['data'] | Promise + : (context: { input: H['fetcherInput'] }) => H['data'] | Promise } export type SwrOptions = ConfigInterface< diff --git a/framework/commerce/utils/use-data.tsx b/framework/commerce/utils/use-data.tsx index 3bd4e4faf..4fc208bab 100644 --- a/framework/commerce/utils/use-data.tsx +++ b/framework/commerce/utils/use-data.tsx @@ -22,7 +22,7 @@ export type UseData = ( }, input: HookFetchInput | HookSWRInput, fetcherFn: Fetcher, - swrOptions?: SwrOptions + swrOptions?: SwrOptions ) => ResponseState const useData: UseData = (options, input, fetcherFn, swrOptions) => {