@eddeee888/gcg-typescript-resolver-files 0.2.1 → 0.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.
Files changed (52) hide show
  1. package/README.md +2 -0
  2. package/package.json +1 -1
  3. package/src/addVirtualTypesFileToTsMorphProject/addVirtualTypesFileToTsMorphProject.d.ts +8 -0
  4. package/src/addVirtualTypesFileToTsMorphProject/addVirtualTypesFileToTsMorphProject.js +35 -0
  5. package/src/addVirtualTypesFileToTsMorphProject/addVirtualTypesFileToTsMorphProject.js.map +1 -0
  6. package/src/addVirtualTypesFileToTsMorphProject/index.d.ts +1 -0
  7. package/src/addVirtualTypesFileToTsMorphProject/index.js +5 -0
  8. package/src/addVirtualTypesFileToTsMorphProject/index.js.map +1 -0
  9. package/src/generateResolverFiles/ensureObjectTypeResolversAreGenerated.d.ts +6 -0
  10. package/src/generateResolverFiles/ensureObjectTypeResolversAreGenerated.js +80 -0
  11. package/src/generateResolverFiles/ensureObjectTypeResolversAreGenerated.js.map +1 -0
  12. package/src/generateResolverFiles/generateResolverFiles.js +3 -3
  13. package/src/generateResolverFiles/generateResolverFiles.js.map +1 -1
  14. package/src/generateResolverFiles/getVariableStatementWithExpectedIdentifier.d.ts +6 -0
  15. package/src/generateResolverFiles/getVariableStatementWithExpectedIdentifier.js +27 -0
  16. package/src/generateResolverFiles/getVariableStatementWithExpectedIdentifier.js.map +1 -0
  17. package/src/generateResolverFiles/handleGraphQLObjectType.js +5 -2
  18. package/src/generateResolverFiles/handleGraphQLObjectType.js.map +1 -1
  19. package/src/generateResolverFiles/postProcessFiles.d.ts +8 -0
  20. package/src/generateResolverFiles/postProcessFiles.js +72 -0
  21. package/src/generateResolverFiles/postProcessFiles.js.map +1 -0
  22. package/src/generateResolverFiles/types.d.ts +9 -0
  23. package/src/getGraphQLObjectTypeResolversToGenerate/getGraphQLObjectTypeResolversToGenerate.d.ts +11 -0
  24. package/src/getGraphQLObjectTypeResolversToGenerate/getGraphQLObjectTypeResolversToGenerate.js +70 -0
  25. package/src/getGraphQLObjectTypeResolversToGenerate/getGraphQLObjectTypeResolversToGenerate.js.map +1 -0
  26. package/src/getGraphQLObjectTypeResolversToGenerate/index.d.ts +1 -0
  27. package/src/getGraphQLObjectTypeResolversToGenerate/index.js +5 -0
  28. package/src/getGraphQLObjectTypeResolversToGenerate/index.js.map +1 -0
  29. package/src/getPluginsConfig/getPluginsConfig.d.ts +7 -1
  30. package/src/getPluginsConfig/getPluginsConfig.js +14 -6
  31. package/src/getPluginsConfig/getPluginsConfig.js.map +1 -1
  32. package/src/parseTypeMappers/collectTypeMappersFromSourceFile.d.ts +3 -2
  33. package/src/parseTypeMappers/collectTypeMappersFromSourceFile.js +38 -8
  34. package/src/parseTypeMappers/collectTypeMappersFromSourceFile.js.map +1 -1
  35. package/src/parseTypeMappers/parseTypeMappers.d.ts +6 -1
  36. package/src/parseTypeMappers/parseTypeMappers.js +9 -7
  37. package/src/parseTypeMappers/parseTypeMappers.js.map +1 -1
  38. package/src/preset.d.ts +2 -1
  39. package/src/preset.js +66 -28
  40. package/src/preset.js.map +1 -1
  41. package/src/utils/getNodePropertyMap.d.ts +9 -0
  42. package/src/utils/getNodePropertyMap.js +49 -0
  43. package/src/utils/getNodePropertyMap.js.map +1 -0
  44. package/src/utils/index.d.ts +1 -0
  45. package/src/utils/index.js +1 -0
  46. package/src/utils/index.js.map +1 -1
  47. package/src/validatePresetConfig/validatePresetConfig.d.ts +6 -1
  48. package/src/validatePresetConfig/validatePresetConfig.js +29 -10
  49. package/src/validatePresetConfig/validatePresetConfig.js.map +1 -1
  50. package/src/generateResolverFiles/fixExistingResolvers.d.ts +0 -2
  51. package/src/generateResolverFiles/fixExistingResolvers.js +0 -62
  52. package/src/generateResolverFiles/fixExistingResolvers.js.map +0 -1
@@ -2,18 +2,21 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.collectTypeMappersFromSourceFile = void 0;
4
4
  const path = require("path");
5
+ const ts_morph_1 = require("ts-morph");
5
6
  const utils_1 = require("../utils");
6
- const collectTypeMappersFromSourceFile = ({ typeMappersSourceFile, typeMappersSuffix, resolverTypesPath, }, result) => {
7
+ const collectTypeMappersFromSourceFile = ({ typeMappersSourceFile, typeMappersSuffix, resolverTypesPath, shouldCollectPropertyMap, }, result) => {
7
8
  // Look for interfaces with exported keywords
8
9
  typeMappersSourceFile.getInterfaces().forEach((interfaceDeclaration) => {
9
10
  if (!interfaceDeclaration.hasExportKeyword()) {
10
11
  return;
11
12
  }
12
13
  addTypeMapperDetailsIfValid({
13
- identifierName: interfaceDeclaration.getName(),
14
+ declarationNode: interfaceDeclaration,
15
+ identifierNode: interfaceDeclaration.getNameNode(),
14
16
  typeMappersSuffix,
15
17
  typeMappersFilePath: typeMappersSourceFile.getFilePath(),
16
18
  resolverTypesPath,
19
+ shouldCollectPropertyMap,
17
20
  }, result);
18
21
  });
19
22
  // Look for exported types with exported keywords
@@ -21,35 +24,41 @@ const collectTypeMappersFromSourceFile = ({ typeMappersSourceFile, typeMappersSu
21
24
  if (!typeAlias.hasExportKeyword()) {
22
25
  return;
23
26
  }
27
+ const identifierNode = typeAlias.getNameNode();
24
28
  addTypeMapperDetailsIfValid({
25
- identifierName: typeAlias.getName(),
29
+ declarationNode: typeAlias,
30
+ identifierNode,
26
31
  typeMappersSuffix,
27
32
  typeMappersFilePath: typeMappersSourceFile.getFilePath(),
28
33
  resolverTypesPath,
34
+ shouldCollectPropertyMap,
29
35
  }, result);
30
36
  });
31
37
  // Look for named exports e.g.
32
38
  // - export { something } from 'module';
33
39
  // - export type { something } from 'module';
34
- // - export { something, somethingelse }'
40
+ // - export { something, somethingelse as somethingelse2 }'
35
41
  typeMappersSourceFile.getExportDeclarations().forEach((exportDeclaration) => {
36
42
  exportDeclaration.getNamedExports().forEach((namedExport) => {
37
- let identifierName = namedExport.getFullText();
43
+ let identifierNode = namedExport.getNameNode();
38
44
  const aliasNode = namedExport.getAliasNode();
39
45
  if (aliasNode) {
40
- identifierName = aliasNode.getFullText();
46
+ identifierNode = aliasNode;
41
47
  }
42
48
  addTypeMapperDetailsIfValid({
43
- identifierName: identifierName.trim(),
49
+ declarationNode: null,
50
+ identifierNode,
44
51
  typeMappersSuffix,
45
52
  typeMappersFilePath: typeMappersSourceFile.getFilePath(),
46
53
  resolverTypesPath,
54
+ shouldCollectPropertyMap,
47
55
  }, result);
48
56
  });
49
57
  });
50
58
  };
51
59
  exports.collectTypeMappersFromSourceFile = collectTypeMappersFromSourceFile;
52
- const addTypeMapperDetailsIfValid = ({ identifierName, typeMappersSuffix, typeMappersFilePath, resolverTypesPath, }, result) => {
60
+ const addTypeMapperDetailsIfValid = ({ declarationNode, identifierNode, typeMappersSuffix, typeMappersFilePath, resolverTypesPath, shouldCollectPropertyMap, }, result) => {
61
+ const identifierName = identifierNode.getText();
53
62
  if (!identifierName.endsWith(typeMappersSuffix)) {
54
63
  return;
55
64
  }
@@ -63,10 +72,31 @@ const addTypeMapperDetailsIfValid = ({ identifierName, typeMappersSuffix, typeMa
63
72
  if (result[schemaType]) {
64
73
  throw new Error(`GraphQL type "${schemaType}" has duplicated "${identifierName}" mappers:\n - ${configImportPath}\n - ${result[schemaType].configImportPath}`);
65
74
  }
75
+ let typeMapperPropertyMap = {};
76
+ if (shouldCollectPropertyMap) {
77
+ const originalDeclarationNode = getOriginalDeclarationNode(declarationNode, identifierNode);
78
+ typeMapperPropertyMap = (0, utils_1.getNodePropertyMap)(originalDeclarationNode);
79
+ }
66
80
  result[schemaType] = {
67
81
  schemaType,
68
82
  typeMapperName: identifierName,
83
+ typeMapperPropertyMap,
69
84
  configImportPath,
70
85
  };
71
86
  };
87
+ const getOriginalDeclarationNode = (declarationNode, identifierNode) => {
88
+ if (!declarationNode) {
89
+ return identifierNode.getDefinitionNodes()[0];
90
+ }
91
+ // InterfaceDeclaration
92
+ if (declarationNode.isKind(ts_morph_1.SyntaxKind.InterfaceDeclaration)) {
93
+ return declarationNode;
94
+ }
95
+ // TypeAliasDeclaration
96
+ const typeNode = declarationNode.getTypeNodeOrThrow();
97
+ const node = ts_morph_1.Node.isTypeReference(typeNode) // If type alias is a reference, go to definition using `getDefinitionNodes`
98
+ ? identifierNode.getDefinitionNodes()[0]
99
+ : declarationNode;
100
+ return node;
101
+ };
72
102
  //# sourceMappingURL=collectTypeMappersFromSourceFile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collectTypeMappersFromSourceFile.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/parseTypeMappers/collectTypeMappersFromSourceFile.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAE7B,oCAAiD;AAG1C,MAAM,gCAAgC,GAAG,CAC9C,EACE,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,GAKlB,EACD,MAAsB,EAChB,EAAE;IACR,6CAA6C;IAC7C,qBAAqB,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,CAAC,oBAAoB,EAAE,EAAE;QACrE,IAAI,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,EAAE;YAC5C,OAAO;SACR;QAED,2BAA2B,CACzB;YACE,cAAc,EAAE,oBAAoB,CAAC,OAAO,EAAE;YAC9C,iBAAiB;YACjB,mBAAmB,EAAE,qBAAqB,CAAC,WAAW,EAAE;YACxD,iBAAiB;SAClB,EACD,MAAM,CACP,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,iDAAiD;IACjD,qBAAqB,CAAC,cAAc,EAAE,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAC3D,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,EAAE;YACjC,OAAO;SACR;QAED,2BAA2B,CACzB;YACE,cAAc,EAAE,SAAS,CAAC,OAAO,EAAE;YACnC,iBAAiB;YACjB,mBAAmB,EAAE,qBAAqB,CAAC,WAAW,EAAE;YACxD,iBAAiB;SAClB,EACD,MAAM,CACP,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,8BAA8B;IAC9B,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AI,CACrD,CACF,CAAC;IAEF,MAAM,gBAAgB,GAAG,GAAG,+CAA+C,IAAI,cAAc,EAAE,CAAC;IAEhG,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE;QACtB,MAAM,IAAI,KAAK,CACb,iBAAiB,UAAU,qBAAqB,cAAc,mBAAmB,gBAAgB,SAAS,MAAM,CAAC,UAAU,CAAC,CAAC,gBAAgB,EAAE,CAChJ,CAAC;KACH;IAED,MAAM,CAAC,UAAU,CAAC,GAAG;QACnB,UAAU;QACV,cAAc,EAAE,cAAc;QAC9B,gBAAgB;KACjB,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"collectTypeMappersFromSourceFile.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/parseTypeMappers/collectTypeMappersFromSourceFile.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,uCAOkB;AAClB,oCAAqE;AAG9D,MAAM,gCAAgC,GAAG,CAC9C,EACE,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,GAMzB,EACD,MAAsB,EAChB,EAAE;IACR,6CAA6C;IAC7C,qBAAqB,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,CAAC,oBAAoB,EAAE,EAAE;QACrE,IAAI,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,EAAE;YAC5C,OAAO;SACR;QAED,2BAA2B,CACzB;YACE,eAAe,EAAE,oBAAoB;YACrC,cAAc,EAAE,oBAAoB,CAAC,WAAW,EAAE;YAClD,iBAAiB;YACjB,mBAAmB,EAAE,qBAAqB,CAAC,WAAW,EAAE;YACxD,iBAAiB;YACjB,wBAAwB;SACzB,EACD,MAAM,CACP,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,iDAAiD;IACjD,qBAAqB,CAAC,cAAc,EAAE,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAC3D,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,EAAE;YACjC,OAAO;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AED,uBAAuB;IACvB,MAAM,QAAQ,GAAG,eAAe,CAAC,kBAAkB,EAAE,CAAC;IACtD,MAAM,IAAI,GAAG,eAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,4EAA4E;QACtH,CAAC,CAAC,cAAc,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;QACxC,CAAC,CAAC,eAAe,CAAC;IACpB,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -1,14 +1,19 @@
1
+ import { Project } from 'ts-morph';
1
2
  import type { ParseSourcesResult } from '../parseSources';
3
+ import type { NodePropertyMap } from '../utils';
2
4
  export interface ParseTypeMappersParams {
3
5
  sourceMap: ParseSourcesResult['sourceMap'];
4
6
  resolverTypesPath: string;
5
7
  typeMappersFileExtension: string;
6
8
  typeMappersSuffix: string;
9
+ tsMorphProject: Project;
10
+ shouldCollectPropertyMap: boolean;
7
11
  }
8
12
  export interface TypeMapperDetails {
9
13
  schemaType: string;
10
14
  typeMapperName: string;
15
+ typeMapperPropertyMap: NodePropertyMap;
11
16
  configImportPath: string;
12
17
  }
13
18
  export declare type TypeMappersMap = Record<string, TypeMapperDetails>;
14
- export declare const parseTypeMappers: ({ sourceMap, resolverTypesPath, typeMappersFileExtension, typeMappersSuffix, }: ParseTypeMappersParams) => TypeMappersMap;
19
+ export declare const parseTypeMappers: ({ sourceMap, resolverTypesPath, typeMappersFileExtension, typeMappersSuffix, tsMorphProject, shouldCollectPropertyMap, }: ParseTypeMappersParams) => TypeMappersMap;
@@ -2,18 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseTypeMappers = void 0;
4
4
  const path = require("path");
5
- const fs = require("fs");
6
- const ts_morph_1 = require("ts-morph");
7
5
  const collectTypeMappersFromSourceFile_1 = require("./collectTypeMappersFromSourceFile");
8
- const parseTypeMappers = ({ sourceMap, resolverTypesPath, typeMappersFileExtension, typeMappersSuffix, }) => {
6
+ const parseTypeMappers = ({ sourceMap, resolverTypesPath, typeMappersFileExtension, typeMappersSuffix, tsMorphProject, shouldCollectPropertyMap, }) => {
9
7
  const result = Object.entries(sourceMap).reduce((res, [_, { sourcePath }]) => {
10
8
  const typeMapperFilePath = path.join(sourcePath.dir, `${sourcePath.name}${typeMappersFileExtension}`);
11
- if (!fs.existsSync(typeMapperFilePath)) {
9
+ const typeMappersSourceFile = tsMorphProject.addSourceFileAtPathIfExists(typeMapperFilePath);
10
+ if (!typeMappersSourceFile) {
12
11
  return res;
13
12
  }
14
- const project = new ts_morph_1.Project();
15
- const [typeMappersSourceFile] = project.addSourceFilesAtPaths(typeMapperFilePath);
16
- (0, collectTypeMappersFromSourceFile_1.collectTypeMappersFromSourceFile)({ typeMappersSourceFile, typeMappersSuffix, resolverTypesPath }, res);
13
+ (0, collectTypeMappersFromSourceFile_1.collectTypeMappersFromSourceFile)({
14
+ typeMappersSourceFile,
15
+ typeMappersSuffix,
16
+ resolverTypesPath,
17
+ shouldCollectPropertyMap,
18
+ }, res);
17
19
  return res;
18
20
  }, {});
19
21
  return result;
@@ -1 +1 @@
1
- {"version":3,"file":"parseTypeMappers.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/parseTypeMappers/parseTypeMappers.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,yBAAyB;AACzB,uCAAmC;AAEnC,yFAAsF;AAiB/E,MAAM,gBAAgB,GAAG,CAAC,EAC/B,SAAS,EACT,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,GACM,EAAkB,EAAE;IAC3C,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAC7C,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE;QAC3B,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAClC,UAAU,CAAC,GAAG,EACd,GAAG,UAAU,CAAC,IAAI,GAAG,wBAAwB,EAAE,CAChD,CAAC;QAEF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE;YACtC,OAAO,GAAG,CAAC;SACZ;QAED,MAAM,OAAO,GAAG,IAAI,kBAAO,EAAE,CAAC;QAC9B,MAAM,CAAC,qBAAqB,CAAC,GAC3B,OAAO,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;QAEpD,IAAA,mEAAgC,EAC9B,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,EAC/D,GAAG,CACJ,CAAC;QAEF,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAE,CACH,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AA/BW,QAAA,gBAAgB,oBA+B3B"}
1
+ {"version":3,"file":"parseTypeMappers.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/parseTypeMappers/parseTypeMappers.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAI7B,yFAAsF;AAoB/E,MAAM,gBAAgB,GAAG,CAAC,EAC/B,SAAS,EACT,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,EACjB,cAAc,EACd,wBAAwB,GACD,EAAkB,EAAE;IAC3C,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAC7C,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE;QAC3B,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAClC,UAAU,CAAC,GAAG,EACd,GAAG,UAAU,CAAC,IAAI,GAAG,wBAAwB,EAAE,CAChD,CAAC;QAEF,MAAM,qBAAqB,GACzB,cAAc,CAAC,2BAA2B,CAAC,kBAAkB,CAAC,CAAC;QAEjE,IAAI,CAAC,qBAAqB,EAAE;YAC1B,OAAO,GAAG,CAAC;SACZ;QAED,IAAA,mEAAgC,EAC9B;YACE,qBAAqB;YACrB,iBAAiB;YACjB,iBAAiB;YACjB,wBAAwB;SACzB,EACD,GAAG,CACJ,CAAC;QAEF,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAE,CACH,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AArCW,QAAA,gBAAgB,oBAqC3B"}
package/src/preset.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- import type { Types } from '@graphql-codegen/plugin-helpers';
1
+ import { type Types } from '@graphql-codegen/plugin-helpers';
2
2
  import { RawPresetConfig } from './validatePresetConfig';
3
+ export declare const presetName = "@eddeee888/gcg-typescript-resolver-files";
3
4
  export declare const preset: Types.OutputPreset<RawPresetConfig>;
package/src/preset.js CHANGED
@@ -1,18 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.preset = void 0;
3
+ exports.preset = exports.presetName = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const path = require("path");
5
6
  const addPlugin = require("@graphql-codegen/add");
6
7
  const typeScriptPlugin = require("@graphql-codegen/typescript");
7
8
  const typeScriptResolversPlugin = require("@graphql-codegen/typescript-resolvers");
9
+ const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
10
+ const ts_morph_1 = require("ts-morph");
8
11
  const parseSources_1 = require("./parseSources");
9
12
  const getPluginsConfig_1 = require("./getPluginsConfig");
10
13
  const generateResolverFiles_1 = require("./generateResolverFiles");
11
14
  const generateTypeDefsContent_1 = require("./generateTypeDefsContent");
15
+ const getGraphQLObjectTypeResolversToGenerate_1 = require("./getGraphQLObjectTypeResolversToGenerate");
16
+ const addVirtualTypesFileToTsMorphProject_1 = require("./addVirtualTypesFileToTsMorphProject");
12
17
  const parseTypeMappers_1 = require("./parseTypeMappers");
13
18
  const validatePresetConfig_1 = require("./validatePresetConfig");
19
+ exports.presetName = '@eddeee888/gcg-typescript-resolver-files';
14
20
  exports.preset = {
15
- buildGeneratesSection: ({ schema, schemaAst, presetConfig: rawPresetConfig, baseOutputDir, }) => {
21
+ buildGeneratesSection: ({ schema, schemaAst, presetConfig: rawPresetConfig, baseOutputDir, profiler = (0, plugin_helpers_1.createNoopProfiler)(), }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
16
22
  if (!schemaAst) {
17
23
  throw new Error('Missing schemaAst');
18
24
  }
@@ -20,24 +26,46 @@ exports.preset = {
20
26
  if (!Array.isArray(sources) || sources.length === 0) {
21
27
  throw new Error('Empty Sources. Make sure schema files are parsed correctly.');
22
28
  }
23
- const { resolverTypesPath: relativeResolverTypesPathFromBaseOutputDir, resolverRelativeTargetDir, mappersFileExtension: typeMappersFileExtension, mappersSuffix: typeMappersSuffix, resolverMainFile, typeDefsFilePath, mode, whitelistedModules, blacklistedModules, externalResolvers, typesPluginsConfig, } = (0, validatePresetConfig_1.validatePresetConfig)(rawPresetConfig);
29
+ const { resolverTypesPath: relativeResolverTypesPathFromBaseOutputDir, resolverRelativeTargetDir, mappersFileExtension: typeMappersFileExtension, mappersSuffix: typeMappersSuffix, resolverMainFile, typeDefsFilePath, mode, whitelistedModules, blacklistedModules, externalResolvers, typesPluginsConfig, tsMorphProjectOptions, fixObjectTypeResolvers, } = (0, validatePresetConfig_1.validatePresetConfig)(rawPresetConfig);
24
30
  const resolverTypesPath = path.join(baseOutputDir, relativeResolverTypesPathFromBaseOutputDir);
25
31
  const { sourceMap, mergedSDL } = (0, parseSources_1.parseSources)(sources);
26
- const typeMappersMap = (0, parseTypeMappers_1.parseTypeMappers)({
27
- sourceMap,
28
- resolverTypesPath,
29
- typeMappersFileExtension,
30
- typeMappersSuffix,
31
- });
32
+ const tsMorphProject = yield profiler.run(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return new ts_morph_1.Project(tsMorphProjectOptions); }), createProfilerRunName('Initialising ts-morph project'));
33
+ const typeMappersMap = yield profiler.run(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
34
+ return (0, parseTypeMappers_1.parseTypeMappers)({
35
+ sourceMap,
36
+ resolverTypesPath,
37
+ typeMappersFileExtension,
38
+ typeMappersSuffix,
39
+ tsMorphProject,
40
+ shouldCollectPropertyMap: fixObjectTypeResolvers !== 'disabled',
41
+ });
42
+ }), createProfilerRunName('parseTypeMappers'));
32
43
  const generatesSection = [];
33
44
  // typescript and typescript-resolvers plugins config
34
- const { defaultScalarTypesMap, defaultScalarExternalResolvers, defaultTypeMappers, } = (0, getPluginsConfig_1.getPluginsConfig)({
45
+ const { userDefinedSchemaTypeMap, pluginsConfig: { defaultScalarTypesMap, defaultScalarExternalResolvers, defaultTypeMappers, }, } = (0, getPluginsConfig_1.getPluginsConfig)({
35
46
  schemaAst,
36
47
  sourceMap,
37
48
  typeMappersMap,
38
49
  whitelistedModules,
39
50
  blacklistedModules,
40
51
  });
52
+ const resolverTypesConfig = Object.assign(Object.assign({ enumsAsTypes: true, nonOptionalTypename: true }, typesPluginsConfig), { scalars: Object.assign(Object.assign({}, defaultScalarTypesMap), typesPluginsConfig.scalars), mappers: Object.assign(Object.assign({}, defaultTypeMappers), typesPluginsConfig.mappers) });
53
+ // typesSourceFile is the virtual `types.generated.ts`
54
+ // This is useful when we need to do static analysis as most types come from this file
55
+ // e.g. comparing mappers field type vs schema object field type
56
+ const typesSourceFile = yield profiler.run(() => (0, addVirtualTypesFileToTsMorphProject_1.addVirtualTypesFileToTsMorphProject)({
57
+ tsMorphProject,
58
+ schemaAst,
59
+ resolverTypesConfig,
60
+ resolverTypesPath,
61
+ }), createProfilerRunName('addVirtualTypesFileToTsMorphProject'));
62
+ const graphQLObjectTypeResolversToGenerate = yield profiler.run(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
63
+ return (0, getGraphQLObjectTypeResolversToGenerate_1.getGraphQLObjectTypeResolversToGenerate)({
64
+ typesSourceFile,
65
+ userDefinedSchemaTypeMap,
66
+ typeMappersMap,
67
+ });
68
+ }), createProfilerRunName('graphQLObjectTypeResolversToGenerate'));
41
69
  const resolverTypesFile = {
42
70
  filename: resolverTypesPath,
43
71
  pluginMap: {
@@ -45,19 +73,20 @@ exports.preset = {
45
73
  'typescript-resolvers': typeScriptResolversPlugin,
46
74
  },
47
75
  plugins: [{ typescript: {} }, { ['typescript-resolvers']: {} }],
48
- config: Object.assign(Object.assign({ enumsAsTypes: true, nonOptionalTypename: true }, typesPluginsConfig), { scalars: Object.assign(Object.assign({}, defaultScalarTypesMap), typesPluginsConfig.scalars), mappers: Object.assign(Object.assign({}, defaultTypeMappers), typesPluginsConfig.mappers) }),
76
+ config: resolverTypesConfig,
49
77
  schema,
50
78
  documents: [],
51
79
  };
52
80
  generatesSection.push(resolverTypesFile);
53
81
  // typeDefs
54
82
  if (typeDefsFilePath) {
83
+ const typeDefsContent = yield profiler.run(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return (0, generateTypeDefsContent_1.generateTypeDefsContent)({ mergedSDL }); }), createProfilerRunName('generateTypeDefsContent'));
55
84
  const typeDefsFile = {
56
85
  filename: path.join(baseOutputDir, typeDefsFilePath),
57
86
  pluginMap: { add: addPlugin },
58
87
  plugins: [
59
88
  {
60
- add: { content: (0, generateTypeDefsContent_1.generateTypeDefsContent)({ mergedSDL }) },
89
+ add: { content: typeDefsContent },
61
90
  },
62
91
  ],
63
92
  config: {},
@@ -71,21 +100,29 @@ exports.preset = {
71
100
  files: {},
72
101
  externalImports: {},
73
102
  };
74
- (0, generateResolverFiles_1.generateResolverFiles)({
75
- config: {
76
- schema: schemaAst,
77
- sourceMap,
78
- baseOutputDir,
79
- resolverTypesPath,
80
- resolverRelativeTargetDir,
81
- resolverMainFile,
82
- mode,
83
- whitelistedModules,
84
- blacklistedModules,
85
- externalResolvers: Object.assign(Object.assign({}, defaultScalarExternalResolvers), externalResolvers),
86
- },
87
- result,
88
- });
103
+ yield profiler.run(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
104
+ return (0, generateResolverFiles_1.generateResolverFiles)({
105
+ config: {
106
+ schema: schemaAst,
107
+ sourceMap,
108
+ baseOutputDir,
109
+ resolverTypesPath,
110
+ resolverRelativeTargetDir,
111
+ resolverMainFile,
112
+ graphQLObjectTypeResolversToGenerate,
113
+ tsMorph: {
114
+ project: tsMorphProject,
115
+ typesSourceFile,
116
+ },
117
+ fixObjectTypeResolvers,
118
+ mode,
119
+ whitelistedModules,
120
+ blacklistedModules,
121
+ externalResolvers: Object.assign(Object.assign({}, defaultScalarExternalResolvers), externalResolvers),
122
+ },
123
+ result,
124
+ });
125
+ }), createProfilerRunName('generateResolverFiles'));
89
126
  const resolverFilesGenerateOptions = Object.entries(result.files).map(([filename, { content }]) => ({
90
127
  filename,
91
128
  pluginMap: { add: addPlugin },
@@ -95,6 +132,7 @@ exports.preset = {
95
132
  documents: [],
96
133
  }));
97
134
  return [...resolverFilesGenerateOptions, ...generatesSection];
98
- },
135
+ }),
99
136
  };
137
+ const createProfilerRunName = (traceName) => `[${exports.presetName}]: ${traceName}`;
100
138
  //# sourceMappingURL=preset.js.map
package/src/preset.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"preset.js","sourceRoot":"","sources":["../../../../packages/typescript-resolver-files/src/preset.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,kDAAkD;AAClD,gEAAgE;AAChE,mFAAmF;AAEnF,iDAA8C;AAC9C,yDAAsD;AACtD,mEAGiC;AACjC,uEAAoE;AACpE,yDAAsD;AACtD,iEAA+E;AAElE,QAAA,MAAM,GAAwC;IACzD,qBAAqB,EAAE,CAAC,EACtB,MAAM,EACN,SAAS,EACT,YAAY,EAAE,eAAe,EAC7B,aAAa,GACd,EAAE,EAAE;QACH,IAAI,CAAC,SAAS,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;SACtC;QACD,MAAM,OAAO,GAAG,SAAS,CAAC,UAAU,CAAC,eAAe,CAAC;QACrD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;YACnD,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;SAC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AAE,EAAE;SACd,CAAC,CAAC,CAAC;QAEN,OAAO,CAAC,GAAG,4BAA4B,EAAE,GAAG,gBAAgB,CAAC,CAAC;IAChE,CAAC;CACF,CAAC"}
1
+ {"version":3,"file":"preset.js","sourceRoot":"","sources":["../../../../packages/typescript-resolver-files/src/preset.ts"],"names":[],"mappings":";;;;AAAA,6BAA6B;AAC7B,kDAAkD;AAClD,gEAAgE;AAChE,mFAAmF;AACnF,oEAGyC;AACzC,uCAAmC;AACnC,iDAA8C;AAC9C,yDAAsD;AACtD,mEAGiC;AACjC,uEAAoE;AACpE,uGAAoG;AACpG,+FAA4F;AAC5F,yDAAsD;AACtD,iEAA+E;AAElE,QAAA,UAAU,GAAG,0CAA0C,CAAC;AAExD,QAAA,MAAM,GAAwC;IACzD,qBAAqB,EAAE,CAAO,EAC5B,MAAM,EACN,SAAS,EACT,YAAY,EAAE,eAAe,EAC7B,aAAa,EACb,QAAQ,GAAG,IAAA,mCAAkB,GAAE,GAChC,EAAE,EAAE;QACH,IAAI,CAAC,SAAS,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;SACtC;QACD,MAAM,OAAO,GAAG,SAAS,CAAC,UAAU,CAAC,eAAe,CAAC;QACrD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;YACnD,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;SACH;QAED,MAAM,EACJ,iBAAiB,EAAE,0CAA0C,EAC7D,yBAAyB,EACzB,oBAAoB,EAAE,wBAAwB,EAC9C,aAAa,EAAE,iBAAiB,EAChC,gBAAgB,EAChB,gBAAgB,EAChB,IAAI,EACJ,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,GACvB,GAAG,IAAA,2CAAoB,EAAC,eAAe,CAAC,CAAC;QAE1C,MAAM,iBAAiB,GA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record<string, {
3
+ name: string;
4
+ }>;
5
+ /**
6
+ * Function to get properties of a Node in a map
7
+ * If unable to find, returns empty object
8
+ */
9
+ export declare const getNodePropertyMap: (node: Node | undefined) => NodePropertyMap;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNodePropertyMap = void 0;
4
+ const ts_morph_1 = require("ts-morph");
5
+ /**
6
+ * Function to get properties of a Node in a map
7
+ * If unable to find, returns empty object
8
+ */
9
+ const getNodePropertyMap = (node) => {
10
+ if (!node) {
11
+ return {};
12
+ }
13
+ const properties = getNodeProperties(node);
14
+ const nodePropertyMap = properties.reduce((res, { propertyName }) => {
15
+ res[propertyName] = {
16
+ name: propertyName,
17
+ };
18
+ return res;
19
+ }, {});
20
+ return nodePropertyMap;
21
+ };
22
+ exports.getNodePropertyMap = getNodePropertyMap;
23
+ const getNodeProperties = (node) => {
24
+ if (node.isKind(ts_morph_1.SyntaxKind.InterfaceDeclaration)) {
25
+ return node.getProperties().map((prop) => ({
26
+ propertyName: prop.getName(),
27
+ }));
28
+ }
29
+ else if (node.isKind(ts_morph_1.SyntaxKind.TypeAliasDeclaration)) {
30
+ const typeNode = node.getTypeNodeOrThrow();
31
+ if (ts_morph_1.Node.isTypeLiteral(typeNode)) {
32
+ return typeNode.getProperties().map((prop) => {
33
+ return {
34
+ propertyName: prop.getName(),
35
+ };
36
+ });
37
+ }
38
+ else if (ts_morph_1.Node.isTypeReference(typeNode)) {
39
+ return typeNode
40
+ .getType()
41
+ .getProperties()
42
+ .map((prop) => ({
43
+ propertyName: prop.getName(),
44
+ }));
45
+ }
46
+ }
47
+ return [];
48
+ };
49
+ //# sourceMappingURL=getNodePropertyMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNodePropertyMap.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/utils/getNodePropertyMap.ts"],"names":[],"mappings":";;;AAAA,uCAA4C;AAI5C;;;GAGG;AACI,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CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACd,YAAY,EAAE,IAAI,CAAC,OAAO,EAAE;aAC7B,CAAC,CAAC,CAAC;SACP;KACF;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC"}
@@ -2,5 +2,6 @@ export * from './parseLocationForWhitelistedModule';
2
2
  export * from './isNativeNamedType';
3
3
  export * from './isRootObjectType';
4
4
  export * from './printImportLine';
5
+ export * from './getNodePropertyMap';
5
6
  export declare const relativeModulePath: (from: string, to: string) => string;
6
7
  export declare const normalizeRelativePath: (path: string) => string;
@@ -7,6 +7,7 @@ tslib_1.__exportStar(require("./parseLocationForWhitelistedModule"), exports);
7
7
  tslib_1.__exportStar(require("./isNativeNamedType"), exports);
8
8
  tslib_1.__exportStar(require("./isRootObjectType"), exports);
9
9
  tslib_1.__exportStar(require("./printImportLine"), exports);
10
+ tslib_1.__exportStar(require("./getNodePropertyMap"), exports);
10
11
  // TODO: break the functions below this line into smaller files
11
12
  // -----------
12
13
  const relativeModulePath = (from, to) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/utils/index.ts"],"names":[],"mappings":";;;;AAAA,6BAA6B;AAE7B,8EAAoD;AACpD,8DAAoC;AACpC,6DAAmC;AACnC,4DAAkC;AAElC,+DAA+D;AAC/D,cAAc;AACP,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,EAAU,EAAU,EAAE;IACrE,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACxC,OAAO,IAAA,6BAAqB,EAAC,OAAO,CAAC,CAAC;AACxC,CAAC,CAAC;AAHW,QAAA,kBAAkB,sBAG7B;AAEK,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAU,EAAE;IAC5D,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QACrD,OAAO,KAAK,IAAI,EAAE,CAAC;KACpB;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AALW,QAAA,qBAAqB,yBAKhC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/utils/index.ts"],"names":[],"mappings":";;;;AAAA,6BAA6B;AAE7B,8EAAoD;AACpD,8DAAoC;AACpC,6DAAmC;AACnC,4DAAkC;AAClC,+DAAqC;AAErC,+DAA+D;AAC/D,cAAc;AACP,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,EAAU,EAAU,EAAE;IACrE,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACxC,OAAO,IAAA,6BAAqB,EAAC,OAAO,CAAC,CAAC;AACxC,CAAC,CAAC;AAHW,QAAA,kBAAkB,sBAG7B;AAEK,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAU,EAAE;IAC5D,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QACrD,OAAO,KAAK,IAAI,EAAE,CAAC;KACpB;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AALW,QAAA,qBAAqB,yBAKhC"}
@@ -1,5 +1,6 @@
1
1
  import * as typeScriptPlugin from '@graphql-codegen/typescript';
2
2
  import * as typeScriptResolversPlugin from '@graphql-codegen/typescript-resolvers';
3
+ import type { ProjectOptions } from 'ts-morph';
3
4
  declare type ParsedTypesPluginsConfig = Omit<typeScriptPlugin.TypeScriptPluginConfig, 'scalars'> & Omit<typeScriptResolversPlugin.TypeScriptResolversPluginConfig, 'scalars'> & {
4
5
  scalars: Record<string, string>;
5
6
  };
@@ -15,6 +16,8 @@ interface ParsedPresetConfig {
15
16
  blacklistedModules: string[];
16
17
  externalResolvers: Record<string, string>;
17
18
  typesPluginsConfig: ParsedTypesPluginsConfig;
19
+ tsMorphProjectOptions: ProjectOptions;
20
+ fixObjectTypeResolvers: 'smart' | 'disabled';
18
21
  }
19
22
  export interface RawPresetConfig {
20
23
  resolverTypesPath?: string;
@@ -28,6 +31,8 @@ export interface RawPresetConfig {
28
31
  blacklistedModules?: string[];
29
32
  externalResolvers?: Record<string, string>;
30
33
  typesPluginsConfig?: typeScriptPlugin.TypeScriptPluginConfig & typeScriptResolversPlugin.TypeScriptResolversPluginConfig;
34
+ tsConfigFilePath?: string;
35
+ fixObjectTypeResolvers?: string;
31
36
  }
32
- export declare const validatePresetConfig: ({ resolverTypesPath, resolverRelativeTargetDir, resolverMainFile, typeDefsFilePath, mappersFileExtension, mappersSuffix, mode, whitelistedModules, blacklistedModules, externalResolvers, typesPluginsConfig, }: RawPresetConfig) => ParsedPresetConfig;
37
+ export declare const validatePresetConfig: ({ resolverTypesPath, resolverRelativeTargetDir, resolverMainFile, typeDefsFilePath, mappersFileExtension, mappersSuffix, mode, whitelistedModules, blacklistedModules, externalResolvers, typesPluginsConfig, tsConfigFilePath, fixObjectTypeResolvers, }: RawPresetConfig) => ParsedPresetConfig;
33
38
  export {};
@@ -2,39 +2,44 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validatePresetConfig = void 0;
4
4
  const path = require("path");
5
- const presetName = '@eddeee888/gcg-typescript-resolver-files';
5
+ const fs = require("fs");
6
+ const preset_1 = require("../preset");
6
7
  const defaultResolverRelativeTargetDirMap = {
7
8
  modules: 'resolvers',
8
9
  merged: '',
9
10
  };
10
11
  const defaultTypeDefsFilePath = './typeDefs.generated.ts';
11
- const validatePresetConfig = ({ resolverTypesPath = './types.generated.ts', resolverRelativeTargetDir, resolverMainFile = 'resolvers.generated.ts', typeDefsFilePath = defaultTypeDefsFilePath, mappersFileExtension = '.mappers.ts', mappersSuffix = 'Mapper', mode = 'modules', whitelistedModules, blacklistedModules, externalResolvers = {}, typesPluginsConfig = {}, }) => {
12
+ const validatePresetConfig = ({ resolverTypesPath = './types.generated.ts', resolverRelativeTargetDir, resolverMainFile = 'resolvers.generated.ts', typeDefsFilePath = defaultTypeDefsFilePath, mappersFileExtension = '.mappers.ts', mappersSuffix = 'Mapper', mode = 'modules', whitelistedModules, blacklistedModules, externalResolvers = {}, typesPluginsConfig = {}, tsConfigFilePath = './tsconfig.json', fixObjectTypeResolvers = 'smart', }) => {
12
13
  if (mode !== 'merged' && mode !== 'modules') {
13
- throw new Error(`Validation Error - ${presetName} - presetConfig.mode must be "merged" or "modules" (default is "modules")`);
14
+ throw new Error(`Validation Error - ${preset_1.presetName} - presetConfig.mode must be "merged" or "modules" (default is "modules")`);
15
+ }
16
+ if (fixObjectTypeResolvers !== 'smart' &&
17
+ fixObjectTypeResolvers !== 'disabled') {
18
+ throw new Error(`Validation Error - ${preset_1.presetName} - presetConfig.fixObjectTypeResolvers must be "smart" or "disabled" (default is "smart")`);
14
19
  }
15
20
  if (!resolverTypesPath) {
16
- throw new Error(`Validation Error - ${presetName} - presetConfig.resolverTypesPath is required`);
21
+ throw new Error(`Validation Error - ${preset_1.presetName} - presetConfig.resolverTypesPath is required`);
17
22
  }
18
23
  const finalResolverRelativeTargetDir = resolverRelativeTargetDir === undefined
19
24
  ? defaultResolverRelativeTargetDirMap[mode]
20
25
  : resolverRelativeTargetDir;
21
26
  if (path.extname(resolverMainFile) === '') {
22
- throw new Error(`Validation Error - ${presetName} - presetConfig.mainFile must be a valid file name`);
27
+ throw new Error(`Validation Error - ${preset_1.presetName} - presetConfig.mainFile must be a valid file name`);
23
28
  }
24
29
  if (whitelistedModules) {
25
30
  if (!Array.isArray(whitelistedModules)) {
26
- throw new Error(`Validation Error - ${presetName} - presetConfig.whitelistedModules must be an array if provided`);
31
+ throw new Error(`Validation Error - ${preset_1.presetName} - presetConfig.whitelistedModules must be an array if provided`);
27
32
  }
28
33
  if (mode !== 'modules') {
29
- throw new Error(`Validation Error - ${presetName} - presetConfig.whitelistedModules can only be used with presetConfig.mode == "modules"`);
34
+ throw new Error(`Validation Error - ${preset_1.presetName} - presetConfig.whitelistedModules can only be used with presetConfig.mode == "modules"`);
30
35
  }
31
36
  }
32
37
  if (blacklistedModules) {
33
38
  if (!Array.isArray(blacklistedModules)) {
34
- throw new Error(`Validation Error - ${presetName} - presetConfig.blacklistedModules must be an array if provided`);
39
+ throw new Error(`Validation Error - ${preset_1.presetName} - presetConfig.blacklistedModules must be an array if provided`);
35
40
  }
36
41
  if (mode !== 'modules') {
37
- throw new Error(`Validation Error - ${presetName} - presetConfig.blacklistedModules can only be used with presetConfig.mode == "modules"`);
42
+ throw new Error(`Validation Error - ${preset_1.presetName} - presetConfig.blacklistedModules can only be used with presetConfig.mode == "modules"`);
38
43
  }
39
44
  }
40
45
  if (!validateTypesPluginsConfig(typesPluginsConfig)) {
@@ -44,6 +49,18 @@ const validatePresetConfig = ({ resolverTypesPath = './types.generated.ts', reso
44
49
  if (finalTypeDefsFilePath === true) {
45
50
  finalTypeDefsFilePath = defaultTypeDefsFilePath;
46
51
  }
52
+ const tsMorphProjectOptions = {
53
+ skipAddingFilesFromTsConfig: true, // avoid long startup time by NOT loading files included by tsconfig.json. We only use this virtually anyways so we don't need all the files
54
+ };
55
+ if (tsConfigFilePath) {
56
+ const absoluteTsConfigFilePath = path.join(process.cwd(), tsConfigFilePath);
57
+ if (fs.existsSync(absoluteTsConfigFilePath)) {
58
+ tsMorphProjectOptions.tsConfigFilePath = absoluteTsConfigFilePath;
59
+ }
60
+ else {
61
+ console.warn(`[${preset_1.presetName}] WARN: Unable to find TypeScript config at ${absoluteTsConfigFilePath}. Use presetConfig.tsConfigFilePath to set a custom value. Otherwise, type analysis may not work correctly.`);
62
+ }
63
+ }
47
64
  return {
48
65
  resolverTypesPath,
49
66
  resolverRelativeTargetDir: finalResolverRelativeTargetDir,
@@ -56,13 +73,15 @@ const validatePresetConfig = ({ resolverTypesPath = './types.generated.ts', reso
56
73
  blacklistedModules: blacklistedModules || [],
57
74
  externalResolvers,
58
75
  typesPluginsConfig,
76
+ tsMorphProjectOptions,
77
+ fixObjectTypeResolvers,
59
78
  };
60
79
  };
61
80
  exports.validatePresetConfig = validatePresetConfig;
62
81
  const validateTypesPluginsConfig = (config) => {
63
82
  config.scalars = config.scalars || {};
64
83
  if (typeof config.scalars === 'string') {
65
- throw new Error(`Validation Error - ${presetName} - presetConfig.typesPluginsConfig.scalars of type "string" is not supported`);
84
+ throw new Error(`Validation Error - ${preset_1.presetName} - presetConfig.typesPluginsConfig.scalars of type "string" is not supported`);
66
85
  }
67
86
  return true;
68
87
  };
@@ -1 +1 @@
1
- {"version":3,"file":"validatePresetConfig.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/validatePresetConfig/validatePresetConfig.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAI7B,MAAM,UAAU,GAAG,0CAA0C,CAAC;AAE9D,MAAM,mCAAmC,GAGrC;IACF,OAAO,EAAE,WAAW;IACpB,MAAM,EAAE,EAAE;CACX,CAAC;AACF,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAuCnD,MAAM,oBAAoB,GAAG,CAAC,EACnC,iBAAiB,GAAG,sBAAsB,EAC1C,yBAAyB,EACzB,gBAAgB,GAAG,wBAAwB,EAC3C,gBAAgB,GAAG,uBAAuB,EAC1C,oBAAoB,GAAG,aAAa,EACpC,aAAa,GAAG,QAAQ,EACxB,IAAI,GAAG,SAAS,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,GAAG,EAAE,EACtB,kBAAkB,GAAG,EAAE,GACP,EAAsB,EAAE;IACxC,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,SAAS,EAAE;QAC3C,MAAM,IAAI,KAAK,CACb,sBAAsB,UAAU,2EAA2E,CAC5G,CAAC;KACH;IAED,IAAI,CAAC,iBAAiB,EAAE;QACtB,MAAM,IAAI,KAAK,CACb,sBAAsB,UAAU,+CAA+C,CAChF,CAAC;KACH;IAED,MAAM,8BAA8B,GA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;QACjB,kBAAkB;KACnB,CAAC;AACJ,CAAC,CAAC;AAtFW,QAAA,oBAAoB,wBAsF/B;AAEF,MAAM,0BAA0B,GAAG,CACjC,MAA0D,EACN,EAAE;IACtD,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;IACtC,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,EAAE;QACtC,MAAM,IAAI,KAAK,CACb,sBAAsB,UAAU,8EAA8E,CAC/G,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
1
+ {"version":3,"file":"validatePresetConfig.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/validatePresetConfig/validatePresetConfig.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,yBAAyB;AAIzB,sCAAuC;AAEvC,MAAM,mCAAmC,GAGrC;IACF,OAAO,EAAE,WAAW;IACpB,MAAM,EAAE,EAAE;CACX,CAAC;AACF,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AA2CnD,MAAM,oBAAoB,GAAG,CAAC,EACnC,iBAAiB,GAAG,sBAAsB,EAC1C,yBAAyB,EACzB,gBAAgB,GAAG,wBAAwB,EAC3C,gBAAgB,GAAG,uBAAuB,EAC1C,oBAAoB,GAAG,aAAa,EACpC,aAAa,GAAG,QAAQ,EACxB,IAAI,GAAG,SAAS,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,GAAG,EAAE,EACtB,kBAAkB,GAAG,EAAE,EACvB,gBAAgB,GAAG,iBAAiB,EACpC,sBAAsB,GAAG,OAAO,GAChB,EAAsB,EAAE;IACxC,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,SAAS,EAAE;QAC3C,MAAM,IAAI,KAAK,CACb,sBAAsB,mBAAU,2EAA2E,CAC5G,CAAC;KACH;IAED,IACE,sBAAsB,KAAK,OAAO;QAClC,sBAAsB,KAAK,UAAU,EACrC;QACA,MAAM,IAAI,KA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I,EAAE,4IAA4I;KAChL,CAAC;IACF,IAAI,gBAAgB,EAAE;QACpB,MAAM,wBAAwB,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC,CAAC;QAE5E,IAAI,EAAE,CAAC,UAAU,CAAC,wBAAwB,CAAC,EAAE;YAC3C,qBAAqB,CAAC,gBAAgB,GAAG,wBAAwB,CAAC;SACnE;aAAM;YACL,OAAO,CAAC,IAAI,CACV,IAAI,mBAAU,+CAA+C,wBAAwB,6GAA6G,CACnM,CAAC;SACH;KACF;IAED,OAAO;QACL,iBAAiB;QACjB,yBAAyB,EAAE,8BAA8B;QACzD,gBAAgB;QAChB,gBAAgB,EAAE,qBAAqB;QACvC,IAAI;QACJ,oBAAoB;QACpB,aAAa;QACb,kBAAkB,EAAE,kBAAkB,IAAI,EAAE;QAC5C,kBAAkB,EAAE,kBAAkB,IAAI,EAAE;QAC5C,iBAAiB;QACjB,kBAAkB;QAClB,qBAAqB;QACrB,sBAAsB;KACvB,CAAC;AACJ,CAAC,CAAC;AAlHW,QAAA,oBAAoB,wBAkH/B;AAEF,MAAM,0BAA0B,GAAG,CACjC,MAA0D,EACN,EAAE;IACtD,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;IACtC,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,EAAE;QACtC,MAAM,IAAI,KAAK,CACb,sBAAsB,mBAAU,8EAA8E,CAC/G,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- import type { GenerateResolverFilesContext } from './types';
2
- export declare const fixExistingResolvers: ({ result, }: GenerateResolverFilesContext) => void;