getDomains method

Future<List<DomainModel>> getDomains()

Every domain RLS grants the caller: their own, shares, org content, and anything public.

This is deliberately NOT scoped to a "library" view. It backs domainBySlug (route resolution) and the learning-guide suggestion builder, both of which must see a domain the learner is merely allowed to read — including the ownerless public domains a seeded or legacy instance carries. Scoping here once broke slug resolution for exactly those rows: /domains/<slug>/topics hung with an unresolvable domain.

The learner's library is myCurriculumDomains (owned + shared + assigned + enrolled starters), which is already opt-in by construction — an un-enrolled starter can never reach it. Put presentation scoping there, not here.

Implementation

Future<List<DomainModel>> getDomains() async {
  final response = await _client
      .from('domains')
      .select()
      .order('sort_order', ascending: true);
  return (response as List<dynamic>)
      .map((row) => DomainModel.fromJson(row as Map<String, dynamic>))
      .toList();
}