@avantstay/graphql-ts-client 12.2.0 → 12.3.0
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/dist/chunk-I4QOADOI.mjs +27 -0
- package/dist/index.js +12 -2
- package/dist/index.mjs +12 -2
- package/dist/{types-9b559f16.d.ts → types-4ecbabdf.d.ts} +2 -14
- package/package.json +11 -1
- package/src/__testClient.d.ts +2 -10
- package/src/__testClient.js +2 -29
- package/src/generateTypescriptClient.ts +1 -1
- package/dist/types-c109c17f.d.ts +0 -85
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
// src/types.ts
|
|
10
|
+
var GraphQLClientError = class extends Error {
|
|
11
|
+
constructor(responseData) {
|
|
12
|
+
super();
|
|
13
|
+
this.responseData = responseData;
|
|
14
|
+
Object.setPrototypeOf(this, GraphQLClientError.prototype);
|
|
15
|
+
}
|
|
16
|
+
get message() {
|
|
17
|
+
return this.response.errors.map((it) => it.message).join(";\n");
|
|
18
|
+
}
|
|
19
|
+
get response() {
|
|
20
|
+
return this.responseData;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
__require,
|
|
26
|
+
GraphQLClientError
|
|
27
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -487,7 +487,7 @@ var prettier = __toESM(require("prettier"));
|
|
|
487
487
|
// package.json
|
|
488
488
|
var package_default = {
|
|
489
489
|
name: "@avantstay/graphql-ts-client",
|
|
490
|
-
version: "12.
|
|
490
|
+
version: "12.3.0",
|
|
491
491
|
description: "GraphQL Typescript Client Generator",
|
|
492
492
|
homepage: "https://github.com/avantstay/graphql-ts-client",
|
|
493
493
|
bugs: {
|
|
@@ -508,6 +508,16 @@ var package_default = {
|
|
|
508
508
|
require: "./dist/index.js",
|
|
509
509
|
types: "./dist/index.d.ts"
|
|
510
510
|
},
|
|
511
|
+
"./endpoint": {
|
|
512
|
+
import: "./dist/endpoint.mjs",
|
|
513
|
+
require: "./dist/endpoint.js",
|
|
514
|
+
types: "./dist/endpoint.d.ts"
|
|
515
|
+
},
|
|
516
|
+
"./dist": {
|
|
517
|
+
import: "./dist/index.mjs",
|
|
518
|
+
require: "./dist/index.js",
|
|
519
|
+
types: "./dist/index.d.ts"
|
|
520
|
+
},
|
|
511
521
|
"./dist/endpoint": {
|
|
512
522
|
import: "./dist/endpoint.mjs",
|
|
513
523
|
require: "./dist/endpoint.js",
|
|
@@ -581,7 +591,7 @@ var package_default = {
|
|
|
581
591
|
};
|
|
582
592
|
// src/generateTypescriptClient.ts
|
|
583
593
|
var tempDir = fs.realpathSync(import_os.default.tmpdir());
|
|
584
|
-
var graphqlTsClientPath = process.env.GQL_CLIENT_DIST_PATH || "@avantstay/graphql-ts-client
|
|
594
|
+
var graphqlTsClientPath = process.env.GQL_CLIENT_DIST_PATH || "@avantstay/graphql-ts-client";
|
|
585
595
|
function gqlScalarToTypescript(gqlType) {
|
|
586
596
|
if (/(int|long|double|decimal|float)/i.test(gqlType)) return "number";
|
|
587
597
|
if (/boolean/i.test(gqlType)) return "boolean";
|
package/dist/index.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import * as prettier from "prettier";
|
|
|
24
24
|
// package.json
|
|
25
25
|
var package_default = {
|
|
26
26
|
name: "@avantstay/graphql-ts-client",
|
|
27
|
-
version: "12.
|
|
27
|
+
version: "12.3.0",
|
|
28
28
|
description: "GraphQL Typescript Client Generator",
|
|
29
29
|
homepage: "https://github.com/avantstay/graphql-ts-client",
|
|
30
30
|
bugs: {
|
|
@@ -45,6 +45,16 @@ var package_default = {
|
|
|
45
45
|
require: "./dist/index.js",
|
|
46
46
|
types: "./dist/index.d.ts"
|
|
47
47
|
},
|
|
48
|
+
"./endpoint": {
|
|
49
|
+
import: "./dist/endpoint.mjs",
|
|
50
|
+
require: "./dist/endpoint.js",
|
|
51
|
+
types: "./dist/endpoint.d.ts"
|
|
52
|
+
},
|
|
53
|
+
"./dist": {
|
|
54
|
+
import: "./dist/index.mjs",
|
|
55
|
+
require: "./dist/index.js",
|
|
56
|
+
types: "./dist/index.d.ts"
|
|
57
|
+
},
|
|
48
58
|
"./dist/endpoint": {
|
|
49
59
|
import: "./dist/endpoint.mjs",
|
|
50
60
|
require: "./dist/endpoint.js",
|
|
@@ -119,7 +129,7 @@ var package_default = {
|
|
|
119
129
|
|
|
120
130
|
// src/generateTypescriptClient.ts
|
|
121
131
|
var tempDir = fs.realpathSync(os.tmpdir());
|
|
122
|
-
var graphqlTsClientPath = process.env.GQL_CLIENT_DIST_PATH || "@avantstay/graphql-ts-client
|
|
132
|
+
var graphqlTsClientPath = process.env.GQL_CLIENT_DIST_PATH || "@avantstay/graphql-ts-client";
|
|
123
133
|
function gqlScalarToTypescript(gqlType) {
|
|
124
134
|
if (/(int|long|double|decimal|float)/i.test(gqlType))
|
|
125
135
|
return "number";
|
|
@@ -9,12 +9,6 @@ type ResponseData = {
|
|
|
9
9
|
message: string;
|
|
10
10
|
}[];
|
|
11
11
|
};
|
|
12
|
-
type RequestListenerInfo = {
|
|
13
|
-
queryName: string;
|
|
14
|
-
query: string;
|
|
15
|
-
variables: any;
|
|
16
|
-
};
|
|
17
|
-
type IRequestListener = (info: RequestListenerInfo) => void | Promise<void>;
|
|
18
12
|
type ResponseListenerInfo = {
|
|
19
13
|
queryName: string;
|
|
20
14
|
query: string;
|
|
@@ -23,8 +17,7 @@ type ResponseListenerInfo = {
|
|
|
23
17
|
};
|
|
24
18
|
type IResponseListener = (info: ResponseListenerInfo) => void | Promise<void>;
|
|
25
19
|
type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[] ? ElementType : never;
|
|
26
|
-
type
|
|
27
|
-
type Projection<Selection, Base, E = never> = Base extends Array<any> ? ArrayElement<Base> extends Primitive | E ? ArrayElement<Base>[] : Projection<Defined<Selection>, ArrayElement<Base>, E>[] : Base extends Primitive | E ? Selection extends undefined ? Base | undefined : Base : {
|
|
20
|
+
type Projection<Selection, Base, E = never> = Base extends Array<any> ? ArrayElement<Base> extends Date | string | number | boolean | null | undefined | E ? ArrayElement<Base>[] : Projection<Defined<Selection>, ArrayElement<Base>, E>[] : Base extends Date | string | number | boolean | null | E ? Selection extends undefined ? Base | undefined : Base : {
|
|
28
21
|
[k in keyof Selection & keyof Base]: Selection[k] extends boolean ? Base[k] : Base[k] extends Array<infer A> ? Projection<Defined<Selection[k]>, A, E>[] : Projection<Defined<Selection[k]>, Base[k], E>;
|
|
29
22
|
};
|
|
30
23
|
type Unpacked<T> = T extends (infer U)[] ? U : T extends (...args: any[]) => infer U ? U : T extends Promise<infer U> ? U : T;
|
|
@@ -66,11 +59,6 @@ type LogInfo = {
|
|
|
66
59
|
error?: Error;
|
|
67
60
|
duration: number;
|
|
68
61
|
};
|
|
69
|
-
type TypescriptClientOutput = {
|
|
70
|
-
js: string;
|
|
71
|
-
mjs: string;
|
|
72
|
-
typings: string;
|
|
73
|
-
};
|
|
74
62
|
declare class GraphQLClientError extends Error {
|
|
75
63
|
responseData: ResponseData;
|
|
76
64
|
constructor(responseData: ResponseData);
|
|
@@ -78,4 +66,4 @@ declare class GraphQLClientError extends Error {
|
|
|
78
66
|
get response(): ResponseData;
|
|
79
67
|
}
|
|
80
68
|
|
|
81
|
-
export { ClientConfig as C, Defined as D, Endpoint as E, GraphQLClientError as G,
|
|
69
|
+
export { ClientConfig as C, Defined as D, Endpoint as E, GraphQLClientError as G, IResponseListener as I, JsonOutput as J, LogInfo as L, Maybe as M, Projection as P, ResponseData as R, Unpacked as U, ResponseListenerInfo as a, Replacement as b, DeepReplace as c, RawEndpoint as d };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avantstay/graphql-ts-client",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.3.0",
|
|
4
4
|
"description": "GraphQL Typescript Client Generator",
|
|
5
5
|
"homepage": "https://github.com/avantstay/graphql-ts-client",
|
|
6
6
|
"bugs": {
|
|
@@ -21,6 +21,16 @@
|
|
|
21
21
|
"require": "./dist/index.js",
|
|
22
22
|
"types": "./dist/index.d.ts"
|
|
23
23
|
},
|
|
24
|
+
"./endpoint": {
|
|
25
|
+
"import": "./dist/endpoint.mjs",
|
|
26
|
+
"require": "./dist/endpoint.js",
|
|
27
|
+
"types": "./dist/endpoint.d.ts"
|
|
28
|
+
},
|
|
29
|
+
"./dist": {
|
|
30
|
+
"import": "./dist/index.mjs",
|
|
31
|
+
"require": "./dist/index.js",
|
|
32
|
+
"types": "./dist/index.d.ts"
|
|
33
|
+
},
|
|
24
34
|
"./dist/endpoint": {
|
|
25
35
|
"import": "./dist/endpoint.mjs",
|
|
26
36
|
"require": "./dist/endpoint.js",
|
package/src/__testClient.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
// noinspection TypeScriptUnresolvedVariable, ES6UnusedImports, JSUnusedLocalSymbols, TypeScriptCheckImport
|
|
2
2
|
import { DeepRequired } from "ts-essentials"
|
|
3
|
-
import {
|
|
4
|
-
Maybe,
|
|
5
|
-
IRequestListener,
|
|
6
|
-
IResponseListener,
|
|
7
|
-
Endpoint,
|
|
8
|
-
} from "@avantstay/graphql-ts-client/dist"
|
|
3
|
+
import { Maybe, IResponseListener, Endpoint } from "."
|
|
9
4
|
|
|
10
5
|
// Scalars
|
|
11
6
|
export type IDate = string | Date
|
|
@@ -97,10 +92,7 @@ export interface BookSearchParamsSomeRequiredSelection {
|
|
|
97
92
|
}
|
|
98
93
|
|
|
99
94
|
export declare const myApiClient: {
|
|
100
|
-
|
|
101
|
-
removeRequestListener: (listener: IRequestListener) => void
|
|
102
|
-
addResponseListener: (listener: IResponseListener) => () => void
|
|
103
|
-
removeResponseListener: (listener: IResponseListener) => void
|
|
95
|
+
addResponseListener: (listener: IResponseListener) => void
|
|
104
96
|
setHeader: (key: string, value: string) => void
|
|
105
97
|
setHeaders: (newHeaders: { [k: string]: string }) => void
|
|
106
98
|
setUrl: (url: string) => void
|
package/src/__testClient.js
CHANGED
|
@@ -26,7 +26,7 @@ __export(exports, {
|
|
|
26
26
|
default: () => stdin_default,
|
|
27
27
|
myApiClient: () => myApiClient
|
|
28
28
|
});
|
|
29
|
-
var import_endpoint = __toModule(require("
|
|
29
|
+
var import_endpoint = __toModule(require("./endpoint"));
|
|
30
30
|
var import_standalone = __toModule(require("prettier/standalone"));
|
|
31
31
|
var import_parser_graphql = __toModule(require("prettier/parser-graphql"));
|
|
32
32
|
const formatGraphQL = (query) => (0, import_standalone.format)(query, { parser: "graphql", plugins: [import_parser_graphql.default] });
|
|
@@ -69,12 +69,10 @@ let retryConfig = {
|
|
|
69
69
|
before: void 0,
|
|
70
70
|
waitBeforeRetry: 0
|
|
71
71
|
};
|
|
72
|
-
let requestListeners = [];
|
|
73
72
|
let responseListeners = [];
|
|
74
73
|
let errorsParser = void 0;
|
|
75
74
|
let apiEndpoint = (0, import_endpoint.getApiEndpointCreator)({
|
|
76
75
|
getClient: () => ({ url, headers, retryConfig }),
|
|
77
|
-
requestListeners,
|
|
78
76
|
responseListeners,
|
|
79
77
|
maxAge: 3e4,
|
|
80
78
|
verbose,
|
|
@@ -83,32 +81,7 @@ let apiEndpoint = (0, import_endpoint.getApiEndpointCreator)({
|
|
|
83
81
|
errorsParser
|
|
84
82
|
});
|
|
85
83
|
const myApiClient = {
|
|
86
|
-
|
|
87
|
-
requestListeners.push(listener);
|
|
88
|
-
return () => {
|
|
89
|
-
const index = requestListeners.indexOf(listener);
|
|
90
|
-
if (index > -1)
|
|
91
|
-
requestListeners.splice(index, 1);
|
|
92
|
-
};
|
|
93
|
-
},
|
|
94
|
-
removeRequestListener: (listener) => {
|
|
95
|
-
const index = requestListeners.indexOf(listener);
|
|
96
|
-
if (index > -1)
|
|
97
|
-
requestListeners.splice(index, 1);
|
|
98
|
-
},
|
|
99
|
-
addResponseListener: (listener) => {
|
|
100
|
-
responseListeners.push(listener);
|
|
101
|
-
return () => {
|
|
102
|
-
const index = responseListeners.indexOf(listener);
|
|
103
|
-
if (index > -1)
|
|
104
|
-
responseListeners.splice(index, 1);
|
|
105
|
-
};
|
|
106
|
-
},
|
|
107
|
-
removeResponseListener: (listener) => {
|
|
108
|
-
const index = responseListeners.indexOf(listener);
|
|
109
|
-
if (index > -1)
|
|
110
|
-
responseListeners.splice(index, 1);
|
|
111
|
-
},
|
|
84
|
+
addResponseListener: (listener) => responseListeners.push(listener),
|
|
112
85
|
setHeader: (key, value) => {
|
|
113
86
|
headers[key] = value;
|
|
114
87
|
},
|
|
@@ -28,7 +28,7 @@ import { TypescriptClientOutput } from './types'
|
|
|
28
28
|
|
|
29
29
|
const tempDir = fs.realpathSync(os.tmpdir())
|
|
30
30
|
|
|
31
|
-
const graphqlTsClientPath = process.env.GQL_CLIENT_DIST_PATH || '@avantstay/graphql-ts-client
|
|
31
|
+
const graphqlTsClientPath = process.env.GQL_CLIENT_DIST_PATH || '@avantstay/graphql-ts-client'
|
|
32
32
|
|
|
33
33
|
function gqlScalarToTypescript(gqlType: string) {
|
|
34
34
|
if (/(int|long|double|decimal|float)/i.test(gqlType)) return 'number'
|
package/dist/types-c109c17f.d.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
type Maybe<T> = null | undefined | T;
|
|
2
|
-
type Defined<T> = Exclude<T, undefined>;
|
|
3
|
-
type ResponseData = {
|
|
4
|
-
data: any;
|
|
5
|
-
warnings: any;
|
|
6
|
-
headers: any;
|
|
7
|
-
status?: number;
|
|
8
|
-
errors: {
|
|
9
|
-
message: string;
|
|
10
|
-
}[];
|
|
11
|
-
};
|
|
12
|
-
type RequestListenerInfo = {
|
|
13
|
-
url: string;
|
|
14
|
-
queryName: string;
|
|
15
|
-
query: string;
|
|
16
|
-
variables: any;
|
|
17
|
-
headers: {
|
|
18
|
-
[key: string]: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
type IRequestListener = (info: RequestListenerInfo) => void | Promise<void>;
|
|
22
|
-
type ResponseListenerInfo = {
|
|
23
|
-
queryName: string;
|
|
24
|
-
query: string;
|
|
25
|
-
variables: any;
|
|
26
|
-
response: ResponseData;
|
|
27
|
-
};
|
|
28
|
-
type IResponseListener = (info: ResponseListenerInfo) => void | Promise<void>;
|
|
29
|
-
type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[] ? ElementType : never;
|
|
30
|
-
type Primitive = Date | string | number | boolean | null | undefined;
|
|
31
|
-
type Projection<Selection, Base, E = never> = Base extends Array<any> ? ArrayElement<Base> extends Primitive | E ? ArrayElement<Base>[] : Projection<Defined<Selection>, ArrayElement<Base>, E>[] : Base extends Primitive | E ? Selection extends undefined ? Base | undefined : Base : {
|
|
32
|
-
[k in keyof Selection & keyof Base]: Selection[k] extends boolean ? Base[k] : Base[k] extends Array<infer A> ? Projection<Defined<Selection[k]>, A, E>[] : Projection<Defined<Selection[k]>, Base[k], E>;
|
|
33
|
-
};
|
|
34
|
-
type Unpacked<T> = T extends (infer U)[] ? U : T extends (...args: any[]) => infer U ? U : T extends Promise<infer U> ? U : T;
|
|
35
|
-
type Replacement<M extends [any, any], T> = M extends any ? ([T] extends [M[0]] ? M[1] : never) : never;
|
|
36
|
-
type DeepReplace<T, Ignore, M extends [any, any]> = {
|
|
37
|
-
[P in keyof T]: T[P] extends M[0] ? T[P] extends Ignore ? T[P] extends object ? DeepReplace<T[P], Ignore, M> : T[P] : Replacement<M, T[P]> : T[P] extends object ? DeepReplace<T[P], Ignore, M> : T[P];
|
|
38
|
-
};
|
|
39
|
-
type RawEndpoint<I, O, E> = <S extends I>(jsonQuery?: S) => Promise<{
|
|
40
|
-
data: Projection<S, O, E>;
|
|
41
|
-
errors: any[];
|
|
42
|
-
warnings: any[];
|
|
43
|
-
headers: any;
|
|
44
|
-
status: any;
|
|
45
|
-
}>;
|
|
46
|
-
type JsonOutput<O, ToBeIgnored> = DeepReplace<O, ToBeIgnored, [string | Date, string]>;
|
|
47
|
-
type Endpoint<I, O, E> = (<S extends I>(jsonQuery?: S) => Promise<Projection<S, JsonOutput<O, E>, E>>) & {
|
|
48
|
-
memo: <S extends I>(jsonQuery?: S) => Promise<Projection<S, JsonOutput<O, E>, E>>;
|
|
49
|
-
memoRaw: RawEndpoint<I, JsonOutput<O, E>, E>;
|
|
50
|
-
raw: RawEndpoint<I, JsonOutput<O, E>, E>;
|
|
51
|
-
};
|
|
52
|
-
type ClientConfig = {
|
|
53
|
-
url: string;
|
|
54
|
-
headers: {
|
|
55
|
-
[key: string]: string;
|
|
56
|
-
};
|
|
57
|
-
retryConfig: {
|
|
58
|
-
max: number;
|
|
59
|
-
waitBeforeRetry?: number;
|
|
60
|
-
before: IResponseListener;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
type LogInfo = {
|
|
64
|
-
query: string;
|
|
65
|
-
variables: any;
|
|
66
|
-
formatGraphQL: any;
|
|
67
|
-
kind: string;
|
|
68
|
-
queryName: string;
|
|
69
|
-
response?: any;
|
|
70
|
-
error?: Error;
|
|
71
|
-
duration: number;
|
|
72
|
-
};
|
|
73
|
-
type TypescriptClientOutput = {
|
|
74
|
-
js: string;
|
|
75
|
-
mjs: string;
|
|
76
|
-
typings: string;
|
|
77
|
-
};
|
|
78
|
-
declare class GraphQLClientError extends Error {
|
|
79
|
-
responseData: ResponseData;
|
|
80
|
-
constructor(responseData: ResponseData);
|
|
81
|
-
get message(): string;
|
|
82
|
-
get response(): ResponseData;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export { ClientConfig as C, Defined as D, Endpoint as E, GraphQLClientError as G, IRequestListener as I, JsonOutput as J, LogInfo as L, Maybe as M, Projection as P, ResponseData as R, TypescriptClientOutput as T, Unpacked as U, RequestListenerInfo as a, ResponseListenerInfo as b, IResponseListener as c, Replacement as d, DeepReplace as e, RawEndpoint as f };
|