Sdk

Factories

What each factory does and how to use it.

Factories

Factories are mixins that implement one Lomkit endpoint family. You mix in what you need per repository.

SearchFactory

  • Endpoint: POST {baseRoute}/search
  • Returns: RestApiResponse<List<T>>
class UsersRepository with SearchFactory<UserModel> {
  @override
  String get baseRoute => '/users';

  @override
  RestApiClient get httpClient => client;

  @override
  UserModel fromJson(Map<String, dynamic> json) => UserModel.fromJson(json);

  @override
  void onCatchError(RestApiResponse? r, Object e, StackTrace s) {}
}

DetailsFactory

  • Endpoint: depends on your backend route (GET {baseRoute}/{id} or POST {baseRoute}/details, etc.)
  • Returns: RestApiResponse<T>

Check your project’s DetailsFactory implementation for the exact signature and route used.

MutateFactory

  • Endpoint: POST {baseRoute}/mutate
  • Returns: RestApiResponse<LaravelRestApiMutateResponse>

ActionsFactory

  • Endpoint: POST {baseRoute}/actions/{actionUriKey}
  • Returns: RestApiResponse<int> where data is impacted

DeleteFactory

  • Endpoint: DELETE {baseRoute}
  • Body: { "resources": [ids...] }
  • Returns: RestApiResponse<List<T>>

RestoreFactory / ForceDeleteFactory

  • Endpoints and signatures follow the same pattern as DeleteFactory.
  • Use when your backend enables soft deletes.