env_serde.dart 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import 'package:json_annotation/json_annotation.dart';
  2. // Run `dart run build_runner build` to generate the json serialization If the
  3. // file `env_serde.i.dart` is existed, delete it first.
  4. //
  5. // the file `env_serde.g.dart` will be generated in the same directory. Rename
  6. // the file to `env_serde.i.dart` because the file is ignored by default.
  7. part 'env_serde.g.dart';
  8. @JsonSerializable()
  9. class AppFlowyEnv {
  10. final SupabaseConfiguration supabase_config;
  11. final AppFlowyCloudConfiguration appflowy_cloud_config;
  12. AppFlowyEnv({
  13. required this.supabase_config,
  14. required this.appflowy_cloud_config,
  15. });
  16. factory AppFlowyEnv.fromJson(Map<String, dynamic> json) =>
  17. _$AppFlowyEnvFromJson(json);
  18. Map<String, dynamic> toJson() => _$AppFlowyEnvToJson(this);
  19. }
  20. @JsonSerializable()
  21. class SupabaseConfiguration {
  22. /// Indicates whether the sync feature is enabled.
  23. final bool enable_sync;
  24. final String url;
  25. final String anon_key;
  26. SupabaseConfiguration({
  27. this.enable_sync = true,
  28. required this.url,
  29. required this.anon_key,
  30. });
  31. factory SupabaseConfiguration.fromJson(Map<String, dynamic> json) =>
  32. _$SupabaseConfigurationFromJson(json);
  33. Map<String, dynamic> toJson() => _$SupabaseConfigurationToJson(this);
  34. }
  35. @JsonSerializable()
  36. class AppFlowyCloudConfiguration {
  37. final String base_url;
  38. final String base_ws_url;
  39. AppFlowyCloudConfiguration({
  40. required this.base_url,
  41. required this.base_ws_url,
  42. });
  43. factory AppFlowyCloudConfiguration.fromJson(Map<String, dynamic> json) =>
  44. _$AppFlowyCloudConfigurationFromJson(json);
  45. Map<String, dynamic> toJson() => _$AppFlowyCloudConfigurationToJson(this);
  46. }