You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
errorDetails+=`Type generation failed: ${numericIdentifierErrors.length} items use numeric identifiers, which result in invalid TypeScript interface names. Use the --prefix flag to resolve this issue.\n\n`;
627
-
628
-
if(contentTypeErrors.length>0){
629
-
errorDetails+="Content Types and Global Fields with Numeric UIDs\n";
630
-
errorDetails+=
631
-
"Note: Global Fields are also Content Types. If their UID begins with a number, they are listed here.\n\n";
errorDetails+=`TypeScript constraint: Object keys cannot start with a number.\n`;
636
-
errorDetails+=`Suggestion: Since UIDs cannot be changed, use the --prefix flag to add a valid prefix to all interface names (e.g., --prefix "ContentType").\n\n`;
errorDetails+=`TypeScript constraint: Object keys cannot start with a number.\n`;
647
-
errorDetails+=`Suggestion: Since UIDs cannot be changed, use the --prefix flag to add a valid prefix to all interface names (e.g., --prefix "ContentType").\n\n`;
648
-
});
649
-
}
650
-
651
-
errorDetails+="To resolve these issues:\n";
652
-
errorDetails+=
653
-
"• Use the --prefix flag to add a valid prefix to all interface names.\n";
Copy file name to clipboardExpand all lines: src/generateTS/shared/utils.ts
+118Lines changed: 118 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -144,3 +144,121 @@ export function createErrorDetails(
144
144
};
145
145
}
146
146
}
147
+
148
+
/**
149
+
* Helper function to format error details consistently
150
+
* @param error - The error object containing uid and other details
151
+
* @param index - The index number for the error
152
+
* @param skipHeader - Whether to skip the header (for global fields)
153
+
* @returns Formatted error details string
154
+
*/
155
+
exportfunctionformatErrorDetails(
156
+
error: any,
157
+
index: number,
158
+
skipHeader: boolean=false
159
+
): string{
160
+
if(skipHeader){
161
+
// For global fields, skip the header since it's already added above
162
+
return`TypeScript constraint: Object keys cannot start with a number.\nSuggestion: Since UIDs cannot be changed, use the --prefix flag to add a valid prefix to all interface names (e.g., --prefix "ContentType").\n\n`;
163
+
}
164
+
165
+
// For content types, include the full header
166
+
return`${index}. UID: "${error.uid}"\nTypeScript constraint: Object keys cannot start with a number.\nSuggestion: Since UIDs cannot be changed, use the --prefix flag to add a valid prefix to all interface names (e.g., --prefix "ContentType").\n\n`;
167
+
}
168
+
169
+
/**
170
+
* Build the main error header for numeric identifier errors
171
+
* @param totalErrors - Total number of errors found
return`Type generation failed: ${totalErrors} items use numeric identifiers, which result in invalid TypeScript interface names. Use the --prefix flag to resolve this issue.\n\n`;
176
+
}
177
+
178
+
/**
179
+
* Build content type errors section
180
+
* @param contentTypeErrors - Array of content type errors
181
+
* @returns Formatted content type errors section string
182
+
*/
183
+
exportfunctionbuildContentTypeErrorsSection(
184
+
contentTypeErrors: any[]
185
+
): string{
186
+
if(contentTypeErrors.length===0)return"";
187
+
188
+
letsection="Content Types and Global Fields with Numeric UIDs\n";
189
+
section+=
190
+
"Note: Global Fields are also Content Types. If their UID begins with a number, they are listed here.\n\n";
191
+
192
+
contentTypeErrors.forEach((error,index)=>{
193
+
section+=formatErrorDetails(error,index+1);
194
+
});
195
+
196
+
returnsection;
197
+
}
198
+
199
+
/**
200
+
* Build global field errors section
201
+
* @param globalFieldErrors - Array of global field errors
202
+
* @returns Formatted global field errors section string
0 commit comments