Skip to content

zfa make canonical command (printed by setup) produces non-compiling code: missing data repo impl + missing orchestrator usecase #284

Description

@arrrrny

Context

Smoke-testing the zfa-only workflow (goal: any agent can build a ZikZak-class app with only zfa commands). The command chain that zfa setup itself prints in its "Next steps" does not compile:

zfa setup zikzak_canon --flutter --platforms=ios,macos
cd zikzak_canon
zfa entity create -n Product --field id:String --field name:String --field price:double
zfa make Product --preset=crud --with=vpc,state,di,test
zfa build
flutter analyze   # 24 errors, 5 files

Actual (after zfa build succeeds)

lib/src/di/repositories/product_repository_di.dart   - imports ../../data/repositories/data_product_repository.dart (DOES NOT EXIST)
lib/src/di/usecases/product_usecase_di.dart          - imports ../../domain/usecases/product/product_usecase.dart (DOES NOT EXIST)
lib/src/presentation/pages/product/product_controller.dart  - #281 class
lib/src/presentation/pages/product/product_presenter.dart   - #281 class
lib/src/presentation/pages/product/product_view.dart        - #281 class

Gap A: repository implementation never generated (crud preset)

preset crud = ['usecase', 'repository', 'datasource']. The repository plugin (lib/src/plugins/repository/repository_plugin.dart:184-190) only emits the implementation when config.generateData || config.generateDataSource:

if (config.isEntityBased || (config.appendToExisting && config.repo != null)) {
  files.add(await interfaceGen.generate(targetConfig));   // product_repository.dart
}
if ((config.generateData || config.generateDataSource || config.appendToExisting) && !config.hasService) {
  files.add(await implementationGen.generate(targetConfig));  // data_product_repository.dart - NOT emitted
}

But the DI plugin (lib/src/plugins/di/di_plugin.dart:204-210) emits product_repository_di.dart importing data_product_repository.dart whenever config.generateRepository || config.generateData:

if (config.generateRepository || config.generateData) {
  files.add(await _generateRepositoryDI(config, fs));  // references DataProductRepository
}

So the interface is generated, the DI references the impl, but the impl is never produced. The reference app (~/Developer/zik_zak) HAS the impls (data/repositories/data_grocery_store_repository.dart etc.), generated by v5 zfa. Adding --data to zfa make does produce the impl and clears the DI errors — so either the crud preset should include the data layer, or the repository plugin should emit the impl for entity-based configs, or DI should skip the repo DI when no impl is generated.

Gap B: orchestrator usecase file never generated (DI references ProductUseCase)

The DI plugin's orchestrator branch (lib/src/plugins/di/di_plugin.dart:814-860, triggered when config.isOrchestrator) emits:

import '../../domain/usecases/product/product_usecase.dart';
getIt.registerLazySingleton<ProductUseCase>(() => ProductUseCase());

But the usecase plugin (lib/src/plugins/usecase/usecase_plugin.dart:180-186) routes isEntityBased to entityGen.generate (per-method usecases: get_product_usecase.dart, toggle_product_usecase.dart, update_product_usecase.dart) and only generates the orchestrator file for isOrchestrator configs. Nothing emits product_usecase.dart + ProductUseCase. The reference app uses per-usecase DI files (check_permission_usecase_di.dart, deal_*_usecase_di.dart) — no aggregator. Either DI should use the entity-based per-usecase DI for entity configs, or the usecase plugin must also emit the orchestrator file when DI expects it.

Suggested fix

  1. Gap A: make the crud preset (and the setup-printed next-steps) include the data layer so the repository impl is generated — or generate the impl whenever the interface is generated for entity-based configs. Minimum: the setup "Next steps" command must produce compiling code.
  2. Gap B: for entity-based configs, DI should emit per-usecase DI files (matching the generated entity usecases) instead of the orchestrator DI, OR generate the orchestrator usecase file too.
  3. The presentation files remain blocked by zfa make generates non-compiling code on v6: presentation imports point to zuraffa (v5) instead of zuraffa_flutter #281.

Impact

Blocks the entire zfa-only build flow: the canonical first command after setup fails to compile, on top of #281. Reference app's own generated layout confirms the expected outputs (data_*_repository.dart impls + per-usecase DI).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions