env_serde.dart 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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.i.dart';
  8. @JsonSerializable()
  9. class AppFlowyEnv {
  10. final SupabaseConfiguration supabase_config;
  11. AppFlowyEnv({
  12. required this.supabase_config,
  13. });
  14. factory AppFlowyEnv.fromJson(Map<String, dynamic> json) =>
  15. _$AppFlowyEnvFromJson(json);
  16. Map<String, dynamic> toJson() => _$AppFlowyEnvToJson(this);
  17. }
  18. @JsonSerializable()
  19. class SupabaseConfiguration {
  20. /// Indicates whether the sync feature is enabled.
  21. final bool enable_sync;
  22. final String url;
  23. final String key;
  24. final String jwt_secret;
  25. final PostgresConfiguration postgres_config;
  26. SupabaseConfiguration({
  27. this.enable_sync = true,
  28. required this.url,
  29. required this.key,
  30. required this.jwt_secret,
  31. required this.postgres_config,
  32. });
  33. factory SupabaseConfiguration.fromJson(Map<String, dynamic> json) =>
  34. _$SupabaseConfigurationFromJson(json);
  35. Map<String, dynamic> toJson() => _$SupabaseConfigurationToJson(this);
  36. }
  37. @JsonSerializable()
  38. class PostgresConfiguration {
  39. final String url;
  40. final String user_name;
  41. final String password;
  42. final int port;
  43. PostgresConfiguration({
  44. required this.url,
  45. required this.user_name,
  46. required this.password,
  47. required this.port,
  48. });
  49. factory PostgresConfiguration.fromJson(Map<String, dynamic> json) =>
  50. _$PostgresConfigurationFromJson(json);
  51. Map<String, dynamic> toJson() => _$PostgresConfigurationToJson(this);
  52. }