@gqlkit-ts/cli 0.6.0 → 0.7.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 (190) hide show
  1. package/dist/auto-type-generator/auto-type-generator.d.ts +7 -0
  2. package/dist/auto-type-generator/auto-type-generator.d.ts.map +1 -1
  3. package/dist/auto-type-generator/auto-type-generator.js +375 -55
  4. package/dist/auto-type-generator/auto-type-generator.js.map +1 -1
  5. package/dist/auto-type-generator/discriminator-field-validator.d.ts +26 -0
  6. package/dist/auto-type-generator/discriminator-field-validator.d.ts.map +1 -0
  7. package/dist/auto-type-generator/discriminator-field-validator.js +242 -0
  8. package/dist/auto-type-generator/discriminator-field-validator.js.map +1 -0
  9. package/dist/auto-type-generator/discriminator-naming.d.ts +11 -0
  10. package/dist/auto-type-generator/discriminator-naming.d.ts.map +1 -0
  11. package/dist/auto-type-generator/discriminator-naming.js +15 -0
  12. package/dist/auto-type-generator/discriminator-naming.js.map +1 -0
  13. package/dist/auto-type-generator/discriminator-resolve-type-generator.d.ts +44 -0
  14. package/dist/auto-type-generator/discriminator-resolve-type-generator.d.ts.map +1 -0
  15. package/dist/auto-type-generator/discriminator-resolve-type-generator.js +77 -0
  16. package/dist/auto-type-generator/discriminator-resolve-type-generator.js.map +1 -0
  17. package/dist/auto-type-generator/index.d.ts +3 -0
  18. package/dist/auto-type-generator/index.d.ts.map +1 -1
  19. package/dist/auto-type-generator/index.js +3 -0
  20. package/dist/auto-type-generator/index.js.map +1 -1
  21. package/dist/auto-type-generator/inline-enum-collector.d.ts.map +1 -1
  22. package/dist/auto-type-generator/inline-enum-collector.js +14 -7
  23. package/dist/auto-type-generator/inline-enum-collector.js.map +1 -1
  24. package/dist/auto-type-generator/inline-object-converter.d.ts +12 -0
  25. package/dist/auto-type-generator/inline-object-converter.d.ts.map +1 -0
  26. package/dist/auto-type-generator/inline-object-converter.js +72 -0
  27. package/dist/auto-type-generator/inline-object-converter.js.map +1 -0
  28. package/dist/auto-type-generator/inline-object-traverser.d.ts +2 -1
  29. package/dist/auto-type-generator/inline-object-traverser.d.ts.map +1 -1
  30. package/dist/auto-type-generator/inline-object-traverser.js +22 -4
  31. package/dist/auto-type-generator/inline-object-traverser.js.map +1 -1
  32. package/dist/auto-type-generator/inline-union-collector.d.ts.map +1 -1
  33. package/dist/auto-type-generator/inline-union-collector.js +20 -6
  34. package/dist/auto-type-generator/inline-union-collector.js.map +1 -1
  35. package/dist/auto-type-generator/inline-union-types.d.ts +2 -0
  36. package/dist/auto-type-generator/inline-union-types.d.ts.map +1 -1
  37. package/dist/auto-type-generator/inline-union-validator.js +3 -3
  38. package/dist/auto-type-generator/inline-union-validator.js.map +1 -1
  39. package/dist/auto-type-generator/intersection-flattener.d.ts +44 -0
  40. package/dist/auto-type-generator/intersection-flattener.d.ts.map +1 -0
  41. package/dist/auto-type-generator/intersection-flattener.js +398 -0
  42. package/dist/auto-type-generator/intersection-flattener.js.map +1 -0
  43. package/dist/auto-type-generator/naming-convention.d.ts +21 -0
  44. package/dist/auto-type-generator/naming-convention.d.ts.map +1 -1
  45. package/dist/auto-type-generator/naming-convention.js +145 -1
  46. package/dist/auto-type-generator/naming-convention.js.map +1 -1
  47. package/dist/auto-type-generator/typename-extractor.d.ts +2 -0
  48. package/dist/auto-type-generator/typename-extractor.d.ts.map +1 -1
  49. package/dist/auto-type-generator/typename-extractor.js +11 -3
  50. package/dist/auto-type-generator/typename-extractor.js.map +1 -1
  51. package/dist/auto-type-generator/typename-resolve-type-generator.d.ts +2 -0
  52. package/dist/auto-type-generator/typename-resolve-type-generator.d.ts.map +1 -1
  53. package/dist/auto-type-generator/typename-resolve-type-generator.js +12 -84
  54. package/dist/auto-type-generator/typename-resolve-type-generator.js.map +1 -1
  55. package/dist/auto-type-generator/typename-types.d.ts +4 -0
  56. package/dist/auto-type-generator/typename-types.d.ts.map +1 -1
  57. package/dist/auto-type-generator/typename-types.js +6 -0
  58. package/dist/auto-type-generator/typename-types.js.map +1 -1
  59. package/dist/auto-type-generator/typename-validator.d.ts.map +1 -1
  60. package/dist/auto-type-generator/typename-validator.js +4 -3
  61. package/dist/auto-type-generator/typename-validator.js.map +1 -1
  62. package/dist/commands/gen.d.ts.map +1 -1
  63. package/dist/commands/gen.js +2 -1
  64. package/dist/commands/gen.js.map +1 -1
  65. package/dist/config/types.d.ts +7 -0
  66. package/dist/config/types.d.ts.map +1 -1
  67. package/dist/config-loader/index.d.ts +1 -1
  68. package/dist/config-loader/index.d.ts.map +1 -1
  69. package/dist/config-loader/index.js.map +1 -1
  70. package/dist/config-loader/loader.d.ts +6 -0
  71. package/dist/config-loader/loader.d.ts.map +1 -1
  72. package/dist/config-loader/loader.js +1 -0
  73. package/dist/config-loader/loader.js.map +1 -1
  74. package/dist/config-loader/validator.d.ts.map +1 -1
  75. package/dist/config-loader/validator.js +84 -1
  76. package/dist/config-loader/validator.js.map +1 -1
  77. package/dist/gen-orchestrator/orchestrator.d.ts +2 -1
  78. package/dist/gen-orchestrator/orchestrator.d.ts.map +1 -1
  79. package/dist/gen-orchestrator/orchestrator.js +15 -2
  80. package/dist/gen-orchestrator/orchestrator.js.map +1 -1
  81. package/dist/resolver-extractor/extractor/define-api-extractor.d.ts.map +1 -1
  82. package/dist/resolver-extractor/extractor/define-api-extractor.js +4 -0
  83. package/dist/resolver-extractor/extractor/define-api-extractor.js.map +1 -1
  84. package/dist/resolver-extractor/validator/abstract-resolver-validator.d.ts +2 -0
  85. package/dist/resolver-extractor/validator/abstract-resolver-validator.d.ts.map +1 -1
  86. package/dist/resolver-extractor/validator/abstract-resolver-validator.js +16 -3
  87. package/dist/resolver-extractor/validator/abstract-resolver-validator.js.map +1 -1
  88. package/dist/schema-generator/emitter/code-emitter.d.ts.map +1 -1
  89. package/dist/schema-generator/emitter/code-emitter.js +13 -1
  90. package/dist/schema-generator/emitter/code-emitter.js.map +1 -1
  91. package/dist/schema-generator/emitter/discriminator-resolve-type-emitter.d.ts +18 -0
  92. package/dist/schema-generator/emitter/discriminator-resolve-type-emitter.d.ts.map +1 -0
  93. package/dist/schema-generator/emitter/discriminator-resolve-type-emitter.js +89 -0
  94. package/dist/schema-generator/emitter/discriminator-resolve-type-emitter.js.map +1 -0
  95. package/dist/schema-generator/generate-schema.d.ts +2 -0
  96. package/dist/schema-generator/generate-schema.d.ts.map +1 -1
  97. package/dist/schema-generator/generate-schema.js +69 -10
  98. package/dist/schema-generator/generate-schema.js.map +1 -1
  99. package/dist/schema-generator/integrator/result-integrator.d.ts +4 -0
  100. package/dist/schema-generator/integrator/result-integrator.d.ts.map +1 -1
  101. package/dist/schema-generator/integrator/result-integrator.js +18 -2
  102. package/dist/schema-generator/integrator/result-integrator.js.map +1 -1
  103. package/dist/schema-generator/resolver-collector/resolver-collector.d.ts +2 -0
  104. package/dist/schema-generator/resolver-collector/resolver-collector.d.ts.map +1 -1
  105. package/dist/schema-generator/resolver-collector/resolver-collector.js +4 -0
  106. package/dist/schema-generator/resolver-collector/resolver-collector.js.map +1 -1
  107. package/dist/shared/constants.d.ts.map +1 -1
  108. package/dist/shared/constants.js +14 -1
  109. package/dist/shared/constants.js.map +1 -1
  110. package/dist/shared/enum-prefix-detector.d.ts.map +1 -1
  111. package/dist/shared/enum-prefix-detector.js +78 -8
  112. package/dist/shared/enum-prefix-detector.js.map +1 -1
  113. package/dist/shared/inline-object-utils.js +1 -1
  114. package/dist/shared/inline-object-utils.js.map +1 -1
  115. package/dist/shared/type-converter.d.ts.map +1 -1
  116. package/dist/shared/type-converter.js +55 -0
  117. package/dist/shared/type-converter.js.map +1 -1
  118. package/dist/type-extractor/converter/graphql-converter.d.ts.map +1 -1
  119. package/dist/type-extractor/converter/graphql-converter.js +11 -1
  120. package/dist/type-extractor/converter/graphql-converter.js.map +1 -1
  121. package/dist/type-extractor/extractor/field-type-resolver.d.ts +18 -0
  122. package/dist/type-extractor/extractor/field-type-resolver.d.ts.map +1 -1
  123. package/dist/type-extractor/extractor/field-type-resolver.js +198 -15
  124. package/dist/type-extractor/extractor/field-type-resolver.js.map +1 -1
  125. package/dist/type-extractor/extractor/type-extractor.d.ts +1 -0
  126. package/dist/type-extractor/extractor/type-extractor.d.ts.map +1 -1
  127. package/dist/type-extractor/extractor/type-extractor.js +100 -9
  128. package/dist/type-extractor/extractor/type-extractor.js.map +1 -1
  129. package/dist/type-extractor/types/diagnostics.d.ts +1 -1
  130. package/dist/type-extractor/types/diagnostics.d.ts.map +1 -1
  131. package/dist/type-extractor/types/index.d.ts +1 -1
  132. package/dist/type-extractor/types/index.d.ts.map +1 -1
  133. package/dist/type-extractor/types/index.js +1 -1
  134. package/dist/type-extractor/types/index.js.map +1 -1
  135. package/dist/type-extractor/types/ts-type-reference-factory.d.ts +7 -1
  136. package/dist/type-extractor/types/ts-type-reference-factory.d.ts.map +1 -1
  137. package/dist/type-extractor/types/ts-type-reference-factory.js +18 -3
  138. package/dist/type-extractor/types/ts-type-reference-factory.js.map +1 -1
  139. package/dist/type-extractor/types/typescript.d.ts +3 -1
  140. package/dist/type-extractor/types/typescript.d.ts.map +1 -1
  141. package/dist/type-extractor/validator/type-validator.d.ts.map +1 -1
  142. package/dist/type-extractor/validator/type-validator.js +6 -1
  143. package/dist/type-extractor/validator/type-validator.js.map +1 -1
  144. package/docs/configuration.md +19 -0
  145. package/docs/index.md +1 -0
  146. package/docs/integration/ai-sdk.md +189 -0
  147. package/docs/schema/unions.md +117 -0
  148. package/package.json +2 -2
  149. package/src/auto-type-generator/auto-type-generator.ts +576 -58
  150. package/src/auto-type-generator/discriminator-field-validator.ts +368 -0
  151. package/src/auto-type-generator/discriminator-naming.ts +24 -0
  152. package/src/auto-type-generator/discriminator-resolve-type-generator.ts +136 -0
  153. package/src/auto-type-generator/index.ts +17 -0
  154. package/src/auto-type-generator/inline-enum-collector.ts +19 -4
  155. package/src/auto-type-generator/inline-object-converter.ts +100 -0
  156. package/src/auto-type-generator/inline-object-traverser.ts +33 -7
  157. package/src/auto-type-generator/inline-union-collector.ts +26 -4
  158. package/src/auto-type-generator/inline-union-types.ts +2 -0
  159. package/src/auto-type-generator/inline-union-validator.ts +3 -3
  160. package/src/auto-type-generator/intersection-flattener.ts +554 -0
  161. package/src/auto-type-generator/naming-convention.ts +205 -1
  162. package/src/auto-type-generator/typename-extractor.ts +17 -3
  163. package/src/auto-type-generator/typename-resolve-type-generator.ts +19 -108
  164. package/src/auto-type-generator/typename-types.ts +7 -0
  165. package/src/auto-type-generator/typename-validator.ts +4 -3
  166. package/src/commands/gen.ts +9 -2
  167. package/src/config/types.ts +10 -0
  168. package/src/config-loader/index.ts +1 -0
  169. package/src/config-loader/loader.ts +11 -0
  170. package/src/config-loader/validator.ts +100 -1
  171. package/src/gen-orchestrator/orchestrator.ts +19 -2
  172. package/src/resolver-extractor/extractor/define-api-extractor.ts +4 -0
  173. package/src/resolver-extractor/validator/abstract-resolver-validator.ts +20 -6
  174. package/src/schema-generator/emitter/code-emitter.ts +26 -1
  175. package/src/schema-generator/emitter/discriminator-resolve-type-emitter.ts +125 -0
  176. package/src/schema-generator/generate-schema.ts +100 -13
  177. package/src/schema-generator/integrator/result-integrator.ts +25 -1
  178. package/src/schema-generator/resolver-collector/resolver-collector.ts +7 -0
  179. package/src/shared/constants.ts +15 -1
  180. package/src/shared/enum-prefix-detector.ts +96 -8
  181. package/src/shared/inline-object-utils.ts +1 -1
  182. package/src/shared/type-converter.ts +63 -0
  183. package/src/type-extractor/converter/graphql-converter.ts +17 -1
  184. package/src/type-extractor/extractor/field-type-resolver.ts +241 -16
  185. package/src/type-extractor/extractor/type-extractor.ts +119 -5
  186. package/src/type-extractor/types/diagnostics.ts +10 -1
  187. package/src/type-extractor/types/index.ts +2 -1
  188. package/src/type-extractor/types/ts-type-reference-factory.ts +24 -3
  189. package/src/type-extractor/types/typescript.ts +6 -2
  190. package/src/type-extractor/validator/type-validator.ts +6 -1
@@ -1,7 +1,9 @@
1
+ import type { ResolvedDiscriminatorFieldsMap } from "../config-loader/index.js";
1
2
  import type { ExtractResolversResult } from "../resolver-extractor/index.js";
2
3
  import type { DirectiveArgumentValue, DirectiveInfo } from "../shared/directive-detector.js";
3
4
  import type { DeprecationInfo } from "../shared/tsdoc-parser.js";
4
5
  import { type Diagnostic, type ExtractedTypeInfo, type GraphQLFieldType, type SourceLocation } from "../type-extractor/types/index.js";
6
+ import { type InlineDiscriminatorResolveType } from "./intersection-flattener.js";
5
7
  import type { ResolveTypeFieldPattern } from "./resolve-type-generator.js";
6
8
  /**
7
9
  * Information about where an auto-generated type was generated from.
@@ -57,12 +59,17 @@ export interface AutoTypeGeneratorInput {
57
59
  readonly extractedTypes: ReadonlyArray<ExtractedTypeInfo>;
58
60
  readonly resolversResult: ExtractResolversResult;
59
61
  readonly knownTypeNames: ReadonlySet<string>;
62
+ readonly discriminatorFields: ResolvedDiscriminatorFieldsMap;
60
63
  }
61
64
  export interface AutoTypeGeneratorResult {
62
65
  readonly autoGeneratedTypes: ReadonlyArray<AutoGeneratedType>;
63
66
  readonly updatedExtractedTypes: ReadonlyArray<ExtractedTypeInfo>;
64
67
  readonly updatedResolversResult: ExtractResolversResult;
65
68
  readonly diagnostics: ReadonlyArray<Diagnostic>;
69
+ /** Mapping from TypeScript type alias names to auto-generated GraphQL union names */
70
+ readonly tsAliasToGraphQLNameMap: ReadonlyMap<string, string>;
71
+ /** Discriminator resolveType info for inline unions that were flattened by discriminator fields */
72
+ readonly inlineDiscriminatorResolveTypes: ReadonlyArray<InlineDiscriminatorResolveType>;
66
73
  }
67
74
  export declare function generateAutoTypes(input: AutoTypeGeneratorInput): AutoTypeGeneratorResult;
68
75
  //# sourceMappingURL=auto-type-generator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auto-type-generator.d.ts","sourceRoot":"","sources":["../../src/auto-type-generator/auto-type-generator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EAEvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EACV,sBAAsB,EACtB,aAAa,EACd,MAAM,iCAAiC,CA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,iBAAiB,CAAC,CAAC;IAC9D,QAAQ,CAAC,qBAAqB,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IACjE,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IACxD,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IAChD,qFAAqF;IACrF,QAAQ,CAAC,uBAAuB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9D,mGAAmG;IACnG,QAAQ,CAAC,+BAA+B,EAAE,aAAa,CAAC,8BAA8B,CAAC,CAAC;CACzF;AAw1DD,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,sBAAsB,GAC5B,uBAAuB,CAyIzB"}
@@ -7,32 +7,60 @@ import { createReferenceType, } from "../type-extractor/types/index.js";
7
7
  import { collectInlineEnumsFromPayloads, collectInlineEnumsFromResolvers, collectInlineEnumsFromTypes, } from "./inline-enum-collector.js";
8
8
  import { collectInlineUnionsFromPayloads, collectInlineUnionsFromResolvers, collectInlineUnionsFromTypes, } from "./inline-union-collector.js";
9
9
  import { validateOneOfMembers, validateUnionMembers, validateUnionMemberTypenames, } from "./inline-union-validator.js";
10
- import { buildFieldContext, generateAutoTypeName, isInputTypeName, } from "./naming-convention.js";
10
+ import { flattenInlineUnionMembers, } from "./intersection-flattener.js";
11
+ import { appendFieldPath, buildFieldContext, generateAutoTypeName, isInputTypeName, } from "./naming-convention.js";
11
12
  import { forEachResolverField, } from "./resolver-field-iterator.js";
12
- import { createFieldNameSet, findTypenameProperty, } from "./typename-types.js";
13
+ import { createFieldNameSet, findTypenameProperty, isTypenameFieldName, } from "./typename-types.js";
14
+ function getInlineObjectTypeInfo(tsType) {
15
+ if (tsType.kind === "inlineObject" && tsType.inlineObjectProperties) {
16
+ return {
17
+ properties: tsType.inlineObjectProperties,
18
+ nullable: tsType.nullable,
19
+ description: tsType.inlineObjectDescription,
20
+ deprecated: tsType.inlineObjectDeprecated,
21
+ };
22
+ }
23
+ if (tsType.kind === "array" &&
24
+ tsType.elementType?.kind === "inlineObject" &&
25
+ tsType.elementType.inlineObjectProperties) {
26
+ return {
27
+ properties: tsType.elementType.inlineObjectProperties,
28
+ nullable: tsType.elementType.nullable,
29
+ description: tsType.elementType.inlineObjectDescription,
30
+ deprecated: tsType.elementType.inlineObjectDeprecated,
31
+ };
32
+ }
33
+ return null;
34
+ }
13
35
  function extractNestedInlineObjectsRecursively(params) {
14
36
  const { properties, currentPath, sourceLocation, buildContext, preserveDocumentation, results, } = params;
37
+ const siblingFieldNames = new Set(properties.map((prop) => prop.name));
15
38
  for (const prop of properties) {
16
- if (prop.tsType.kind === "inlineObject" &&
17
- prop.tsType.inlineObjectProperties) {
18
- const nestedPath = [...currentPath, prop.name];
39
+ const inlineObjectTypeInfo = getInlineObjectTypeInfo(prop.tsType);
40
+ if (inlineObjectTypeInfo) {
41
+ const nestedPath = appendFieldPath({
42
+ parentPath: currentPath,
43
+ fieldName: prop.name,
44
+ singularize: prop.tsType.kind === "array",
45
+ siblingFieldNames,
46
+ });
19
47
  const nestedContext = buildContext(nestedPath);
20
48
  // Use property's source location if available for more accurate diagnostics
21
49
  const nestedSourceLocation = prop.sourceLocation ?? sourceLocation;
22
50
  results.push({
23
- properties: prop.tsType.inlineObjectProperties,
51
+ properties: inlineObjectTypeInfo.properties,
24
52
  context: nestedContext,
25
53
  sourceLocation: nestedSourceLocation,
26
- nullable: prop.tsType.nullable,
54
+ nullable: inlineObjectTypeInfo.nullable,
27
55
  description: preserveDocumentation
28
- ? prop.tsType.inlineObjectDescription
56
+ ? inlineObjectTypeInfo.description
29
57
  : null,
30
58
  deprecated: preserveDocumentation
31
- ? prop.tsType.inlineObjectDeprecated
59
+ ? inlineObjectTypeInfo.deprecated
32
60
  : null,
33
61
  });
34
62
  extractNestedInlineObjectsRecursively({
35
- properties: prop.tsType.inlineObjectProperties,
63
+ properties: inlineObjectTypeInfo.properties,
36
64
  currentPath: nestedPath,
37
65
  sourceLocation: nestedSourceLocation,
38
66
  buildContext,
@@ -79,6 +107,7 @@ function buildGeneratedFromInfo(context) {
79
107
  function collectInlineObjectsFromType(typeInfo) {
80
108
  const results = [];
81
109
  const isInput = isInputTypeName(typeInfo.metadata.name);
110
+ const siblingFieldNames = new Set(typeInfo.fields.map((field) => field.name));
82
111
  for (const field of typeInfo.fields) {
83
112
  collectInlineObjectsFromField({
84
113
  field,
@@ -86,18 +115,24 @@ function collectInlineObjectsFromType(typeInfo) {
86
115
  parentPath: [],
87
116
  isInput,
88
117
  sourceFile: typeInfo.metadata.sourceFile,
118
+ siblingFieldNames,
89
119
  results,
90
120
  });
91
121
  }
92
122
  return results;
93
123
  }
94
124
  function collectInlineObjectsFromField(params) {
95
- const { field, parentTypeName, parentPath, isInput, sourceFile, results } = params;
96
- const tsType = field.tsType;
97
- if (tsType.kind !== "inlineObject" || !tsType.inlineObjectProperties) {
125
+ const { field, parentTypeName, parentPath, isInput, sourceFile, siblingFieldNames, results, } = params;
126
+ const inlineObjectTypeInfo = getInlineObjectTypeInfo(field.tsType);
127
+ if (!inlineObjectTypeInfo) {
98
128
  return;
99
129
  }
100
- const fieldPath = [...parentPath, field.name];
130
+ const fieldPath = appendFieldPath({
131
+ parentPath,
132
+ fieldName: field.name,
133
+ singularize: field.tsType.kind === "array",
134
+ siblingFieldNames,
135
+ });
101
136
  const context = isInput
102
137
  ? {
103
138
  kind: "inputField",
@@ -111,15 +146,15 @@ function collectInlineObjectsFromField(params) {
111
146
  };
112
147
  const sourceLocation = getSourceLocationOrDefault(field.sourceLocation, sourceFile);
113
148
  results.push({
114
- properties: tsType.inlineObjectProperties,
149
+ properties: inlineObjectTypeInfo.properties,
115
150
  context,
116
151
  sourceLocation,
117
- nullable: tsType.nullable,
118
- description: tsType.inlineObjectDescription,
119
- deprecated: tsType.inlineObjectDeprecated,
152
+ nullable: inlineObjectTypeInfo.nullable,
153
+ description: inlineObjectTypeInfo.description,
154
+ deprecated: inlineObjectTypeInfo.deprecated,
120
155
  });
121
156
  extractNestedInlineObjectsRecursively({
122
- properties: tsType.inlineObjectProperties,
157
+ properties: inlineObjectTypeInfo.properties,
123
158
  currentPath: fieldPath,
124
159
  sourceLocation,
125
160
  buildContext: (nestedPath) => isInput
@@ -222,7 +257,12 @@ function generateAutoType(params) {
222
257
  inlineObj.context.kind === "resolverArg";
223
258
  const fields = [];
224
259
  const diagnostics = [];
260
+ const siblingFieldNames = new Set(inlineObj.properties.map((prop) => prop.name));
225
261
  for (const prop of inlineObj.properties) {
262
+ // Typename discrimination fields are silently excluded from the schema
263
+ if (isTypenameFieldName(prop.name)) {
264
+ continue;
265
+ }
226
266
  const eligibility = isEligibleField({
227
267
  fieldName: prop.name,
228
268
  kind: isInput ? "input" : "object",
@@ -242,7 +282,12 @@ function generateAutoType(params) {
242
282
  enumTypeNames,
243
283
  unionTypeNames,
244
284
  parentContext: inlineObj.context,
285
+ siblingFieldNames,
245
286
  });
287
+ // Skip fields with never type — they represent impossible values
288
+ if (fieldType.typeName === "__NEVER__") {
289
+ continue;
290
+ }
246
291
  fields.push({
247
292
  name: prop.name,
248
293
  type: fieldType,
@@ -268,8 +313,13 @@ function generateAutoType(params) {
268
313
  diagnostics,
269
314
  };
270
315
  }
271
- function tryResolveNestedType(prop, parentContext, typeNamesMap) {
272
- const nestedPath = [...parentContext.fieldPath, prop.name];
316
+ function tryResolveNestedType(prop, parentContext, typeNamesMap, siblingFieldNames) {
317
+ const nestedPath = appendFieldPath({
318
+ parentPath: parentContext.fieldPath,
319
+ fieldName: prop.name,
320
+ singularize: prop.tsType.kind === "array",
321
+ siblingFieldNames,
322
+ });
273
323
  const nestedContext = {
274
324
  ...parentContext,
275
325
  fieldPath: nestedPath,
@@ -278,29 +328,36 @@ function tryResolveNestedType(prop, parentContext, typeNamesMap) {
278
328
  const resolvedTypeName = typeNamesMap.get(contextKey);
279
329
  if (resolvedTypeName) {
280
330
  return {
331
+ ...convertTsTypeToGraphQLType(prop.tsType, prop.optional),
281
332
  typeName: resolvedTypeName,
282
- nullable: prop.tsType.nullable || prop.optional,
283
- list: false,
284
- listItemNullable: null,
285
333
  };
286
334
  }
287
335
  return null;
288
336
  }
289
337
  function resolveFieldType(params) {
290
- const { prop, generatedTypeNames, enumTypeNames, unionTypeNames, parentContext, } = params;
291
- if (prop.tsType.kind === "inlineObject" &&
292
- prop.tsType.inlineObjectProperties) {
293
- const result = tryResolveNestedType(prop, parentContext, generatedTypeNames);
338
+ const { prop, generatedTypeNames, enumTypeNames, unionTypeNames, parentContext, siblingFieldNames, } = params;
339
+ if ((prop.tsType.kind === "inlineObject" &&
340
+ prop.tsType.inlineObjectProperties) ||
341
+ (prop.tsType.kind === "array" &&
342
+ prop.tsType.elementType?.kind === "inlineObject" &&
343
+ prop.tsType.elementType.inlineObjectProperties)) {
344
+ const result = tryResolveNestedType(prop, parentContext, generatedTypeNames, siblingFieldNames);
294
345
  if (result)
295
346
  return result;
296
347
  }
297
- if (prop.tsType.kind === "inlineEnum" && prop.tsType.inlineEnumMembers) {
298
- const result = tryResolveNestedType(prop, parentContext, enumTypeNames);
348
+ if ((prop.tsType.kind === "inlineEnum" && prop.tsType.inlineEnumMembers) ||
349
+ (prop.tsType.kind === "array" &&
350
+ prop.tsType.elementType?.kind === "inlineEnum" &&
351
+ prop.tsType.elementType.inlineEnumMembers)) {
352
+ const result = tryResolveNestedType(prop, parentContext, enumTypeNames, siblingFieldNames);
299
353
  if (result)
300
354
  return result;
301
355
  }
302
- if (prop.tsType.kind === "union" && prop.tsType.members) {
303
- const result = tryResolveNestedType(prop, parentContext, unionTypeNames);
356
+ if ((prop.tsType.kind === "union" && prop.tsType.members) ||
357
+ (prop.tsType.kind === "array" &&
358
+ prop.tsType.elementType?.kind === "union" &&
359
+ prop.tsType.elementType.members)) {
360
+ const result = tryResolveNestedType(prop, parentContext, unionTypeNames, siblingFieldNames);
304
361
  if (result)
305
362
  return result;
306
363
  }
@@ -309,15 +366,21 @@ function resolveFieldType(params) {
309
366
  function updateExtractedTypes(extractedTypes, params) {
310
367
  return extractedTypes.map((typeInfo) => {
311
368
  const isInput = isInputTypeName(typeInfo.metadata.name);
369
+ const siblingFieldNames = new Set(typeInfo.fields.map((field) => field.name));
312
370
  return {
313
371
  ...typeInfo,
314
- fields: typeInfo.fields.map((field) => updateField(field, params, typeInfo.metadata.name, isInput)),
372
+ fields: typeInfo.fields.map((field) => updateField(field, params, typeInfo.metadata.name, isInput, siblingFieldNames)),
315
373
  };
316
374
  });
317
375
  }
318
- function updateField(field, params, parentTypeName, isInput) {
376
+ function updateField(field, params, parentTypeName, isInput, siblingFieldNames) {
319
377
  const { generatedTypeNames, enumTypeNames, unionTypeNames } = params;
320
- const context = buildFieldContext(parentTypeName, [field.name], isInput);
378
+ const context = buildFieldContext(parentTypeName, appendFieldPath({
379
+ parentPath: [],
380
+ fieldName: field.name,
381
+ singularize: field.tsType.kind === "array",
382
+ siblingFieldNames,
383
+ }), isInput);
321
384
  const contextKey = getContextKey(context);
322
385
  // Handle inline objects
323
386
  if (field.tsType.kind === "inlineObject" &&
@@ -333,6 +396,24 @@ function updateField(field, params, parentTypeName, isInput) {
333
396
  };
334
397
  }
335
398
  }
399
+ // Handle array of inline objects
400
+ if (field.tsType.kind === "array" &&
401
+ field.tsType.elementType?.kind === "inlineObject" &&
402
+ field.tsType.elementType.inlineObjectProperties) {
403
+ const resolvedTypeName = generatedTypeNames.get(contextKey);
404
+ if (resolvedTypeName) {
405
+ return {
406
+ ...field,
407
+ tsType: {
408
+ ...field.tsType,
409
+ elementType: createReferenceType({
410
+ name: resolvedTypeName,
411
+ nullable: field.tsType.elementType.nullable,
412
+ }),
413
+ },
414
+ };
415
+ }
416
+ }
336
417
  // Handle inline enums
337
418
  if (field.tsType.kind === "inlineEnum" && field.tsType.inlineEnumMembers) {
338
419
  const resolvedTypeName = enumTypeNames.get(contextKey);
@@ -377,6 +458,24 @@ function updateField(field, params, parentTypeName, isInput) {
377
458
  };
378
459
  }
379
460
  }
461
+ // Handle array of inline union types
462
+ if (field.tsType.kind === "array" &&
463
+ field.tsType.elementType?.kind === "union" &&
464
+ field.tsType.elementType.members) {
465
+ const resolvedTypeName = unionTypeNames.get(contextKey);
466
+ if (resolvedTypeName) {
467
+ return {
468
+ ...field,
469
+ tsType: {
470
+ ...field.tsType,
471
+ elementType: createReferenceType({
472
+ name: resolvedTypeName,
473
+ nullable: field.tsType.elementType.nullable,
474
+ }),
475
+ },
476
+ };
477
+ }
478
+ }
380
479
  return field;
381
480
  }
382
481
  function updateResolversResult(resolversResult, params) {
@@ -765,6 +864,9 @@ function generateOneOfFields(params) {
765
864
  memberType.inlineObjectProperties) {
766
865
  for (const prop of memberType.inlineObjectProperties) {
767
866
  const fieldType = convertTsTypeToGraphQLType(prop.tsType, prop.optional);
867
+ if (fieldType.typeName === "__NEVER__") {
868
+ continue;
869
+ }
768
870
  fields.push({
769
871
  name: prop.name,
770
872
  type: {
@@ -811,11 +913,195 @@ function extractTypenameFromInlineObject(properties) {
811
913
  }
812
914
  const { property, fieldName } = found;
813
915
  const { tsType } = property;
814
- if (tsType.kind === "literal" && tsType.name !== null) {
916
+ if (tsType.kind === "stringLiteral" && tsType.name !== null) {
815
917
  return { typeName: tsType.name, fieldName };
816
918
  }
817
919
  return null;
818
920
  }
921
+ /**
922
+ * Convert inline object/enum/union properties within a union member to AutoGeneratedFields.
923
+ * Handles __INLINE_OBJECT__, __INLINE_ENUM__, and inline union (kind: "union") sentinels
924
+ * by generating appropriate auto types and replacing sentinel type names.
925
+ */
926
+ function convertMemberPropertiesToFields(properties, parentTypeName, ctx) {
927
+ const siblingFieldNames = new Set(properties.map((prop) => prop.name));
928
+ return properties.flatMap((prop) => {
929
+ const fieldType = convertTsTypeToGraphQLType(prop.tsType, prop.optional);
930
+ if (fieldType.typeName === "__NEVER__") {
931
+ return [];
932
+ }
933
+ const resolvedTypeName = resolveInlineTypeInMember(prop, fieldType, parentTypeName, siblingFieldNames, ctx);
934
+ return {
935
+ name: prop.name,
936
+ type: resolvedTypeName
937
+ ? { ...fieldType, typeName: resolvedTypeName }
938
+ : fieldType,
939
+ description: prop.description,
940
+ deprecated: prop.deprecated,
941
+ directives: prop.directives,
942
+ defaultValue: prop.defaultValue,
943
+ };
944
+ });
945
+ }
946
+ /**
947
+ * Resolve an inline type (object, enum, or union) within a union member property.
948
+ * Returns the generated type name if resolved, or null if no resolution is needed.
949
+ */
950
+ function resolveInlineTypeInMember(prop, fieldType, parentTypeName, siblingFieldNames, ctx) {
951
+ // Determine the inline TS type (direct or array element)
952
+ const inlineTsType = prop.tsType.kind === "array" ? prop.tsType.elementType : prop.tsType;
953
+ const singularizeArrayFieldName = prop.tsType.kind === "array";
954
+ if (!inlineTsType)
955
+ return null;
956
+ // Resolve nested inline objects
957
+ if (fieldType.typeName === "__INLINE_OBJECT__" &&
958
+ inlineTsType.kind === "inlineObject" &&
959
+ inlineTsType.inlineObjectProperties) {
960
+ return resolveNestedInlineObjectInMember(inlineTsType.inlineObjectProperties, prop.name, singularizeArrayFieldName, parentTypeName, siblingFieldNames, ctx, inlineTsType.inlineObjectDescription);
961
+ }
962
+ // Resolve inline enums (string literal unions)
963
+ if (fieldType.typeName === "__INLINE_ENUM__" &&
964
+ inlineTsType.kind === "inlineEnum" &&
965
+ inlineTsType.inlineEnumMembers) {
966
+ return resolveInlineEnumInMember(inlineTsType.inlineEnumMembers, prop.name, singularizeArrayFieldName, parentTypeName, siblingFieldNames, ctx, inlineTsType.externalEnumDescription);
967
+ }
968
+ // Resolve inline unions (reference type unions like User | Bot)
969
+ if (inlineTsType.kind === "union" && inlineTsType.members) {
970
+ return resolveInlineUnionInMember(inlineTsType.members, prop.name, singularizeArrayFieldName, parentTypeName, siblingFieldNames, ctx);
971
+ }
972
+ return null;
973
+ }
974
+ /**
975
+ * Resolve a nested inline object within an inline union member.
976
+ * Generates an AutoGeneratedType using objectField context and recurses
977
+ * into deeper nesting levels.
978
+ */
979
+ function resolveNestedInlineObjectInMember(properties, fieldName, singularizeArrayFieldName, parentTypeName, siblingFieldNames, ctx, description) {
980
+ const context = {
981
+ kind: "objectField",
982
+ parentTypeName,
983
+ fieldPath: appendFieldPath({
984
+ parentPath: [],
985
+ fieldName,
986
+ singularize: singularizeArrayFieldName,
987
+ siblingFieldNames,
988
+ }),
989
+ };
990
+ const typeName = generateAutoTypeName(context);
991
+ const contextKey = getContextKey(context);
992
+ if (ctx.generatedTypeNames.has(contextKey)) {
993
+ return ctx.generatedTypeNames.get(contextKey);
994
+ }
995
+ const fields = convertMemberPropertiesToFields(properties, typeName, ctx);
996
+ ctx.types.push({
997
+ name: typeName,
998
+ kind: "Object",
999
+ fields,
1000
+ enumValues: null,
1001
+ unionMembers: null,
1002
+ needsStringEnumMapping: false,
1003
+ sourceLocation: ctx.sourceLocation,
1004
+ generatedFrom: buildGeneratedFromInfo(context),
1005
+ description,
1006
+ resolveTypeFieldPattern: null,
1007
+ });
1008
+ ctx.generatedTypeNames.set(contextKey, typeName);
1009
+ return typeName;
1010
+ }
1011
+ /**
1012
+ * Resolve an inline enum (string literal union) within an inline union member.
1013
+ */
1014
+ function resolveInlineEnumInMember(members, fieldName, singularizeArrayFieldName, parentTypeName, siblingFieldNames, ctx, description) {
1015
+ const context = {
1016
+ kind: "objectField",
1017
+ parentTypeName,
1018
+ fieldPath: appendFieldPath({
1019
+ parentPath: [],
1020
+ fieldName,
1021
+ singularize: singularizeArrayFieldName,
1022
+ siblingFieldNames,
1023
+ }),
1024
+ };
1025
+ const typeName = generateAutoTypeName(context);
1026
+ const contextKey = getContextKey(context);
1027
+ if (ctx.generatedTypeNames.has(contextKey)) {
1028
+ return ctx.generatedTypeNames.get(contextKey);
1029
+ }
1030
+ const { enumValues, needsStringEnumMapping, diagnostics: enumDiagnostics, } = convertInlineEnumMembers({
1031
+ members,
1032
+ enumName: typeName,
1033
+ sourceLocation: ctx.sourceLocation,
1034
+ });
1035
+ ctx.diagnostics.push(...enumDiagnostics);
1036
+ ctx.types.push({
1037
+ name: typeName,
1038
+ kind: "Enum",
1039
+ fields: null,
1040
+ enumValues,
1041
+ unionMembers: null,
1042
+ needsStringEnumMapping,
1043
+ sourceLocation: ctx.sourceLocation,
1044
+ generatedFrom: buildGeneratedFromInfo(context),
1045
+ description,
1046
+ resolveTypeFieldPattern: null,
1047
+ });
1048
+ ctx.generatedTypeNames.set(contextKey, typeName);
1049
+ return typeName;
1050
+ }
1051
+ /**
1052
+ * Resolve an inline union of reference types within an inline union member.
1053
+ */
1054
+ function resolveInlineUnionInMember(members, fieldName, singularizeArrayFieldName, parentTypeName, siblingFieldNames, ctx) {
1055
+ const context = {
1056
+ kind: "objectField",
1057
+ parentTypeName,
1058
+ fieldPath: appendFieldPath({
1059
+ parentPath: [],
1060
+ fieldName,
1061
+ singularize: singularizeArrayFieldName,
1062
+ siblingFieldNames,
1063
+ }),
1064
+ };
1065
+ const typeName = generateAutoTypeName(context);
1066
+ const contextKey = getContextKey(context);
1067
+ if (ctx.generatedTypeNames.has(contextKey)) {
1068
+ return ctx.generatedTypeNames.get(contextKey);
1069
+ }
1070
+ const memberNames = [];
1071
+ for (const member of members) {
1072
+ if (member.kind === "reference" && member.name) {
1073
+ if (ctx.knownTypeNames.has(member.name)) {
1074
+ memberNames.push(member.name);
1075
+ }
1076
+ }
1077
+ }
1078
+ if (memberNames.length === 0) {
1079
+ const memberDescriptions = members
1080
+ .map((m) => m.name ?? "(anonymous)")
1081
+ .join(", ");
1082
+ ctx.diagnostics.push({
1083
+ code: "INLINE_UNION_UNRESOLVABLE_MEMBER",
1084
+ message: `Could not resolve any members of inline union '${typeName}' in '${parentTypeName}.${fieldName}'. None of the member types [${memberDescriptions}] are known schema types.`,
1085
+ severity: "error",
1086
+ location: ctx.sourceLocation,
1087
+ });
1088
+ return typeName;
1089
+ }
1090
+ ctx.types.push({
1091
+ name: typeName,
1092
+ kind: "Union",
1093
+ fields: null,
1094
+ enumValues: null,
1095
+ unionMembers: memberNames,
1096
+ needsStringEnumMapping: false,
1097
+ sourceLocation: ctx.sourceLocation,
1098
+ generatedFrom: buildGeneratedFromInfo(context),
1099
+ description: null,
1100
+ resolveTypeFieldPattern: null,
1101
+ });
1102
+ ctx.generatedTypeNames.set(contextKey, typeName);
1103
+ return typeName;
1104
+ }
819
1105
  function resolveMemberNames(params) {
820
1106
  const { members, generatedTypeNames, parentContext, types, generatedTypenameTypes, diagnostics, sourceLocation, } = params;
821
1107
  const memberNames = [];
@@ -843,31 +1129,39 @@ function resolveMemberNames(params) {
843
1129
  };
844
1130
  contextKey = getContextKey(nestedContext);
845
1131
  }
846
- else {
1132
+ else if (memberType.inlineObjectHintName !== null) {
847
1133
  const nestedContext = {
848
1134
  ...parentContext,
849
- fieldPath: [...parentContext.fieldPath, `member${i}`],
1135
+ fieldPath: [
1136
+ ...parentContext.fieldPath,
1137
+ memberType.inlineObjectHintName,
1138
+ ],
850
1139
  };
851
- memberTypeName = generateAutoTypeName(nestedContext);
1140
+ memberTypeName = memberType.inlineObjectHintName;
852
1141
  contextKey = getContextKey(nestedContext);
853
1142
  }
1143
+ else {
1144
+ diagnostics.push({
1145
+ code: "UNNAMEABLE_UNION_MEMBER",
1146
+ message: `Inline object union member at index ${i} cannot be named. Use a named type (type alias or interface) for each union member, or add a '__typename' property with a string literal type.`,
1147
+ severity: "error",
1148
+ location: sourceLocation,
1149
+ });
1150
+ continue;
1151
+ }
854
1152
  // Only filter out __typename or $typeName for resolverPayload context
855
1153
  // For other contexts, these are regular fields that should be preserved
856
1154
  const typenameFieldToFilter = extractedInfo?.fieldName ?? null;
857
- const fields = memberType.inlineObjectProperties
858
- .filter((prop) => parentContext.kind !== "resolverPayload" ||
859
- prop.name !== typenameFieldToFilter)
860
- .map((prop) => {
861
- const fieldType = convertTsTypeToGraphQLType(prop.tsType, prop.optional);
862
- return {
863
- name: prop.name,
864
- type: fieldType,
865
- description: prop.description,
866
- deprecated: prop.deprecated,
867
- directives: prop.directives,
868
- defaultValue: prop.defaultValue,
869
- };
870
- });
1155
+ const filteredProperties = memberType.inlineObjectProperties.filter((prop) => parentContext.kind !== "resolverPayload" ||
1156
+ prop.name !== typenameFieldToFilter);
1157
+ const fieldCtx = {
1158
+ types,
1159
+ generatedTypeNames,
1160
+ diagnostics,
1161
+ sourceLocation,
1162
+ knownTypeNames: params.knownTypeNames,
1163
+ };
1164
+ const fields = convertMemberPropertiesToFields(filteredProperties, memberTypeName, fieldCtx);
871
1165
  // Check if this typename was already seen with a different field structure
872
1166
  if (extractedInfo !== null) {
873
1167
  const existingFields = generatedTypenameTypes.get(extractedInfo.typeName);
@@ -892,7 +1186,7 @@ function resolveMemberNames(params) {
892
1186
  ...parentContext,
893
1187
  fieldPath: [
894
1188
  ...parentContext.fieldPath,
895
- extractedInfo?.typeName ?? `member${i}`,
1189
+ extractedInfo?.typeName ?? memberType.inlineObjectHintName,
896
1190
  ],
897
1191
  };
898
1192
  types.push({
@@ -999,11 +1293,19 @@ export function generateAutoTypes(input) {
999
1293
  resolversResult: input.resolversResult,
1000
1294
  knownTypeNames: input.knownTypeNames,
1001
1295
  });
1002
- const allInlineUnions = [
1296
+ const allInlineUnionsRaw = [
1003
1297
  ...inlineUnionsFromTypes,
1004
1298
  ...inlineUnionsFromResolvers,
1005
1299
  ...inlineUnionsFromPayloads,
1006
1300
  ];
1301
+ // Apply discriminator-aware flattening to inline unions before processing.
1302
+ // This resolves the case where TypeScript distributes intersections over unions
1303
+ // within field types, creating many anonymous inline objects.
1304
+ const flattenResult = flattenInlineUnionMembers({
1305
+ inlineUnions: allInlineUnionsRaw,
1306
+ discriminatorFields: input.discriminatorFields,
1307
+ });
1308
+ const allInlineUnions = [...flattenResult.inlineUnions];
1007
1309
  // Build union type names map before generating auto types
1008
1310
  const unionTypeNames = buildUnionTypeNamesMap(allInlineUnions);
1009
1311
  const autoGeneratedTypes = [];
@@ -1043,11 +1345,29 @@ export function generateAutoTypes(input) {
1043
1345
  };
1044
1346
  const updatedExtractedTypes = updateExtractedTypes(input.extractedTypes, updateParams);
1045
1347
  const updatedResolversResult = updateResolversResult(input.resolversResult, updateParams);
1348
+ // Build mapping from TS type alias names to auto-generated GraphQL union names
1349
+ const tsAliasToGraphQLNameMap = buildTsAliasToGraphQLNameMap(allInlineUnions, unionTypeNames);
1046
1350
  return {
1047
1351
  autoGeneratedTypes,
1048
1352
  updatedExtractedTypes,
1049
1353
  updatedResolversResult,
1050
1354
  diagnostics,
1355
+ tsAliasToGraphQLNameMap,
1356
+ inlineDiscriminatorResolveTypes: flattenResult.inlineDiscriminatorResolveTypes,
1051
1357
  };
1052
1358
  }
1359
+ function buildTsAliasToGraphQLNameMap(inlineUnions, unionTypeNames) {
1360
+ const result = new Map();
1361
+ for (const inlineUnion of inlineUnions) {
1362
+ if (inlineUnion.unionAliasName === null) {
1363
+ continue;
1364
+ }
1365
+ const contextKey = getContextKey(inlineUnion.context);
1366
+ const generatedName = unionTypeNames.get(contextKey);
1367
+ if (generatedName !== undefined) {
1368
+ result.set(inlineUnion.unionAliasName, generatedName);
1369
+ }
1370
+ }
1371
+ return result;
1372
+ }
1053
1373
  //# sourceMappingURL=auto-type-generator.js.map