@avantstay/graphql-ts-client 11.0.0 → 12.0.1

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/index.mjs ADDED
@@ -0,0 +1,528 @@
1
+ import {
2
+ GraphQLClientError
3
+ } from "./chunk-2VJ7JZPA.mjs";
4
+
5
+ // src/generateTypescriptClient.ts
6
+ import axios from "axios";
7
+ import axiosRetry from "axios-retry";
8
+ import Case from "case";
9
+ import * as esbuild from "esbuild";
10
+ import * as fs from "fs";
11
+ import {
12
+ buildSchema,
13
+ getIntrospectionQuery,
14
+ graphqlSync
15
+ } from "graphql";
16
+ import { kebabCase, orderBy, set } from "lodash";
17
+ import md5 from "md5";
18
+ import os from "os";
19
+ import path from "path";
20
+ import * as prettier from "prettier";
21
+
22
+ // package.json
23
+ var package_default = {
24
+ name: "@avantstay/graphql-ts-client",
25
+ version: "12.0.1",
26
+ description: "GraphQL Typescript Client Generator",
27
+ homepage: "https://github.com/avantstay/graphql-ts-client",
28
+ bugs: {
29
+ url: "https://github.com/avantstay/graphql-ts-client/issues"
30
+ },
31
+ repository: {
32
+ type: "git",
33
+ url: "git+https://github.com/avantstay/graphql-ts-client.git"
34
+ },
35
+ license: "MIT",
36
+ author: "Wellington Guimaraes",
37
+ contributors: [
38
+ "Felipe Pinheiro <felipe.pinheiro.90@hotmail.com>"
39
+ ],
40
+ exports: {
41
+ ".": {
42
+ import: "./dist/index.mjs",
43
+ require: "./dist/index.js",
44
+ types: "./dist/index.d.ts"
45
+ },
46
+ "./dist/endpoint": {
47
+ import: "./dist/endpoint.mjs",
48
+ require: "./dist/endpoint.js",
49
+ types: "./dist/endpoint.d.ts"
50
+ }
51
+ },
52
+ main: "dist/index.js",
53
+ module: "dist/index.mjs",
54
+ typings: "dist/index.d.ts",
55
+ files: [
56
+ "dist",
57
+ "src"
58
+ ],
59
+ scripts: {
60
+ build: "yarn tsup src/index.ts src/endpoint.ts --dts --format cjs,esm",
61
+ prepublishOnly: "yarn build",
62
+ test: "cross-env GQL_CLIENT_DIST_PATH='.' jest --watch"
63
+ },
64
+ dependencies: {
65
+ "@types/md5": "^2.3.2",
66
+ axios: "^0.24.0",
67
+ "axios-retry": "^3.2.4",
68
+ case: "^1.6.3",
69
+ esbuild: "^0.13.14",
70
+ graphql: "^16.13.2",
71
+ lodash: "^4.17.21",
72
+ md5: "^2.3.0",
73
+ moize: "^6.1.0",
74
+ prettier: "^2.5.1",
75
+ "temp-dir": "^3.0.0",
76
+ "ts-essentials": "^8.1.0"
77
+ },
78
+ devDependencies: {
79
+ "@babel/preset-env": "^7.20.2",
80
+ "@babel/preset-typescript": "^7.18.6",
81
+ "@jest/globals": "^29.3.1",
82
+ "@size-limit/preset-small-lib": "^5.0.4",
83
+ "@swc/core": "^1.3.22",
84
+ "@types/graphql": "^14.5.0",
85
+ "@types/jest": "^29.2.4",
86
+ "@types/lodash": "^4.14.177",
87
+ "@types/node": "^16.11.12",
88
+ "@types/prettier": "^2.4.2",
89
+ "apollo-server": "^3.11.1",
90
+ concurrently: "^7.6.0",
91
+ "cross-env": "^7.0.3",
92
+ jest: "^29.3.1",
93
+ "ts-jest": "^29.0.3",
94
+ "ts-node": "^10.9.1",
95
+ tslib: "^2.3.1",
96
+ tsup: "^6.5.0",
97
+ typescript: "^4.9.4"
98
+ },
99
+ peerDependencies: {},
100
+ engines: {
101
+ node: ">=12"
102
+ },
103
+ publishConfig: {
104
+ "@avantstay:registry": "https://registry.npmjs.org/"
105
+ },
106
+ "size-limit": [
107
+ {
108
+ path: "dist/graphql-ts-client.cjs.production.min.js",
109
+ limit: "10 KB"
110
+ },
111
+ {
112
+ path: "dist/graphql-ts-client.esm.js",
113
+ limit: "10 KB"
114
+ }
115
+ ]
116
+ };
117
+
118
+ // src/generateTypescriptClient.ts
119
+ var tempDir = fs.realpathSync(os.tmpdir());
120
+ var graphqlTsClientPath = process.env.GQL_CLIENT_DIST_PATH || "@avantstay/graphql-ts-client/dist";
121
+ function gqlScalarToTypescript(gqlType) {
122
+ if (/(int|long|double|decimal|float)/i.test(gqlType))
123
+ return "number";
124
+ if (/boolean/i.test(gqlType))
125
+ return "boolean";
126
+ if (/String/i.test(gqlType))
127
+ return "string";
128
+ return gqlType;
129
+ }
130
+ function gqlTypeToTypescript(gqlType, { required = false, isInput = false, selection = false } = {}) {
131
+ if (!gqlType)
132
+ return "";
133
+ const maybeWrapped = (it) => required || selection ? it : `Maybe<${it}>`;
134
+ if (typeof gqlType === "string") {
135
+ return maybeWrapped(gqlType);
136
+ }
137
+ if (gqlType.kind.endsWith("OBJECT")) {
138
+ return maybeWrapped(gqlType.name + (selection ? "Selection" : ""));
139
+ }
140
+ if (gqlType.kind === "NON_NULL") {
141
+ return `${gqlTypeToTypescript(gqlType.ofType, {
142
+ isInput,
143
+ required: true,
144
+ selection
145
+ })}`;
146
+ }
147
+ if (gqlType.kind === "LIST") {
148
+ return maybeWrapped(
149
+ `${gqlTypeToTypescript(gqlType.ofType, {
150
+ isInput,
151
+ required: true,
152
+ selection
153
+ })}${selection ? "" : "[]"}`
154
+ );
155
+ }
156
+ if (selection) {
157
+ return "";
158
+ }
159
+ if (gqlType.kind === "ENUM" && gqlType.name) {
160
+ return maybeWrapped(gqlType.name);
161
+ }
162
+ if (gqlType.kind === "SCALAR") {
163
+ return maybeWrapped(gqlScalarToTypescript(gqlType.name));
164
+ }
165
+ return "";
166
+ }
167
+ function gqlFieldToTypescript(field, { isInput, selection, defaultValue }) {
168
+ let fieldTypeDefinition = gqlTypeToTypescript(field.type, {
169
+ isInput,
170
+ selection
171
+ });
172
+ fieldTypeDefinition = `${fieldTypeDefinition}`;
173
+ if (selection && field.args && field.args.length) {
174
+ let fieldsOnArgs = field.args.map(
175
+ (arg) => gqlFieldToTypescript(arg, {
176
+ defaultValue: arg.defaultValue,
177
+ isInput: true,
178
+ selection: false
179
+ })
180
+ );
181
+ fieldTypeDefinition = `{ __headers?: {[key: string]: string}; __retry?: boolean; __alias?: string; __url?: string; __args${fieldsOnArgs.every((arg) => arg.isOptional) ? "?" : ""}: { ${fieldsOnArgs.map((arg) => arg.code).join(", ")} }}${fieldTypeDefinition ? ` & ${fieldTypeDefinition}` : ""}`;
182
+ }
183
+ const isOptional = defaultValue || selection || fieldTypeDefinition.startsWith("Maybe");
184
+ const rawType = fieldTypeDefinition || selection && "boolean";
185
+ const wrappedType = isOptional ? rawType.replace(/Maybe<(.+?)>/, "$1") : rawType;
186
+ return {
187
+ isOptional,
188
+ code: `${field.name}${isOptional ? "?:" : ":"} ${wrappedType}`
189
+ };
190
+ }
191
+ function getArgsType(endpoint) {
192
+ const fieldsOnArgs = endpoint.args.map(
193
+ (arg) => gqlFieldToTypescript(arg, {
194
+ defaultValue: arg.defaultValue,
195
+ isInput: true,
196
+ selection: false
197
+ })
198
+ );
199
+ const argsType = `{ ${fieldsOnArgs.map((arg) => arg.code).join(", ")} }`;
200
+ const argsFullyOptional = fieldsOnArgs.every((arg) => arg.isOptional);
201
+ return { alias: Case.pascal(`${endpoint.name}Args`), type: argsType, optional: argsFullyOptional };
202
+ }
203
+ function gqlEndpointToCode(kind, endpoint, codeOutputType) {
204
+ const selectionType = gqlTypeToTypescript(endpoint.type, {
205
+ isInput: false,
206
+ selection: true
207
+ });
208
+ const argsType = endpoint.args && endpoint.args.length ? getArgsType(endpoint) : null;
209
+ const inputType = `{
210
+ __headers?: {[key: string]: string};
211
+ __retry?: boolean;
212
+ __alias?: string;
213
+ __url?: string;
214
+ ${argsType ? `__args${argsType.optional ? "?" : ""}: ${argsType.alias}` : ""}
215
+ }${selectionType ? ` & ${selectionType}` : ""}`;
216
+ const outputType = gqlTypeToTypescript(endpoint.type, { required: true });
217
+ return codeOutputType === "ts" ? `${endpoint.name}: Endpoint<${inputType}, ${outputType}, AllEnums>` : `${endpoint.name}: apiEndpoint('${kind}', '${endpoint.name}')`;
218
+ }
219
+ function gqlSchemaToCode(gqlType, { selection = false, outputType }) {
220
+ const rawKind = gqlType.kind || gqlType.type;
221
+ if (rawKind === "SCALAR") {
222
+ return outputType === "ts" ? `export declare type ${gqlType.name} = ${/date/i.test(gqlType.name) ? "IDate" : "string"}` : "";
223
+ }
224
+ if (rawKind === "ENUM")
225
+ return outputType === "ts" ? `
226
+ export declare enum ${gqlType.name} {
227
+ ${orderBy(gqlType.enumValues, "name").map((_) => `${Case.camel(_.name)} = '${_.name}'`).join(",\n ")}
228
+ }` : `export const ${gqlType.name} = {${orderBy(gqlType.enumValues, "name").map((_) => `${Case.camel(_.name)}: '${_.name}'`).join(",\n ")}}`;
229
+ const fields = gqlType.fields && gqlType.fields || gqlType.inputFields && gqlType.inputFields || [];
230
+ return outputType === "ts" ? `
231
+ export interface ${gqlType.name}${selection ? "Selection" : ""} {
232
+ ${fields.map(
233
+ (_) => gqlFieldToTypescript(_, {
234
+ isInput: gqlType.kind === "INPUT_OBJECT",
235
+ selection
236
+ }).code
237
+ ).join(",\n ")}
238
+ }` : "";
239
+ }
240
+ function getGraphQLInputType(type) {
241
+ switch (type.kind) {
242
+ case "NON_NULL":
243
+ return `${getGraphQLInputType(type.ofType)}!`;
244
+ case "SCALAR":
245
+ case "INPUT_OBJECT":
246
+ case "ENUM":
247
+ return type.name;
248
+ case "LIST":
249
+ return `[${getGraphQLInputType(type.ofType)}]`;
250
+ default:
251
+ return "";
252
+ }
253
+ }
254
+ function getGraphQLOutputType(type) {
255
+ switch (type.kind) {
256
+ case "LIST":
257
+ return `${getGraphQLOutputType(type.ofType)}[]`;
258
+ case "NON_NULL":
259
+ return getGraphQLOutputType(type.ofType);
260
+ case "OBJECT":
261
+ return type.name;
262
+ default:
263
+ return "";
264
+ }
265
+ }
266
+ function getTypesTreeCode(types) {
267
+ const typesTree = {};
268
+ types.forEach(
269
+ (type) => type.fields.filter((_) => _.args && _.args.length).forEach(
270
+ (_) => _.args.forEach((a) => {
271
+ let inputType = getGraphQLInputType(a.type);
272
+ if (inputType) {
273
+ set(typesTree, `${type.name}.${_.name}.__args.${a.name}`, inputType);
274
+ }
275
+ })
276
+ )
277
+ );
278
+ types.forEach(
279
+ (t) => t.fields.forEach((f) => {
280
+ let outputType = getGraphQLOutputType(f.type);
281
+ if (outputType) {
282
+ set(typesTree, `${t.name}.${f.name}.__shape`, outputType);
283
+ }
284
+ })
285
+ );
286
+ return `
287
+ const typesTree = {
288
+ ${Object.entries(typesTree).map(([key, value]) => {
289
+ let entryCode = Object.entries(value).map(([k, v]) => {
290
+ const cleanShapeType = v.__shape && v.__shape.replace(/[\[\]!?]/g, "");
291
+ const fieldsCode = v.__shape && typesTree.hasOwnProperty(cleanShapeType) ? `__fields: typesTree.${cleanShapeType},` : "";
292
+ const argsCode = v.__args ? `__args: {
293
+ ${Object.entries(v.__args).map(([k2, v2]) => `${k2}: '${v2}'`).join(",\n")}
294
+ }` : "";
295
+ return fieldsCode || argsCode ? `get ${k}() {
296
+ return {
297
+ ${fieldsCode}
298
+ ${argsCode}
299
+ }
300
+ }` : `${k}: {}`;
301
+ }).filter(Boolean).join(",\n").trim();
302
+ return entryCode && `
303
+ ${key}: {
304
+ ${entryCode}
305
+ }`;
306
+ }).filter(Boolean).join(",\n")}
307
+ }
308
+ `;
309
+ }
310
+ function generateClientCode(types, options) {
311
+ const typesHash = md5(`${JSON.stringify(options)}__${JSON.stringify(types)}`);
312
+ const clientCacheFileName = `gql-ts-client__client__${typesHash}__${package_default.version}.json`;
313
+ const clientCacheFilePath = path.resolve(tempDir, clientCacheFileName);
314
+ if (!options.skipCache && fs.existsSync(clientCacheFilePath)) {
315
+ const output2 = JSON.parse(fs.readFileSync(clientCacheFilePath, { encoding: "utf8" }));
316
+ if (output2.js && output2.mjs && output2.typings) {
317
+ return output2;
318
+ }
319
+ }
320
+ const queries = types.find((it) => it.name === "Query")?.fields || [];
321
+ const mutations = types.find((it) => it.name === "Mutation")?.fields || [];
322
+ const enums = types.filter((it) => it.kind === "ENUM" && !it.name.startsWith("__"));
323
+ const scalars = types.filter(
324
+ (it) => it.kind === "SCALAR" && !/decimal|int|float|string|long|boolean/i.test(it.name)
325
+ );
326
+ const objectTypes = types.filter((it) => ["OBJECT", "INPUT_OBJECT"].includes(it.kind) && !it.name.startsWith("__"));
327
+ const forInputExtraction = types.filter(
328
+ (it) => !it.name.startsWith("__") && ["OBJECT"].includes(it.kind)
329
+ );
330
+ const clientName = options.clientName || "client";
331
+ const jsCode = `
332
+ // noinspection TypeScriptUnresolvedVariable, ES6UnusedImports, JSUnusedLocalSymbols
333
+ import { getApiEndpointCreator } from '${graphqlTsClientPath}/endpoint'
334
+
335
+ ${options.formatGraphQL || options.verbose ? `
336
+ import { format as formatCode } from "prettier/standalone"
337
+ import parserGraphql from "prettier/parser-graphql"
338
+
339
+ const formatGraphQL = (query) => formatCode(query, {parser: 'graphql', plugins: [parserGraphql]})` : `
340
+ const formatGraphQL = (query) => query`}
341
+
342
+ // Enums
343
+ ${enums.map((it) => gqlSchemaToCode(it, { selection: false, outputType: "js" })).join("\n")}
344
+
345
+ // Schema Resolution Tree
346
+ ${getTypesTreeCode(forInputExtraction)}
347
+
348
+ let verbose = ${Boolean(options.verbose)}
349
+ let headers = {}
350
+ let url = '${options.endpoint}'
351
+ let retryConfig = {
352
+ max: 0,
353
+ before: undefined,
354
+ waitBeforeRetry: 0
355
+ }
356
+ let responseListeners = []
357
+ let errorsParser = ${options.errorsParser}
358
+ // noinspection JSUnusedLocalSymbols
359
+ let apiEndpoint = getApiEndpointCreator({
360
+ getClient: () => ({ url, headers, retryConfig }),
361
+ responseListeners,
362
+ maxAge: 30000,
363
+ verbose,
364
+ typesTree,
365
+ formatGraphQL,
366
+ errorsParser
367
+ })
368
+
369
+ export const ${clientName} = {
370
+ addResponseListener: (listener) => responseListeners.push(
371
+ listener),
372
+ setHeader: (key, value) => {
373
+ headers[key] = value
374
+ },
375
+ setHeaders: (newHeaders) => {
376
+ headers = newHeaders
377
+ },
378
+ setRetryConfig: (options) => {
379
+ if (!Number.isInteger(options.max) || options.max < 0) {
380
+ throw new Error('retryOptions.max should be a non-negative integer')
381
+ }
382
+
383
+ retryConfig = {
384
+ max: options.max,
385
+ waitBeforeRetry: options.waitBeforeRetry,
386
+ before: options.before
387
+ }
388
+ },
389
+ setUrl: (_url) => url = _url,
390
+ queries: {
391
+ ${queries.map((query) => gqlEndpointToCode("query", query, "js")).join(",\n")}
392
+ },
393
+ mutations: {
394
+ ${mutations.map((mutation) => gqlEndpointToCode("mutation", mutation, "js")).join(",\n")}
395
+ }
396
+ }
397
+
398
+ export default ${clientName}`;
399
+ const typingsCode = `
400
+ // noinspection TypeScriptUnresolvedVariable, ES6UnusedImports, JSUnusedLocalSymbols, TypeScriptCheckImport
401
+ import { DeepRequired } from 'ts-essentials'
402
+ import { Maybe, IResponseListener, Endpoint } from '${graphqlTsClientPath}'
403
+
404
+ // Scalars
405
+ export type IDate = string | Date
406
+ ${scalars.map((it) => gqlSchemaToCode(it, { selection: false, outputType: "ts" })).join("\n")}
407
+
408
+ // Enums
409
+ ${enums.map((it) => gqlSchemaToCode(it, { selection: false, outputType: "ts" })).join("\n")}
410
+
411
+ type AllEnums = ${enums.length ? enums.map((it) => it.name).join(" | ") : "never"}
412
+
413
+ // Args
414
+ ${[...queries, ...mutations].map((query) => {
415
+ const argsType = getArgsType(query);
416
+ return `export interface ${argsType.alias} ${argsType.type}`;
417
+ }).join("\n")}
418
+
419
+ // Input/Output Types
420
+ ${objectTypes.map(
421
+ (it) => `
422
+ /**
423
+ * @deprecated Avoid directly using this interface. Instead, create a type alias based on the query/mutation return type.
424
+ */
425
+ ${gqlSchemaToCode(it, { selection: false, outputType: "ts" })}`
426
+ ).join("\n")}
427
+
428
+ // Selection Types
429
+ ${objectTypes.filter((it) => it.name !== "Query").map((it) => gqlSchemaToCode(it, { selection: true, outputType: "ts" })).join("\n")}
430
+
431
+ export declare const ${clientName}: {
432
+ addResponseListener: (listener: IResponseListener) => void
433
+ setHeader: (key: string, value: string) => void
434
+ setHeaders: (newHeaders: { [k: string]: string }) => void,
435
+ setUrl: (url: string) => void,
436
+ setRetryConfig: (options: { max: number, waitBeforeRetry?: number, before?: IResponseListener }) => void
437
+ queries: {
438
+ ${queries.map((q) => gqlEndpointToCode("query", q, "ts")).join(",\n")}
439
+ },
440
+ mutations: {
441
+ ${mutations.map((q) => gqlEndpointToCode("mutation", q, "ts")).join(",\n")}
442
+ }
443
+ }
444
+
445
+ export default ${clientName}`;
446
+ const output = {
447
+ js: esbuild.transformSync(jsCode, { format: "cjs", loader: "js" }).code,
448
+ mjs: esbuild.transformSync(jsCode, { format: "esm", loader: "js" }).code,
449
+ typings: prettier.format(typingsCode, { semi: false, parser: "typescript" })
450
+ };
451
+ fs.writeFileSync(clientCacheFilePath, JSON.stringify(output));
452
+ return output;
453
+ }
454
+ async function fetchIntrospection({ endpoint, headers }) {
455
+ const introspectionCacheFileName = `gql-ts-client__introspection__${kebabCase(endpoint)}.json`;
456
+ const introspectionCacheFilePath = path.resolve(tempDir, introspectionCacheFileName);
457
+ let loadedFromCache = false;
458
+ let types;
459
+ const { data } = await axios.post(
460
+ endpoint,
461
+ { query: getIntrospectionQuery() },
462
+ {
463
+ headers: {
464
+ "Content-Type": "application/json",
465
+ ...headers
466
+ },
467
+ timeout: 5e3
468
+ }
469
+ ).catch((e) => {
470
+ if (fs.existsSync(introspectionCacheFilePath)) {
471
+ const cachedSchema = JSON.parse(fs.readFileSync(introspectionCacheFilePath, { encoding: "utf8" }));
472
+ loadedFromCache = true;
473
+ console.warn(`Successfully restored (${endpoint}) from local cache.`);
474
+ return { data: cachedSchema };
475
+ } else {
476
+ console.error(e);
477
+ return Promise.reject(`The GraphQL introspection request failed (${endpoint})`);
478
+ }
479
+ });
480
+ types = data.data.__schema.types;
481
+ if (!loadedFromCache) {
482
+ console.log(`Successfully loaded GraphQL introspection from ${endpoint}`);
483
+ fs.writeFileSync(introspectionCacheFilePath, JSON.stringify(data), {
484
+ encoding: "utf8"
485
+ });
486
+ }
487
+ return types;
488
+ }
489
+ function generateClient(introspectionTypes, { output, ...restOptions }) {
490
+ const { js, mjs, typings } = generateClientCode(introspectionTypes, restOptions);
491
+ if (output && typeof output === "string") {
492
+ const outputDir = path.dirname(output);
493
+ if (!fs.existsSync(outputDir)) {
494
+ fs.mkdirSync(outputDir, { recursive: true });
495
+ }
496
+ fs.writeFileSync(output.replace(/(\.(ts|js))?$/, ".d.ts"), typings, { encoding: "utf8" });
497
+ fs.writeFileSync(output.replace(/(\.(ts|js))?$/, ".js"), js, { encoding: "utf8" });
498
+ fs.writeFileSync(output.replace(/(\.(ts|js))?$/, ".mjs"), mjs, { encoding: "utf8" });
499
+ }
500
+ return { js, mjs, typings };
501
+ }
502
+ async function generateTypescriptClient({
503
+ introspectionEndpoint,
504
+ ...options
505
+ }) {
506
+ console.log(`Generating TypeScript client (name: ${options.clientName ?? "n/a"})`);
507
+ axiosRetry(axios, { retries: 5, retryDelay: (retryCount) => 1e3 * 2 ** retryCount });
508
+ const introspectionTypes = await fetchIntrospection({
509
+ ...options,
510
+ endpoint: introspectionEndpoint || options.endpoint
511
+ });
512
+ return generateClient(introspectionTypes, options);
513
+ }
514
+ function generateTypescriptClientFromSDL(SDL, options) {
515
+ console.log(`Generating TypeScript client from SDL (name: ${options.clientName ?? "n/a"})`);
516
+ const graphqlSchemaObj = buildSchema(SDL);
517
+ const introspectionResult = graphqlSync({
518
+ schema: graphqlSchemaObj,
519
+ source: getIntrospectionQuery()
520
+ });
521
+ const introspectionTypes = introspectionResult.data?.__schema.types;
522
+ return generateClient(introspectionTypes, options);
523
+ }
524
+ export {
525
+ GraphQLClientError,
526
+ generateTypescriptClient,
527
+ generateTypescriptClientFromSDL
528
+ };
@@ -60,6 +60,11 @@ type LogInfo = {
60
60
  error?: Error;
61
61
  duration: number;
62
62
  };
63
+ type TypescriptClientOutput = {
64
+ js: string;
65
+ mjs: string;
66
+ typings: string;
67
+ };
63
68
  declare class GraphQLClientError extends Error {
64
69
  responseData: ResponseData;
65
70
  constructor(responseData: ResponseData);
@@ -67,4 +72,4 @@ declare class GraphQLClientError extends Error {
67
72
  get response(): ResponseData;
68
73
  }
69
74
 
70
- 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 };
75
+ 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, TypescriptClientOutput as T, Unpacked as U, ResponseListenerInfo as a, Replacement as b, DeepReplace as c, RawEndpoint as d };
package/package.json CHANGED
@@ -1,64 +1,51 @@
1
1
  {
2
2
  "name": "@avantstay/graphql-ts-client",
3
- "version": "11.0.0",
3
+ "version": "12.0.1",
4
4
  "description": "GraphQL Typescript Client Generator",
5
- "author": "Wellington Guimaraes",
6
- "license": "MIT",
7
- "main": "dist/index.js",
8
- "typings": "dist/index.d.ts",
9
- "scripts": {
10
- "build": "tsup src/index.ts src/endpoint.ts --dts",
11
- "test": "cross-env GQL_CLIENT_DIST_PATH='.' jest --watch",
12
- "prepublishOnly": "yarn build"
13
- },
14
- "files": [
15
- "dist",
16
- "src"
17
- ],
18
- "engines": {
19
- "node": ">=12"
20
- },
5
+ "homepage": "https://github.com/avantstay/graphql-ts-client",
21
6
  "bugs": {
22
7
  "url": "https://github.com/avantstay/graphql-ts-client/issues"
23
8
  },
24
- "homepage": "https://github.com/avantstay/graphql-ts-client#readme",
25
9
  "repository": {
26
10
  "type": "git",
27
11
  "url": "git+https://github.com/avantstay/graphql-ts-client.git"
28
12
  },
29
- "peerDependencies": {},
30
- "prettier": {
31
- "trailingComma": "es5",
32
- "tabWidth": 2,
33
- "proseWrap": "always",
34
- "bracketSpacing": true,
35
- "jsxBracketSameLine": false,
36
- "semi": false,
37
- "singleQuote": true,
38
- "arrowParens": "avoid",
39
- "endOfLine": "lf",
40
- "printWidth": 130,
41
- "htmlWhitespaceSensitivity": "ignore",
42
- "jsxSingleQuote": false
43
- },
44
- "module": "dist/graphql-ts-client.esm.js",
45
- "size-limit": [
46
- {
47
- "path": "dist/graphql-ts-client.cjs.production.min.js",
48
- "limit": "10 KB"
13
+ "license": "MIT",
14
+ "author": "Wellington Guimaraes",
15
+ "contributors": [
16
+ "Felipe Pinheiro <felipe.pinheiro.90@hotmail.com>"
17
+ ],
18
+ "exports": {
19
+ ".": {
20
+ "import": "./dist/index.mjs",
21
+ "require": "./dist/index.js",
22
+ "types": "./dist/index.d.ts"
49
23
  },
50
- {
51
- "path": "dist/graphql-ts-client.esm.js",
52
- "limit": "10 KB"
24
+ "./dist/endpoint": {
25
+ "import": "./dist/endpoint.mjs",
26
+ "require": "./dist/endpoint.js",
27
+ "types": "./dist/endpoint.d.ts"
53
28
  }
29
+ },
30
+ "main": "dist/index.js",
31
+ "module": "dist/index.mjs",
32
+ "typings": "dist/index.d.ts",
33
+ "files": [
34
+ "dist",
35
+ "src"
54
36
  ],
37
+ "scripts": {
38
+ "build": "yarn tsup src/index.ts src/endpoint.ts --dts --format cjs,esm",
39
+ "prepublishOnly": "yarn build",
40
+ "test": "cross-env GQL_CLIENT_DIST_PATH='.' jest --watch"
41
+ },
55
42
  "dependencies": {
56
43
  "@types/md5": "^2.3.2",
57
44
  "axios": "^0.24.0",
58
45
  "axios-retry": "^3.2.4",
59
46
  "case": "^1.6.3",
60
47
  "esbuild": "^0.13.14",
61
- "graphql": "^15.6.0",
48
+ "graphql": "^16.13.2",
62
49
  "lodash": "^4.17.21",
63
50
  "md5": "^2.3.0",
64
51
  "moize": "^6.1.0",
@@ -87,7 +74,21 @@
87
74
  "tsup": "^6.5.0",
88
75
  "typescript": "^4.9.4"
89
76
  },
77
+ "peerDependencies": {},
78
+ "engines": {
79
+ "node": ">=12"
80
+ },
90
81
  "publishConfig": {
91
82
  "@avantstay:registry": "https://registry.npmjs.org/"
92
- }
83
+ },
84
+ "size-limit": [
85
+ {
86
+ "path": "dist/graphql-ts-client.cjs.production.min.js",
87
+ "limit": "10 KB"
88
+ },
89
+ {
90
+ "path": "dist/graphql-ts-client.esm.js",
91
+ "limit": "10 KB"
92
+ }
93
+ ]
93
94
  }