graphql-data-generator 0.1.6 → 0.1.7
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/package.json +1 -1
- package/types/extendedTypes.d.ts +3 -6
- package/types/proxy.d.ts +3 -3
- package/types/types.d.ts +7 -0
package/package.json
CHANGED
package/types/extendedTypes.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import type { ContravariantEmpty, OperationMock, Patch, SimpleOperationMock } from "./types.js";
|
|
1
|
+
import type { ContravariantEmpty, OperationMock, Patch, SimpleOperationMock, SimpleOperationPatch } from "./types.js";
|
|
2
2
|
type DefaultObjectTransformSwitch<T, U> = T extends (infer G)[] ? DefaultObjectTransformSwitch<G, U>[] : DefaultObjectTransform<T, U>;
|
|
3
3
|
type DefaultObjectTransform<T, U = T> = {
|
|
4
4
|
[K in keyof T]?: T[K] extends object ? DefaultObjectTransformSwitch<T[K], U> | ((host: U) => DefaultObjectTransformSwitch<T[K], U>) : T[K] | ((host: U) => T[K]);
|
|
5
5
|
};
|
|
6
6
|
export type Shift<T extends unknown[]> = T extends [infer _First, ...infer Rest] ? Rest : [];
|
|
7
|
-
type OperationBuilder<Data extends Record<string, unknown> = Record<string, unknown>, Variables = unknown, Transforms = unknown, Extra = ContravariantEmpty> = ((...patches: ((
|
|
7
|
+
type OperationBuilder<Data extends Record<string, unknown> = Record<string, unknown>, Variables = unknown, Transforms = unknown, Extra = ContravariantEmpty> = ((...patches: ((SimpleOperationPatch<Data, Variables> & Partial<Extra>) | ((prev: SimpleOperationMock<Data, Variables>) => SimpleOperationPatch<Data, Variables>))[]) => OperationBuilderWithMock<Data, Variables, Transforms, Extra>) & {
|
|
8
8
|
variables: (variables: Patch<Variables> | ((data: Data, variables: Variables) => Patch<Variables>)) => OperationBuilderWithMock<Data, Variables, Transforms, Extra>;
|
|
9
9
|
data: (data: Patch<Data> | ((variables: Variables, data: Data) => Patch<Data>)) => OperationBuilderWithMock<Data, Variables, Transforms, Extra>;
|
|
10
|
-
patch: (patch:
|
|
11
|
-
data: Data;
|
|
12
|
-
variables: Variables;
|
|
13
|
-
}>) => OperationBuilderWithMock<Data, Variables, Transforms, Extra>;
|
|
10
|
+
patch: (patch: SimpleOperationPatch<Data, Variables>) => OperationBuilderWithMock<Data, Variables, Transforms, Extra>;
|
|
14
11
|
} & {
|
|
15
12
|
[Transform in keyof Transforms]: Transforms[Transform] extends (...args: any[]) => unknown ? (...params: Shift<Parameters<Transforms[Transform]>>) => OperationBuilderWithMock<Data, Variables, Transforms, Extra> : () => OperationBuilderWithMock<Data, Variables, Transforms, Extra>;
|
|
16
13
|
};
|
package/types/proxy.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { DefinitionNode } from "graphql";
|
|
1
|
+
import type { DefinitionNode, GraphQLError } from "graphql";
|
|
2
2
|
import type { OperationMock, Patch, SimpleOperationMock } from "./types.js";
|
|
3
3
|
export declare const withGetDefaultPatch: <T>(newGetDefaultPatch: <U>(__typename: string) => Patch<U> | ((prev: U) => Patch<U> | undefined) | undefined, fn: () => T) => T;
|
|
4
4
|
export declare const proxy: <T>(definitions: readonly DefinitionNode[], scalars: Record<string, unknown | ((typename: string) => unknown)>, type: string, ...patches: (Patch<T> | ((prev: T) => Patch<T>))[]) => T;
|
|
5
5
|
export declare const operation: <O extends SimpleOperationMock, Extra = object>(definitions: readonly DefinitionNode[], scalars: Record<string, unknown | ((typename: string) => unknown)>, query: string, ...patches: (Patch<Omit<O, "error" | "errors">> & {
|
|
6
|
-
error?:
|
|
7
|
-
errors?:
|
|
6
|
+
error?: Error;
|
|
7
|
+
errors?: GraphQLError[];
|
|
8
8
|
} & Partial<Extra>)[]) => OperationMock<O["data"], O["variables"]> & Partial<Extra>;
|
package/types/types.d.ts
CHANGED
|
@@ -34,4 +34,11 @@ export type SimpleOperationMock<Data extends Record<string, unknown> = Record<st
|
|
|
34
34
|
error?: Error;
|
|
35
35
|
errors?: GraphQLError[];
|
|
36
36
|
};
|
|
37
|
+
export type SimpleOperationPatch<Data extends Record<string, unknown> = Record<string, unknown>, Variables = Record<string, unknown> | never> = Patch<{
|
|
38
|
+
data: Data;
|
|
39
|
+
variables?: Variables;
|
|
40
|
+
}> & {
|
|
41
|
+
error?: Error;
|
|
42
|
+
errors?: GraphQLError[];
|
|
43
|
+
};
|
|
37
44
|
export {};
|