Browse Source

Merge pull request #869 from nextcloud/refactor/nextcloud/exports

Refactor nextcloud package exports
pull/877/head
Kate 1 year ago committed by GitHub
parent
commit
0ad957ce60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .cspell/dart_flutter.txt
  2. 1
      packages/neon/neon/lib/models.dart
  3. 1
      packages/neon/neon/lib/src/app.dart
  4. 1
      packages/neon/neon/lib/src/blocs/accounts.dart
  5. 1
      packages/neon/neon/lib/src/blocs/apps.dart
  6. 1
      packages/neon/neon/lib/src/blocs/next_push.dart
  7. 6
      packages/neon/neon/lib/src/models/app_ids.dart
  8. 1
      packages/neon/neon/lib/src/pages/home.dart
  9. 2
      packages/neon/neon/lib/src/settings/models/storage.dart
  10. 2
      packages/neon/neon/lib/src/widgets/cached_image.dart
  11. 2
      packages/neon/neon_files/lib/routes.dart
  12. 2
      packages/neon/neon_news/lib/routes.dart
  13. 2
      packages/neon/neon_notes/lib/routes.dart
  14. 2
      packages/neon/neon_notifications/lib/routes.dart
  15. 62
      packages/nextcloud/bin/generate_exports.dart
  16. 12
      packages/nextcloud/lib/comments.dart
  17. 13
      packages/nextcloud/lib/core.dart
  18. 12
      packages/nextcloud/lib/dashboard.dart
  19. 12
      packages/nextcloud/lib/dav.dart
  20. 12
      packages/nextcloud/lib/files.dart
  21. 12
      packages/nextcloud/lib/files_external.dart
  22. 12
      packages/nextcloud/lib/files_reminders.dart
  23. 12
      packages/nextcloud/lib/files_sharing.dart
  24. 12
      packages/nextcloud/lib/files_trashbin.dart
  25. 12
      packages/nextcloud/lib/files_versions.dart
  26. 25
      packages/nextcloud/lib/ids.dart
  27. 13
      packages/nextcloud/lib/news.dart
  28. 56
      packages/nextcloud/lib/nextcloud.dart
  29. 13
      packages/nextcloud/lib/notes.dart
  30. 13
      packages/nextcloud/lib/notifications.dart
  31. 12
      packages/nextcloud/lib/provisioning_api.dart
  32. 12
      packages/nextcloud/lib/settings.dart
  33. 12
      packages/nextcloud/lib/sharebymail.dart
  34. 18
      packages/nextcloud/lib/src/app_type.dart
  35. 108
      packages/nextcloud/lib/src/client.dart
  36. 20
      packages/nextcloud/lib/src/helpers/core.dart
  37. 18
      packages/nextcloud/lib/src/helpers/news.dart
  38. 21
      packages/nextcloud/lib/src/helpers/notes.dart
  39. 2
      packages/nextcloud/lib/src/helpers/notifications.dart
  40. 59
      packages/nextcloud/lib/src/version_supported.dart
  41. 12
      packages/nextcloud/lib/theming.dart
  42. 13
      packages/nextcloud/lib/updatenotification.dart
  43. 12
      packages/nextcloud/lib/uppush.dart
  44. 12
      packages/nextcloud/lib/user_status.dart
  45. 12
      packages/nextcloud/lib/weather_status.dart
  46. 15
      packages/nextcloud/lib/webdav.dart
  47. 1
      packages/nextcloud/pubspec.yaml
  48. 2
      packages/nextcloud/test/core_test.dart
  49. 1
      packages/nextcloud/test/dashboard_test.dart
  50. 2
      packages/nextcloud/test/news_test.dart
  51. 3
      packages/nextcloud/test/notes_test.dart
  52. 2
      packages/nextcloud/test/notifications_test.dart
  53. 1
      packages/nextcloud/test/provisioning_api_test.dart
  54. 1
      packages/nextcloud/test/settings_test.dart
  55. 1
      packages/nextcloud/test/uppush_test.dart
  56. 2
      packages/nextcloud/test/user_status_test.dart
  57. 1
      tool/generate-nextcloud.sh

1
.cspell/dart_flutter.txt

@ -1,4 +1,5 @@
autofocus autofocus
expando
gapless gapless
lerp lerp
pubspec pubspec

1
packages/neon/neon/lib/models.dart

@ -1,4 +1,3 @@
export 'package:neon/src/models/account.dart' hide Credentials, LoginQRcode; export 'package:neon/src/models/account.dart' hide Credentials, LoginQRcode;
export 'package:neon/src/models/app_ids.dart';
export 'package:neon/src/models/app_implementation.dart'; export 'package:neon/src/models/app_implementation.dart';
export 'package:neon/src/models/notifications_interface.dart'; export 'package:neon/src/models/notifications_interface.dart';

1
packages/neon/neon/lib/src/app.dart

@ -10,7 +10,6 @@ import 'package:neon/l10n/localizations.dart';
import 'package:neon/src/bloc/result_builder.dart'; import 'package:neon/src/bloc/result_builder.dart';
import 'package:neon/src/blocs/accounts.dart'; import 'package:neon/src/blocs/accounts.dart';
import 'package:neon/src/models/account.dart'; import 'package:neon/src/models/account.dart';
import 'package:neon/src/models/app_ids.dart';
import 'package:neon/src/models/app_implementation.dart'; import 'package:neon/src/models/app_implementation.dart';
import 'package:neon/src/models/notifications_interface.dart'; import 'package:neon/src/models/notifications_interface.dart';
import 'package:neon/src/models/push_notification.dart'; import 'package:neon/src/models/push_notification.dart';

1
packages/neon/neon/lib/src/blocs/accounts.dart

@ -16,6 +16,7 @@ import 'package:neon/src/models/app_implementation.dart';
import 'package:neon/src/settings/models/storage.dart'; import 'package:neon/src/settings/models/storage.dart';
import 'package:neon/src/utils/account_options.dart'; import 'package:neon/src/utils/account_options.dart';
import 'package:neon/src/utils/global_options.dart'; import 'package:neon/src/utils/global_options.dart';
import 'package:nextcloud/nextcloud.dart';
import 'package:rxdart/rxdart.dart'; import 'package:rxdart/rxdart.dart';
const _keyAccounts = 'accounts'; const _keyAccounts = 'accounts';

1
packages/neon/neon/lib/src/blocs/apps.dart

@ -7,7 +7,6 @@ import 'package:neon/src/bloc/result.dart';
import 'package:neon/src/blocs/accounts.dart'; import 'package:neon/src/blocs/accounts.dart';
import 'package:neon/src/blocs/capabilities.dart'; import 'package:neon/src/blocs/capabilities.dart';
import 'package:neon/src/models/account.dart'; import 'package:neon/src/models/account.dart';
import 'package:neon/src/models/app_ids.dart';
import 'package:neon/src/models/app_implementation.dart'; import 'package:neon/src/models/app_implementation.dart';
import 'package:neon/src/models/notifications_interface.dart'; import 'package:neon/src/models/notifications_interface.dart';
import 'package:neon/src/settings/models/options_collection.dart'; import 'package:neon/src/settings/models/options_collection.dart';

1
packages/neon/neon/lib/src/blocs/next_push.dart

@ -6,6 +6,7 @@ import 'package:neon/src/bloc/bloc.dart';
import 'package:neon/src/blocs/accounts.dart'; import 'package:neon/src/blocs/accounts.dart';
import 'package:neon/src/models/account.dart'; import 'package:neon/src/models/account.dart';
import 'package:neon/src/utils/global_options.dart'; import 'package:neon/src/utils/global_options.dart';
import 'package:nextcloud/nextcloud.dart';
import 'package:rxdart/rxdart.dart'; import 'package:rxdart/rxdart.dart';
@internal @internal

6
packages/neon/neon/lib/src/models/app_ids.dart

@ -1,6 +0,0 @@
sealed class AppIDs {
static const files = 'files';
static const news = 'news';
static const notes = 'notes';
static const notifications = 'notifications';
}

1
packages/neon/neon/lib/src/pages/home.dart

@ -16,6 +16,7 @@ import 'package:neon/src/widgets/app_bar.dart';
import 'package:neon/src/widgets/drawer.dart'; import 'package:neon/src/widgets/drawer.dart';
import 'package:neon/src/widgets/error.dart'; import 'package:neon/src/widgets/error.dart';
import 'package:neon/src/widgets/unified_search_results.dart'; import 'package:neon/src/widgets/unified_search_results.dart';
import 'package:nextcloud/nextcloud.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@internal @internal

2
packages/neon/neon/lib/src/settings/models/storage.dart

@ -1,5 +1,5 @@
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:neon/src/models/app_ids.dart'; import 'package:nextcloud/ids.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
@internal @internal

2
packages/neon/neon/lib/src/widgets/cached_image.dart

@ -5,12 +5,12 @@ import 'dart:typed_data';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:neon/nextcloud.dart';
import 'package:neon/src/blocs/accounts.dart'; import 'package:neon/src/blocs/accounts.dart';
import 'package:neon/src/models/account.dart'; import 'package:neon/src/models/account.dart';
import 'package:neon/src/utils/provider.dart'; import 'package:neon/src/utils/provider.dart';
import 'package:neon/src/widgets/error.dart'; import 'package:neon/src/widgets/error.dart';
import 'package:neon/src/widgets/linear_progress_indicator.dart'; import 'package:neon/src/widgets/linear_progress_indicator.dart';
import 'package:nextcloud/nextcloud.dart';
typedef CacheReviver = FutureOr<Uint8List?> Function(CacheManager cacheManager); typedef CacheReviver = FutureOr<Uint8List?> Function(CacheManager cacheManager);
typedef ImageDownloader = FutureOr<Uint8List> Function(); typedef ImageDownloader = FutureOr<Uint8List> Function();

2
packages/neon/neon_files/lib/routes.dart

@ -1,6 +1,6 @@
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:neon/models.dart'; import 'package:neon/nextcloud.dart';
import 'package:neon/utils.dart'; import 'package:neon/utils.dart';
import 'package:neon_files/neon_files.dart'; import 'package:neon_files/neon_files.dart';

2
packages/neon/neon_news/lib/routes.dart

@ -1,6 +1,6 @@
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:neon/models.dart'; import 'package:neon/nextcloud.dart';
import 'package:neon/utils.dart'; import 'package:neon/utils.dart';
import 'package:neon_news/neon_news.dart'; import 'package:neon_news/neon_news.dart';

2
packages/neon/neon_notes/lib/routes.dart

@ -1,6 +1,6 @@
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:neon/models.dart'; import 'package:neon/nextcloud.dart';
import 'package:neon/utils.dart'; import 'package:neon/utils.dart';
import 'package:neon_notes/neon_notes.dart'; import 'package:neon_notes/neon_notes.dart';

2
packages/neon/neon_notifications/lib/routes.dart

@ -1,6 +1,6 @@
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:neon/models.dart'; import 'package:neon/nextcloud.dart';
import 'package:neon/utils.dart'; import 'package:neon/utils.dart';
import 'package:neon_notifications/neon_notifications.dart'; import 'package:neon_notifications/neon_notifications.dart';

62
packages/nextcloud/bin/generate_exports.dart

@ -0,0 +1,62 @@
// ignore_for_file: depend_on_referenced_packages
import 'dart:io';
import 'package:collection/collection.dart';
import 'package:dynamite/src/helpers/dart_helpers.dart';
import 'package:path/path.dart' as p;
void main() {
final files =
Directory('lib/src/api').listSync().cast<File>().where((final file) => file.path.endsWith('.openapi.dart'));
final idStatements = <String>[];
final exportStatements = <String>[
"export 'ids.dart';",
"export 'src/client.dart';",
"export 'webdav.dart';",
];
for (final file in files) {
final basename = p.basename(file.path);
final id = basename.substring(0, basename.length - 13);
final variablePrefix = toDartName(id);
final classPrefix = toDartName(id, uppercaseFirstCharacter: true);
idStatements.add(" static const $variablePrefix = '$id';");
exportStatements.add("export '$id.dart';");
final exports = ["export 'src/api/$id.openapi.dart';"];
if (File('lib/src/helpers/$id.dart').existsSync()) {
exports.add("export 'src/helpers/$id.dart';");
}
File('lib/$id.dart').writeAsStringSync('''
import 'package:nextcloud/src/api/$id.openapi.dart';
import 'package:nextcloud/src/client.dart';
${exports.join('\n')}
// ignore: public_member_api_docs
extension ${classPrefix}Extension on NextcloudClient {
static final _$variablePrefix = Expando<${classPrefix}Client>();
/// Client for the $id APIs
${classPrefix}Client get $variablePrefix => _$variablePrefix[this] ??= ${classPrefix}Client.fromClient(this);
}
''');
}
File('lib/ids.dart').writeAsStringSync('''
// ignore_for_file: public_member_api_docs
final class AppIDs {
${idStatements.join('\n')}
}
''');
File('lib/nextcloud.dart').writeAsStringSync('''
export 'package:dynamite_runtime/http_client.dart' show CookieJar, DynamiteApiException, DynamiteRawResponse, DynamiteResponse;
${exportStatements.sorted((final a, final b) => a.compareTo(b)).join('\n')}
''');
}

12
packages/nextcloud/lib/comments.dart

@ -0,0 +1,12 @@
import 'package:nextcloud/src/api/comments.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/comments.openapi.dart';
// ignore: public_member_api_docs
extension CommentsExtension on NextcloudClient {
static final _comments = Expando<CommentsClient>();
/// Client for the comments APIs
CommentsClient get comments => _comments[this] ??= CommentsClient.fromClient(this);
}

13
packages/nextcloud/lib/core.dart

@ -0,0 +1,13 @@
import 'package:nextcloud/src/api/core.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/core.openapi.dart';
export 'src/helpers/core.dart';
// ignore: public_member_api_docs
extension CoreExtension on NextcloudClient {
static final _core = Expando<CoreClient>();
/// Client for the core APIs
CoreClient get core => _core[this] ??= CoreClient.fromClient(this);
}

12
packages/nextcloud/lib/dashboard.dart

@ -0,0 +1,12 @@
import 'package:nextcloud/src/api/dashboard.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/dashboard.openapi.dart';
// ignore: public_member_api_docs
extension DashboardExtension on NextcloudClient {
static final _dashboard = Expando<DashboardClient>();
/// Client for the dashboard APIs
DashboardClient get dashboard => _dashboard[this] ??= DashboardClient.fromClient(this);
}

12
packages/nextcloud/lib/dav.dart

@ -0,0 +1,12 @@
import 'package:nextcloud/src/api/dav.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/dav.openapi.dart';
// ignore: public_member_api_docs
extension DavExtension on NextcloudClient {
static final _dav = Expando<DavClient>();
/// Client for the dav APIs
DavClient get dav => _dav[this] ??= DavClient.fromClient(this);
}

12
packages/nextcloud/lib/files.dart

@ -0,0 +1,12 @@
import 'package:nextcloud/src/api/files.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/files.openapi.dart';
// ignore: public_member_api_docs
extension FilesExtension on NextcloudClient {
static final _files = Expando<FilesClient>();
/// Client for the files APIs
FilesClient get files => _files[this] ??= FilesClient.fromClient(this);
}

12
packages/nextcloud/lib/files_external.dart

@ -0,0 +1,12 @@
import 'package:nextcloud/src/api/files_external.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/files_external.openapi.dart';
// ignore: public_member_api_docs
extension FilesExternalExtension on NextcloudClient {
static final _filesExternal = Expando<FilesExternalClient>();
/// Client for the files_external APIs
FilesExternalClient get filesExternal => _filesExternal[this] ??= FilesExternalClient.fromClient(this);
}

12
packages/nextcloud/lib/files_reminders.dart

@ -0,0 +1,12 @@
import 'package:nextcloud/src/api/files_reminders.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/files_reminders.openapi.dart';
// ignore: public_member_api_docs
extension FilesRemindersExtension on NextcloudClient {
static final _filesReminders = Expando<FilesRemindersClient>();
/// Client for the files_reminders APIs
FilesRemindersClient get filesReminders => _filesReminders[this] ??= FilesRemindersClient.fromClient(this);
}

12
packages/nextcloud/lib/files_sharing.dart

@ -0,0 +1,12 @@
import 'package:nextcloud/src/api/files_sharing.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/files_sharing.openapi.dart';
// ignore: public_member_api_docs
extension FilesSharingExtension on NextcloudClient {
static final _filesSharing = Expando<FilesSharingClient>();
/// Client for the files_sharing APIs
FilesSharingClient get filesSharing => _filesSharing[this] ??= FilesSharingClient.fromClient(this);
}

12
packages/nextcloud/lib/files_trashbin.dart

@ -0,0 +1,12 @@
import 'package:nextcloud/src/api/files_trashbin.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/files_trashbin.openapi.dart';
// ignore: public_member_api_docs
extension FilesTrashbinExtension on NextcloudClient {
static final _filesTrashbin = Expando<FilesTrashbinClient>();
/// Client for the files_trashbin APIs
FilesTrashbinClient get filesTrashbin => _filesTrashbin[this] ??= FilesTrashbinClient.fromClient(this);
}

12
packages/nextcloud/lib/files_versions.dart

@ -0,0 +1,12 @@
import 'package:nextcloud/src/api/files_versions.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/files_versions.openapi.dart';
// ignore: public_member_api_docs
extension FilesVersionsExtension on NextcloudClient {
static final _filesVersions = Expando<FilesVersionsClient>();
/// Client for the files_versions APIs
FilesVersionsClient get filesVersions => _filesVersions[this] ??= FilesVersionsClient.fromClient(this);
}

25
packages/nextcloud/lib/ids.dart

@ -0,0 +1,25 @@
// ignore_for_file: public_member_api_docs
final class AppIDs {
static const filesSharing = 'files_sharing';
static const filesVersions = 'files_versions';
static const files = 'files';
static const updatenotification = 'updatenotification';
static const dashboard = 'dashboard';
static const uppush = 'uppush';
static const settings = 'settings';
static const dav = 'dav';
static const userStatus = 'user_status';
static const notifications = 'notifications';
static const notes = 'notes';
static const news = 'news';
static const core = 'core';
static const filesTrashbin = 'files_trashbin';
static const comments = 'comments';
static const sharebymail = 'sharebymail';
static const filesExternal = 'files_external';
static const filesReminders = 'files_reminders';
static const provisioningApi = 'provisioning_api';
static const theming = 'theming';
static const weatherStatus = 'weather_status';
}

13
packages/nextcloud/lib/news.dart

@ -0,0 +1,13 @@
import 'package:nextcloud/src/api/news.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/news.openapi.dart';
export 'src/helpers/news.dart';
// ignore: public_member_api_docs
extension NewsExtension on NextcloudClient {
static final _news = Expando<NewsClient>();
/// Client for the news APIs
NewsClient get news => _news[this] ??= NewsClient.fromClient(this);
}

56
packages/nextcloud/lib/nextcloud.dart

@ -1,33 +1,27 @@
export 'package:crypton/crypton.dart' show RSAKeypair, RSAPrivateKey, RSAPublicKey; export 'package:dynamite_runtime/http_client.dart'
show CookieJar, DynamiteApiException, DynamiteRawResponse, DynamiteResponse;
export 'src/api/comments.openapi.dart'; export 'comments.dart';
export 'src/api/core.openapi.dart'; export 'core.dart';
export 'src/api/dashboard.openapi.dart'; export 'dashboard.dart';
export 'src/api/dav.openapi.dart'; export 'dav.dart';
export 'src/api/files.openapi.dart'; export 'files.dart';
export 'src/api/files_external.openapi.dart'; export 'files_external.dart';
export 'src/api/files_reminders.openapi.dart'; export 'files_reminders.dart';
export 'src/api/files_sharing.openapi.dart'; export 'files_sharing.dart';
export 'src/api/files_trashbin.openapi.dart'; export 'files_trashbin.dart';
export 'src/api/files_versions.openapi.dart'; export 'files_versions.dart';
export 'src/api/news.openapi.dart'; export 'ids.dart';
export 'src/api/notes.openapi.dart'; export 'news.dart';
export 'src/api/notifications.openapi.dart'; export 'notes.dart';
export 'src/api/provisioning_api.openapi.dart'; export 'notifications.dart';
export 'src/api/settings.openapi.dart'; export 'provisioning_api.dart';
export 'src/api/sharebymail.openapi.dart'; export 'settings.dart';
export 'src/api/theming.openapi.dart'; export 'sharebymail.dart';
export 'src/api/updatenotification.openapi.dart';
export 'src/api/uppush.openapi.dart';
export 'src/api/user_status.openapi.dart';
export 'src/api/weather_status.openapi.dart';
export 'src/app_type.dart';
export 'src/client.dart'; export 'src/client.dart';
export 'src/helpers/core.dart'; export 'theming.dart';
export 'src/helpers/news.dart'; export 'updatenotification.dart';
export 'src/helpers/notifications.dart'; export 'uppush.dart';
export 'src/version_supported.dart'; export 'user_status.dart';
export 'src/webdav/client.dart'; export 'weather_status.dart';
export 'src/webdav/file.dart'; export 'webdav.dart';
export 'src/webdav/props.dart';
export 'src/webdav/webdav.dart';

13
packages/nextcloud/lib/notes.dart

@ -0,0 +1,13 @@
import 'package:nextcloud/src/api/notes.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/notes.openapi.dart';
export 'src/helpers/notes.dart';
// ignore: public_member_api_docs
extension NotesExtension on NextcloudClient {
static final _notes = Expando<NotesClient>();
/// Client for the notes APIs
NotesClient get notes => _notes[this] ??= NotesClient.fromClient(this);
}

13
packages/nextcloud/lib/notifications.dart

@ -0,0 +1,13 @@
import 'package:nextcloud/src/api/notifications.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/notifications.openapi.dart';
export 'src/helpers/notifications.dart';
// ignore: public_member_api_docs
extension NotificationsExtension on NextcloudClient {
static final _notifications = Expando<NotificationsClient>();
/// Client for the notifications APIs
NotificationsClient get notifications => _notifications[this] ??= NotificationsClient.fromClient(this);
}

12
packages/nextcloud/lib/provisioning_api.dart

@ -0,0 +1,12 @@
import 'package:nextcloud/src/api/provisioning_api.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/provisioning_api.openapi.dart';
// ignore: public_member_api_docs
extension ProvisioningApiExtension on NextcloudClient {
static final _provisioningApi = Expando<ProvisioningApiClient>();
/// Client for the provisioning_api APIs
ProvisioningApiClient get provisioningApi => _provisioningApi[this] ??= ProvisioningApiClient.fromClient(this);
}

12
packages/nextcloud/lib/settings.dart

@ -0,0 +1,12 @@
import 'package:nextcloud/src/api/settings.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/settings.openapi.dart';
// ignore: public_member_api_docs
extension SettingsExtension on NextcloudClient {
static final _settings = Expando<SettingsClient>();
/// Client for the settings APIs
SettingsClient get settings => _settings[this] ??= SettingsClient.fromClient(this);
}

12
packages/nextcloud/lib/sharebymail.dart

@ -0,0 +1,12 @@
import 'package:nextcloud/src/api/sharebymail.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/sharebymail.openapi.dart';
// ignore: public_member_api_docs
extension SharebymailExtension on NextcloudClient {
static final _sharebymail = Expando<SharebymailClient>();
/// Client for the sharebymail APIs
SharebymailClient get sharebymail => _sharebymail[this] ??= SharebymailClient.fromClient(this);
}

18
packages/nextcloud/lib/src/app_type.dart

@ -1,18 +0,0 @@
/// Different app types to register for
enum AppType {
/// Will only receive Talk notifications
talk('Mozilla/5.0 (Android) Nextcloud-Talk'),
/// Will receive all notifications except Talk notifications if another Talk
/// app is already registered for the user
nextcloud('Mozilla/5.0 (Android) Nextcloud-android'),
/// Default. Same problem with notifications as the [nextcloud] type
unknown(null);
// ignore: public_member_api_docs
const AppType(this.userAgent);
// ignore: public_member_api_docs
final String? userAgent;
}

108
packages/nextcloud/lib/src/client.dart

@ -1,4 +1,23 @@
import 'package:nextcloud/nextcloud.dart'; import 'package:dynamite_runtime/http_client.dart';
/// Different app types to register for
enum AppType {
/// Will only receive Talk notifications
talk('Mozilla/5.0 (Android) Nextcloud-Talk'),
/// Will receive all notifications except Talk notifications if another Talk
/// app is already registered for the user
nextcloud('Mozilla/5.0 (Android) Nextcloud-android'),
/// Default. Same problem with notifications as the [nextcloud] type
unknown(null);
// ignore: public_member_api_docs
const AppType(this.userAgent);
// ignore: public_member_api_docs
final String? userAgent;
}
// ignore: public_member_api_docs // ignore: public_member_api_docs
class NextcloudClient extends DynamiteClient { class NextcloudClient extends DynamiteClient {
@ -32,91 +51,4 @@ class NextcloudClient extends DynamiteClient {
/// Identifier used for authentication. This can be the username or email or something else. /// Identifier used for authentication. This can be the username or email or something else.
final String? loginName; final String? loginName;
WebDavClient? _webdav;
CommentsClient? _comments;
CoreClient? _core;
DashboardClient? _dashboard;
DavClient? _dav;
FilesClient? _files;
FilesExternalClient? _filesExternal;
FilesRemindersClient? _filesReminders;
FilesSharingClient? _filesSharing;
FilesTrashbinClient? _filesTrashbin;
FilesVersionsClient? _filesVersions;
NewsClient? _news;
NotesClient? _notes;
NotificationsClient? _notifications;
ProvisioningApiClient? _provisioningApi;
SettingsClient? _settings;
ThemingClient? _theming;
UpdatenotificationClient? _updatenotification;
UppushClient? _uppush;
UserStatusClient? _userStatus;
WeatherStatusClient? _weatherStatus;
/// Client for WebDAV
WebDavClient get webdav => _webdav ??= WebDavClient(this);
/// Client for the comments APIs
CommentsClient get comments => _comments ??= CommentsClient.fromClient(this);
/// Client for the core APIs
CoreClient get core => _core ??= CoreClient.fromClient(this);
/// Client for the dashboard APIs
DashboardClient get dashboard => _dashboard ??= DashboardClient.fromClient(this);
/// Client for the dav APIs
///
/// This client does not expose WebDAV functionality. Use [webdav] instead.
DavClient get dav => _dav ??= DavClient.fromClient(this);
/// Client for the files APIs
FilesClient get files => _files ??= FilesClient.fromClient(this);
/// Client for the files external APIs
FilesExternalClient get filesExternal => _filesExternal ??= FilesExternalClient.fromClient(this);
/// Client for the files reminders APIs
FilesRemindersClient get filesReminders => _filesReminders ??= FilesRemindersClient.fromClient(this);
/// Client for the files sharing APIs
FilesSharingClient get filesSharing => _filesSharing ??= FilesSharingClient.fromClient(this);
/// Client for the files trashbin APIs
FilesTrashbinClient get filesTrashbin => _filesTrashbin ??= FilesTrashbinClient.fromClient(this);
/// Client for the files versions APIs
FilesVersionsClient get filesVersions => _filesVersions ??= FilesVersionsClient.fromClient(this);
/// Client for the news app APIs
NewsClient get news => _news ??= NewsClient.fromClient(this);
/// Client for the notes app APIs
NotesClient get notes => _notes ??= NotesClient.fromClient(this);
/// Client for the notifications app APIs
NotificationsClient get notifications => _notifications ??= NotificationsClient.fromClient(this);
/// Client for the provisioning APIs
ProvisioningApiClient get provisioningApi => _provisioningApi ??= ProvisioningApiClient.fromClient(this);
/// Client for the settings APIs
SettingsClient get settings => _settings ??= SettingsClient.fromClient(this);
/// Client for the theming APIs
ThemingClient get theming => _theming ??= ThemingClient.fromClient(this);
/// Client for the updatenotification APIs
UpdatenotificationClient get updatenotification => _updatenotification ??= UpdatenotificationClient.fromClient(this);
/// Client for the uppush app APIs
UppushClient get uppush => _uppush ??= UppushClient.fromClient(this);
/// Client for the user status APIs
UserStatusClient get userStatus => _userStatus ??= UserStatusClient.fromClient(this);
/// Client for the weather status APIs
WeatherStatusClient get weatherStatus => _weatherStatus ??= WeatherStatusClient.fromClient(this);
} }

20
packages/nextcloud/lib/src/helpers/core.dart

@ -1,5 +1,25 @@
// ignore_for_file: public_member_api_docs // ignore_for_file: public_member_api_docs
import 'package:nextcloud/src/api/core.openapi.dart';
/// Version of core/Server supported
const coreSupportedVersion = 27;
extension CoreVersionSupported on CoreClient {
/// Check if the core/Server version is supported by this client
///
/// Also returns the supported version number
(bool, int) isSupported(final CoreOcsGetCapabilitiesResponseApplicationJson_Ocs_Data capabilities) => (
capabilities.version.major == coreSupportedVersion,
coreSupportedVersion,
);
}
extension CoreStatusVersionSupported on CoreStatus {
/// Check if the core/Server version is supported
bool get isSupported => version.startsWith('$coreSupportedVersion.');
}
enum ShareType { enum ShareType {
user, user,
group, group,

18
packages/nextcloud/lib/src/helpers/news.dart

@ -1,5 +1,23 @@
// ignore_for_file: public_member_api_docs // ignore_for_file: public_member_api_docs
import 'package:nextcloud/src/api/news.openapi.dart';
/// API version of the news app supported
const newsSupportedVersion = 'v1-3';
extension NewsVersionSupported on NewsClient {
/// Check if the news app version is supported by this client
///
/// Also returns the supported API version number
Future<(bool, String)> isSupported() async {
final response = await getSupportedApiVersions();
return (
response.body.apiLevels!.contains(newsSupportedVersion),
newsSupportedVersion,
);
}
}
/// See https://github.com/nextcloud/news/blob/4a107b3d53c4fe651ac704251b99e04a53cd587f/lib/Db/ListType.php /// See https://github.com/nextcloud/news/blob/4a107b3d53c4fe651ac704251b99e04a53cd587f/lib/Db/ListType.php
enum NewsListType { enum NewsListType {
feed, feed,

21
packages/nextcloud/lib/src/helpers/notes.dart

@ -0,0 +1,21 @@
import 'package:collection/collection.dart';
import 'package:nextcloud/src/api/core.openapi.dart';
import 'package:nextcloud/src/api/notes.openapi.dart';
import 'package:version/version.dart';
/// API version of the notes app supported
const notesSupportedVersion = 1;
// ignore: public_member_api_docs
extension NotesVersionSupported on NotesClient {
/// Check if the notes app version is supported by this client
///
/// Also returns the supported API version number
(bool, int) isSupported(final CoreOcsGetCapabilitiesResponseApplicationJson_Ocs_Data capabilities) => (
capabilities.capabilities.notesCapabilities?.notes.apiVersion
?.map(Version.parse)
.firstWhereOrNull((final version) => version.major == notesSupportedVersion) !=
null,
notesSupportedVersion,
);
}

2
packages/nextcloud/lib/src/helpers/notifications.dart

@ -6,6 +6,8 @@ import 'package:crypto/crypto.dart';
import 'package:crypton/crypton.dart'; import 'package:crypton/crypton.dart';
import 'package:json_annotation/json_annotation.dart'; import 'package:json_annotation/json_annotation.dart';
export 'package:crypton/crypton.dart' show RSAKeypair, RSAPrivateKey, RSAPublicKey;
part 'notifications.g.dart'; part 'notifications.g.dart';
/// Generates the push token hash which is just sha512 /// Generates the push token hash which is just sha512

59
packages/nextcloud/lib/src/version_supported.dart

@ -1,59 +0,0 @@
import 'package:collection/collection.dart';
import 'package:nextcloud/src/api/core.openapi.dart';
import 'package:nextcloud/src/api/news.openapi.dart';
import 'package:nextcloud/src/api/notes.openapi.dart';
import 'package:version/version.dart';
/// Version of core/Server supported
const coreSupportedVersion = 27;
/// API version of the news app supported
const newsSupportedVersion = 'v1-3';
/// API version of the notes app supported
const notesSupportedVersion = 1;
// ignore: public_member_api_docs
extension CoreVersionSupported on CoreClient {
/// Check if the core/Server version is supported by this client
///
/// Also returns the supported version number
(bool, int) isSupported(final CoreOcsGetCapabilitiesResponseApplicationJson_Ocs_Data capabilities) => (
capabilities.version.major == coreSupportedVersion,
coreSupportedVersion,
);
}
// ignore: public_member_api_docs
extension CoreStatusVersionSupported on CoreStatus {
/// Check if the core/Server version is supported
bool get isSupported => version.startsWith('$coreSupportedVersion.');
}
// ignore: public_member_api_docs
extension NewsVersionSupported on NewsClient {
/// Check if the news app version is supported by this client
///
/// Also returns the supported API version number
Future<(bool, String)> isSupported() async {
final response = await getSupportedApiVersions();
return (
response.body.apiLevels!.contains(newsSupportedVersion),
newsSupportedVersion,
);
}
}
// ignore: public_member_api_docs
extension NotesVersionSupported on NotesClient {
/// Check if the notes app version is supported by this client
///
/// Also returns the supported API version number
(bool, int) isSupported(final CoreOcsGetCapabilitiesResponseApplicationJson_Ocs_Data capabilities) => (
capabilities.capabilities.notesCapabilities?.notes.apiVersion
?.map(Version.parse)
.firstWhereOrNull((final version) => version.major == notesSupportedVersion) !=
null,
notesSupportedVersion,
);
}

12
packages/nextcloud/lib/theming.dart

@ -0,0 +1,12 @@
import 'package:nextcloud/src/api/theming.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/theming.openapi.dart';
// ignore: public_member_api_docs
extension ThemingExtension on NextcloudClient {
static final _theming = Expando<ThemingClient>();
/// Client for the theming APIs
ThemingClient get theming => _theming[this] ??= ThemingClient.fromClient(this);
}

13
packages/nextcloud/lib/updatenotification.dart

@ -0,0 +1,13 @@
import 'package:nextcloud/src/api/updatenotification.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/updatenotification.openapi.dart';
// ignore: public_member_api_docs
extension UpdatenotificationExtension on NextcloudClient {
static final _updatenotification = Expando<UpdatenotificationClient>();
/// Client for the updatenotification APIs
UpdatenotificationClient get updatenotification =>
_updatenotification[this] ??= UpdatenotificationClient.fromClient(this);
}

12
packages/nextcloud/lib/uppush.dart

@ -0,0 +1,12 @@
import 'package:nextcloud/src/api/uppush.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/uppush.openapi.dart';
// ignore: public_member_api_docs
extension UppushExtension on NextcloudClient {
static final _uppush = Expando<UppushClient>();
/// Client for the uppush APIs
UppushClient get uppush => _uppush[this] ??= UppushClient.fromClient(this);
}

12
packages/nextcloud/lib/user_status.dart

@ -0,0 +1,12 @@
import 'package:nextcloud/src/api/user_status.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/user_status.openapi.dart';
// ignore: public_member_api_docs
extension UserStatusExtension on NextcloudClient {
static final _userStatus = Expando<UserStatusClient>();
/// Client for the user_status APIs
UserStatusClient get userStatus => _userStatus[this] ??= UserStatusClient.fromClient(this);
}

12
packages/nextcloud/lib/weather_status.dart

@ -0,0 +1,12 @@
import 'package:nextcloud/src/api/weather_status.openapi.dart';
import 'package:nextcloud/src/client.dart';
export 'src/api/weather_status.openapi.dart';
// ignore: public_member_api_docs
extension WeatherStatusExtension on NextcloudClient {
static final _weatherStatus = Expando<WeatherStatusClient>();
/// Client for the weather_status APIs
WeatherStatusClient get weatherStatus => _weatherStatus[this] ??= WeatherStatusClient.fromClient(this);
}

15
packages/nextcloud/lib/webdav.dart

@ -0,0 +1,15 @@
import 'package:nextcloud/src/client.dart';
import 'package:nextcloud/src/webdav/client.dart';
export 'src/webdav/client.dart';
export 'src/webdav/file.dart';
export 'src/webdav/props.dart';
export 'src/webdav/webdav.dart';
// ignore: public_member_api_docs
extension WebDAVExtension on NextcloudClient {
static final _webdav = Expando<WebDavClient>();
/// Client for WebDAV
WebDavClient get webdav => _webdav[this] ??= WebDavClient(this);
}

1
packages/nextcloud/pubspec.yaml

@ -36,6 +36,7 @@ dev_dependencies:
git: git:
url: https://github.com/nextcloud/neon url: https://github.com/nextcloud/neon
path: packages/neon_lints path: packages/neon_lints
path: ^1.8.3
process_run: ^0.13.1 process_run: ^0.13.1
test: ^1.24.6 test: ^1.24.6
xml_serializable: ^2.3.0 xml_serializable: ^2.3.0

2
packages/nextcloud/test/core_test.dart

@ -1,4 +1,4 @@
import 'package:nextcloud/nextcloud.dart'; import 'package:nextcloud/core.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'helper.dart'; import 'helper.dart';

1
packages/nextcloud/test/dashboard_test.dart

@ -1,3 +1,4 @@
import 'package:nextcloud/dashboard.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'helper.dart'; import 'helper.dart';

2
packages/nextcloud/test/news_test.dart

@ -1,7 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:nextcloud/nextcloud.dart'; import 'package:nextcloud/news.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'helper.dart'; import 'helper.dart';

3
packages/nextcloud/test/notes_test.dart

@ -1,4 +1,5 @@
import 'package:nextcloud/nextcloud.dart'; import 'package:nextcloud/core.dart';
import 'package:nextcloud/notes.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'helper.dart'; import 'helper.dart';

2
packages/nextcloud/test/notifications_test.dart

@ -1,6 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'package:nextcloud/nextcloud.dart'; import 'package:nextcloud/notifications.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'helper.dart'; import 'helper.dart';

1
packages/nextcloud/test/provisioning_api_test.dart

@ -1,3 +1,4 @@
import 'package:nextcloud/provisioning_api.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'helper.dart'; import 'helper.dart';

1
packages/nextcloud/test/settings_test.dart

@ -1,5 +1,6 @@
import 'dart:convert'; import 'dart:convert';
import 'package:nextcloud/settings.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'helper.dart'; import 'helper.dart';

1
packages/nextcloud/test/uppush_test.dart

@ -1,3 +1,4 @@
import 'package:nextcloud/uppush.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'helper.dart'; import 'helper.dart';

2
packages/nextcloud/test/user_status_test.dart

@ -1,4 +1,4 @@
import 'package:nextcloud/nextcloud.dart'; import 'package:nextcloud/user_status.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'helper.dart'; import 'helper.dart';

1
tool/generate-nextcloud.sh

@ -7,6 +7,7 @@ cd "$(dirname "$0")/.."
rm -rf .dart_tool/build rm -rf .dart_tool/build
fvm dart run nextcloud:generate_props fvm dart run nextcloud:generate_props
fvm dart pub run build_runner build --delete-conflicting-outputs fvm dart pub run build_runner build --delete-conflicting-outputs
fvm dart run nextcloud:generate_exports
# For some reason we need to fix and format twice, otherwise not everything gets fixed # For some reason we need to fix and format twice, otherwise not everything gets fixed
fvm dart fix --apply lib/src/api/ fvm dart fix --apply lib/src/api/
melos run format melos run format

Loading…
Cancel
Save