generateAuthManagerFiles function
Future<void>
generateAuthManagerFiles({
- required SupabaseGenConfig config,
- required List<
SupabaseTableInfo> allTables,
Implementation
Future<void> generateAuthManagerFiles({
required SupabaseGenConfig config,
required List<SupabaseTableInfo> allTables,
}) async {
if (!config.generateAuthentication) {
print('AuthManager generation is disabled in the config. Skipping.');
return;
}
final profileTableInfo = allTables.firstWhere(
(t) => t.originalName == config.authProfileTableName,
orElse: () {
print(
'Error: Profile table "${config.authProfileTableName}" not found in allTables. Cannot generate AuthManager.',
);
// Return a dummy SupabaseTableInfo to prevent null errors if we were to proceed,
// but ideally, we should throw or handle this more gracefully.
// For now, we'll just print and exit this function.
return SupabaseTableInfo(
name: '',
originalName: '',
localName: '',
schema: '',
columns: [],
foreignKeys: [],
indexes: [],
reverseRelations: [],
comment: '',
);
},
);
if (profileTableInfo.originalName.isEmpty) {
// Error already printed
return;
}
final profileModelClassName = _getDartClassName(profileTableInfo, config);
// Assuming local profile table name is the same as the Supabase one for simplicity.
// This could be made configurable if needed.
final localProfileTableName = profileTableInfo.localName;
await _generateAuthProvidersFile(
config: config,
profileModelClassName: profileModelClassName,
supabaseProfileTableName: config.authProfileTableName,
localProfileTableName: localProfileTableName,
);
}