@eddeee888/gcg-typescript-resolver-files 0.2.1 → 0.4.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 (108) hide show
  1. package/README.md +191 -30
  2. package/package.json +5 -5
  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/defineConfig.d.ts +5 -0
  10. package/src/defineConfig.js +19 -0
  11. package/src/defineConfig.js.map +1 -0
  12. package/src/generateResolverFiles/addExternalResolverImport.d.ts +1 -0
  13. package/src/generateResolverFiles/addExternalResolverImport.js +1 -0
  14. package/src/generateResolverFiles/addExternalResolverImport.js.map +1 -1
  15. package/src/generateResolverFiles/addResolverMainFile.d.ts +4 -1
  16. package/src/generateResolverFiles/addResolverMainFile.js +71 -50
  17. package/src/generateResolverFiles/addResolverMainFile.js.map +1 -1
  18. package/src/generateResolverFiles/ensureObjectTypeResolversAreGenerated.d.ts +6 -0
  19. package/src/generateResolverFiles/ensureObjectTypeResolversAreGenerated.js +80 -0
  20. package/src/generateResolverFiles/ensureObjectTypeResolversAreGenerated.js.map +1 -0
  21. package/src/generateResolverFiles/generateResolverFiles.js +3 -3
  22. package/src/generateResolverFiles/generateResolverFiles.js.map +1 -1
  23. package/src/generateResolverFiles/getVariableStatementWithExpectedIdentifier.d.ts +6 -0
  24. package/src/generateResolverFiles/getVariableStatementWithExpectedIdentifier.js +27 -0
  25. package/src/generateResolverFiles/getVariableStatementWithExpectedIdentifier.js.map +1 -0
  26. package/src/generateResolverFiles/handleGraphQLObjectType.js +6 -2
  27. package/src/generateResolverFiles/handleGraphQLObjectType.js.map +1 -1
  28. package/src/generateResolverFiles/handleGraphQLRootObjectTypeField.js +9 -2
  29. package/src/generateResolverFiles/handleGraphQLRootObjectTypeField.js.map +1 -1
  30. package/src/generateResolverFiles/handleGraphQLScalarType.js +2 -1
  31. package/src/generateResolverFiles/handleGraphQLScalarType.js.map +1 -1
  32. package/src/generateResolverFiles/handleGraphQLUninionType.js +2 -1
  33. package/src/generateResolverFiles/handleGraphQLUninionType.js.map +1 -1
  34. package/src/generateResolverFiles/postProcessFiles.d.ts +8 -0
  35. package/src/generateResolverFiles/postProcessFiles.js +73 -0
  36. package/src/generateResolverFiles/postProcessFiles.js.map +1 -0
  37. package/src/generateResolverFiles/types.d.ts +19 -3
  38. package/src/generateResolverFiles/visitNamedType.js +28 -11
  39. package/src/generateResolverFiles/visitNamedType.js.map +1 -1
  40. package/src/generateTypeDefsFiles/generateTypeDefsContent.js.map +1 -0
  41. package/src/generateTypeDefsFiles/generateTypeDefsFiles.d.ts +13 -0
  42. package/src/generateTypeDefsFiles/generateTypeDefsFiles.js +60 -0
  43. package/src/generateTypeDefsFiles/generateTypeDefsFiles.js.map +1 -0
  44. package/src/generateTypeDefsFiles/index.d.ts +1 -0
  45. package/src/{generateTypeDefsContent → generateTypeDefsFiles}/index.js +1 -1
  46. package/src/{generateTypeDefsContent → generateTypeDefsFiles}/index.js.map +1 -1
  47. package/src/getGraphQLObjectTypeResolversToGenerate/getGraphQLObjectTypeResolversToGenerate.d.ts +11 -0
  48. package/src/getGraphQLObjectTypeResolversToGenerate/getGraphQLObjectTypeResolversToGenerate.js +70 -0
  49. package/src/getGraphQLObjectTypeResolversToGenerate/getGraphQLObjectTypeResolversToGenerate.js.map +1 -0
  50. package/src/getGraphQLObjectTypeResolversToGenerate/index.d.ts +1 -0
  51. package/src/getGraphQLObjectTypeResolversToGenerate/index.js +5 -0
  52. package/src/getGraphQLObjectTypeResolversToGenerate/index.js.map +1 -0
  53. package/src/index.d.ts +1 -0
  54. package/src/index.js +3 -1
  55. package/src/index.js.map +1 -1
  56. package/src/parseGraphQLSchema/index.d.ts +1 -0
  57. package/src/{getPluginsConfig → parseGraphQLSchema}/index.js +1 -1
  58. package/src/parseGraphQLSchema/index.js.map +1 -0
  59. package/src/parseGraphQLSchema/parseGraphQLSchema.d.ts +16 -0
  60. package/src/{getPluginsConfig/getPluginsConfig.js → parseGraphQLSchema/parseGraphQLSchema.js} +15 -10
  61. package/src/parseGraphQLSchema/parseGraphQLSchema.js.map +1 -0
  62. package/src/parseSources/parseSources.d.ts +0 -1
  63. package/src/parseSources/parseSources.js +2 -3
  64. package/src/parseSources/parseSources.js.map +1 -1
  65. package/src/parseTypeMappers/collectTypeMappersFromSourceFile.d.ts +3 -2
  66. package/src/parseTypeMappers/collectTypeMappersFromSourceFile.js +51 -10
  67. package/src/parseTypeMappers/collectTypeMappersFromSourceFile.js.map +1 -1
  68. package/src/parseTypeMappers/parseTypeMappers.d.ts +7 -2
  69. package/src/parseTypeMappers/parseTypeMappers.js +10 -8
  70. package/src/parseTypeMappers/parseTypeMappers.js.map +1 -1
  71. package/src/preset.d.ts +2 -1
  72. package/src/preset.js +90 -44
  73. package/src/preset.js.map +1 -1
  74. package/src/utils/cwd.d.ts +4 -0
  75. package/src/utils/cwd.js +12 -0
  76. package/src/utils/cwd.js.map +1 -0
  77. package/src/utils/getNodePropertyMap.d.ts +9 -0
  78. package/src/utils/getNodePropertyMap.js +57 -0
  79. package/src/utils/getNodePropertyMap.js.map +1 -0
  80. package/src/utils/index.d.ts +5 -2
  81. package/src/utils/index.js +5 -16
  82. package/src/utils/index.js.map +1 -1
  83. package/src/utils/isRootObjectType.d.ts +1 -1
  84. package/src/utils/isWhitelistedModule.d.ts +5 -0
  85. package/src/utils/isWhitelistedModule.js +16 -0
  86. package/src/utils/isWhitelistedModule.js.map +1 -0
  87. package/src/utils/normalizeRelativePath.d.ts +1 -0
  88. package/src/utils/normalizeRelativePath.js +11 -0
  89. package/src/utils/normalizeRelativePath.js.map +1 -0
  90. package/src/utils/parseLocationForWhitelistedModule.js +7 -9
  91. package/src/utils/parseLocationForWhitelistedModule.js.map +1 -1
  92. package/src/utils/relativeModulePath.d.ts +1 -0
  93. package/src/utils/relativeModulePath.js +11 -0
  94. package/src/utils/relativeModulePath.js.map +1 -0
  95. package/src/validatePresetConfig/validatePresetConfig.d.ts +23 -4
  96. package/src/validatePresetConfig/validatePresetConfig.js +57 -17
  97. package/src/validatePresetConfig/validatePresetConfig.js.map +1 -1
  98. package/src/generateResolverFiles/fixExistingResolvers.d.ts +0 -2
  99. package/src/generateResolverFiles/fixExistingResolvers.js +0 -62
  100. package/src/generateResolverFiles/fixExistingResolvers.js.map +0 -1
  101. package/src/generateTypeDefsContent/generateTypeDefsContent.js.map +0 -1
  102. package/src/generateTypeDefsContent/index.d.ts +0 -1
  103. package/src/getPluginsConfig/getPluginsConfig.d.ts +0 -13
  104. package/src/getPluginsConfig/getPluginsConfig.js.map +0 -1
  105. package/src/getPluginsConfig/index.d.ts +0 -1
  106. package/src/getPluginsConfig/index.js.map +0 -1
  107. /package/src/{generateTypeDefsContent → generateTypeDefsFiles}/generateTypeDefsContent.d.ts +0 -0
  108. /package/src/{generateTypeDefsContent → generateTypeDefsFiles}/generateTypeDefsContent.js +0 -0
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
- const getPluginsConfig_1 = require("./getPluginsConfig");
12
+ const parseGraphQLSchema_1 = require("./parseGraphQLSchema");
10
13
  const generateResolverFiles_1 = require("./generateResolverFiles");
11
- const generateTypeDefsContent_1 = require("./generateTypeDefsContent");
14
+ const generateTypeDefsFiles_1 = require("./generateTypeDefsFiles");
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);
24
- const resolverTypesPath = path.join(baseOutputDir, relativeResolverTypesPathFromBaseOutputDir);
25
- const { sourceMap, mergedSDL } = (0, parseSources_1.parseSources)(sources);
26
- const typeMappersMap = (0, parseTypeMappers_1.parseTypeMappers)({
27
- sourceMap,
28
- resolverTypesPath,
29
- typeMappersFileExtension,
30
- typeMappersSuffix,
31
- });
29
+ const { resolverTypesPath: relativeResolverTypesPathFromBaseOutputDir, resolverRelativeTargetDir, mappersFileExtension: typeMappersFileExtension, mappersSuffix: typeMappersSuffix, resolverMainFile, resolverMainFileMode, typeDefsFilePath, typeDefsFileMode, mode, whitelistedModules, blacklistedModules, externalResolvers, typesPluginsConfig, tsMorphProjectOptions, fixObjectTypeResolvers, } = (0, validatePresetConfig_1.validatePresetConfig)(rawPresetConfig);
30
+ const resolverTypesPath = path.posix.join(baseOutputDir, relativeResolverTypesPathFromBaseOutputDir);
31
+ const { sourceMap } = (0, parseSources_1.parseSources)(sources);
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, parseGraphQLSchema_1.parseGraphQLSchema)({
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,47 +73,64 @@ 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) {
55
- const typeDefsFile = {
56
- filename: path.join(baseOutputDir, typeDefsFilePath),
57
- pluginMap: { add: addPlugin },
58
- plugins: [
59
- {
60
- add: { content: (0, generateTypeDefsContent_1.generateTypeDefsContent)({ mergedSDL }) },
61
- },
62
- ],
63
- config: {},
64
- schema,
65
- documents: [],
66
- };
67
- generatesSection.push(typeDefsFile);
83
+ const typeDefsFiles = yield profiler.run(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
84
+ return (0, generateTypeDefsFiles_1.generateTypeDefsFiles)({
85
+ baseOutputDir,
86
+ typeDefsFilePath,
87
+ typeDefsFileMode,
88
+ sourceMap,
89
+ whitelistedModules,
90
+ blacklistedModules,
91
+ });
92
+ }), createProfilerRunName('generateTypeDefsFiles'));
93
+ Object.entries(typeDefsFiles).forEach(([filename, meta]) => {
94
+ const typeDefsFile = {
95
+ filename: filename,
96
+ pluginMap: { add: addPlugin },
97
+ plugins: [{ add: { content: meta.content } }],
98
+ config: {},
99
+ schema,
100
+ documents: [],
101
+ };
102
+ generatesSection.push(typeDefsFile);
103
+ });
68
104
  }
69
105
  // resolver files
70
106
  const result = {
71
107
  files: {},
72
108
  externalImports: {},
73
109
  };
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
- });
110
+ yield profiler.run(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
111
+ return (0, generateResolverFiles_1.generateResolverFiles)({
112
+ config: {
113
+ schema: schemaAst,
114
+ sourceMap,
115
+ baseOutputDir,
116
+ resolverTypesPath,
117
+ resolverRelativeTargetDir,
118
+ resolverMainFile,
119
+ resolverMainFileMode,
120
+ graphQLObjectTypeResolversToGenerate,
121
+ tsMorph: {
122
+ project: tsMorphProject,
123
+ typesSourceFile,
124
+ },
125
+ fixObjectTypeResolvers,
126
+ mode,
127
+ whitelistedModules,
128
+ blacklistedModules,
129
+ externalResolvers: Object.assign(Object.assign({}, defaultScalarExternalResolvers), externalResolvers),
130
+ },
131
+ result,
132
+ });
133
+ }), createProfilerRunName('generateResolverFiles'));
89
134
  const resolverFilesGenerateOptions = Object.entries(result.files).map(([filename, { content }]) => ({
90
135
  filename,
91
136
  pluginMap: { add: addPlugin },
@@ -95,6 +140,7 @@ exports.preset = {
95
140
  documents: [],
96
141
  }));
97
142
  return [...resolverFilesGenerateOptions, ...generatesSection];
98
- },
143
+ }),
99
144
  };
145
+ const createProfilerRunName = (traceName) => `[${exports.presetName}]: ${traceName}`;
100
146
  //# 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;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,GACnB,GAAG,IAAA,2CAAoB,EAAC,e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,EAAE,SAAS,EAAE;gBAC7B,OAAO,EAAE;oBACP;wBACE,GAAG,EAAE,EAAE,OAAO,EAAE,IAAA,iDAAuB,EAAC,EAAE,SAAS,EAAE,CAAC,EAAE;qBACzD;iBACF;gBACD,MAAM,EAAE,EAAE;gBACV,MAAM;gBACN,SAAS,EAAE,EAAE;aACd,CAAC;YACF,gBAAgB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SACrC;QAED,iBAAiB;QACjB,MAAM,MAAM,GAA2C;YACrD,KAAK,EAAE,EAAE;YACT,eAAe,EAAE,EAAE;SACpB,CAAC;QACF,IAAA,6CAAqB,EAAC;YACpB,MAAM,EAAE;gBACN,MAAM,EAAE,SAAS;gBACjB,SAAS;gBACT,aAAa;gBACb,iBAAiB;gBACjB,yBAAyB;gBACzB,gBAAgB;gBAChB,IAAI;gBACJ,kBAAkB;gBAClB,kBAAkB;gBAClB,iBAAiB,kCACZ,8BAA8B,GAC9B,iBAAiB,CACrB;aACF;YACD,MAAM;SACP,CAAC,CAAC;QACH,MAAM,4BAA4B,GAChC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YAC7D,QAAQ;YACR,SAAS,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE;YAC7B,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC;YAC/B,MAAM,EAAE,EAAE;YACV,MAAM;YACN,SAAS,EAAE,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,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declare const cwd: () => string;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cwd = void 0;
4
+ const path = require("path");
5
+ /**
6
+ * It is process.cwd() but normalised for all OS
7
+ */
8
+ const cwd = () => {
9
+ return process.cwd().split(path.sep).join(path.posix.sep);
10
+ };
11
+ exports.cwd = cwd;
12
+ //# sourceMappingURL=cwd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cwd.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/utils/cwd.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAE7B;;GAEG;AACI,MAAM,GAAG,GAAG,GAAW,EAAE;IAC9B,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC5D,CAAC,CAAC;AAFW,QAAA,GAAG,OAEd"}
@@ -0,0 +1,9 @@
1
+ import { Node } from 'ts-morph';
2
+ export type NodePropertyMap = 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,57 @@
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
+ const properties = [];
32
+ collectTypeNodeProperties(typeNode, properties);
33
+ return properties;
34
+ }
35
+ return [];
36
+ };
37
+ const collectTypeNodeProperties = (typeNode, result) => {
38
+ if (ts_morph_1.Node.isTypeLiteral(typeNode)) {
39
+ typeNode.getProperties().forEach((prop) => {
40
+ result.push({ propertyName: prop.getName() });
41
+ });
42
+ }
43
+ else if (ts_morph_1.Node.isTypeReference(typeNode)) {
44
+ typeNode
45
+ .getType()
46
+ .getProperties()
47
+ .forEach((prop) => {
48
+ result.push({ propertyName: prop.getName() });
49
+ });
50
+ }
51
+ else if (ts_morph_1.Node.isIntersectionTypeNode(typeNode)) {
52
+ typeNode.getTypeNodes().forEach((typeNode) => {
53
+ collectTypeNodeProperties(typeNode, result); // May contain duplicated properties from different typeNodes. Will be deduped in getNodePropertyMap.
54
+ });
55
+ }
56
+ };
57
+ //# 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,uCAA2D;AAI3D;;;GAGG;AACI,MAAM,kBAAkB,GAAG,CAAC,IAAsB,EAAmB,EAAE;IAC5E,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,EAAE,CAAC;KACX;IAED,MAAM,UAAU,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAE3C,MAAM,eAAe,GAAG,UAAU,CAAC,MAAM,CACvC,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE;QACxB,GAAG,CAAC,YAAY,CAAC,GAAG;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,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;KACN;SAAM,IAAI,eAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,EAAE;QAChD,QAAQ,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YAC3C,yBAAyB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,qGAAqG;QACpJ,CAAC,CAAC,CAAC;KACJ;AACH,CAAC,CAAC"}
@@ -1,6 +1,9 @@
1
+ export * from './cwd';
1
2
  export * from './parseLocationForWhitelistedModule';
2
3
  export * from './isNativeNamedType';
3
4
  export * from './isRootObjectType';
5
+ export * from './isWhitelistedModule';
4
6
  export * from './printImportLine';
5
- export declare const relativeModulePath: (from: string, to: string) => string;
6
- export declare const normalizeRelativePath: (path: string) => string;
7
+ export * from './getNodePropertyMap';
8
+ export * from './normalizeRelativePath';
9
+ export * from './relativeModulePath';
@@ -1,24 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeRelativePath = exports.relativeModulePath = void 0;
4
3
  const tslib_1 = require("tslib");
5
- const path = require("path");
4
+ tslib_1.__exportStar(require("./cwd"), exports);
6
5
  tslib_1.__exportStar(require("./parseLocationForWhitelistedModule"), exports);
7
6
  tslib_1.__exportStar(require("./isNativeNamedType"), exports);
8
7
  tslib_1.__exportStar(require("./isRootObjectType"), exports);
8
+ tslib_1.__exportStar(require("./isWhitelistedModule"), exports);
9
9
  tslib_1.__exportStar(require("./printImportLine"), exports);
10
- // TODO: break the functions below this line into smaller files
11
- // -----------
12
- const relativeModulePath = (from, to) => {
13
- const rawPath = path.relative(from, to);
14
- return (0, exports.normalizeRelativePath)(rawPath);
15
- };
16
- exports.relativeModulePath = relativeModulePath;
17
- const normalizeRelativePath = (path) => {
18
- if (!path.startsWith('../') || !path.startsWith('./')) {
19
- return `./${path}`;
20
- }
21
- return path;
22
- };
23
- exports.normalizeRelativePath = normalizeRelativePath;
10
+ tslib_1.__exportStar(require("./getNodePropertyMap"), exports);
11
+ tslib_1.__exportStar(require("./normalizeRelativePath"), exports);
12
+ tslib_1.__exportStar(require("./relativeModulePath"), exports);
24
13
  //# sourceMappingURL=index.js.map
@@ -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,gDAAsB;AACtB,8EAAoD;AACpD,8DAAoC;AACpC,6DAAmC;AACnC,gEAAsC;AACtC,4DAAkC;AAClC,+DAAqC;AACrC,kEAAwC;AACxC,+DAAqC"}
@@ -1,2 +1,2 @@
1
- export declare type RootObjectType = 'Query' | 'Mutation' | 'Subscription';
1
+ export type RootObjectType = 'Query' | 'Mutation' | 'Subscription';
2
2
  export declare const isRootObjectType: (typeName: string) => typeName is RootObjectType;
@@ -0,0 +1,5 @@
1
+ export declare const isWhitelistedModule: ({ moduleName, whitelistedModules, blacklistedModules, }: {
2
+ moduleName: string;
3
+ whitelistedModules: string[];
4
+ blacklistedModules: string[];
5
+ }) => boolean;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isWhitelistedModule = void 0;
4
+ const isWhitelistedModule = ({ moduleName, whitelistedModules, blacklistedModules, }) => {
5
+ if (blacklistedModules.includes(moduleName)) {
6
+ return false;
7
+ }
8
+ const isInWhitelistedModule =
9
+ // whitelistedModules is empty a.k.a. all are whitelisted
10
+ whitelistedModules.length === 0
11
+ ? true
12
+ : whitelistedModules.includes(moduleName);
13
+ return isInWhitelistedModule;
14
+ };
15
+ exports.isWhitelistedModule = isWhitelistedModule;
16
+ //# sourceMappingURL=isWhitelistedModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isWhitelistedModule.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/utils/isWhitelistedModule.ts"],"names":[],"mappings":";;;AAAO,MAAM,mBAAmB,GAAG,CAAC,EAClC,UAAU,EACV,kBAAkB,EAClB,kBAAkB,GAKnB,EAAW,EAAE;IACZ,IAAI,kBAAkB,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;QAC3C,OAAO,KAAK,CAAC;KACd;IAED,MAAM,qBAAqB;IACzB,yDAAyD;IACzD,kBAAkB,CAAC,MAAM,KAAK,CAAC;QAC7B,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAE9C,OAAO,qBAAqB,CAAC;AAC/B,CAAC,CAAC;AApBW,QAAA,mBAAmB,uBAoB9B"}
@@ -0,0 +1 @@
1
+ export declare const normalizeRelativePath: (path: string) => string;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeRelativePath = void 0;
4
+ const normalizeRelativePath = (path) => {
5
+ if (!path.startsWith('../') || !path.startsWith('./')) {
6
+ return `./${path}`;
7
+ }
8
+ return path;
9
+ };
10
+ exports.normalizeRelativePath = normalizeRelativePath;
11
+ //# sourceMappingURL=normalizeRelativePath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeRelativePath.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/utils/normalizeRelativePath.ts"],"names":[],"mappings":";;;AAAO,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,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseLocationForWhitelistedModule = void 0;
4
+ const isWhitelistedModule_1 = require("./isWhitelistedModule");
4
5
  const parseLocationForWhitelistedModule = ({ location, sourceMap, whitelistedModules, blacklistedModules, }) => {
5
6
  if (!location) {
6
7
  throw new Error('Location is invalid');
@@ -10,15 +11,12 @@ const parseLocationForWhitelistedModule = ({ location, sourceMap, whitelistedMod
10
11
  if (!sourceFile) {
11
12
  throw new Error(`Unable to find ${sourceFilename} in sourceMap`);
12
13
  }
13
- if (blacklistedModules.includes(sourceFile.moduleName)) {
14
- return;
15
- }
16
- const isInWhitelistedModule =
17
- // whitelistedModules is empty a.k.a. all are whitelisted
18
- whitelistedModules.length === 0
19
- ? true
20
- : whitelistedModules.includes(sourceFile.moduleName);
21
- return isInWhitelistedModule ? sourceFile : undefined;
14
+ const isWhitelisted = (0, isWhitelistedModule_1.isWhitelistedModule)({
15
+ moduleName: sourceFile.moduleName,
16
+ whitelistedModules,
17
+ blacklistedModules,
18
+ });
19
+ return isWhitelisted ? sourceFile : undefined;
22
20
  };
23
21
  exports.parseLocationForWhitelistedModule = parseLocationForWhitelistedModule;
24
22
  //# sourceMappingURL=parseLocationForWhitelistedModule.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseLocationForWhitelistedModule.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/utils/parseLocationForWhitelistedModule.ts"],"names":[],"mappings":";;;AAUO,MAAM,iCAAiC,GAAG,CAAC,EAChD,QAAQ,EACR,SAAS,EACT,kBAAkB,EAClB,kBAAkB,GACgB,EAA4B,EAAE;IAChE,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;KACxC;IAED,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;IAC5C,MAAM,UAAU,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;IAC7C,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,IAAI,KAAK,CAAC,kBAAkB,cAAc,eAAe,CAAC,CAAC;KAClE;IAED,IAAI,kBAAkB,CAAC,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QACtD,OAAO;KACR;IAED,MAAM,qBAAqB;IACzB,yDAAyD;IACzD,kBAAkB,CAAC,MAAM,KAAK,CAAC;QAC7B,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAEzD,OAAO,qBAAqB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;AACxD,CAAC,CAAC;AA3BW,QAAA,iCAAiC,qCA2B5C"}
1
+ {"version":3,"file":"parseLocationForWhitelistedModule.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/utils/parseLocationForWhitelistedModule.ts"],"names":[],"mappings":";;;AAEA,+DAA4D;AASrD,MAAM,iCAAiC,GAAG,CAAC,EAChD,QAAQ,EACR,SAAS,EACT,kBAAkB,EAClB,kBAAkB,GACgB,EAA4B,EAAE;IAChE,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;KACxC;IAED,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;IAC5C,MAAM,UAAU,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;IAC7C,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,IAAI,KAAK,CAAC,kBAAkB,cAAc,eAAe,CAAC,CAAC;KAClE;IAED,MAAM,aAAa,GAAG,IAAA,yCAAmB,EAAC;QACxC,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,kBAAkB;QAClB,kBAAkB;KACnB,CAAC,CAAC;IAEH,OAAO,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;AAChD,CAAC,CAAC;AAvBW,QAAA,iCAAiC,qCAuB5C"}
@@ -0,0 +1 @@
1
+ export declare const relativeModulePath: (from: string, to: string) => string;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.relativeModulePath = void 0;
4
+ const path = require("path");
5
+ const normalizeRelativePath_1 = require("./normalizeRelativePath");
6
+ const relativeModulePath = (from, to) => {
7
+ const rawPath = path.posix.relative(from, to);
8
+ return (0, normalizeRelativePath_1.normalizeRelativePath)(rawPath);
9
+ };
10
+ exports.relativeModulePath = relativeModulePath;
11
+ //# sourceMappingURL=relativeModulePath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relativeModulePath.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/utils/relativeModulePath.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,mEAAgE;AAEzD,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,EAAU,EAAU,EAAE;IACrE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC9C,OAAO,IAAA,6CAAqB,EAAC,OAAO,CAAC,CAAC;AACxC,CAAC,CAAC;AAHW,QAAA,kBAAkB,sBAG7B"}
@@ -1,26 +1,37 @@
1
1
  import * as typeScriptPlugin from '@graphql-codegen/typescript';
2
2
  import * as typeScriptResolversPlugin from '@graphql-codegen/typescript-resolvers';
3
- declare type ParsedTypesPluginsConfig = Omit<typeScriptPlugin.TypeScriptPluginConfig, 'scalars'> & Omit<typeScriptResolversPlugin.TypeScriptResolversPluginConfig, 'scalars'> & {
3
+ import type { ProjectOptions } from 'ts-morph';
4
+ type ParsedTypesPluginsConfig = Omit<typeScriptPlugin.TypeScriptPluginConfig, 'scalars'> & Omit<typeScriptResolversPlugin.TypeScriptResolversPluginConfig, 'scalars'> & {
4
5
  scalars: Record<string, string>;
5
6
  };
6
- interface ParsedPresetConfig {
7
+ type ConfigMode = 'merged' | 'modules';
8
+ type ResolverMainFileMode = 'merged' | 'modules';
9
+ export type TypeDefsFileMode = 'merged' | 'mergedWhitelisted' | 'modules';
10
+ type FixObjectTypeResolvers = 'smart' | 'disabled';
11
+ export interface ParsedPresetConfig {
7
12
  resolverTypesPath: string;
8
13
  resolverRelativeTargetDir: string;
9
14
  resolverMainFile: string;
15
+ resolverMainFileMode: ResolverMainFileMode;
10
16
  typeDefsFilePath: string | false;
17
+ typeDefsFileMode: TypeDefsFileMode;
11
18
  mappersFileExtension: string;
12
19
  mappersSuffix: string;
13
- mode: 'merged' | 'modules';
20
+ mode: ConfigMode;
14
21
  whitelistedModules: string[];
15
22
  blacklistedModules: string[];
16
23
  externalResolvers: Record<string, string>;
17
24
  typesPluginsConfig: ParsedTypesPluginsConfig;
25
+ tsMorphProjectOptions: ProjectOptions;
26
+ fixObjectTypeResolvers: FixObjectTypeResolvers;
18
27
  }
19
28
  export interface RawPresetConfig {
20
29
  resolverTypesPath?: string;
21
30
  resolverRelativeTargetDir?: string;
22
31
  resolverMainFile?: string;
32
+ resolverMainFileMode?: string;
23
33
  typeDefsFilePath?: string | boolean;
34
+ typeDefsFileMode?: string;
24
35
  mappersFileExtension?: string;
25
36
  mappersSuffix?: string;
26
37
  mode?: string;
@@ -28,6 +39,14 @@ export interface RawPresetConfig {
28
39
  blacklistedModules?: string[];
29
40
  externalResolvers?: Record<string, string>;
30
41
  typesPluginsConfig?: typeScriptPlugin.TypeScriptPluginConfig & typeScriptResolversPlugin.TypeScriptResolversPluginConfig;
42
+ tsConfigFilePath?: string;
43
+ fixObjectTypeResolvers?: string;
31
44
  }
32
- export declare const validatePresetConfig: ({ resolverTypesPath, resolverRelativeTargetDir, resolverMainFile, typeDefsFilePath, mappersFileExtension, mappersSuffix, mode, whitelistedModules, blacklistedModules, externalResolvers, typesPluginsConfig, }: RawPresetConfig) => ParsedPresetConfig;
45
+ export interface TypedPresetConfig extends RawPresetConfig {
46
+ mode?: ConfigMode;
47
+ resolverMainFileMode?: ResolverMainFileMode;
48
+ typeDefsFileMode?: TypeDefsFileMode;
49
+ fixObjectTypeResolvers?: FixObjectTypeResolvers;
50
+ }
51
+ export declare const validatePresetConfig: ({ resolverTypesPath, resolverRelativeTargetDir, resolverMainFile, resolverMainFileMode, typeDefsFilePath, typeDefsFileMode: inputTypeDefsFileMode, mappersFileExtension, mappersSuffix, mode, whitelistedModules, blacklistedModules, externalResolvers, typesPluginsConfig, tsConfigFilePath, fixObjectTypeResolvers, }: RawPresetConfig) => ParsedPresetConfig;
33
52
  export {};