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