@vladimirdev635/gql-client-react 0.0.26 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore +1 -1
- package/package.json +1 -1
- package/tests/utils.d.ts +1 -0
- package/types.d.ts +3 -3
- package/useLazyOperation.d.ts +3 -3
- package/useOperation.d.ts +3 -3
package/.npmignore
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
tests
|
|
1
|
+
tests/
|
package/package.json
CHANGED
package/tests/utils.d.ts
CHANGED
package/types.d.ts
CHANGED
|
@@ -6,11 +6,11 @@ export interface Operation {
|
|
|
6
6
|
variablesSchema: z.ZodType;
|
|
7
7
|
resultSchema: z.ZodType;
|
|
8
8
|
}
|
|
9
|
-
export interface ExecuteResult<
|
|
10
|
-
result:
|
|
9
|
+
export interface ExecuteResult<TResult> {
|
|
10
|
+
result: TResult;
|
|
11
11
|
response: Response;
|
|
12
12
|
}
|
|
13
13
|
export interface RequestContext {
|
|
14
14
|
fetchOptions?: RequestInit;
|
|
15
15
|
}
|
|
16
|
-
export type Executor<TRequestContext extends RequestContext> = <T extends Operation>(operation: T, variables: z.infer<T['variablesSchema']>, context: TRequestContext) => Promise<ExecuteResult<T
|
|
16
|
+
export type Executor<TRequestContext extends RequestContext> = <T extends Operation>(operation: T, variables: z.infer<T['variablesSchema']>, context: TRequestContext) => Promise<ExecuteResult<z.infer<T['resultSchema']>>>;
|
package/useLazyOperation.d.ts
CHANGED
|
@@ -4,13 +4,13 @@ import { OperationState } from './useOperation.jsx';
|
|
|
4
4
|
export interface LazyOperationInitialState {
|
|
5
5
|
state: 'initial';
|
|
6
6
|
}
|
|
7
|
-
export type LazyOperationState<
|
|
7
|
+
export type LazyOperationState<TResult> = OperationState<TResult> | LazyOperationInitialState;
|
|
8
8
|
export declare const lazyInitialState: Readonly<{
|
|
9
9
|
readonly state: "initial";
|
|
10
10
|
}>;
|
|
11
11
|
interface UseLazyOperationReturnType<T extends Operation, TRequestContext extends RequestContext> {
|
|
12
|
-
execute: (variables: z.infer<T['variablesSchema']>, requestContext: TRequestContext) => Promise<LazyOperationState<T
|
|
13
|
-
state: LazyOperationState<T
|
|
12
|
+
execute: (variables: z.infer<T['variablesSchema']>, requestContext: TRequestContext) => Promise<LazyOperationState<z.infer<T['resultSchema']>>>;
|
|
13
|
+
state: LazyOperationState<z.infer<T['resultSchema']>>;
|
|
14
14
|
reset: () => void;
|
|
15
15
|
}
|
|
16
16
|
export declare function useLazyOperation<T extends Operation, TRequestContext extends RequestContext>(executor: Executor<TRequestContext>, operation: T): UseLazyOperationReturnType<T, TRequestContext>;
|
package/useOperation.d.ts
CHANGED
|
@@ -3,15 +3,15 @@ import { ExecuteResult, Executor, Operation, RequestContext } from './types.js';
|
|
|
3
3
|
export interface OperationLoadingState {
|
|
4
4
|
state: 'loading';
|
|
5
5
|
}
|
|
6
|
-
export interface OperationSuccessState<
|
|
6
|
+
export interface OperationSuccessState<TResult> extends ExecuteResult<TResult> {
|
|
7
7
|
state: 'success';
|
|
8
8
|
}
|
|
9
9
|
export interface OperationFailureState {
|
|
10
10
|
state: 'failure';
|
|
11
11
|
error: Error;
|
|
12
12
|
}
|
|
13
|
-
export type OperationState<
|
|
13
|
+
export type OperationState<TResult> = OperationLoadingState | OperationSuccessState<TResult> | OperationFailureState;
|
|
14
14
|
export declare const loadingState: Readonly<{
|
|
15
15
|
readonly state: "loading";
|
|
16
16
|
}>;
|
|
17
|
-
export declare function useOperation<T extends Operation, TRequestContext extends RequestContext>(executor: Executor<TRequestContext>, operation: T, variables: z.infer<T['variablesSchema']>, requestContext: TRequestContext): OperationState<T
|
|
17
|
+
export declare function useOperation<T extends Operation, TRequestContext extends RequestContext>(executor: Executor<TRequestContext>, operation: T, variables: z.infer<T['variablesSchema']>, requestContext: TRequestContext): OperationState<z.infer<T['resultSchema']>>;
|