From b44cfe5d1c15609bf4fabb3a7e8c7bd09834b731 Mon Sep 17 00:00:00 2001 From: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Date: Mon, 21 Apr 2025 16:19:22 +0530 Subject: [PATCH] feat: sync stream repo impl for assets and exif --- .../drift_schemas/main/drift_schema_v1.json | 2 +- .../lib/domain/models/asset/asset.model.dart | 12 +- .../models/asset/local_asset.model.dart | 23 +- .../models/asset/merged_asset.model.dart | 4 - .../models/asset/remote_asset.model.dart | 36 +- .../lib/domain/models/local_album.model.dart | 4 +- .../infrastructure/entities/exif.entity.dart | 53 + .../entities/exif.entity.drift.dart | 1481 +++++++++++++++++ .../entities/local_asset.entity.dart | 4 + .../entities/local_asset.entity.drift.dart | 222 +-- .../entities/remote_asset.entity.dart | 28 + .../entities/remote_asset.entity.drift.dart | 1017 +++++++++++ .../repositories/db.repository.dart | 4 + .../repositories/db.repository.drift.dart | 30 +- .../repositories/sync_stream.repository.dart | 140 +- .../lib/infrastructure/utils/asset.mixin.dart | 2 - mobile/lib/utils/nullable_value.dart | 3 + .../services/device_sync_service_test.dart | 6 +- 18 files changed, 2907 insertions(+), 164 deletions(-) create mode 100644 mobile/lib/infrastructure/entities/exif.entity.drift.dart create mode 100644 mobile/lib/infrastructure/entities/remote_asset.entity.dart create mode 100644 mobile/lib/infrastructure/entities/remote_asset.entity.drift.dart diff --git a/mobile/drift_schemas/main/drift_schema_v1.json b/mobile/drift_schemas/main/drift_schema_v1.json index 1508394b75..448691afd0 100644 --- a/mobile/drift_schemas/main/drift_schema_v1.json +++ b/mobile/drift_schemas/main/drift_schema_v1.json @@ -1 +1 @@ -{"_meta":{"description":"This file contains a serialized version of schema entities for drift.","version":"1.2.0"},"options":{"store_date_time_values_as_text":true},"entities":[{"id":0,"references":[],"type":"table","data":{"name":"user_entity","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"blob","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"name","getter_name":"name","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"is_admin","getter_name":"isAdmin","moor_type":"bool","nullable":false,"customConstraints":null,"defaultConstraints":"CHECK (\"is_admin\" IN (0, 1))","dialectAwareDefaultConstraints":{"sqlite":"CHECK (\"is_admin\" IN (0, 1))"},"default_dart":"const CustomExpression('0')","default_client_dart":null,"dsl_features":[]},{"name":"email","getter_name":"email","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"profile_image_path","getter_name":"profileImagePath","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"updated_at","getter_name":"updatedAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('CURRENT_TIMESTAMP')","default_client_dart":null,"dsl_features":[]},{"name":"quota_size_in_bytes","getter_name":"quotaSizeInBytes","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"quota_usage_in_bytes","getter_name":"quotaUsageInBytes","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('0')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":true,"constraints":[],"strict":true,"explicit_pk":["id"]}},{"id":1,"references":[0],"type":"table","data":{"name":"user_metadata_entity","was_declared_in_moor":false,"columns":[{"name":"user_id","getter_name":"userId","moor_type":"blob","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES user_entity (id) ON DELETE CASCADE","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES user_entity (id) ON DELETE CASCADE"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"preferences","getter_name":"preferences","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"userPreferenceConverter","dart_type_name":"UserPreferences"}}],"is_virtual":false,"without_rowid":true,"constraints":[],"strict":true,"explicit_pk":["user_id"]}},{"id":2,"references":[0],"type":"table","data":{"name":"partner_entity","was_declared_in_moor":false,"columns":[{"name":"shared_by_id","getter_name":"sharedById","moor_type":"blob","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES user_entity (id) ON DELETE CASCADE","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES user_entity (id) ON DELETE CASCADE"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"shared_with_id","getter_name":"sharedWithId","moor_type":"blob","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES user_entity (id) ON DELETE CASCADE","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES user_entity (id) ON DELETE CASCADE"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"in_timeline","getter_name":"inTimeline","moor_type":"bool","nullable":false,"customConstraints":null,"defaultConstraints":"CHECK (\"in_timeline\" IN (0, 1))","dialectAwareDefaultConstraints":{"sqlite":"CHECK (\"in_timeline\" IN (0, 1))"},"default_dart":"const CustomExpression('0')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":true,"constraints":[],"strict":true,"explicit_pk":["shared_by_id","shared_with_id"]}},{"id":3,"references":[],"type":"table","data":{"name":"local_asset_entity","was_declared_in_moor":false,"columns":[{"name":"name","getter_name":"name","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"type","getter_name":"type","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const EnumIndexConverter(AssetType.values)","dart_type_name":"AssetType"}},{"name":"created_at","getter_name":"createdAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('CURRENT_TIMESTAMP')","default_client_dart":null,"dsl_features":[]},{"name":"updated_at","getter_name":"updatedAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('CURRENT_TIMESTAMP')","default_client_dart":null,"dsl_features":[]},{"name":"width","getter_name":"width","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"height","getter_name":"height","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"duration_in_seconds","getter_name":"durationInSeconds","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"local_id","getter_name":"localId","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"checksum","getter_name":"checksum","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":true,"constraints":[],"strict":true,"explicit_pk":["local_id"]}},{"id":4,"references":[3],"type":"table","data":{"name":"local_album_entity","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"name","getter_name":"name","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"updated_at","getter_name":"updatedAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('CURRENT_TIMESTAMP')","default_client_dart":null,"dsl_features":[]},{"name":"asset_count","getter_name":"assetCount","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('0')","default_client_dart":null,"dsl_features":[]},{"name":"thumbnail_id","getter_name":"thumbnailId","moor_type":"string","nullable":true,"customConstraints":null,"defaultConstraints":"REFERENCES local_asset_entity (local_id) ON DELETE SET NULL","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES local_asset_entity (local_id) ON DELETE SET NULL"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"backup_selection","getter_name":"backupSelection","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const EnumIndexConverter(BackupSelection.values)","dart_type_name":"BackupSelection"}},{"name":"is_all","getter_name":"isAll","moor_type":"bool","nullable":false,"customConstraints":null,"defaultConstraints":"CHECK (\"is_all\" IN (0, 1))","dialectAwareDefaultConstraints":{"sqlite":"CHECK (\"is_all\" IN (0, 1))"},"default_dart":"const CustomExpression('0')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":true,"constraints":[],"strict":true,"explicit_pk":["id"]}},{"id":5,"references":[3,4],"type":"table","data":{"name":"local_album_asset_entity","was_declared_in_moor":false,"columns":[{"name":"asset_id","getter_name":"assetId","moor_type":"string","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES local_asset_entity (local_id) ON DELETE CASCADE","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES local_asset_entity (local_id) ON DELETE CASCADE"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"album_id","getter_name":"albumId","moor_type":"string","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES local_album_entity (id) ON DELETE CASCADE","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES local_album_entity (id) ON DELETE CASCADE"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false,"without_rowid":true,"constraints":[],"strict":true,"explicit_pk":["asset_id","album_id"]}},{"id":6,"references":[3],"type":"index","data":{"on":3,"name":"local_asset_checksum","sql":null,"unique":false,"columns":["checksum"]}}]} \ No newline at end of file +{"_meta":{"description":"This file contains a serialized version of schema entities for drift.","version":"1.2.0"},"options":{"store_date_time_values_as_text":true},"entities":[{"id":0,"references":[],"type":"table","data":{"name":"user_entity","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"blob","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"name","getter_name":"name","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"is_admin","getter_name":"isAdmin","moor_type":"bool","nullable":false,"customConstraints":null,"defaultConstraints":"CHECK (\"is_admin\" IN (0, 1))","dialectAwareDefaultConstraints":{"sqlite":"CHECK (\"is_admin\" IN (0, 1))"},"default_dart":"const CustomExpression('0')","default_client_dart":null,"dsl_features":[]},{"name":"email","getter_name":"email","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"profile_image_path","getter_name":"profileImagePath","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"updated_at","getter_name":"updatedAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('CURRENT_TIMESTAMP')","default_client_dart":null,"dsl_features":[]},{"name":"quota_size_in_bytes","getter_name":"quotaSizeInBytes","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"quota_usage_in_bytes","getter_name":"quotaUsageInBytes","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('0')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":true,"constraints":[],"strict":true,"explicit_pk":["id"]}},{"id":1,"references":[0],"type":"table","data":{"name":"user_metadata_entity","was_declared_in_moor":false,"columns":[{"name":"user_id","getter_name":"userId","moor_type":"blob","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES user_entity (id) ON DELETE CASCADE","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES user_entity (id) ON DELETE CASCADE"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"preferences","getter_name":"preferences","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"userPreferenceConverter","dart_type_name":"UserPreferences"}}],"is_virtual":false,"without_rowid":true,"constraints":[],"strict":true,"explicit_pk":["user_id"]}},{"id":2,"references":[0],"type":"table","data":{"name":"partner_entity","was_declared_in_moor":false,"columns":[{"name":"shared_by_id","getter_name":"sharedById","moor_type":"blob","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES user_entity (id) ON DELETE CASCADE","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES user_entity (id) ON DELETE CASCADE"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"shared_with_id","getter_name":"sharedWithId","moor_type":"blob","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES user_entity (id) ON DELETE CASCADE","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES user_entity (id) ON DELETE CASCADE"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"in_timeline","getter_name":"inTimeline","moor_type":"bool","nullable":false,"customConstraints":null,"defaultConstraints":"CHECK (\"in_timeline\" IN (0, 1))","dialectAwareDefaultConstraints":{"sqlite":"CHECK (\"in_timeline\" IN (0, 1))"},"default_dart":"const CustomExpression('0')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":true,"constraints":[],"strict":true,"explicit_pk":["shared_by_id","shared_with_id"]}},{"id":3,"references":[],"type":"table","data":{"name":"local_asset_entity","was_declared_in_moor":false,"columns":[{"name":"name","getter_name":"name","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"type","getter_name":"type","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const EnumIndexConverter(AssetType.values)","dart_type_name":"AssetType"}},{"name":"created_at","getter_name":"createdAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('CURRENT_TIMESTAMP')","default_client_dart":null,"dsl_features":[]},{"name":"updated_at","getter_name":"updatedAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('CURRENT_TIMESTAMP')","default_client_dart":null,"dsl_features":[]},{"name":"duration_in_seconds","getter_name":"durationInSeconds","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"local_id","getter_name":"localId","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"checksum","getter_name":"checksum","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"width","getter_name":"width","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"height","getter_name":"height","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":true,"constraints":[],"strict":true,"explicit_pk":["local_id"]}},{"id":4,"references":[3],"type":"table","data":{"name":"local_album_entity","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"name","getter_name":"name","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"updated_at","getter_name":"updatedAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('CURRENT_TIMESTAMP')","default_client_dart":null,"dsl_features":[]},{"name":"asset_count","getter_name":"assetCount","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('0')","default_client_dart":null,"dsl_features":[]},{"name":"thumbnail_id","getter_name":"thumbnailId","moor_type":"string","nullable":true,"customConstraints":null,"defaultConstraints":"REFERENCES local_asset_entity (local_id) ON DELETE SET NULL","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES local_asset_entity (local_id) ON DELETE SET NULL"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"backup_selection","getter_name":"backupSelection","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const EnumIndexConverter(BackupSelection.values)","dart_type_name":"BackupSelection"}},{"name":"is_all","getter_name":"isAll","moor_type":"bool","nullable":false,"customConstraints":null,"defaultConstraints":"CHECK (\"is_all\" IN (0, 1))","dialectAwareDefaultConstraints":{"sqlite":"CHECK (\"is_all\" IN (0, 1))"},"default_dart":"const CustomExpression('0')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":true,"constraints":[],"strict":true,"explicit_pk":["id"]}},{"id":5,"references":[3,4],"type":"table","data":{"name":"local_album_asset_entity","was_declared_in_moor":false,"columns":[{"name":"asset_id","getter_name":"assetId","moor_type":"string","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES local_asset_entity (local_id) ON DELETE CASCADE","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES local_asset_entity (local_id) ON DELETE CASCADE"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"album_id","getter_name":"albumId","moor_type":"string","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES local_album_entity (id) ON DELETE CASCADE","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES local_album_entity (id) ON DELETE CASCADE"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false,"without_rowid":true,"constraints":[],"strict":true,"explicit_pk":["asset_id","album_id"]}},{"id":6,"references":[0],"type":"table","data":{"name":"remote_asset_entity","was_declared_in_moor":false,"columns":[{"name":"name","getter_name":"name","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"type","getter_name":"type","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const EnumIndexConverter(AssetType.values)","dart_type_name":"AssetType"}},{"name":"created_at","getter_name":"createdAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('CURRENT_TIMESTAMP')","default_client_dart":null,"dsl_features":[]},{"name":"updated_at","getter_name":"updatedAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('CURRENT_TIMESTAMP')","default_client_dart":null,"dsl_features":[]},{"name":"duration_in_seconds","getter_name":"durationInSeconds","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"remote_id","getter_name":"remoteId","moor_type":"blob","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"checksum","getter_name":"checksum","moor_type":"string","nullable":false,"customConstraints":null,"defaultConstraints":"UNIQUE","dialectAwareDefaultConstraints":{"sqlite":"UNIQUE"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"is_favorite","getter_name":"isFavorite","moor_type":"bool","nullable":false,"customConstraints":null,"defaultConstraints":"CHECK (\"is_favorite\" IN (0, 1))","dialectAwareDefaultConstraints":{"sqlite":"CHECK (\"is_favorite\" IN (0, 1))"},"default_dart":"const CustomExpression('0')","default_client_dart":null,"dsl_features":[]},{"name":"owner_id","getter_name":"ownerId","moor_type":"blob","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES user_entity (id) ON DELETE CASCADE","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES user_entity (id) ON DELETE CASCADE"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"local_date_time","getter_name":"localDateTime","moor_type":"dateTime","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"thumbhash","getter_name":"thumbhash","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"deleted_at","getter_name":"deletedAt","moor_type":"dateTime","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":true,"constraints":[],"strict":true,"explicit_pk":["remote_id"]}},{"id":7,"references":[6],"type":"table","data":{"name":"exif_entity","was_declared_in_moor":false,"columns":[{"name":"asset_id","getter_name":"assetId","moor_type":"blob","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES remote_asset_entity (remote_id) ON DELETE CASCADE","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES remote_asset_entity (remote_id) ON DELETE CASCADE"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"city","getter_name":"city","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"state","getter_name":"state","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"country","getter_name":"country","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"date_time_original","getter_name":"dateTimeOriginal","moor_type":"dateTime","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"description","getter_name":"description","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"height","getter_name":"height","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"width","getter_name":"width","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"exposure_time","getter_name":"exposureTime","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"f_number","getter_name":"fNumber","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"file_size","getter_name":"fileSize","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"focal_length","getter_name":"focalLength","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"latitude","getter_name":"latitude","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"longitude","getter_name":"longitude","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"iso","getter_name":"iso","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"make","getter_name":"make","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"model","getter_name":"model","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"orientation","getter_name":"orientation","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"time_zone","getter_name":"timeZone","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"rating","getter_name":"rating","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"projection_type","getter_name":"projectionType","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":true,"constraints":[],"strict":true,"explicit_pk":["asset_id"]}},{"id":8,"references":[3],"type":"index","data":{"on":3,"name":"local_asset_checksum","sql":null,"unique":false,"columns":["checksum"]}},{"id":9,"references":[6],"type":"index","data":{"on":6,"name":"remote_asset_checksum","sql":null,"unique":false,"columns":["checksum"]}}]} \ No newline at end of file diff --git a/mobile/lib/domain/models/asset/asset.model.dart b/mobile/lib/domain/models/asset/asset.model.dart index e6b11c3130..36f8ada253 100644 --- a/mobile/lib/domain/models/asset/asset.model.dart +++ b/mobile/lib/domain/models/asset/asset.model.dart @@ -1,3 +1,5 @@ +import 'package:immich_mobile/utils/nullable_value.dart'; + part 'local_asset.model.dart'; part 'merged_asset.model.dart'; part 'remote_asset.model.dart'; @@ -16,8 +18,6 @@ sealed class Asset { final AssetType type; final DateTime createdAt; final DateTime updatedAt; - final int? width; - final int? height; final int? durationInSeconds; const Asset({ @@ -26,8 +26,6 @@ sealed class Asset { required this.type, required this.createdAt, required this.updatedAt, - this.width, - this.height, this.durationInSeconds, }); @@ -38,8 +36,6 @@ sealed class Asset { type: $type, createdAt: $createdAt, updatedAt: $updatedAt, - width: ${width ?? ""}, - height: ${height ?? ""}, durationInSeconds: ${durationInSeconds ?? ""} }'''; } @@ -52,8 +48,6 @@ sealed class Asset { type == other.type && createdAt == other.createdAt && updatedAt == other.updatedAt && - width == other.width && - height == other.height && durationInSeconds == other.durationInSeconds; } return false; @@ -65,8 +59,6 @@ sealed class Asset { type.hashCode ^ createdAt.hashCode ^ updatedAt.hashCode ^ - width.hashCode ^ - height.hashCode ^ durationInSeconds.hashCode; } } diff --git a/mobile/lib/domain/models/asset/local_asset.model.dart b/mobile/lib/domain/models/asset/local_asset.model.dart index afab9832b5..28f3d8c9fb 100644 --- a/mobile/lib/domain/models/asset/local_asset.model.dart +++ b/mobile/lib/domain/models/asset/local_asset.model.dart @@ -2,6 +2,8 @@ part of 'asset.model.dart'; class LocalAsset extends Asset { final String localId; + final int? width; + final int? height; const LocalAsset({ required this.localId, @@ -10,8 +12,8 @@ class LocalAsset extends Asset { required super.type, required super.createdAt, required super.updatedAt, - super.width, - super.height, + this.width, + this.height, super.durationInSeconds, }); @@ -33,7 +35,10 @@ class LocalAsset extends Asset { bool operator ==(Object other) { if (other is! LocalAsset) return false; if (identical(this, other)) return true; - return super == other && localId == other.localId; + return super == other && + localId == other.localId && + width == other.width && + height == other.height; } @override @@ -48,9 +53,9 @@ class LocalAsset extends Asset { AssetType? type, DateTime? createdAt, DateTime? updatedAt, - int? width, - int? height, - int? durationInSeconds, + NullableValue width = const NullableValue.absent(), + NullableValue height = const NullableValue.absent(), + NullableValue durationInSeconds = const NullableValue.absent(), }) { return LocalAsset( localId: localId ?? this.localId, @@ -59,9 +64,9 @@ class LocalAsset extends Asset { type: type ?? this.type, createdAt: createdAt ?? this.createdAt, updatedAt: updatedAt ?? this.updatedAt, - width: width ?? this.width, - height: height ?? this.height, - durationInSeconds: durationInSeconds ?? this.durationInSeconds, + width: width.getOrDefault(this.width), + height: height.getOrDefault(this.height), + durationInSeconds: durationInSeconds.getOrDefault(this.durationInSeconds), ); } } diff --git a/mobile/lib/domain/models/asset/merged_asset.model.dart b/mobile/lib/domain/models/asset/merged_asset.model.dart index 7b0b6e16c4..e02cdfcb89 100644 --- a/mobile/lib/domain/models/asset/merged_asset.model.dart +++ b/mobile/lib/domain/models/asset/merged_asset.model.dart @@ -12,8 +12,6 @@ class MergedAsset extends Asset { required super.type, required super.createdAt, required super.updatedAt, - super.width, - super.height, super.durationInSeconds, }); @@ -26,8 +24,6 @@ class MergedAsset extends Asset { type: $type, createdAt: $createdAt, updatedAt: $updatedAt, - width: ${width ?? ""}, - height: ${height ?? ""}, durationInSeconds: ${durationInSeconds ?? ""} }'''; } diff --git a/mobile/lib/domain/models/asset/remote_asset.model.dart b/mobile/lib/domain/models/asset/remote_asset.model.dart index ae04499574..30c1fa2158 100644 --- a/mobile/lib/domain/models/asset/remote_asset.model.dart +++ b/mobile/lib/domain/models/asset/remote_asset.model.dart @@ -2,16 +2,24 @@ part of 'asset.model.dart'; class RemoteAsset extends Asset { final String remoteId; + final bool isFavorite; + final String ownerId; + final DateTime localDateTime; + final String? thumbhash; + final DateTime? deletedAt; const RemoteAsset({ required this.remoteId, + required this.ownerId, required super.name, required super.checksum, required super.type, + required this.isFavorite, + required this.localDateTime, required super.createdAt, required super.updatedAt, - super.width, - super.height, + this.deletedAt, + this.thumbhash, super.durationInSeconds, }); @@ -19,13 +27,15 @@ class RemoteAsset extends Asset { String toString() { return '''RemoteAsset { remoteId: $remoteId, + ownerId: $ownerId, name: $name, type: $type, + isFavorite: $isFavorite, createdAt: $createdAt, updatedAt: $updatedAt, - width: ${width ?? ""}, - height: ${height ?? ""}, - durationInSeconds: ${durationInSeconds ?? ""} + localDateTime: $localDateTime, + deletedAt: ${deletedAt ?? ""}, + durationInSeconds: ${durationInSeconds ?? ""}, }'''; } @@ -33,11 +43,23 @@ class RemoteAsset extends Asset { bool operator ==(Object other) { if (other is! RemoteAsset) return false; if (identical(this, other)) return true; - return super == other && remoteId == other.remoteId; + return super == other && + remoteId == other.remoteId && + isFavorite == other.isFavorite && + ownerId == other.ownerId && + localDateTime == other.localDateTime && + deletedAt == other.deletedAt && + thumbhash == other.thumbhash; } @override int get hashCode { - return super.hashCode ^ remoteId.hashCode; + return super.hashCode ^ + remoteId.hashCode ^ + isFavorite.hashCode ^ + ownerId.hashCode ^ + localDateTime.hashCode ^ + deletedAt.hashCode ^ + thumbhash.hashCode; } } diff --git a/mobile/lib/domain/models/local_album.model.dart b/mobile/lib/domain/models/local_album.model.dart index de7c86a64f..eb005ee43a 100644 --- a/mobile/lib/domain/models/local_album.model.dart +++ b/mobile/lib/domain/models/local_album.model.dart @@ -32,7 +32,7 @@ class LocalAlbum { String? name, DateTime? updatedAt, int? assetCount, - NullableValue? thumbnailId, + NullableValue thumbnailId = const NullableValue.absent(), BackupSelection? backupSelection, bool? isAll, }) { @@ -41,7 +41,7 @@ class LocalAlbum { name: name ?? this.name, updatedAt: updatedAt ?? this.updatedAt, assetCount: assetCount ?? this.assetCount, - thumbnailId: thumbnailId?.getOrDefault(this.thumbnailId), + thumbnailId: thumbnailId.getOrDefault(this.thumbnailId), backupSelection: backupSelection ?? this.backupSelection, isAll: isAll ?? this.isAll, ); diff --git a/mobile/lib/infrastructure/entities/exif.entity.dart b/mobile/lib/infrastructure/entities/exif.entity.dart index 5a93bc9768..bb3f2d177c 100644 --- a/mobile/lib/infrastructure/entities/exif.entity.dart +++ b/mobile/lib/infrastructure/entities/exif.entity.dart @@ -1,4 +1,7 @@ +import 'package:drift/drift.dart' hide Query; import 'package:immich_mobile/domain/models/exif.model.dart' as domain; +import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.dart'; +import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart'; import 'package:immich_mobile/infrastructure/utils/exif.converter.dart'; import 'package:isar/isar.dart'; @@ -90,3 +93,53 @@ class ExifInfo { exposureSeconds: exposureSeconds, ); } + +class ExifEntity extends Table with DriftDefaultsMixin { + const ExifEntity(); + + BlobColumn get assetId => blob() + .references(RemoteAssetEntity, #remoteId, onDelete: KeyAction.cascade)(); + + TextColumn get city => text().nullable()(); + + TextColumn get state => text().nullable()(); + + TextColumn get country => text().nullable()(); + + DateTimeColumn get dateTimeOriginal => dateTime().nullable()(); + + TextColumn get description => text().nullable()(); + + IntColumn get height => integer().nullable()(); + + IntColumn get width => integer().nullable()(); + + TextColumn get exposureTime => text().nullable()(); + + IntColumn get fNumber => integer().nullable()(); + + IntColumn get fileSize => integer().nullable()(); + + IntColumn get focalLength => integer().nullable()(); + + IntColumn get latitude => integer().nullable()(); + + IntColumn get longitude => integer().nullable()(); + + IntColumn get iso => integer().nullable()(); + + TextColumn get make => text().nullable()(); + + TextColumn get model => text().nullable()(); + + TextColumn get orientation => text().nullable()(); + + TextColumn get timeZone => text().nullable()(); + + IntColumn get rating => integer().nullable()(); + + TextColumn get projectionType => text().nullable()(); + + @override + Set get primaryKey => {assetId}; +} diff --git a/mobile/lib/infrastructure/entities/exif.entity.drift.dart b/mobile/lib/infrastructure/entities/exif.entity.drift.dart new file mode 100644 index 0000000000..75ec61d3c7 --- /dev/null +++ b/mobile/lib/infrastructure/entities/exif.entity.drift.dart @@ -0,0 +1,1481 @@ +// dart format width=80 +// ignore_for_file: type=lint +import 'package:drift/drift.dart' as i0; +import 'package:immich_mobile/infrastructure/entities/exif.entity.drift.dart' + as i1; +import 'dart:typed_data' as i2; +import 'package:immich_mobile/infrastructure/entities/exif.entity.dart' as i3; +import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.drift.dart' + as i4; +import 'package:drift/internal/modular.dart' as i5; + +typedef $$ExifEntityTableCreateCompanionBuilder = i1.ExifEntityCompanion + Function({ + required i2.Uint8List assetId, + i0.Value city, + i0.Value state, + i0.Value country, + i0.Value dateTimeOriginal, + i0.Value description, + i0.Value height, + i0.Value width, + i0.Value exposureTime, + i0.Value fNumber, + i0.Value fileSize, + i0.Value focalLength, + i0.Value latitude, + i0.Value longitude, + i0.Value iso, + i0.Value make, + i0.Value model, + i0.Value orientation, + i0.Value timeZone, + i0.Value rating, + i0.Value projectionType, +}); +typedef $$ExifEntityTableUpdateCompanionBuilder = i1.ExifEntityCompanion + Function({ + i0.Value assetId, + i0.Value city, + i0.Value state, + i0.Value country, + i0.Value dateTimeOriginal, + i0.Value description, + i0.Value height, + i0.Value width, + i0.Value exposureTime, + i0.Value fNumber, + i0.Value fileSize, + i0.Value focalLength, + i0.Value latitude, + i0.Value longitude, + i0.Value iso, + i0.Value make, + i0.Value model, + i0.Value orientation, + i0.Value timeZone, + i0.Value rating, + i0.Value projectionType, +}); + +final class $$ExifEntityTableReferences extends i0.BaseReferences< + i0.GeneratedDatabase, i1.$ExifEntityTable, i1.ExifEntityData> { + $$ExifEntityTableReferences(super.$_db, super.$_table, super.$_typedResult); + + static i4.$RemoteAssetEntityTable _assetIdTable(i0.GeneratedDatabase db) => + i5.ReadDatabaseContainer(db) + .resultSet('remote_asset_entity') + .createAlias(i0.$_aliasNameGenerator( + i5.ReadDatabaseContainer(db) + .resultSet('exif_entity') + .assetId, + i5.ReadDatabaseContainer(db) + .resultSet('remote_asset_entity') + .remoteId)); + + i4.$$RemoteAssetEntityTableProcessedTableManager get assetId { + final $_column = $_itemColumn('asset_id')!; + + final manager = i4 + .$$RemoteAssetEntityTableTableManager( + $_db, + i5.ReadDatabaseContainer($_db) + .resultSet('remote_asset_entity')) + .filter((f) => f.remoteId.sqlEquals($_column)); + final item = $_typedResult.readTableOrNull(_assetIdTable($_db)); + if (item == null) return manager; + return i0.ProcessedTableManager( + manager.$state.copyWith(prefetchedData: [item])); + } +} + +class $$ExifEntityTableFilterComposer + extends i0.Composer { + $$ExifEntityTableFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + i0.ColumnFilters get city => $composableBuilder( + column: $table.city, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get state => $composableBuilder( + column: $table.state, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get country => $composableBuilder( + column: $table.country, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get dateTimeOriginal => $composableBuilder( + column: $table.dateTimeOriginal, + builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get description => $composableBuilder( + column: $table.description, + builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get height => $composableBuilder( + column: $table.height, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get width => $composableBuilder( + column: $table.width, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get exposureTime => $composableBuilder( + column: $table.exposureTime, + builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get fNumber => $composableBuilder( + column: $table.fNumber, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get fileSize => $composableBuilder( + column: $table.fileSize, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get focalLength => $composableBuilder( + column: $table.focalLength, + builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get latitude => $composableBuilder( + column: $table.latitude, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get longitude => $composableBuilder( + column: $table.longitude, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get iso => $composableBuilder( + column: $table.iso, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get make => $composableBuilder( + column: $table.make, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get model => $composableBuilder( + column: $table.model, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get orientation => $composableBuilder( + column: $table.orientation, + builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get timeZone => $composableBuilder( + column: $table.timeZone, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get rating => $composableBuilder( + column: $table.rating, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get projectionType => $composableBuilder( + column: $table.projectionType, + builder: (column) => i0.ColumnFilters(column)); + + i4.$$RemoteAssetEntityTableFilterComposer get assetId { + final i4.$$RemoteAssetEntityTableFilterComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.assetId, + referencedTable: i5.ReadDatabaseContainer($db) + .resultSet('remote_asset_entity'), + getReferencedColumn: (t) => t.remoteId, + builder: (joinBuilder, + {$addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer}) => + i4.$$RemoteAssetEntityTableFilterComposer( + $db: $db, + $table: i5.ReadDatabaseContainer($db) + .resultSet('remote_asset_entity'), + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + )); + return composer; + } +} + +class $$ExifEntityTableOrderingComposer + extends i0.Composer { + $$ExifEntityTableOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + i0.ColumnOrderings get city => $composableBuilder( + column: $table.city, builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get state => $composableBuilder( + column: $table.state, builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get country => $composableBuilder( + column: $table.country, builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get dateTimeOriginal => $composableBuilder( + column: $table.dateTimeOriginal, + builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get description => $composableBuilder( + column: $table.description, + builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get height => $composableBuilder( + column: $table.height, builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get width => $composableBuilder( + column: $table.width, builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get exposureTime => $composableBuilder( + column: $table.exposureTime, + builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get fNumber => $composableBuilder( + column: $table.fNumber, builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get fileSize => $composableBuilder( + column: $table.fileSize, builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get focalLength => $composableBuilder( + column: $table.focalLength, + builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get latitude => $composableBuilder( + column: $table.latitude, builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get longitude => $composableBuilder( + column: $table.longitude, + builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get iso => $composableBuilder( + column: $table.iso, builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get make => $composableBuilder( + column: $table.make, builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get model => $composableBuilder( + column: $table.model, builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get orientation => $composableBuilder( + column: $table.orientation, + builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get timeZone => $composableBuilder( + column: $table.timeZone, builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get rating => $composableBuilder( + column: $table.rating, builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get projectionType => $composableBuilder( + column: $table.projectionType, + builder: (column) => i0.ColumnOrderings(column)); + + i4.$$RemoteAssetEntityTableOrderingComposer get assetId { + final i4.$$RemoteAssetEntityTableOrderingComposer composer = + $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.assetId, + referencedTable: i5.ReadDatabaseContainer($db) + .resultSet('remote_asset_entity'), + getReferencedColumn: (t) => t.remoteId, + builder: (joinBuilder, + {$addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer}) => + i4.$$RemoteAssetEntityTableOrderingComposer( + $db: $db, + $table: i5.ReadDatabaseContainer($db) + .resultSet( + 'remote_asset_entity'), + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + )); + return composer; + } +} + +class $$ExifEntityTableAnnotationComposer + extends i0.Composer { + $$ExifEntityTableAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + i0.GeneratedColumn get city => + $composableBuilder(column: $table.city, builder: (column) => column); + + i0.GeneratedColumn get state => + $composableBuilder(column: $table.state, builder: (column) => column); + + i0.GeneratedColumn get country => + $composableBuilder(column: $table.country, builder: (column) => column); + + i0.GeneratedColumn get dateTimeOriginal => $composableBuilder( + column: $table.dateTimeOriginal, builder: (column) => column); + + i0.GeneratedColumn get description => $composableBuilder( + column: $table.description, builder: (column) => column); + + i0.GeneratedColumn get height => + $composableBuilder(column: $table.height, builder: (column) => column); + + i0.GeneratedColumn get width => + $composableBuilder(column: $table.width, builder: (column) => column); + + i0.GeneratedColumn get exposureTime => $composableBuilder( + column: $table.exposureTime, builder: (column) => column); + + i0.GeneratedColumn get fNumber => + $composableBuilder(column: $table.fNumber, builder: (column) => column); + + i0.GeneratedColumn get fileSize => + $composableBuilder(column: $table.fileSize, builder: (column) => column); + + i0.GeneratedColumn get focalLength => $composableBuilder( + column: $table.focalLength, builder: (column) => column); + + i0.GeneratedColumn get latitude => + $composableBuilder(column: $table.latitude, builder: (column) => column); + + i0.GeneratedColumn get longitude => + $composableBuilder(column: $table.longitude, builder: (column) => column); + + i0.GeneratedColumn get iso => + $composableBuilder(column: $table.iso, builder: (column) => column); + + i0.GeneratedColumn get make => + $composableBuilder(column: $table.make, builder: (column) => column); + + i0.GeneratedColumn get model => + $composableBuilder(column: $table.model, builder: (column) => column); + + i0.GeneratedColumn get orientation => $composableBuilder( + column: $table.orientation, builder: (column) => column); + + i0.GeneratedColumn get timeZone => + $composableBuilder(column: $table.timeZone, builder: (column) => column); + + i0.GeneratedColumn get rating => + $composableBuilder(column: $table.rating, builder: (column) => column); + + i0.GeneratedColumn get projectionType => $composableBuilder( + column: $table.projectionType, builder: (column) => column); + + i4.$$RemoteAssetEntityTableAnnotationComposer get assetId { + final i4.$$RemoteAssetEntityTableAnnotationComposer composer = + $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.assetId, + referencedTable: i5.ReadDatabaseContainer($db) + .resultSet('remote_asset_entity'), + getReferencedColumn: (t) => t.remoteId, + builder: (joinBuilder, + {$addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer}) => + i4.$$RemoteAssetEntityTableAnnotationComposer( + $db: $db, + $table: i5.ReadDatabaseContainer($db) + .resultSet( + 'remote_asset_entity'), + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + )); + return composer; + } +} + +class $$ExifEntityTableTableManager extends i0.RootTableManager< + i0.GeneratedDatabase, + i1.$ExifEntityTable, + i1.ExifEntityData, + i1.$$ExifEntityTableFilterComposer, + i1.$$ExifEntityTableOrderingComposer, + i1.$$ExifEntityTableAnnotationComposer, + $$ExifEntityTableCreateCompanionBuilder, + $$ExifEntityTableUpdateCompanionBuilder, + (i1.ExifEntityData, i1.$$ExifEntityTableReferences), + i1.ExifEntityData, + i0.PrefetchHooks Function({bool assetId})> { + $$ExifEntityTableTableManager( + i0.GeneratedDatabase db, i1.$ExifEntityTable table) + : super(i0.TableManagerState( + db: db, + table: table, + createFilteringComposer: () => + i1.$$ExifEntityTableFilterComposer($db: db, $table: table), + createOrderingComposer: () => + i1.$$ExifEntityTableOrderingComposer($db: db, $table: table), + createComputedFieldComposer: () => + i1.$$ExifEntityTableAnnotationComposer($db: db, $table: table), + updateCompanionCallback: ({ + i0.Value assetId = const i0.Value.absent(), + i0.Value city = const i0.Value.absent(), + i0.Value state = const i0.Value.absent(), + i0.Value country = const i0.Value.absent(), + i0.Value dateTimeOriginal = const i0.Value.absent(), + i0.Value description = const i0.Value.absent(), + i0.Value height = const i0.Value.absent(), + i0.Value width = const i0.Value.absent(), + i0.Value exposureTime = const i0.Value.absent(), + i0.Value fNumber = const i0.Value.absent(), + i0.Value fileSize = const i0.Value.absent(), + i0.Value focalLength = const i0.Value.absent(), + i0.Value latitude = const i0.Value.absent(), + i0.Value longitude = const i0.Value.absent(), + i0.Value iso = const i0.Value.absent(), + i0.Value make = const i0.Value.absent(), + i0.Value model = const i0.Value.absent(), + i0.Value orientation = const i0.Value.absent(), + i0.Value timeZone = const i0.Value.absent(), + i0.Value rating = const i0.Value.absent(), + i0.Value projectionType = const i0.Value.absent(), + }) => + i1.ExifEntityCompanion( + assetId: assetId, + city: city, + state: state, + country: country, + dateTimeOriginal: dateTimeOriginal, + description: description, + height: height, + width: width, + exposureTime: exposureTime, + fNumber: fNumber, + fileSize: fileSize, + focalLength: focalLength, + latitude: latitude, + longitude: longitude, + iso: iso, + make: make, + model: model, + orientation: orientation, + timeZone: timeZone, + rating: rating, + projectionType: projectionType, + ), + createCompanionCallback: ({ + required i2.Uint8List assetId, + i0.Value city = const i0.Value.absent(), + i0.Value state = const i0.Value.absent(), + i0.Value country = const i0.Value.absent(), + i0.Value dateTimeOriginal = const i0.Value.absent(), + i0.Value description = const i0.Value.absent(), + i0.Value height = const i0.Value.absent(), + i0.Value width = const i0.Value.absent(), + i0.Value exposureTime = const i0.Value.absent(), + i0.Value fNumber = const i0.Value.absent(), + i0.Value fileSize = const i0.Value.absent(), + i0.Value focalLength = const i0.Value.absent(), + i0.Value latitude = const i0.Value.absent(), + i0.Value longitude = const i0.Value.absent(), + i0.Value iso = const i0.Value.absent(), + i0.Value make = const i0.Value.absent(), + i0.Value model = const i0.Value.absent(), + i0.Value orientation = const i0.Value.absent(), + i0.Value timeZone = const i0.Value.absent(), + i0.Value rating = const i0.Value.absent(), + i0.Value projectionType = const i0.Value.absent(), + }) => + i1.ExifEntityCompanion.insert( + assetId: assetId, + city: city, + state: state, + country: country, + dateTimeOriginal: dateTimeOriginal, + description: description, + height: height, + width: width, + exposureTime: exposureTime, + fNumber: fNumber, + fileSize: fileSize, + focalLength: focalLength, + latitude: latitude, + longitude: longitude, + iso: iso, + make: make, + model: model, + orientation: orientation, + timeZone: timeZone, + rating: rating, + projectionType: projectionType, + ), + withReferenceMapper: (p0) => p0 + .map((e) => ( + e.readTable(table), + i1.$$ExifEntityTableReferences(db, table, e) + )) + .toList(), + prefetchHooksCallback: ({assetId = false}) { + return i0.PrefetchHooks( + db: db, + explicitlyWatchedTables: [], + addJoins: < + T extends i0.TableManagerState< + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic>>(state) { + if (assetId) { + state = state.withJoin( + currentTable: table, + currentColumn: table.assetId, + referencedTable: + i1.$$ExifEntityTableReferences._assetIdTable(db), + referencedColumn: i1.$$ExifEntityTableReferences + ._assetIdTable(db) + .remoteId, + ) as T; + } + + return state; + }, + getPrefetchedDataCallback: (items) async { + return []; + }, + ); + }, + )); +} + +typedef $$ExifEntityTableProcessedTableManager = i0.ProcessedTableManager< + i0.GeneratedDatabase, + i1.$ExifEntityTable, + i1.ExifEntityData, + i1.$$ExifEntityTableFilterComposer, + i1.$$ExifEntityTableOrderingComposer, + i1.$$ExifEntityTableAnnotationComposer, + $$ExifEntityTableCreateCompanionBuilder, + $$ExifEntityTableUpdateCompanionBuilder, + (i1.ExifEntityData, i1.$$ExifEntityTableReferences), + i1.ExifEntityData, + i0.PrefetchHooks Function({bool assetId})>; + +class $ExifEntityTable extends i3.ExifEntity + with i0.TableInfo<$ExifEntityTable, i1.ExifEntityData> { + @override + final i0.GeneratedDatabase attachedDatabase; + final String? _alias; + $ExifEntityTable(this.attachedDatabase, [this._alias]); + static const i0.VerificationMeta _assetIdMeta = + const i0.VerificationMeta('assetId'); + @override + late final i0.GeneratedColumn assetId = + i0.GeneratedColumn('asset_id', aliasedName, false, + type: i0.DriftSqlType.blob, + requiredDuringInsert: true, + defaultConstraints: i0.GeneratedColumn.constraintIsAlways( + 'REFERENCES remote_asset_entity (remote_id) ON DELETE CASCADE')); + static const i0.VerificationMeta _cityMeta = + const i0.VerificationMeta('city'); + @override + late final i0.GeneratedColumn city = i0.GeneratedColumn( + 'city', aliasedName, true, + type: i0.DriftSqlType.string, requiredDuringInsert: false); + static const i0.VerificationMeta _stateMeta = + const i0.VerificationMeta('state'); + @override + late final i0.GeneratedColumn state = i0.GeneratedColumn( + 'state', aliasedName, true, + type: i0.DriftSqlType.string, requiredDuringInsert: false); + static const i0.VerificationMeta _countryMeta = + const i0.VerificationMeta('country'); + @override + late final i0.GeneratedColumn country = i0.GeneratedColumn( + 'country', aliasedName, true, + type: i0.DriftSqlType.string, requiredDuringInsert: false); + static const i0.VerificationMeta _dateTimeOriginalMeta = + const i0.VerificationMeta('dateTimeOriginal'); + @override + late final i0.GeneratedColumn dateTimeOriginal = + i0.GeneratedColumn('date_time_original', aliasedName, true, + type: i0.DriftSqlType.dateTime, requiredDuringInsert: false); + static const i0.VerificationMeta _descriptionMeta = + const i0.VerificationMeta('description'); + @override + late final i0.GeneratedColumn description = + i0.GeneratedColumn('description', aliasedName, true, + type: i0.DriftSqlType.string, requiredDuringInsert: false); + static const i0.VerificationMeta _heightMeta = + const i0.VerificationMeta('height'); + @override + late final i0.GeneratedColumn height = i0.GeneratedColumn( + 'height', aliasedName, true, + type: i0.DriftSqlType.int, requiredDuringInsert: false); + static const i0.VerificationMeta _widthMeta = + const i0.VerificationMeta('width'); + @override + late final i0.GeneratedColumn width = i0.GeneratedColumn( + 'width', aliasedName, true, + type: i0.DriftSqlType.int, requiredDuringInsert: false); + static const i0.VerificationMeta _exposureTimeMeta = + const i0.VerificationMeta('exposureTime'); + @override + late final i0.GeneratedColumn exposureTime = + i0.GeneratedColumn('exposure_time', aliasedName, true, + type: i0.DriftSqlType.string, requiredDuringInsert: false); + static const i0.VerificationMeta _fNumberMeta = + const i0.VerificationMeta('fNumber'); + @override + late final i0.GeneratedColumn fNumber = i0.GeneratedColumn( + 'f_number', aliasedName, true, + type: i0.DriftSqlType.int, requiredDuringInsert: false); + static const i0.VerificationMeta _fileSizeMeta = + const i0.VerificationMeta('fileSize'); + @override + late final i0.GeneratedColumn fileSize = i0.GeneratedColumn( + 'file_size', aliasedName, true, + type: i0.DriftSqlType.int, requiredDuringInsert: false); + static const i0.VerificationMeta _focalLengthMeta = + const i0.VerificationMeta('focalLength'); + @override + late final i0.GeneratedColumn focalLength = i0.GeneratedColumn( + 'focal_length', aliasedName, true, + type: i0.DriftSqlType.int, requiredDuringInsert: false); + static const i0.VerificationMeta _latitudeMeta = + const i0.VerificationMeta('latitude'); + @override + late final i0.GeneratedColumn latitude = i0.GeneratedColumn( + 'latitude', aliasedName, true, + type: i0.DriftSqlType.int, requiredDuringInsert: false); + static const i0.VerificationMeta _longitudeMeta = + const i0.VerificationMeta('longitude'); + @override + late final i0.GeneratedColumn longitude = i0.GeneratedColumn( + 'longitude', aliasedName, true, + type: i0.DriftSqlType.int, requiredDuringInsert: false); + static const i0.VerificationMeta _isoMeta = const i0.VerificationMeta('iso'); + @override + late final i0.GeneratedColumn iso = i0.GeneratedColumn( + 'iso', aliasedName, true, + type: i0.DriftSqlType.int, requiredDuringInsert: false); + static const i0.VerificationMeta _makeMeta = + const i0.VerificationMeta('make'); + @override + late final i0.GeneratedColumn make = i0.GeneratedColumn( + 'make', aliasedName, true, + type: i0.DriftSqlType.string, requiredDuringInsert: false); + static const i0.VerificationMeta _modelMeta = + const i0.VerificationMeta('model'); + @override + late final i0.GeneratedColumn model = i0.GeneratedColumn( + 'model', aliasedName, true, + type: i0.DriftSqlType.string, requiredDuringInsert: false); + static const i0.VerificationMeta _orientationMeta = + const i0.VerificationMeta('orientation'); + @override + late final i0.GeneratedColumn orientation = + i0.GeneratedColumn('orientation', aliasedName, true, + type: i0.DriftSqlType.string, requiredDuringInsert: false); + static const i0.VerificationMeta _timeZoneMeta = + const i0.VerificationMeta('timeZone'); + @override + late final i0.GeneratedColumn timeZone = i0.GeneratedColumn( + 'time_zone', aliasedName, true, + type: i0.DriftSqlType.string, requiredDuringInsert: false); + static const i0.VerificationMeta _ratingMeta = + const i0.VerificationMeta('rating'); + @override + late final i0.GeneratedColumn rating = i0.GeneratedColumn( + 'rating', aliasedName, true, + type: i0.DriftSqlType.int, requiredDuringInsert: false); + static const i0.VerificationMeta _projectionTypeMeta = + const i0.VerificationMeta('projectionType'); + @override + late final i0.GeneratedColumn projectionType = + i0.GeneratedColumn('projection_type', aliasedName, true, + type: i0.DriftSqlType.string, requiredDuringInsert: false); + @override + List get $columns => [ + assetId, + city, + state, + country, + dateTimeOriginal, + description, + height, + width, + exposureTime, + fNumber, + fileSize, + focalLength, + latitude, + longitude, + iso, + make, + model, + orientation, + timeZone, + rating, + projectionType + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'exif_entity'; + @override + i0.VerificationContext validateIntegrity( + i0.Insertable instance, + {bool isInserting = false}) { + final context = i0.VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('asset_id')) { + context.handle(_assetIdMeta, + assetId.isAcceptableOrUnknown(data['asset_id']!, _assetIdMeta)); + } else if (isInserting) { + context.missing(_assetIdMeta); + } + if (data.containsKey('city')) { + context.handle( + _cityMeta, city.isAcceptableOrUnknown(data['city']!, _cityMeta)); + } + if (data.containsKey('state')) { + context.handle( + _stateMeta, state.isAcceptableOrUnknown(data['state']!, _stateMeta)); + } + if (data.containsKey('country')) { + context.handle(_countryMeta, + country.isAcceptableOrUnknown(data['country']!, _countryMeta)); + } + if (data.containsKey('date_time_original')) { + context.handle( + _dateTimeOriginalMeta, + dateTimeOriginal.isAcceptableOrUnknown( + data['date_time_original']!, _dateTimeOriginalMeta)); + } + if (data.containsKey('description')) { + context.handle( + _descriptionMeta, + description.isAcceptableOrUnknown( + data['description']!, _descriptionMeta)); + } + if (data.containsKey('height')) { + context.handle(_heightMeta, + height.isAcceptableOrUnknown(data['height']!, _heightMeta)); + } + if (data.containsKey('width')) { + context.handle( + _widthMeta, width.isAcceptableOrUnknown(data['width']!, _widthMeta)); + } + if (data.containsKey('exposure_time')) { + context.handle( + _exposureTimeMeta, + exposureTime.isAcceptableOrUnknown( + data['exposure_time']!, _exposureTimeMeta)); + } + if (data.containsKey('f_number')) { + context.handle(_fNumberMeta, + fNumber.isAcceptableOrUnknown(data['f_number']!, _fNumberMeta)); + } + if (data.containsKey('file_size')) { + context.handle(_fileSizeMeta, + fileSize.isAcceptableOrUnknown(data['file_size']!, _fileSizeMeta)); + } + if (data.containsKey('focal_length')) { + context.handle( + _focalLengthMeta, + focalLength.isAcceptableOrUnknown( + data['focal_length']!, _focalLengthMeta)); + } + if (data.containsKey('latitude')) { + context.handle(_latitudeMeta, + latitude.isAcceptableOrUnknown(data['latitude']!, _latitudeMeta)); + } + if (data.containsKey('longitude')) { + context.handle(_longitudeMeta, + longitude.isAcceptableOrUnknown(data['longitude']!, _longitudeMeta)); + } + if (data.containsKey('iso')) { + context.handle( + _isoMeta, iso.isAcceptableOrUnknown(data['iso']!, _isoMeta)); + } + if (data.containsKey('make')) { + context.handle( + _makeMeta, make.isAcceptableOrUnknown(data['make']!, _makeMeta)); + } + if (data.containsKey('model')) { + context.handle( + _modelMeta, model.isAcceptableOrUnknown(data['model']!, _modelMeta)); + } + if (data.containsKey('orientation')) { + context.handle( + _orientationMeta, + orientation.isAcceptableOrUnknown( + data['orientation']!, _orientationMeta)); + } + if (data.containsKey('time_zone')) { + context.handle(_timeZoneMeta, + timeZone.isAcceptableOrUnknown(data['time_zone']!, _timeZoneMeta)); + } + if (data.containsKey('rating')) { + context.handle(_ratingMeta, + rating.isAcceptableOrUnknown(data['rating']!, _ratingMeta)); + } + if (data.containsKey('projection_type')) { + context.handle( + _projectionTypeMeta, + projectionType.isAcceptableOrUnknown( + data['projection_type']!, _projectionTypeMeta)); + } + return context; + } + + @override + Set get $primaryKey => {assetId}; + @override + i1.ExifEntityData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return i1.ExifEntityData( + assetId: attachedDatabase.typeMapping + .read(i0.DriftSqlType.blob, data['${effectivePrefix}asset_id'])!, + city: attachedDatabase.typeMapping + .read(i0.DriftSqlType.string, data['${effectivePrefix}city']), + state: attachedDatabase.typeMapping + .read(i0.DriftSqlType.string, data['${effectivePrefix}state']), + country: attachedDatabase.typeMapping + .read(i0.DriftSqlType.string, data['${effectivePrefix}country']), + dateTimeOriginal: attachedDatabase.typeMapping.read( + i0.DriftSqlType.dateTime, + data['${effectivePrefix}date_time_original']), + description: attachedDatabase.typeMapping + .read(i0.DriftSqlType.string, data['${effectivePrefix}description']), + height: attachedDatabase.typeMapping + .read(i0.DriftSqlType.int, data['${effectivePrefix}height']), + width: attachedDatabase.typeMapping + .read(i0.DriftSqlType.int, data['${effectivePrefix}width']), + exposureTime: attachedDatabase.typeMapping.read( + i0.DriftSqlType.string, data['${effectivePrefix}exposure_time']), + fNumber: attachedDatabase.typeMapping + .read(i0.DriftSqlType.int, data['${effectivePrefix}f_number']), + fileSize: attachedDatabase.typeMapping + .read(i0.DriftSqlType.int, data['${effectivePrefix}file_size']), + focalLength: attachedDatabase.typeMapping + .read(i0.DriftSqlType.int, data['${effectivePrefix}focal_length']), + latitude: attachedDatabase.typeMapping + .read(i0.DriftSqlType.int, data['${effectivePrefix}latitude']), + longitude: attachedDatabase.typeMapping + .read(i0.DriftSqlType.int, data['${effectivePrefix}longitude']), + iso: attachedDatabase.typeMapping + .read(i0.DriftSqlType.int, data['${effectivePrefix}iso']), + make: attachedDatabase.typeMapping + .read(i0.DriftSqlType.string, data['${effectivePrefix}make']), + model: attachedDatabase.typeMapping + .read(i0.DriftSqlType.string, data['${effectivePrefix}model']), + orientation: attachedDatabase.typeMapping + .read(i0.DriftSqlType.string, data['${effectivePrefix}orientation']), + timeZone: attachedDatabase.typeMapping + .read(i0.DriftSqlType.string, data['${effectivePrefix}time_zone']), + rating: attachedDatabase.typeMapping + .read(i0.DriftSqlType.int, data['${effectivePrefix}rating']), + projectionType: attachedDatabase.typeMapping.read( + i0.DriftSqlType.string, data['${effectivePrefix}projection_type']), + ); + } + + @override + $ExifEntityTable createAlias(String alias) { + return $ExifEntityTable(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; +} + +class ExifEntityData extends i0.DataClass + implements i0.Insertable { + final i2.Uint8List assetId; + final String? city; + final String? state; + final String? country; + final DateTime? dateTimeOriginal; + final String? description; + final int? height; + final int? width; + final String? exposureTime; + final int? fNumber; + final int? fileSize; + final int? focalLength; + final int? latitude; + final int? longitude; + final int? iso; + final String? make; + final String? model; + final String? orientation; + final String? timeZone; + final int? rating; + final String? projectionType; + const ExifEntityData( + {required this.assetId, + this.city, + this.state, + this.country, + this.dateTimeOriginal, + this.description, + this.height, + this.width, + this.exposureTime, + this.fNumber, + this.fileSize, + this.focalLength, + this.latitude, + this.longitude, + this.iso, + this.make, + this.model, + this.orientation, + this.timeZone, + this.rating, + this.projectionType}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['asset_id'] = i0.Variable(assetId); + if (!nullToAbsent || city != null) { + map['city'] = i0.Variable(city); + } + if (!nullToAbsent || state != null) { + map['state'] = i0.Variable(state); + } + if (!nullToAbsent || country != null) { + map['country'] = i0.Variable(country); + } + if (!nullToAbsent || dateTimeOriginal != null) { + map['date_time_original'] = i0.Variable(dateTimeOriginal); + } + if (!nullToAbsent || description != null) { + map['description'] = i0.Variable(description); + } + if (!nullToAbsent || height != null) { + map['height'] = i0.Variable(height); + } + if (!nullToAbsent || width != null) { + map['width'] = i0.Variable(width); + } + if (!nullToAbsent || exposureTime != null) { + map['exposure_time'] = i0.Variable(exposureTime); + } + if (!nullToAbsent || fNumber != null) { + map['f_number'] = i0.Variable(fNumber); + } + if (!nullToAbsent || fileSize != null) { + map['file_size'] = i0.Variable(fileSize); + } + if (!nullToAbsent || focalLength != null) { + map['focal_length'] = i0.Variable(focalLength); + } + if (!nullToAbsent || latitude != null) { + map['latitude'] = i0.Variable(latitude); + } + if (!nullToAbsent || longitude != null) { + map['longitude'] = i0.Variable(longitude); + } + if (!nullToAbsent || iso != null) { + map['iso'] = i0.Variable(iso); + } + if (!nullToAbsent || make != null) { + map['make'] = i0.Variable(make); + } + if (!nullToAbsent || model != null) { + map['model'] = i0.Variable(model); + } + if (!nullToAbsent || orientation != null) { + map['orientation'] = i0.Variable(orientation); + } + if (!nullToAbsent || timeZone != null) { + map['time_zone'] = i0.Variable(timeZone); + } + if (!nullToAbsent || rating != null) { + map['rating'] = i0.Variable(rating); + } + if (!nullToAbsent || projectionType != null) { + map['projection_type'] = i0.Variable(projectionType); + } + return map; + } + + factory ExifEntityData.fromJson(Map json, + {i0.ValueSerializer? serializer}) { + serializer ??= i0.driftRuntimeOptions.defaultSerializer; + return ExifEntityData( + assetId: serializer.fromJson(json['assetId']), + city: serializer.fromJson(json['city']), + state: serializer.fromJson(json['state']), + country: serializer.fromJson(json['country']), + dateTimeOriginal: + serializer.fromJson(json['dateTimeOriginal']), + description: serializer.fromJson(json['description']), + height: serializer.fromJson(json['height']), + width: serializer.fromJson(json['width']), + exposureTime: serializer.fromJson(json['exposureTime']), + fNumber: serializer.fromJson(json['fNumber']), + fileSize: serializer.fromJson(json['fileSize']), + focalLength: serializer.fromJson(json['focalLength']), + latitude: serializer.fromJson(json['latitude']), + longitude: serializer.fromJson(json['longitude']), + iso: serializer.fromJson(json['iso']), + make: serializer.fromJson(json['make']), + model: serializer.fromJson(json['model']), + orientation: serializer.fromJson(json['orientation']), + timeZone: serializer.fromJson(json['timeZone']), + rating: serializer.fromJson(json['rating']), + projectionType: serializer.fromJson(json['projectionType']), + ); + } + @override + Map toJson({i0.ValueSerializer? serializer}) { + serializer ??= i0.driftRuntimeOptions.defaultSerializer; + return { + 'assetId': serializer.toJson(assetId), + 'city': serializer.toJson(city), + 'state': serializer.toJson(state), + 'country': serializer.toJson(country), + 'dateTimeOriginal': serializer.toJson(dateTimeOriginal), + 'description': serializer.toJson(description), + 'height': serializer.toJson(height), + 'width': serializer.toJson(width), + 'exposureTime': serializer.toJson(exposureTime), + 'fNumber': serializer.toJson(fNumber), + 'fileSize': serializer.toJson(fileSize), + 'focalLength': serializer.toJson(focalLength), + 'latitude': serializer.toJson(latitude), + 'longitude': serializer.toJson(longitude), + 'iso': serializer.toJson(iso), + 'make': serializer.toJson(make), + 'model': serializer.toJson(model), + 'orientation': serializer.toJson(orientation), + 'timeZone': serializer.toJson(timeZone), + 'rating': serializer.toJson(rating), + 'projectionType': serializer.toJson(projectionType), + }; + } + + i1.ExifEntityData copyWith( + {i2.Uint8List? assetId, + i0.Value city = const i0.Value.absent(), + i0.Value state = const i0.Value.absent(), + i0.Value country = const i0.Value.absent(), + i0.Value dateTimeOriginal = const i0.Value.absent(), + i0.Value description = const i0.Value.absent(), + i0.Value height = const i0.Value.absent(), + i0.Value width = const i0.Value.absent(), + i0.Value exposureTime = const i0.Value.absent(), + i0.Value fNumber = const i0.Value.absent(), + i0.Value fileSize = const i0.Value.absent(), + i0.Value focalLength = const i0.Value.absent(), + i0.Value latitude = const i0.Value.absent(), + i0.Value longitude = const i0.Value.absent(), + i0.Value iso = const i0.Value.absent(), + i0.Value make = const i0.Value.absent(), + i0.Value model = const i0.Value.absent(), + i0.Value orientation = const i0.Value.absent(), + i0.Value timeZone = const i0.Value.absent(), + i0.Value rating = const i0.Value.absent(), + i0.Value projectionType = const i0.Value.absent()}) => + i1.ExifEntityData( + assetId: assetId ?? this.assetId, + city: city.present ? city.value : this.city, + state: state.present ? state.value : this.state, + country: country.present ? country.value : this.country, + dateTimeOriginal: dateTimeOriginal.present + ? dateTimeOriginal.value + : this.dateTimeOriginal, + description: description.present ? description.value : this.description, + height: height.present ? height.value : this.height, + width: width.present ? width.value : this.width, + exposureTime: + exposureTime.present ? exposureTime.value : this.exposureTime, + fNumber: fNumber.present ? fNumber.value : this.fNumber, + fileSize: fileSize.present ? fileSize.value : this.fileSize, + focalLength: focalLength.present ? focalLength.value : this.focalLength, + latitude: latitude.present ? latitude.value : this.latitude, + longitude: longitude.present ? longitude.value : this.longitude, + iso: iso.present ? iso.value : this.iso, + make: make.present ? make.value : this.make, + model: model.present ? model.value : this.model, + orientation: orientation.present ? orientation.value : this.orientation, + timeZone: timeZone.present ? timeZone.value : this.timeZone, + rating: rating.present ? rating.value : this.rating, + projectionType: + projectionType.present ? projectionType.value : this.projectionType, + ); + ExifEntityData copyWithCompanion(i1.ExifEntityCompanion data) { + return ExifEntityData( + assetId: data.assetId.present ? data.assetId.value : this.assetId, + city: data.city.present ? data.city.value : this.city, + state: data.state.present ? data.state.value : this.state, + country: data.country.present ? data.country.value : this.country, + dateTimeOriginal: data.dateTimeOriginal.present + ? data.dateTimeOriginal.value + : this.dateTimeOriginal, + description: + data.description.present ? data.description.value : this.description, + height: data.height.present ? data.height.value : this.height, + width: data.width.present ? data.width.value : this.width, + exposureTime: data.exposureTime.present + ? data.exposureTime.value + : this.exposureTime, + fNumber: data.fNumber.present ? data.fNumber.value : this.fNumber, + fileSize: data.fileSize.present ? data.fileSize.value : this.fileSize, + focalLength: + data.focalLength.present ? data.focalLength.value : this.focalLength, + latitude: data.latitude.present ? data.latitude.value : this.latitude, + longitude: data.longitude.present ? data.longitude.value : this.longitude, + iso: data.iso.present ? data.iso.value : this.iso, + make: data.make.present ? data.make.value : this.make, + model: data.model.present ? data.model.value : this.model, + orientation: + data.orientation.present ? data.orientation.value : this.orientation, + timeZone: data.timeZone.present ? data.timeZone.value : this.timeZone, + rating: data.rating.present ? data.rating.value : this.rating, + projectionType: data.projectionType.present + ? data.projectionType.value + : this.projectionType, + ); + } + + @override + String toString() { + return (StringBuffer('ExifEntityData(') + ..write('assetId: $assetId, ') + ..write('city: $city, ') + ..write('state: $state, ') + ..write('country: $country, ') + ..write('dateTimeOriginal: $dateTimeOriginal, ') + ..write('description: $description, ') + ..write('height: $height, ') + ..write('width: $width, ') + ..write('exposureTime: $exposureTime, ') + ..write('fNumber: $fNumber, ') + ..write('fileSize: $fileSize, ') + ..write('focalLength: $focalLength, ') + ..write('latitude: $latitude, ') + ..write('longitude: $longitude, ') + ..write('iso: $iso, ') + ..write('make: $make, ') + ..write('model: $model, ') + ..write('orientation: $orientation, ') + ..write('timeZone: $timeZone, ') + ..write('rating: $rating, ') + ..write('projectionType: $projectionType') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hashAll([ + i0.$driftBlobEquality.hash(assetId), + city, + state, + country, + dateTimeOriginal, + description, + height, + width, + exposureTime, + fNumber, + fileSize, + focalLength, + latitude, + longitude, + iso, + make, + model, + orientation, + timeZone, + rating, + projectionType + ]); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is i1.ExifEntityData && + i0.$driftBlobEquality.equals(other.assetId, this.assetId) && + other.city == this.city && + other.state == this.state && + other.country == this.country && + other.dateTimeOriginal == this.dateTimeOriginal && + other.description == this.description && + other.height == this.height && + other.width == this.width && + other.exposureTime == this.exposureTime && + other.fNumber == this.fNumber && + other.fileSize == this.fileSize && + other.focalLength == this.focalLength && + other.latitude == this.latitude && + other.longitude == this.longitude && + other.iso == this.iso && + other.make == this.make && + other.model == this.model && + other.orientation == this.orientation && + other.timeZone == this.timeZone && + other.rating == this.rating && + other.projectionType == this.projectionType); +} + +class ExifEntityCompanion extends i0.UpdateCompanion { + final i0.Value assetId; + final i0.Value city; + final i0.Value state; + final i0.Value country; + final i0.Value dateTimeOriginal; + final i0.Value description; + final i0.Value height; + final i0.Value width; + final i0.Value exposureTime; + final i0.Value fNumber; + final i0.Value fileSize; + final i0.Value focalLength; + final i0.Value latitude; + final i0.Value longitude; + final i0.Value iso; + final i0.Value make; + final i0.Value model; + final i0.Value orientation; + final i0.Value timeZone; + final i0.Value rating; + final i0.Value projectionType; + const ExifEntityCompanion({ + this.assetId = const i0.Value.absent(), + this.city = const i0.Value.absent(), + this.state = const i0.Value.absent(), + this.country = const i0.Value.absent(), + this.dateTimeOriginal = const i0.Value.absent(), + this.description = const i0.Value.absent(), + this.height = const i0.Value.absent(), + this.width = const i0.Value.absent(), + this.exposureTime = const i0.Value.absent(), + this.fNumber = const i0.Value.absent(), + this.fileSize = const i0.Value.absent(), + this.focalLength = const i0.Value.absent(), + this.latitude = const i0.Value.absent(), + this.longitude = const i0.Value.absent(), + this.iso = const i0.Value.absent(), + this.make = const i0.Value.absent(), + this.model = const i0.Value.absent(), + this.orientation = const i0.Value.absent(), + this.timeZone = const i0.Value.absent(), + this.rating = const i0.Value.absent(), + this.projectionType = const i0.Value.absent(), + }); + ExifEntityCompanion.insert({ + required i2.Uint8List assetId, + this.city = const i0.Value.absent(), + this.state = const i0.Value.absent(), + this.country = const i0.Value.absent(), + this.dateTimeOriginal = const i0.Value.absent(), + this.description = const i0.Value.absent(), + this.height = const i0.Value.absent(), + this.width = const i0.Value.absent(), + this.exposureTime = const i0.Value.absent(), + this.fNumber = const i0.Value.absent(), + this.fileSize = const i0.Value.absent(), + this.focalLength = const i0.Value.absent(), + this.latitude = const i0.Value.absent(), + this.longitude = const i0.Value.absent(), + this.iso = const i0.Value.absent(), + this.make = const i0.Value.absent(), + this.model = const i0.Value.absent(), + this.orientation = const i0.Value.absent(), + this.timeZone = const i0.Value.absent(), + this.rating = const i0.Value.absent(), + this.projectionType = const i0.Value.absent(), + }) : assetId = i0.Value(assetId); + static i0.Insertable custom({ + i0.Expression? assetId, + i0.Expression? city, + i0.Expression? state, + i0.Expression? country, + i0.Expression? dateTimeOriginal, + i0.Expression? description, + i0.Expression? height, + i0.Expression? width, + i0.Expression? exposureTime, + i0.Expression? fNumber, + i0.Expression? fileSize, + i0.Expression? focalLength, + i0.Expression? latitude, + i0.Expression? longitude, + i0.Expression? iso, + i0.Expression? make, + i0.Expression? model, + i0.Expression? orientation, + i0.Expression? timeZone, + i0.Expression? rating, + i0.Expression? projectionType, + }) { + return i0.RawValuesInsertable({ + if (assetId != null) 'asset_id': assetId, + if (city != null) 'city': city, + if (state != null) 'state': state, + if (country != null) 'country': country, + if (dateTimeOriginal != null) 'date_time_original': dateTimeOriginal, + if (description != null) 'description': description, + if (height != null) 'height': height, + if (width != null) 'width': width, + if (exposureTime != null) 'exposure_time': exposureTime, + if (fNumber != null) 'f_number': fNumber, + if (fileSize != null) 'file_size': fileSize, + if (focalLength != null) 'focal_length': focalLength, + if (latitude != null) 'latitude': latitude, + if (longitude != null) 'longitude': longitude, + if (iso != null) 'iso': iso, + if (make != null) 'make': make, + if (model != null) 'model': model, + if (orientation != null) 'orientation': orientation, + if (timeZone != null) 'time_zone': timeZone, + if (rating != null) 'rating': rating, + if (projectionType != null) 'projection_type': projectionType, + }); + } + + i1.ExifEntityCompanion copyWith( + {i0.Value? assetId, + i0.Value? city, + i0.Value? state, + i0.Value? country, + i0.Value? dateTimeOriginal, + i0.Value? description, + i0.Value? height, + i0.Value? width, + i0.Value? exposureTime, + i0.Value? fNumber, + i0.Value? fileSize, + i0.Value? focalLength, + i0.Value? latitude, + i0.Value? longitude, + i0.Value? iso, + i0.Value? make, + i0.Value? model, + i0.Value? orientation, + i0.Value? timeZone, + i0.Value? rating, + i0.Value? projectionType}) { + return i1.ExifEntityCompanion( + assetId: assetId ?? this.assetId, + city: city ?? this.city, + state: state ?? this.state, + country: country ?? this.country, + dateTimeOriginal: dateTimeOriginal ?? this.dateTimeOriginal, + description: description ?? this.description, + height: height ?? this.height, + width: width ?? this.width, + exposureTime: exposureTime ?? this.exposureTime, + fNumber: fNumber ?? this.fNumber, + fileSize: fileSize ?? this.fileSize, + focalLength: focalLength ?? this.focalLength, + latitude: latitude ?? this.latitude, + longitude: longitude ?? this.longitude, + iso: iso ?? this.iso, + make: make ?? this.make, + model: model ?? this.model, + orientation: orientation ?? this.orientation, + timeZone: timeZone ?? this.timeZone, + rating: rating ?? this.rating, + projectionType: projectionType ?? this.projectionType, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (assetId.present) { + map['asset_id'] = i0.Variable(assetId.value); + } + if (city.present) { + map['city'] = i0.Variable(city.value); + } + if (state.present) { + map['state'] = i0.Variable(state.value); + } + if (country.present) { + map['country'] = i0.Variable(country.value); + } + if (dateTimeOriginal.present) { + map['date_time_original'] = i0.Variable(dateTimeOriginal.value); + } + if (description.present) { + map['description'] = i0.Variable(description.value); + } + if (height.present) { + map['height'] = i0.Variable(height.value); + } + if (width.present) { + map['width'] = i0.Variable(width.value); + } + if (exposureTime.present) { + map['exposure_time'] = i0.Variable(exposureTime.value); + } + if (fNumber.present) { + map['f_number'] = i0.Variable(fNumber.value); + } + if (fileSize.present) { + map['file_size'] = i0.Variable(fileSize.value); + } + if (focalLength.present) { + map['focal_length'] = i0.Variable(focalLength.value); + } + if (latitude.present) { + map['latitude'] = i0.Variable(latitude.value); + } + if (longitude.present) { + map['longitude'] = i0.Variable(longitude.value); + } + if (iso.present) { + map['iso'] = i0.Variable(iso.value); + } + if (make.present) { + map['make'] = i0.Variable(make.value); + } + if (model.present) { + map['model'] = i0.Variable(model.value); + } + if (orientation.present) { + map['orientation'] = i0.Variable(orientation.value); + } + if (timeZone.present) { + map['time_zone'] = i0.Variable(timeZone.value); + } + if (rating.present) { + map['rating'] = i0.Variable(rating.value); + } + if (projectionType.present) { + map['projection_type'] = i0.Variable(projectionType.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('ExifEntityCompanion(') + ..write('assetId: $assetId, ') + ..write('city: $city, ') + ..write('state: $state, ') + ..write('country: $country, ') + ..write('dateTimeOriginal: $dateTimeOriginal, ') + ..write('description: $description, ') + ..write('height: $height, ') + ..write('width: $width, ') + ..write('exposureTime: $exposureTime, ') + ..write('fNumber: $fNumber, ') + ..write('fileSize: $fileSize, ') + ..write('focalLength: $focalLength, ') + ..write('latitude: $latitude, ') + ..write('longitude: $longitude, ') + ..write('iso: $iso, ') + ..write('make: $make, ') + ..write('model: $model, ') + ..write('orientation: $orientation, ') + ..write('timeZone: $timeZone, ') + ..write('rating: $rating, ') + ..write('projectionType: $projectionType') + ..write(')')) + .toString(); + } +} diff --git a/mobile/lib/infrastructure/entities/local_asset.entity.dart b/mobile/lib/infrastructure/entities/local_asset.entity.dart index 1620e703f4..92ff3f2c62 100644 --- a/mobile/lib/infrastructure/entities/local_asset.entity.dart +++ b/mobile/lib/infrastructure/entities/local_asset.entity.dart @@ -12,6 +12,10 @@ class LocalAssetEntity extends Table with DriftDefaultsMixin, AssetEntityMixin { TextColumn get checksum => text().nullable()(); + IntColumn get width => integer().nullable()(); + + IntColumn get height => integer().nullable()(); + @override Set get primaryKey => {localId}; } diff --git a/mobile/lib/infrastructure/entities/local_asset.entity.drift.dart b/mobile/lib/infrastructure/entities/local_asset.entity.drift.dart index e9ab09e8cf..d8635097b1 100644 --- a/mobile/lib/infrastructure/entities/local_asset.entity.drift.dart +++ b/mobile/lib/infrastructure/entities/local_asset.entity.drift.dart @@ -14,11 +14,11 @@ typedef $$LocalAssetEntityTableCreateCompanionBuilder required i2.AssetType type, i0.Value createdAt, i0.Value updatedAt, - i0.Value width, - i0.Value height, i0.Value durationInSeconds, required String localId, i0.Value checksum, + i0.Value width, + i0.Value height, }); typedef $$LocalAssetEntityTableUpdateCompanionBuilder = i1.LocalAssetEntityCompanion Function({ @@ -26,11 +26,11 @@ typedef $$LocalAssetEntityTableUpdateCompanionBuilder i0.Value type, i0.Value createdAt, i0.Value updatedAt, - i0.Value width, - i0.Value height, i0.Value durationInSeconds, i0.Value localId, i0.Value checksum, + i0.Value width, + i0.Value height, }); class $$LocalAssetEntityTableFilterComposer @@ -56,12 +56,6 @@ class $$LocalAssetEntityTableFilterComposer i0.ColumnFilters get updatedAt => $composableBuilder( column: $table.updatedAt, builder: (column) => i0.ColumnFilters(column)); - i0.ColumnFilters get width => $composableBuilder( - column: $table.width, builder: (column) => i0.ColumnFilters(column)); - - i0.ColumnFilters get height => $composableBuilder( - column: $table.height, builder: (column) => i0.ColumnFilters(column)); - i0.ColumnFilters get durationInSeconds => $composableBuilder( column: $table.durationInSeconds, builder: (column) => i0.ColumnFilters(column)); @@ -71,6 +65,12 @@ class $$LocalAssetEntityTableFilterComposer i0.ColumnFilters get checksum => $composableBuilder( column: $table.checksum, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get width => $composableBuilder( + column: $table.width, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get height => $composableBuilder( + column: $table.height, builder: (column) => i0.ColumnFilters(column)); } class $$LocalAssetEntityTableOrderingComposer @@ -96,12 +96,6 @@ class $$LocalAssetEntityTableOrderingComposer column: $table.updatedAt, builder: (column) => i0.ColumnOrderings(column)); - i0.ColumnOrderings get width => $composableBuilder( - column: $table.width, builder: (column) => i0.ColumnOrderings(column)); - - i0.ColumnOrderings get height => $composableBuilder( - column: $table.height, builder: (column) => i0.ColumnOrderings(column)); - i0.ColumnOrderings get durationInSeconds => $composableBuilder( column: $table.durationInSeconds, builder: (column) => i0.ColumnOrderings(column)); @@ -111,6 +105,12 @@ class $$LocalAssetEntityTableOrderingComposer i0.ColumnOrderings get checksum => $composableBuilder( column: $table.checksum, builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get width => $composableBuilder( + column: $table.width, builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get height => $composableBuilder( + column: $table.height, builder: (column) => i0.ColumnOrderings(column)); } class $$LocalAssetEntityTableAnnotationComposer @@ -134,12 +134,6 @@ class $$LocalAssetEntityTableAnnotationComposer i0.GeneratedColumn get updatedAt => $composableBuilder(column: $table.updatedAt, builder: (column) => column); - i0.GeneratedColumn get width => - $composableBuilder(column: $table.width, builder: (column) => column); - - i0.GeneratedColumn get height => - $composableBuilder(column: $table.height, builder: (column) => column); - i0.GeneratedColumn get durationInSeconds => $composableBuilder( column: $table.durationInSeconds, builder: (column) => column); @@ -148,6 +142,12 @@ class $$LocalAssetEntityTableAnnotationComposer i0.GeneratedColumn get checksum => $composableBuilder(column: $table.checksum, builder: (column) => column); + + i0.GeneratedColumn get width => + $composableBuilder(column: $table.width, builder: (column) => column); + + i0.GeneratedColumn get height => + $composableBuilder(column: $table.height, builder: (column) => column); } class $$LocalAssetEntityTableTableManager extends i0.RootTableManager< @@ -183,44 +183,44 @@ class $$LocalAssetEntityTableTableManager extends i0.RootTableManager< i0.Value type = const i0.Value.absent(), i0.Value createdAt = const i0.Value.absent(), i0.Value updatedAt = const i0.Value.absent(), - i0.Value width = const i0.Value.absent(), - i0.Value height = const i0.Value.absent(), i0.Value durationInSeconds = const i0.Value.absent(), i0.Value localId = const i0.Value.absent(), i0.Value checksum = const i0.Value.absent(), + i0.Value width = const i0.Value.absent(), + i0.Value height = const i0.Value.absent(), }) => i1.LocalAssetEntityCompanion( name: name, type: type, createdAt: createdAt, updatedAt: updatedAt, - width: width, - height: height, durationInSeconds: durationInSeconds, localId: localId, checksum: checksum, + width: width, + height: height, ), createCompanionCallback: ({ required String name, required i2.AssetType type, i0.Value createdAt = const i0.Value.absent(), i0.Value updatedAt = const i0.Value.absent(), - i0.Value width = const i0.Value.absent(), - i0.Value height = const i0.Value.absent(), i0.Value durationInSeconds = const i0.Value.absent(), required String localId, i0.Value checksum = const i0.Value.absent(), + i0.Value width = const i0.Value.absent(), + i0.Value height = const i0.Value.absent(), }) => i1.LocalAssetEntityCompanion.insert( name: name, type: type, createdAt: createdAt, updatedAt: updatedAt, - width: width, - height: height, durationInSeconds: durationInSeconds, localId: localId, checksum: checksum, + width: width, + height: height, ), withReferenceMapper: (p0) => p0 .map((e) => (e.readTable(table), i0.BaseReferences(db, table, e))) @@ -282,18 +282,6 @@ class $LocalAssetEntityTable extends i3.LocalAssetEntity type: i0.DriftSqlType.dateTime, requiredDuringInsert: false, defaultValue: i4.currentDateAndTime); - static const i0.VerificationMeta _widthMeta = - const i0.VerificationMeta('width'); - @override - late final i0.GeneratedColumn width = i0.GeneratedColumn( - 'width', aliasedName, true, - type: i0.DriftSqlType.int, requiredDuringInsert: false); - static const i0.VerificationMeta _heightMeta = - const i0.VerificationMeta('height'); - @override - late final i0.GeneratedColumn height = i0.GeneratedColumn( - 'height', aliasedName, true, - type: i0.DriftSqlType.int, requiredDuringInsert: false); static const i0.VerificationMeta _durationInSecondsMeta = const i0.VerificationMeta('durationInSeconds'); @override @@ -312,17 +300,29 @@ class $LocalAssetEntityTable extends i3.LocalAssetEntity late final i0.GeneratedColumn checksum = i0.GeneratedColumn( 'checksum', aliasedName, true, type: i0.DriftSqlType.string, requiredDuringInsert: false); + static const i0.VerificationMeta _widthMeta = + const i0.VerificationMeta('width'); + @override + late final i0.GeneratedColumn width = i0.GeneratedColumn( + 'width', aliasedName, true, + type: i0.DriftSqlType.int, requiredDuringInsert: false); + static const i0.VerificationMeta _heightMeta = + const i0.VerificationMeta('height'); + @override + late final i0.GeneratedColumn height = i0.GeneratedColumn( + 'height', aliasedName, true, + type: i0.DriftSqlType.int, requiredDuringInsert: false); @override List get $columns => [ name, type, createdAt, updatedAt, - width, - height, durationInSeconds, localId, - checksum + checksum, + width, + height ]; @override String get aliasedName => _alias ?? actualTableName; @@ -349,14 +349,6 @@ class $LocalAssetEntityTable extends i3.LocalAssetEntity context.handle(_updatedAtMeta, updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta)); } - if (data.containsKey('width')) { - context.handle( - _widthMeta, width.isAcceptableOrUnknown(data['width']!, _widthMeta)); - } - if (data.containsKey('height')) { - context.handle(_heightMeta, - height.isAcceptableOrUnknown(data['height']!, _heightMeta)); - } if (data.containsKey('duration_in_seconds')) { context.handle( _durationInSecondsMeta, @@ -373,6 +365,14 @@ class $LocalAssetEntityTable extends i3.LocalAssetEntity context.handle(_checksumMeta, checksum.isAcceptableOrUnknown(data['checksum']!, _checksumMeta)); } + if (data.containsKey('width')) { + context.handle( + _widthMeta, width.isAcceptableOrUnknown(data['width']!, _widthMeta)); + } + if (data.containsKey('height')) { + context.handle(_heightMeta, + height.isAcceptableOrUnknown(data['height']!, _heightMeta)); + } return context; } @@ -392,16 +392,16 @@ class $LocalAssetEntityTable extends i3.LocalAssetEntity i0.DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, updatedAt: attachedDatabase.typeMapping.read( i0.DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!, - width: attachedDatabase.typeMapping - .read(i0.DriftSqlType.int, data['${effectivePrefix}width']), - height: attachedDatabase.typeMapping - .read(i0.DriftSqlType.int, data['${effectivePrefix}height']), durationInSeconds: attachedDatabase.typeMapping.read( i0.DriftSqlType.int, data['${effectivePrefix}duration_in_seconds']), localId: attachedDatabase.typeMapping .read(i0.DriftSqlType.string, data['${effectivePrefix}local_id'])!, checksum: attachedDatabase.typeMapping .read(i0.DriftSqlType.string, data['${effectivePrefix}checksum']), + width: attachedDatabase.typeMapping + .read(i0.DriftSqlType.int, data['${effectivePrefix}width']), + height: attachedDatabase.typeMapping + .read(i0.DriftSqlType.int, data['${effectivePrefix}height']), ); } @@ -424,21 +424,21 @@ class LocalAssetEntityData extends i0.DataClass final i2.AssetType type; final DateTime createdAt; final DateTime updatedAt; - final int? width; - final int? height; final int? durationInSeconds; final String localId; final String? checksum; + final int? width; + final int? height; const LocalAssetEntityData( {required this.name, required this.type, required this.createdAt, required this.updatedAt, - this.width, - this.height, this.durationInSeconds, required this.localId, - this.checksum}); + this.checksum, + this.width, + this.height}); @override Map toColumns(bool nullToAbsent) { final map = {}; @@ -449,12 +449,6 @@ class LocalAssetEntityData extends i0.DataClass } map['created_at'] = i0.Variable(createdAt); map['updated_at'] = i0.Variable(updatedAt); - if (!nullToAbsent || width != null) { - map['width'] = i0.Variable(width); - } - if (!nullToAbsent || height != null) { - map['height'] = i0.Variable(height); - } if (!nullToAbsent || durationInSeconds != null) { map['duration_in_seconds'] = i0.Variable(durationInSeconds); } @@ -462,6 +456,12 @@ class LocalAssetEntityData extends i0.DataClass if (!nullToAbsent || checksum != null) { map['checksum'] = i0.Variable(checksum); } + if (!nullToAbsent || width != null) { + map['width'] = i0.Variable(width); + } + if (!nullToAbsent || height != null) { + map['height'] = i0.Variable(height); + } return map; } @@ -474,11 +474,11 @@ class LocalAssetEntityData extends i0.DataClass .fromJson(serializer.fromJson(json['type'])), createdAt: serializer.fromJson(json['createdAt']), updatedAt: serializer.fromJson(json['updatedAt']), - width: serializer.fromJson(json['width']), - height: serializer.fromJson(json['height']), durationInSeconds: serializer.fromJson(json['durationInSeconds']), localId: serializer.fromJson(json['localId']), checksum: serializer.fromJson(json['checksum']), + width: serializer.fromJson(json['width']), + height: serializer.fromJson(json['height']), ); } @override @@ -490,11 +490,11 @@ class LocalAssetEntityData extends i0.DataClass .toJson(i1.$LocalAssetEntityTable.$convertertype.toJson(type)), 'createdAt': serializer.toJson(createdAt), 'updatedAt': serializer.toJson(updatedAt), - 'width': serializer.toJson(width), - 'height': serializer.toJson(height), 'durationInSeconds': serializer.toJson(durationInSeconds), 'localId': serializer.toJson(localId), 'checksum': serializer.toJson(checksum), + 'width': serializer.toJson(width), + 'height': serializer.toJson(height), }; } @@ -503,23 +503,23 @@ class LocalAssetEntityData extends i0.DataClass i2.AssetType? type, DateTime? createdAt, DateTime? updatedAt, - i0.Value width = const i0.Value.absent(), - i0.Value height = const i0.Value.absent(), i0.Value durationInSeconds = const i0.Value.absent(), String? localId, - i0.Value checksum = const i0.Value.absent()}) => + i0.Value checksum = const i0.Value.absent(), + i0.Value width = const i0.Value.absent(), + i0.Value height = const i0.Value.absent()}) => i1.LocalAssetEntityData( name: name ?? this.name, type: type ?? this.type, createdAt: createdAt ?? this.createdAt, updatedAt: updatedAt ?? this.updatedAt, - width: width.present ? width.value : this.width, - height: height.present ? height.value : this.height, durationInSeconds: durationInSeconds.present ? durationInSeconds.value : this.durationInSeconds, localId: localId ?? this.localId, checksum: checksum.present ? checksum.value : this.checksum, + width: width.present ? width.value : this.width, + height: height.present ? height.value : this.height, ); LocalAssetEntityData copyWithCompanion(i1.LocalAssetEntityCompanion data) { return LocalAssetEntityData( @@ -527,13 +527,13 @@ class LocalAssetEntityData extends i0.DataClass type: data.type.present ? data.type.value : this.type, createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, - width: data.width.present ? data.width.value : this.width, - height: data.height.present ? data.height.value : this.height, durationInSeconds: data.durationInSeconds.present ? data.durationInSeconds.value : this.durationInSeconds, localId: data.localId.present ? data.localId.value : this.localId, checksum: data.checksum.present ? data.checksum.value : this.checksum, + width: data.width.present ? data.width.value : this.width, + height: data.height.present ? data.height.value : this.height, ); } @@ -544,18 +544,18 @@ class LocalAssetEntityData extends i0.DataClass ..write('type: $type, ') ..write('createdAt: $createdAt, ') ..write('updatedAt: $updatedAt, ') - ..write('width: $width, ') - ..write('height: $height, ') ..write('durationInSeconds: $durationInSeconds, ') ..write('localId: $localId, ') - ..write('checksum: $checksum') + ..write('checksum: $checksum, ') + ..write('width: $width, ') + ..write('height: $height') ..write(')')) .toString(); } @override - int get hashCode => Object.hash(name, type, createdAt, updatedAt, width, - height, durationInSeconds, localId, checksum); + int get hashCode => Object.hash(name, type, createdAt, updatedAt, + durationInSeconds, localId, checksum, width, height); @override bool operator ==(Object other) => identical(this, other) || @@ -564,11 +564,11 @@ class LocalAssetEntityData extends i0.DataClass other.type == this.type && other.createdAt == this.createdAt && other.updatedAt == this.updatedAt && - other.width == this.width && - other.height == this.height && other.durationInSeconds == this.durationInSeconds && other.localId == this.localId && - other.checksum == this.checksum); + other.checksum == this.checksum && + other.width == this.width && + other.height == this.height); } class LocalAssetEntityCompanion @@ -577,32 +577,32 @@ class LocalAssetEntityCompanion final i0.Value type; final i0.Value createdAt; final i0.Value updatedAt; - final i0.Value width; - final i0.Value height; final i0.Value durationInSeconds; final i0.Value localId; final i0.Value checksum; + final i0.Value width; + final i0.Value height; const LocalAssetEntityCompanion({ this.name = const i0.Value.absent(), this.type = const i0.Value.absent(), this.createdAt = const i0.Value.absent(), this.updatedAt = const i0.Value.absent(), - this.width = const i0.Value.absent(), - this.height = const i0.Value.absent(), this.durationInSeconds = const i0.Value.absent(), this.localId = const i0.Value.absent(), this.checksum = const i0.Value.absent(), + this.width = const i0.Value.absent(), + this.height = const i0.Value.absent(), }); LocalAssetEntityCompanion.insert({ required String name, required i2.AssetType type, this.createdAt = const i0.Value.absent(), this.updatedAt = const i0.Value.absent(), - this.width = const i0.Value.absent(), - this.height = const i0.Value.absent(), this.durationInSeconds = const i0.Value.absent(), required String localId, this.checksum = const i0.Value.absent(), + this.width = const i0.Value.absent(), + this.height = const i0.Value.absent(), }) : name = i0.Value(name), type = i0.Value(type), localId = i0.Value(localId); @@ -611,22 +611,22 @@ class LocalAssetEntityCompanion i0.Expression? type, i0.Expression? createdAt, i0.Expression? updatedAt, - i0.Expression? width, - i0.Expression? height, i0.Expression? durationInSeconds, i0.Expression? localId, i0.Expression? checksum, + i0.Expression? width, + i0.Expression? height, }) { return i0.RawValuesInsertable({ if (name != null) 'name': name, if (type != null) 'type': type, if (createdAt != null) 'created_at': createdAt, if (updatedAt != null) 'updated_at': updatedAt, - if (width != null) 'width': width, - if (height != null) 'height': height, if (durationInSeconds != null) 'duration_in_seconds': durationInSeconds, if (localId != null) 'local_id': localId, if (checksum != null) 'checksum': checksum, + if (width != null) 'width': width, + if (height != null) 'height': height, }); } @@ -635,21 +635,21 @@ class LocalAssetEntityCompanion i0.Value? type, i0.Value? createdAt, i0.Value? updatedAt, - i0.Value? width, - i0.Value? height, i0.Value? durationInSeconds, i0.Value? localId, - i0.Value? checksum}) { + i0.Value? checksum, + i0.Value? width, + i0.Value? height}) { return i1.LocalAssetEntityCompanion( name: name ?? this.name, type: type ?? this.type, createdAt: createdAt ?? this.createdAt, updatedAt: updatedAt ?? this.updatedAt, - width: width ?? this.width, - height: height ?? this.height, durationInSeconds: durationInSeconds ?? this.durationInSeconds, localId: localId ?? this.localId, checksum: checksum ?? this.checksum, + width: width ?? this.width, + height: height ?? this.height, ); } @@ -669,12 +669,6 @@ class LocalAssetEntityCompanion if (updatedAt.present) { map['updated_at'] = i0.Variable(updatedAt.value); } - if (width.present) { - map['width'] = i0.Variable(width.value); - } - if (height.present) { - map['height'] = i0.Variable(height.value); - } if (durationInSeconds.present) { map['duration_in_seconds'] = i0.Variable(durationInSeconds.value); } @@ -684,6 +678,12 @@ class LocalAssetEntityCompanion if (checksum.present) { map['checksum'] = i0.Variable(checksum.value); } + if (width.present) { + map['width'] = i0.Variable(width.value); + } + if (height.present) { + map['height'] = i0.Variable(height.value); + } return map; } @@ -694,11 +694,11 @@ class LocalAssetEntityCompanion ..write('type: $type, ') ..write('createdAt: $createdAt, ') ..write('updatedAt: $updatedAt, ') - ..write('width: $width, ') - ..write('height: $height, ') ..write('durationInSeconds: $durationInSeconds, ') ..write('localId: $localId, ') - ..write('checksum: $checksum') + ..write('checksum: $checksum, ') + ..write('width: $width, ') + ..write('height: $height') ..write(')')) .toString(); } diff --git a/mobile/lib/infrastructure/entities/remote_asset.entity.dart b/mobile/lib/infrastructure/entities/remote_asset.entity.dart new file mode 100644 index 0000000000..8036ea18b5 --- /dev/null +++ b/mobile/lib/infrastructure/entities/remote_asset.entity.dart @@ -0,0 +1,28 @@ +import 'package:drift/drift.dart'; +import 'package:immich_mobile/infrastructure/entities/user.entity.dart'; +import 'package:immich_mobile/infrastructure/utils/asset.mixin.dart'; +import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart'; + +@TableIndex(name: 'remote_asset_checksum', columns: {#checksum}) +class RemoteAssetEntity extends Table + with DriftDefaultsMixin, AssetEntityMixin { + const RemoteAssetEntity(); + + BlobColumn get remoteId => blob()(); + + TextColumn get checksum => text().unique()(); + + BoolColumn get isFavorite => boolean().withDefault(const Constant(false))(); + + BlobColumn get ownerId => + blob().references(UserEntity, #id, onDelete: KeyAction.cascade)(); + + DateTimeColumn get localDateTime => dateTime().nullable()(); + + TextColumn get thumbhash => text().nullable()(); + + DateTimeColumn get deletedAt => dateTime().nullable()(); + + @override + Set get primaryKey => {remoteId}; +} diff --git a/mobile/lib/infrastructure/entities/remote_asset.entity.drift.dart b/mobile/lib/infrastructure/entities/remote_asset.entity.drift.dart new file mode 100644 index 0000000000..4f036150b3 --- /dev/null +++ b/mobile/lib/infrastructure/entities/remote_asset.entity.drift.dart @@ -0,0 +1,1017 @@ +// dart format width=80 +// ignore_for_file: type=lint +import 'package:drift/drift.dart' as i0; +import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.drift.dart' + as i1; +import 'package:immich_mobile/domain/models/asset/asset.model.dart' as i2; +import 'dart:typed_data' as i3; +import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.dart' + as i4; +import 'package:drift/src/runtime/query_builder/query_builder.dart' as i5; +import 'package:immich_mobile/infrastructure/entities/user.entity.drift.dart' + as i6; +import 'package:drift/internal/modular.dart' as i7; + +typedef $$RemoteAssetEntityTableCreateCompanionBuilder + = i1.RemoteAssetEntityCompanion Function({ + required String name, + required i2.AssetType type, + i0.Value createdAt, + i0.Value updatedAt, + i0.Value durationInSeconds, + required i3.Uint8List remoteId, + required String checksum, + i0.Value isFavorite, + required i3.Uint8List ownerId, + i0.Value localDateTime, + i0.Value thumbhash, + i0.Value deletedAt, +}); +typedef $$RemoteAssetEntityTableUpdateCompanionBuilder + = i1.RemoteAssetEntityCompanion Function({ + i0.Value name, + i0.Value type, + i0.Value createdAt, + i0.Value updatedAt, + i0.Value durationInSeconds, + i0.Value remoteId, + i0.Value checksum, + i0.Value isFavorite, + i0.Value ownerId, + i0.Value localDateTime, + i0.Value thumbhash, + i0.Value deletedAt, +}); + +final class $$RemoteAssetEntityTableReferences extends i0.BaseReferences< + i0.GeneratedDatabase, + i1.$RemoteAssetEntityTable, + i1.RemoteAssetEntityData> { + $$RemoteAssetEntityTableReferences( + super.$_db, super.$_table, super.$_typedResult); + + static i6.$UserEntityTable _ownerIdTable(i0.GeneratedDatabase db) => + i7.ReadDatabaseContainer(db) + .resultSet('user_entity') + .createAlias(i0.$_aliasNameGenerator( + i7.ReadDatabaseContainer(db) + .resultSet('remote_asset_entity') + .ownerId, + i7.ReadDatabaseContainer(db) + .resultSet('user_entity') + .id)); + + i6.$$UserEntityTableProcessedTableManager get ownerId { + final $_column = $_itemColumn('owner_id')!; + + final manager = i6 + .$$UserEntityTableTableManager( + $_db, + i7.ReadDatabaseContainer($_db) + .resultSet('user_entity')) + .filter((f) => f.id.sqlEquals($_column)); + final item = $_typedResult.readTableOrNull(_ownerIdTable($_db)); + if (item == null) return manager; + return i0.ProcessedTableManager( + manager.$state.copyWith(prefetchedData: [item])); + } +} + +class $$RemoteAssetEntityTableFilterComposer + extends i0.Composer { + $$RemoteAssetEntityTableFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + i0.ColumnFilters get name => $composableBuilder( + column: $table.name, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnWithTypeConverterFilters get type => + $composableBuilder( + column: $table.type, + builder: (column) => i0.ColumnWithTypeConverterFilters(column)); + + i0.ColumnFilters get createdAt => $composableBuilder( + column: $table.createdAt, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get updatedAt => $composableBuilder( + column: $table.updatedAt, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get durationInSeconds => $composableBuilder( + column: $table.durationInSeconds, + builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get remoteId => $composableBuilder( + column: $table.remoteId, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get checksum => $composableBuilder( + column: $table.checksum, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get isFavorite => $composableBuilder( + column: $table.isFavorite, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get localDateTime => $composableBuilder( + column: $table.localDateTime, + builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get thumbhash => $composableBuilder( + column: $table.thumbhash, builder: (column) => i0.ColumnFilters(column)); + + i0.ColumnFilters get deletedAt => $composableBuilder( + column: $table.deletedAt, builder: (column) => i0.ColumnFilters(column)); + + i6.$$UserEntityTableFilterComposer get ownerId { + final i6.$$UserEntityTableFilterComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.ownerId, + referencedTable: i7.ReadDatabaseContainer($db) + .resultSet('user_entity'), + getReferencedColumn: (t) => t.id, + builder: (joinBuilder, + {$addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer}) => + i6.$$UserEntityTableFilterComposer( + $db: $db, + $table: i7.ReadDatabaseContainer($db) + .resultSet('user_entity'), + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + )); + return composer; + } +} + +class $$RemoteAssetEntityTableOrderingComposer + extends i0.Composer { + $$RemoteAssetEntityTableOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + i0.ColumnOrderings get name => $composableBuilder( + column: $table.name, builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get type => $composableBuilder( + column: $table.type, builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get createdAt => $composableBuilder( + column: $table.createdAt, + builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get updatedAt => $composableBuilder( + column: $table.updatedAt, + builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get durationInSeconds => $composableBuilder( + column: $table.durationInSeconds, + builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get remoteId => $composableBuilder( + column: $table.remoteId, builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get checksum => $composableBuilder( + column: $table.checksum, builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get isFavorite => $composableBuilder( + column: $table.isFavorite, + builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get localDateTime => $composableBuilder( + column: $table.localDateTime, + builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get thumbhash => $composableBuilder( + column: $table.thumbhash, + builder: (column) => i0.ColumnOrderings(column)); + + i0.ColumnOrderings get deletedAt => $composableBuilder( + column: $table.deletedAt, + builder: (column) => i0.ColumnOrderings(column)); + + i6.$$UserEntityTableOrderingComposer get ownerId { + final i6.$$UserEntityTableOrderingComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.ownerId, + referencedTable: i7.ReadDatabaseContainer($db) + .resultSet('user_entity'), + getReferencedColumn: (t) => t.id, + builder: (joinBuilder, + {$addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer}) => + i6.$$UserEntityTableOrderingComposer( + $db: $db, + $table: i7.ReadDatabaseContainer($db) + .resultSet('user_entity'), + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + )); + return composer; + } +} + +class $$RemoteAssetEntityTableAnnotationComposer + extends i0.Composer { + $$RemoteAssetEntityTableAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + i0.GeneratedColumn get name => + $composableBuilder(column: $table.name, builder: (column) => column); + + i0.GeneratedColumnWithTypeConverter get type => + $composableBuilder(column: $table.type, builder: (column) => column); + + i0.GeneratedColumn get createdAt => + $composableBuilder(column: $table.createdAt, builder: (column) => column); + + i0.GeneratedColumn get updatedAt => + $composableBuilder(column: $table.updatedAt, builder: (column) => column); + + i0.GeneratedColumn get durationInSeconds => $composableBuilder( + column: $table.durationInSeconds, builder: (column) => column); + + i0.GeneratedColumn get remoteId => + $composableBuilder(column: $table.remoteId, builder: (column) => column); + + i0.GeneratedColumn get checksum => + $composableBuilder(column: $table.checksum, builder: (column) => column); + + i0.GeneratedColumn get isFavorite => $composableBuilder( + column: $table.isFavorite, builder: (column) => column); + + i0.GeneratedColumn get localDateTime => $composableBuilder( + column: $table.localDateTime, builder: (column) => column); + + i0.GeneratedColumn get thumbhash => + $composableBuilder(column: $table.thumbhash, builder: (column) => column); + + i0.GeneratedColumn get deletedAt => + $composableBuilder(column: $table.deletedAt, builder: (column) => column); + + i6.$$UserEntityTableAnnotationComposer get ownerId { + final i6.$$UserEntityTableAnnotationComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.ownerId, + referencedTable: i7.ReadDatabaseContainer($db) + .resultSet('user_entity'), + getReferencedColumn: (t) => t.id, + builder: (joinBuilder, + {$addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer}) => + i6.$$UserEntityTableAnnotationComposer( + $db: $db, + $table: i7.ReadDatabaseContainer($db) + .resultSet('user_entity'), + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + )); + return composer; + } +} + +class $$RemoteAssetEntityTableTableManager extends i0.RootTableManager< + i0.GeneratedDatabase, + i1.$RemoteAssetEntityTable, + i1.RemoteAssetEntityData, + i1.$$RemoteAssetEntityTableFilterComposer, + i1.$$RemoteAssetEntityTableOrderingComposer, + i1.$$RemoteAssetEntityTableAnnotationComposer, + $$RemoteAssetEntityTableCreateCompanionBuilder, + $$RemoteAssetEntityTableUpdateCompanionBuilder, + (i1.RemoteAssetEntityData, i1.$$RemoteAssetEntityTableReferences), + i1.RemoteAssetEntityData, + i0.PrefetchHooks Function({bool ownerId})> { + $$RemoteAssetEntityTableTableManager( + i0.GeneratedDatabase db, i1.$RemoteAssetEntityTable table) + : super(i0.TableManagerState( + db: db, + table: table, + createFilteringComposer: () => + i1.$$RemoteAssetEntityTableFilterComposer($db: db, $table: table), + createOrderingComposer: () => i1 + .$$RemoteAssetEntityTableOrderingComposer($db: db, $table: table), + createComputedFieldComposer: () => + i1.$$RemoteAssetEntityTableAnnotationComposer( + $db: db, $table: table), + updateCompanionCallback: ({ + i0.Value name = const i0.Value.absent(), + i0.Value type = const i0.Value.absent(), + i0.Value createdAt = const i0.Value.absent(), + i0.Value updatedAt = const i0.Value.absent(), + i0.Value durationInSeconds = const i0.Value.absent(), + i0.Value remoteId = const i0.Value.absent(), + i0.Value checksum = const i0.Value.absent(), + i0.Value isFavorite = const i0.Value.absent(), + i0.Value ownerId = const i0.Value.absent(), + i0.Value localDateTime = const i0.Value.absent(), + i0.Value thumbhash = const i0.Value.absent(), + i0.Value deletedAt = const i0.Value.absent(), + }) => + i1.RemoteAssetEntityCompanion( + name: name, + type: type, + createdAt: createdAt, + updatedAt: updatedAt, + durationInSeconds: durationInSeconds, + remoteId: remoteId, + checksum: checksum, + isFavorite: isFavorite, + ownerId: ownerId, + localDateTime: localDateTime, + thumbhash: thumbhash, + deletedAt: deletedAt, + ), + createCompanionCallback: ({ + required String name, + required i2.AssetType type, + i0.Value createdAt = const i0.Value.absent(), + i0.Value updatedAt = const i0.Value.absent(), + i0.Value durationInSeconds = const i0.Value.absent(), + required i3.Uint8List remoteId, + required String checksum, + i0.Value isFavorite = const i0.Value.absent(), + required i3.Uint8List ownerId, + i0.Value localDateTime = const i0.Value.absent(), + i0.Value thumbhash = const i0.Value.absent(), + i0.Value deletedAt = const i0.Value.absent(), + }) => + i1.RemoteAssetEntityCompanion.insert( + name: name, + type: type, + createdAt: createdAt, + updatedAt: updatedAt, + durationInSeconds: durationInSeconds, + remoteId: remoteId, + checksum: checksum, + isFavorite: isFavorite, + ownerId: ownerId, + localDateTime: localDateTime, + thumbhash: thumbhash, + deletedAt: deletedAt, + ), + withReferenceMapper: (p0) => p0 + .map((e) => ( + e.readTable(table), + i1.$$RemoteAssetEntityTableReferences(db, table, e) + )) + .toList(), + prefetchHooksCallback: ({ownerId = false}) { + return i0.PrefetchHooks( + db: db, + explicitlyWatchedTables: [], + addJoins: < + T extends i0.TableManagerState< + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic>>(state) { + if (ownerId) { + state = state.withJoin( + currentTable: table, + currentColumn: table.ownerId, + referencedTable: + i1.$$RemoteAssetEntityTableReferences._ownerIdTable(db), + referencedColumn: i1.$$RemoteAssetEntityTableReferences + ._ownerIdTable(db) + .id, + ) as T; + } + + return state; + }, + getPrefetchedDataCallback: (items) async { + return []; + }, + ); + }, + )); +} + +typedef $$RemoteAssetEntityTableProcessedTableManager + = i0.ProcessedTableManager< + i0.GeneratedDatabase, + i1.$RemoteAssetEntityTable, + i1.RemoteAssetEntityData, + i1.$$RemoteAssetEntityTableFilterComposer, + i1.$$RemoteAssetEntityTableOrderingComposer, + i1.$$RemoteAssetEntityTableAnnotationComposer, + $$RemoteAssetEntityTableCreateCompanionBuilder, + $$RemoteAssetEntityTableUpdateCompanionBuilder, + (i1.RemoteAssetEntityData, i1.$$RemoteAssetEntityTableReferences), + i1.RemoteAssetEntityData, + i0.PrefetchHooks Function({bool ownerId})>; +i0.Index get remoteAssetChecksum => i0.Index('remote_asset_checksum', + 'CREATE INDEX remote_asset_checksum ON remote_asset_entity (checksum)'); + +class $RemoteAssetEntityTable extends i4.RemoteAssetEntity + with i0.TableInfo<$RemoteAssetEntityTable, i1.RemoteAssetEntityData> { + @override + final i0.GeneratedDatabase attachedDatabase; + final String? _alias; + $RemoteAssetEntityTable(this.attachedDatabase, [this._alias]); + static const i0.VerificationMeta _nameMeta = + const i0.VerificationMeta('name'); + @override + late final i0.GeneratedColumn name = i0.GeneratedColumn( + 'name', aliasedName, false, + type: i0.DriftSqlType.string, requiredDuringInsert: true); + @override + late final i0.GeneratedColumnWithTypeConverter type = + i0.GeneratedColumn('type', aliasedName, false, + type: i0.DriftSqlType.int, requiredDuringInsert: true) + .withConverter( + i1.$RemoteAssetEntityTable.$convertertype); + static const i0.VerificationMeta _createdAtMeta = + const i0.VerificationMeta('createdAt'); + @override + late final i0.GeneratedColumn createdAt = + i0.GeneratedColumn('created_at', aliasedName, false, + type: i0.DriftSqlType.dateTime, + requiredDuringInsert: false, + defaultValue: i5.currentDateAndTime); + static const i0.VerificationMeta _updatedAtMeta = + const i0.VerificationMeta('updatedAt'); + @override + late final i0.GeneratedColumn updatedAt = + i0.GeneratedColumn('updated_at', aliasedName, false, + type: i0.DriftSqlType.dateTime, + requiredDuringInsert: false, + defaultValue: i5.currentDateAndTime); + static const i0.VerificationMeta _durationInSecondsMeta = + const i0.VerificationMeta('durationInSeconds'); + @override + late final i0.GeneratedColumn durationInSeconds = + i0.GeneratedColumn('duration_in_seconds', aliasedName, true, + type: i0.DriftSqlType.int, requiredDuringInsert: false); + static const i0.VerificationMeta _remoteIdMeta = + const i0.VerificationMeta('remoteId'); + @override + late final i0.GeneratedColumn remoteId = + i0.GeneratedColumn('remote_id', aliasedName, false, + type: i0.DriftSqlType.blob, requiredDuringInsert: true); + static const i0.VerificationMeta _checksumMeta = + const i0.VerificationMeta('checksum'); + @override + late final i0.GeneratedColumn checksum = i0.GeneratedColumn( + 'checksum', aliasedName, false, + type: i0.DriftSqlType.string, + requiredDuringInsert: true, + defaultConstraints: i0.GeneratedColumn.constraintIsAlways('UNIQUE')); + static const i0.VerificationMeta _isFavoriteMeta = + const i0.VerificationMeta('isFavorite'); + @override + late final i0.GeneratedColumn isFavorite = i0.GeneratedColumn( + 'is_favorite', aliasedName, false, + type: i0.DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: i0.GeneratedColumn.constraintIsAlways( + 'CHECK ("is_favorite" IN (0, 1))'), + defaultValue: const i5.Constant(false)); + static const i0.VerificationMeta _ownerIdMeta = + const i0.VerificationMeta('ownerId'); + @override + late final i0.GeneratedColumn ownerId = + i0.GeneratedColumn('owner_id', aliasedName, false, + type: i0.DriftSqlType.blob, + requiredDuringInsert: true, + defaultConstraints: i0.GeneratedColumn.constraintIsAlways( + 'REFERENCES user_entity (id) ON DELETE CASCADE')); + static const i0.VerificationMeta _localDateTimeMeta = + const i0.VerificationMeta('localDateTime'); + @override + late final i0.GeneratedColumn localDateTime = + i0.GeneratedColumn('local_date_time', aliasedName, true, + type: i0.DriftSqlType.dateTime, requiredDuringInsert: false); + static const i0.VerificationMeta _thumbhashMeta = + const i0.VerificationMeta('thumbhash'); + @override + late final i0.GeneratedColumn thumbhash = i0.GeneratedColumn( + 'thumbhash', aliasedName, true, + type: i0.DriftSqlType.string, requiredDuringInsert: false); + static const i0.VerificationMeta _deletedAtMeta = + const i0.VerificationMeta('deletedAt'); + @override + late final i0.GeneratedColumn deletedAt = + i0.GeneratedColumn('deleted_at', aliasedName, true, + type: i0.DriftSqlType.dateTime, requiredDuringInsert: false); + @override + List get $columns => [ + name, + type, + createdAt, + updatedAt, + durationInSeconds, + remoteId, + checksum, + isFavorite, + ownerId, + localDateTime, + thumbhash, + deletedAt + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'remote_asset_entity'; + @override + i0.VerificationContext validateIntegrity( + i0.Insertable instance, + {bool isInserting = false}) { + final context = i0.VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('name')) { + context.handle( + _nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta)); + } else if (isInserting) { + context.missing(_nameMeta); + } + if (data.containsKey('created_at')) { + context.handle(_createdAtMeta, + createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta)); + } + if (data.containsKey('updated_at')) { + context.handle(_updatedAtMeta, + updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta)); + } + if (data.containsKey('duration_in_seconds')) { + context.handle( + _durationInSecondsMeta, + durationInSeconds.isAcceptableOrUnknown( + data['duration_in_seconds']!, _durationInSecondsMeta)); + } + if (data.containsKey('remote_id')) { + context.handle(_remoteIdMeta, + remoteId.isAcceptableOrUnknown(data['remote_id']!, _remoteIdMeta)); + } else if (isInserting) { + context.missing(_remoteIdMeta); + } + if (data.containsKey('checksum')) { + context.handle(_checksumMeta, + checksum.isAcceptableOrUnknown(data['checksum']!, _checksumMeta)); + } else if (isInserting) { + context.missing(_checksumMeta); + } + if (data.containsKey('is_favorite')) { + context.handle( + _isFavoriteMeta, + isFavorite.isAcceptableOrUnknown( + data['is_favorite']!, _isFavoriteMeta)); + } + if (data.containsKey('owner_id')) { + context.handle(_ownerIdMeta, + ownerId.isAcceptableOrUnknown(data['owner_id']!, _ownerIdMeta)); + } else if (isInserting) { + context.missing(_ownerIdMeta); + } + if (data.containsKey('local_date_time')) { + context.handle( + _localDateTimeMeta, + localDateTime.isAcceptableOrUnknown( + data['local_date_time']!, _localDateTimeMeta)); + } + if (data.containsKey('thumbhash')) { + context.handle(_thumbhashMeta, + thumbhash.isAcceptableOrUnknown(data['thumbhash']!, _thumbhashMeta)); + } + if (data.containsKey('deleted_at')) { + context.handle(_deletedAtMeta, + deletedAt.isAcceptableOrUnknown(data['deleted_at']!, _deletedAtMeta)); + } + return context; + } + + @override + Set get $primaryKey => {remoteId}; + @override + i1.RemoteAssetEntityData map(Map data, + {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return i1.RemoteAssetEntityData( + name: attachedDatabase.typeMapping + .read(i0.DriftSqlType.string, data['${effectivePrefix}name'])!, + type: i1.$RemoteAssetEntityTable.$convertertype.fromSql(attachedDatabase + .typeMapping + .read(i0.DriftSqlType.int, data['${effectivePrefix}type'])!), + createdAt: attachedDatabase.typeMapping.read( + i0.DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, + updatedAt: attachedDatabase.typeMapping.read( + i0.DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!, + durationInSeconds: attachedDatabase.typeMapping.read( + i0.DriftSqlType.int, data['${effectivePrefix}duration_in_seconds']), + remoteId: attachedDatabase.typeMapping + .read(i0.DriftSqlType.blob, data['${effectivePrefix}remote_id'])!, + checksum: attachedDatabase.typeMapping + .read(i0.DriftSqlType.string, data['${effectivePrefix}checksum'])!, + isFavorite: attachedDatabase.typeMapping + .read(i0.DriftSqlType.bool, data['${effectivePrefix}is_favorite'])!, + ownerId: attachedDatabase.typeMapping + .read(i0.DriftSqlType.blob, data['${effectivePrefix}owner_id'])!, + localDateTime: attachedDatabase.typeMapping.read( + i0.DriftSqlType.dateTime, data['${effectivePrefix}local_date_time']), + thumbhash: attachedDatabase.typeMapping + .read(i0.DriftSqlType.string, data['${effectivePrefix}thumbhash']), + deletedAt: attachedDatabase.typeMapping + .read(i0.DriftSqlType.dateTime, data['${effectivePrefix}deleted_at']), + ); + } + + @override + $RemoteAssetEntityTable createAlias(String alias) { + return $RemoteAssetEntityTable(attachedDatabase, alias); + } + + static i0.JsonTypeConverter2 $convertertype = + const i0.EnumIndexConverter(i2.AssetType.values); + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; +} + +class RemoteAssetEntityData extends i0.DataClass + implements i0.Insertable { + final String name; + final i2.AssetType type; + final DateTime createdAt; + final DateTime updatedAt; + final int? durationInSeconds; + final i3.Uint8List remoteId; + final String checksum; + final bool isFavorite; + final i3.Uint8List ownerId; + final DateTime? localDateTime; + final String? thumbhash; + final DateTime? deletedAt; + const RemoteAssetEntityData( + {required this.name, + required this.type, + required this.createdAt, + required this.updatedAt, + this.durationInSeconds, + required this.remoteId, + required this.checksum, + required this.isFavorite, + required this.ownerId, + this.localDateTime, + this.thumbhash, + this.deletedAt}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['name'] = i0.Variable(name); + { + map['type'] = i0.Variable( + i1.$RemoteAssetEntityTable.$convertertype.toSql(type)); + } + map['created_at'] = i0.Variable(createdAt); + map['updated_at'] = i0.Variable(updatedAt); + if (!nullToAbsent || durationInSeconds != null) { + map['duration_in_seconds'] = i0.Variable(durationInSeconds); + } + map['remote_id'] = i0.Variable(remoteId); + map['checksum'] = i0.Variable(checksum); + map['is_favorite'] = i0.Variable(isFavorite); + map['owner_id'] = i0.Variable(ownerId); + if (!nullToAbsent || localDateTime != null) { + map['local_date_time'] = i0.Variable(localDateTime); + } + if (!nullToAbsent || thumbhash != null) { + map['thumbhash'] = i0.Variable(thumbhash); + } + if (!nullToAbsent || deletedAt != null) { + map['deleted_at'] = i0.Variable(deletedAt); + } + return map; + } + + factory RemoteAssetEntityData.fromJson(Map json, + {i0.ValueSerializer? serializer}) { + serializer ??= i0.driftRuntimeOptions.defaultSerializer; + return RemoteAssetEntityData( + name: serializer.fromJson(json['name']), + type: i1.$RemoteAssetEntityTable.$convertertype + .fromJson(serializer.fromJson(json['type'])), + createdAt: serializer.fromJson(json['createdAt']), + updatedAt: serializer.fromJson(json['updatedAt']), + durationInSeconds: serializer.fromJson(json['durationInSeconds']), + remoteId: serializer.fromJson(json['remoteId']), + checksum: serializer.fromJson(json['checksum']), + isFavorite: serializer.fromJson(json['isFavorite']), + ownerId: serializer.fromJson(json['ownerId']), + localDateTime: serializer.fromJson(json['localDateTime']), + thumbhash: serializer.fromJson(json['thumbhash']), + deletedAt: serializer.fromJson(json['deletedAt']), + ); + } + @override + Map toJson({i0.ValueSerializer? serializer}) { + serializer ??= i0.driftRuntimeOptions.defaultSerializer; + return { + 'name': serializer.toJson(name), + 'type': serializer + .toJson(i1.$RemoteAssetEntityTable.$convertertype.toJson(type)), + 'createdAt': serializer.toJson(createdAt), + 'updatedAt': serializer.toJson(updatedAt), + 'durationInSeconds': serializer.toJson(durationInSeconds), + 'remoteId': serializer.toJson(remoteId), + 'checksum': serializer.toJson(checksum), + 'isFavorite': serializer.toJson(isFavorite), + 'ownerId': serializer.toJson(ownerId), + 'localDateTime': serializer.toJson(localDateTime), + 'thumbhash': serializer.toJson(thumbhash), + 'deletedAt': serializer.toJson(deletedAt), + }; + } + + i1.RemoteAssetEntityData copyWith( + {String? name, + i2.AssetType? type, + DateTime? createdAt, + DateTime? updatedAt, + i0.Value durationInSeconds = const i0.Value.absent(), + i3.Uint8List? remoteId, + String? checksum, + bool? isFavorite, + i3.Uint8List? ownerId, + i0.Value localDateTime = const i0.Value.absent(), + i0.Value thumbhash = const i0.Value.absent(), + i0.Value deletedAt = const i0.Value.absent()}) => + i1.RemoteAssetEntityData( + name: name ?? this.name, + type: type ?? this.type, + createdAt: createdAt ?? this.createdAt, + updatedAt: updatedAt ?? this.updatedAt, + durationInSeconds: durationInSeconds.present + ? durationInSeconds.value + : this.durationInSeconds, + remoteId: remoteId ?? this.remoteId, + checksum: checksum ?? this.checksum, + isFavorite: isFavorite ?? this.isFavorite, + ownerId: ownerId ?? this.ownerId, + localDateTime: + localDateTime.present ? localDateTime.value : this.localDateTime, + thumbhash: thumbhash.present ? thumbhash.value : this.thumbhash, + deletedAt: deletedAt.present ? deletedAt.value : this.deletedAt, + ); + RemoteAssetEntityData copyWithCompanion(i1.RemoteAssetEntityCompanion data) { + return RemoteAssetEntityData( + name: data.name.present ? data.name.value : this.name, + type: data.type.present ? data.type.value : this.type, + createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, + updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, + durationInSeconds: data.durationInSeconds.present + ? data.durationInSeconds.value + : this.durationInSeconds, + remoteId: data.remoteId.present ? data.remoteId.value : this.remoteId, + checksum: data.checksum.present ? data.checksum.value : this.checksum, + isFavorite: + data.isFavorite.present ? data.isFavorite.value : this.isFavorite, + ownerId: data.ownerId.present ? data.ownerId.value : this.ownerId, + localDateTime: data.localDateTime.present + ? data.localDateTime.value + : this.localDateTime, + thumbhash: data.thumbhash.present ? data.thumbhash.value : this.thumbhash, + deletedAt: data.deletedAt.present ? data.deletedAt.value : this.deletedAt, + ); + } + + @override + String toString() { + return (StringBuffer('RemoteAssetEntityData(') + ..write('name: $name, ') + ..write('type: $type, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt, ') + ..write('durationInSeconds: $durationInSeconds, ') + ..write('remoteId: $remoteId, ') + ..write('checksum: $checksum, ') + ..write('isFavorite: $isFavorite, ') + ..write('ownerId: $ownerId, ') + ..write('localDateTime: $localDateTime, ') + ..write('thumbhash: $thumbhash, ') + ..write('deletedAt: $deletedAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + name, + type, + createdAt, + updatedAt, + durationInSeconds, + i0.$driftBlobEquality.hash(remoteId), + checksum, + isFavorite, + i0.$driftBlobEquality.hash(ownerId), + localDateTime, + thumbhash, + deletedAt); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is i1.RemoteAssetEntityData && + other.name == this.name && + other.type == this.type && + other.createdAt == this.createdAt && + other.updatedAt == this.updatedAt && + other.durationInSeconds == this.durationInSeconds && + i0.$driftBlobEquality.equals(other.remoteId, this.remoteId) && + other.checksum == this.checksum && + other.isFavorite == this.isFavorite && + i0.$driftBlobEquality.equals(other.ownerId, this.ownerId) && + other.localDateTime == this.localDateTime && + other.thumbhash == this.thumbhash && + other.deletedAt == this.deletedAt); +} + +class RemoteAssetEntityCompanion + extends i0.UpdateCompanion { + final i0.Value name; + final i0.Value type; + final i0.Value createdAt; + final i0.Value updatedAt; + final i0.Value durationInSeconds; + final i0.Value remoteId; + final i0.Value checksum; + final i0.Value isFavorite; + final i0.Value ownerId; + final i0.Value localDateTime; + final i0.Value thumbhash; + final i0.Value deletedAt; + const RemoteAssetEntityCompanion({ + this.name = const i0.Value.absent(), + this.type = const i0.Value.absent(), + this.createdAt = const i0.Value.absent(), + this.updatedAt = const i0.Value.absent(), + this.durationInSeconds = const i0.Value.absent(), + this.remoteId = const i0.Value.absent(), + this.checksum = const i0.Value.absent(), + this.isFavorite = const i0.Value.absent(), + this.ownerId = const i0.Value.absent(), + this.localDateTime = const i0.Value.absent(), + this.thumbhash = const i0.Value.absent(), + this.deletedAt = const i0.Value.absent(), + }); + RemoteAssetEntityCompanion.insert({ + required String name, + required i2.AssetType type, + this.createdAt = const i0.Value.absent(), + this.updatedAt = const i0.Value.absent(), + this.durationInSeconds = const i0.Value.absent(), + required i3.Uint8List remoteId, + required String checksum, + this.isFavorite = const i0.Value.absent(), + required i3.Uint8List ownerId, + this.localDateTime = const i0.Value.absent(), + this.thumbhash = const i0.Value.absent(), + this.deletedAt = const i0.Value.absent(), + }) : name = i0.Value(name), + type = i0.Value(type), + remoteId = i0.Value(remoteId), + checksum = i0.Value(checksum), + ownerId = i0.Value(ownerId); + static i0.Insertable custom({ + i0.Expression? name, + i0.Expression? type, + i0.Expression? createdAt, + i0.Expression? updatedAt, + i0.Expression? durationInSeconds, + i0.Expression? remoteId, + i0.Expression? checksum, + i0.Expression? isFavorite, + i0.Expression? ownerId, + i0.Expression? localDateTime, + i0.Expression? thumbhash, + i0.Expression? deletedAt, + }) { + return i0.RawValuesInsertable({ + if (name != null) 'name': name, + if (type != null) 'type': type, + if (createdAt != null) 'created_at': createdAt, + if (updatedAt != null) 'updated_at': updatedAt, + if (durationInSeconds != null) 'duration_in_seconds': durationInSeconds, + if (remoteId != null) 'remote_id': remoteId, + if (checksum != null) 'checksum': checksum, + if (isFavorite != null) 'is_favorite': isFavorite, + if (ownerId != null) 'owner_id': ownerId, + if (localDateTime != null) 'local_date_time': localDateTime, + if (thumbhash != null) 'thumbhash': thumbhash, + if (deletedAt != null) 'deleted_at': deletedAt, + }); + } + + i1.RemoteAssetEntityCompanion copyWith( + {i0.Value? name, + i0.Value? type, + i0.Value? createdAt, + i0.Value? updatedAt, + i0.Value? durationInSeconds, + i0.Value? remoteId, + i0.Value? checksum, + i0.Value? isFavorite, + i0.Value? ownerId, + i0.Value? localDateTime, + i0.Value? thumbhash, + i0.Value? deletedAt}) { + return i1.RemoteAssetEntityCompanion( + name: name ?? this.name, + type: type ?? this.type, + createdAt: createdAt ?? this.createdAt, + updatedAt: updatedAt ?? this.updatedAt, + durationInSeconds: durationInSeconds ?? this.durationInSeconds, + remoteId: remoteId ?? this.remoteId, + checksum: checksum ?? this.checksum, + isFavorite: isFavorite ?? this.isFavorite, + ownerId: ownerId ?? this.ownerId, + localDateTime: localDateTime ?? this.localDateTime, + thumbhash: thumbhash ?? this.thumbhash, + deletedAt: deletedAt ?? this.deletedAt, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (name.present) { + map['name'] = i0.Variable(name.value); + } + if (type.present) { + map['type'] = i0.Variable( + i1.$RemoteAssetEntityTable.$convertertype.toSql(type.value)); + } + if (createdAt.present) { + map['created_at'] = i0.Variable(createdAt.value); + } + if (updatedAt.present) { + map['updated_at'] = i0.Variable(updatedAt.value); + } + if (durationInSeconds.present) { + map['duration_in_seconds'] = i0.Variable(durationInSeconds.value); + } + if (remoteId.present) { + map['remote_id'] = i0.Variable(remoteId.value); + } + if (checksum.present) { + map['checksum'] = i0.Variable(checksum.value); + } + if (isFavorite.present) { + map['is_favorite'] = i0.Variable(isFavorite.value); + } + if (ownerId.present) { + map['owner_id'] = i0.Variable(ownerId.value); + } + if (localDateTime.present) { + map['local_date_time'] = i0.Variable(localDateTime.value); + } + if (thumbhash.present) { + map['thumbhash'] = i0.Variable(thumbhash.value); + } + if (deletedAt.present) { + map['deleted_at'] = i0.Variable(deletedAt.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('RemoteAssetEntityCompanion(') + ..write('name: $name, ') + ..write('type: $type, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt, ') + ..write('durationInSeconds: $durationInSeconds, ') + ..write('remoteId: $remoteId, ') + ..write('checksum: $checksum, ') + ..write('isFavorite: $isFavorite, ') + ..write('ownerId: $ownerId, ') + ..write('localDateTime: $localDateTime, ') + ..write('thumbhash: $thumbhash, ') + ..write('deletedAt: $deletedAt') + ..write(')')) + .toString(); + } +} diff --git a/mobile/lib/infrastructure/repositories/db.repository.dart b/mobile/lib/infrastructure/repositories/db.repository.dart index 7424de5ce7..bc5dfe376b 100644 --- a/mobile/lib/infrastructure/repositories/db.repository.dart +++ b/mobile/lib/infrastructure/repositories/db.repository.dart @@ -3,10 +3,12 @@ import 'dart:async'; import 'package:drift/drift.dart'; import 'package:drift_flutter/drift_flutter.dart'; import 'package:immich_mobile/domain/interfaces/db.interface.dart'; +import 'package:immich_mobile/infrastructure/entities/exif.entity.dart'; import 'package:immich_mobile/infrastructure/entities/local_album.entity.dart'; import 'package:immich_mobile/infrastructure/entities/local_album_asset.entity.dart'; import 'package:immich_mobile/infrastructure/entities/local_asset.entity.dart'; import 'package:immich_mobile/infrastructure/entities/partner.entity.dart'; +import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.dart'; import 'package:immich_mobile/infrastructure/entities/user.entity.dart'; import 'package:immich_mobile/infrastructure/entities/user_metadata.entity.dart'; import 'package:isar/isar.dart'; @@ -36,6 +38,8 @@ class IsarDatabaseRepository implements IDatabaseRepository { LocalAlbumEntity, LocalAssetEntity, LocalAlbumAssetEntity, + RemoteAssetEntity, + ExifEntity, ], ) class Drift extends $Drift implements IDatabaseRepository { diff --git a/mobile/lib/infrastructure/repositories/db.repository.drift.dart b/mobile/lib/infrastructure/repositories/db.repository.drift.dart index c067b15253..1935e38f3e 100644 --- a/mobile/lib/infrastructure/repositories/db.repository.drift.dart +++ b/mobile/lib/infrastructure/repositories/db.repository.drift.dart @@ -13,6 +13,10 @@ import 'package:immich_mobile/infrastructure/entities/local_album.entity.drift.d as i5; import 'package:immich_mobile/infrastructure/entities/local_album_asset.entity.drift.dart' as i6; +import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.drift.dart' + as i7; +import 'package:immich_mobile/infrastructure/entities/exif.entity.drift.dart' + as i8; abstract class $Drift extends i0.GeneratedDatabase { $Drift(i0.QueryExecutor e) : super(e); @@ -28,6 +32,9 @@ abstract class $Drift extends i0.GeneratedDatabase { i5.$LocalAlbumEntityTable(this); late final i6.$LocalAlbumAssetEntityTable localAlbumAssetEntity = i6.$LocalAlbumAssetEntityTable(this); + late final i7.$RemoteAssetEntityTable remoteAssetEntity = + i7.$RemoteAssetEntityTable(this); + late final i8.$ExifEntityTable exifEntity = i8.$ExifEntityTable(this); @override Iterable> get allTables => allSchemaEntities.whereType>(); @@ -39,7 +46,10 @@ abstract class $Drift extends i0.GeneratedDatabase { localAssetEntity, localAlbumEntity, localAlbumAssetEntity, - i4.localAssetChecksum + remoteAssetEntity, + exifEntity, + i4.localAssetChecksum, + i7.remoteAssetChecksum ]; @override i0.StreamQueryUpdateRules get streamUpdateRules => @@ -90,6 +100,20 @@ abstract class $Drift extends i0.GeneratedDatabase { kind: i0.UpdateKind.delete), ], ), + i0.WritePropagation( + on: i0.TableUpdateQuery.onTableName('user_entity', + limitUpdateKind: i0.UpdateKind.delete), + result: [ + i0.TableUpdate('remote_asset_entity', kind: i0.UpdateKind.delete), + ], + ), + i0.WritePropagation( + on: i0.TableUpdateQuery.onTableName('remote_asset_entity', + limitUpdateKind: i0.UpdateKind.delete), + result: [ + i0.TableUpdate('exif_entity', kind: i0.UpdateKind.delete), + ], + ), ], ); @override @@ -112,4 +136,8 @@ class $DriftManager { i5.$$LocalAlbumEntityTableTableManager(_db, _db.localAlbumEntity); i6.$$LocalAlbumAssetEntityTableTableManager get localAlbumAssetEntity => i6 .$$LocalAlbumAssetEntityTableTableManager(_db, _db.localAlbumAssetEntity); + i7.$$RemoteAssetEntityTableTableManager get remoteAssetEntity => + i7.$$RemoteAssetEntityTableTableManager(_db, _db.remoteAssetEntity); + i8.$$ExifEntityTableTableManager get exifEntity => + i8.$$ExifEntityTableTableManager(_db, _db.exifEntity); } diff --git a/mobile/lib/infrastructure/repositories/sync_stream.repository.dart b/mobile/lib/infrastructure/repositories/sync_stream.repository.dart index 5ad9a369df..f1abcfed27 100644 --- a/mobile/lib/infrastructure/repositories/sync_stream.repository.dart +++ b/mobile/lib/infrastructure/repositories/sync_stream.repository.dart @@ -1,8 +1,10 @@ import 'package:drift/drift.dart'; -import 'package:flutter/foundation.dart'; import 'package:immich_mobile/domain/interfaces/sync_stream.interface.dart'; +import 'package:immich_mobile/domain/models/asset/asset.model.dart'; import 'package:immich_mobile/extensions/string_extensions.dart'; +import 'package:immich_mobile/infrastructure/entities/exif.entity.drift.dart'; import 'package:immich_mobile/infrastructure/entities/partner.entity.drift.dart'; +import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.drift.dart'; import 'package:immich_mobile/infrastructure/entities/user.entity.drift.dart'; import 'package:immich_mobile/infrastructure/repositories/db.repository.dart'; import 'package:logging/logging.dart'; @@ -99,36 +101,144 @@ class DriftSyncStreamRepository extends DriftDatabaseRepository } } - // Assets - @override - Future updateAssetsV1(Iterable data) async { - debugPrint("updateAssetsV1 - ${data.length}"); - } - @override Future deleteAssetsV1(Iterable data) async { - debugPrint("deleteAssetsV1 - ${data.length}"); + try { + await _deleteAssetsV1(data); + } catch (e, s) { + _logger.severe('Error while processing deleteAssetsV1', e, s); + rethrow; + } } - // Partner Assets @override - Future updatePartnerAssetsV1(Iterable data) async { - debugPrint("updatePartnerAssetsV1 - ${data.length}"); + Future updateAssetsV1(Iterable data) async { + try { + await _updateAssetsV1(data); + } catch (e, s) { + _logger.severe('Error while processing updateAssetsV1', e, s); + rethrow; + } } @override Future deletePartnerAssetsV1(Iterable data) async { - debugPrint("deletePartnerAssetsV1 - ${data.length}"); + try { + await _deleteAssetsV1(data); + } catch (e, s) { + _logger.severe('Error while processing deletePartnerAssetsV1', e, s); + rethrow; + } + } + + @override + Future updatePartnerAssetsV1(Iterable data) async { + try { + await _updateAssetsV1(data); + } catch (e, s) { + _logger.severe('Error while processing updatePartnerAssetsV1', e, s); + rethrow; + } } - // EXIF @override Future updateAssetsExifV1(Iterable data) async { - debugPrint("updateAssetsExifV1 - ${data.length}"); + try { + await _updateAssetExifV1(data); + } catch (e, s) { + _logger.severe('Error while processing updateAssetsExifV1', e, s); + rethrow; + } } @override Future updatePartnerAssetsExifV1(Iterable data) async { - debugPrint("updatePartnerAssetsExifV1 - ${data.length}"); + try { + await _updateAssetExifV1(data); + } catch (e, s) { + _logger.severe('Error while processing updatePartnerAssetsExifV1', e, s); + rethrow; + } } + + Future _updateAssetsV1(Iterable data) => + _db.batch((batch) { + for (final asset in data) { + final companion = RemoteAssetEntityCompanion( + name: const Value(''), // TODO: Needed from the server + type: Value(asset.type.toAssetType()), + createdAt: Value.absentIfNull(asset.fileCreatedAt), + updatedAt: Value.absentIfNull(asset.fileModifiedAt), + durationInSeconds: const Value(0), + checksum: Value(asset.checksum), + isFavorite: Value(asset.isFavorite), + ownerId: Value(asset.ownerId.toUuidByte()), + localDateTime: Value(asset.localDateTime), + thumbhash: Value(asset.thumbhash), + deletedAt: Value(asset.deletedAt), + ); + + batch.insert( + _db.remoteAssetEntity, + companion.copyWith(remoteId: Value(asset.id.toUuidByte())), + onConflict: DoUpdate((_) => companion), + ); + } + }); + + Future _deleteAssetsV1(Iterable assets) => + _db.batch((batch) { + for (final asset in assets) { + batch.delete( + _db.remoteAssetEntity, + RemoteAssetEntityCompanion( + remoteId: Value(asset.assetId.toUuidByte()), + ), + ); + } + }); + + Future _updateAssetExifV1(Iterable data) => + _db.batch((batch) { + for (final exif in data) { + final companion = ExifEntityCompanion( + city: Value(exif.city), + state: Value(exif.state), + country: Value(exif.country), + dateTimeOriginal: Value(exif.dateTimeOriginal), + description: Value(exif.description), + height: Value(exif.exifImageHeight), + width: Value(exif.exifImageWidth), + exposureTime: Value(exif.exposureTime), + fNumber: Value(exif.fNumber), + fileSize: Value(exif.fileSizeInByte), + focalLength: Value(exif.focalLength), + latitude: Value(exif.latitude), + longitude: Value(exif.longitude), + iso: Value(exif.iso), + make: Value(exif.make), + model: Value(exif.model), + orientation: Value(exif.orientation), + timeZone: Value(exif.timeZone), + rating: Value(exif.rating), + projectionType: Value(exif.projectionType), + ); + + batch.insert( + _db.exifEntity, + companion.copyWith(assetId: Value(exif.assetId.toUuidByte())), + onConflict: DoUpdate((_) => companion), + ); + } + }); +} + +extension on SyncAssetV1TypeEnum { + AssetType toAssetType() => switch (this) { + SyncAssetV1TypeEnum.IMAGE => AssetType.image, + SyncAssetV1TypeEnum.VIDEO => AssetType.video, + SyncAssetV1TypeEnum.AUDIO => AssetType.audio, + SyncAssetV1TypeEnum.OTHER => AssetType.other, + _ => throw Exception('Unknown SyncAssetV1TypeEnum value: $this'), + }; } diff --git a/mobile/lib/infrastructure/utils/asset.mixin.dart b/mobile/lib/infrastructure/utils/asset.mixin.dart index e632b0a49d..4221ae27dd 100644 --- a/mobile/lib/infrastructure/utils/asset.mixin.dart +++ b/mobile/lib/infrastructure/utils/asset.mixin.dart @@ -6,7 +6,5 @@ mixin AssetEntityMixin on Table { IntColumn get type => intEnum()(); DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)(); DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)(); - IntColumn get width => integer().nullable()(); - IntColumn get height => integer().nullable()(); IntColumn get durationInSeconds => integer().nullable()(); } diff --git a/mobile/lib/utils/nullable_value.dart b/mobile/lib/utils/nullable_value.dart index bd9c2c566c..2aaae3fdf2 100644 --- a/mobile/lib/utils/nullable_value.dart +++ b/mobile/lib/utils/nullable_value.dart @@ -8,6 +8,9 @@ class NullableValue { const NullableValue._(this._value, {bool present = false}) : _present = present; + /// Creates an instance without value + const NullableValue.absent() : this._(null, present: false); + /// Forces the value to be null const NullableValue.empty() : this._(null, present: true); diff --git a/mobile/test/domain/services/device_sync_service_test.dart b/mobile/test/domain/services/device_sync_service_test.dart index 49ccb81117..a8c5894fec 100644 --- a/mobile/test/domain/services/device_sync_service_test.dart +++ b/mobile/test/domain/services/device_sync_service_test.dart @@ -361,7 +361,8 @@ void main() { updateTimeCond: any(named: 'updateTimeCond'), ), ).thenAnswer((_) async => [newAsset]); - final dbAlbumNoThumb = dbAlbum.copyWith(thumbnailId: null); + final dbAlbumNoThumb = + dbAlbum.copyWith(thumbnailId: const NullableValue.absent()); final result = await sut.updateAlbum(dbAlbumNoThumb, LocalAlbumStub.album1); @@ -612,7 +613,8 @@ void main() { }); test('returns true and sets new thumbnail if db thumb is null', () async { - final dbAlbumNoThumb = dbAlbum.copyWith(thumbnailId: null); + final dbAlbumNoThumb = + dbAlbum.copyWith(thumbnailId: const NullableValue.empty()); final newAsset = LocalAssetStub.image2.copyWith( localId: "asset2", createdAt: DateTime(2024, 1, 1, 10, 30, 0),