From f8be7dc573cce47d12de80ed627be04d9e5314c2 Mon Sep 17 00:00:00 2001 From: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Date: Wed, 3 Jun 2026 10:40:45 +0530 Subject: [PATCH 1/8] refactor(mobile): extract shared ValueCodec from SettingsKey # Conflicts: # mobile/lib/domain/models/settings_key.dart # Conflicts: # mobile/lib/domain/models/settings_key.dart --- mobile/lib/domain/models/settings_key.dart | 179 ++------------------- mobile/lib/domain/models/value_codec.dart | 133 +++++++++++++++ 2 files changed, 147 insertions(+), 165 deletions(-) create mode 100644 mobile/lib/domain/models/value_codec.dart diff --git a/mobile/lib/domain/models/settings_key.dart b/mobile/lib/domain/models/settings_key.dart index 00c5286e07..e979f07f75 100644 --- a/mobile/lib/domain/models/settings_key.dart +++ b/mobile/lib/domain/models/settings_key.dart @@ -1,17 +1,16 @@ -import 'dart:convert'; - import 'package:flutter/material.dart'; import 'package:immich_mobile/constants/colors.dart'; import 'package:immich_mobile/constants/enums.dart'; import 'package:immich_mobile/domain/models/log.model.dart'; import 'package:immich_mobile/domain/models/timeline.model.dart'; +import 'package:immich_mobile/domain/models/value_codec.dart'; import 'package:immich_mobile/providers/album/album_sort_by_options.provider.dart'; import 'package:immich_mobile/utils/semver.dart'; enum SettingsKey { // Theme - themePrimaryColor(codec: _EnumCodec(ImmichColorPreset.values)), - themeMode(codec: _EnumCodec(ThemeMode.values)), + themePrimaryColor(codec: EnumCodec(ImmichColorPreset.values)), + themeMode(codec: EnumCodec(ThemeMode.values)), themeDynamic(), themeColorfulInterface(), @@ -27,13 +26,13 @@ enum SettingsKey { // Network networkAutoEndpointSwitching(), + networkExternalEndpointList>(codec: ListCodec(PrimitiveCodec.string)), + networkCustomHeaders>(codec: MapCodec(PrimitiveCodec.string, PrimitiveCodec.string)), networkPreferredWifiName(), networkLocalEndpoint(), - networkExternalEndpointList>(codec: _ListCodec(_PrimitiveCodec.string)), - networkCustomHeaders>(codec: _MapCodec(_PrimitiveCodec.string, _PrimitiveCodec.string)), // Album - albumSortMode(codec: _EnumCodec(AlbumSortMode.values)), + albumSortMode(codec: EnumCodec(AlbumSortMode.values)), albumIsReverse(), albumIsGrid(), @@ -47,23 +46,23 @@ enum SettingsKey { // Timeline timelineTilesPerRow(), - timelineGroupAssetsBy(codec: _EnumCodec(GroupAssetsBy.values)), + timelineGroupAssetsBy(codec: EnumCodec(GroupAssetsBy.values)), timelineStorageIndicator(), // Log - logLevel(codec: _EnumCodec(LogLevel.values)), + logLevel(codec: EnumCodec(LogLevel.values)), // Map mapShowFavoriteOnly(), mapRelativeDate(), mapIncludeArchived(), - mapThemeMode(codec: _EnumCodec(ThemeMode.values)), + mapThemeMode(codec: EnumCodec(ThemeMode.values)), mapWithPartners(), // Cleanup cleanupKeepFavorites(), - cleanupKeepMediaType(codec: _EnumCodec(AssetKeepType.values)), - cleanupKeepAlbumIds>(codec: _ListCodec(_PrimitiveCodec.string)), + cleanupKeepMediaType(codec: EnumCodec(AssetKeepType.values)), + cleanupKeepAlbumIds>(codec: ListCodec(PrimitiveCodec.string)), cleanupCutoffDaysAgo(), cleanupDefaultsInitialized(), @@ -79,163 +78,13 @@ enum SettingsKey { // Feature message featureMessageSeenRelease(codec: _SemVerCodec()); - final _SettingsCodec? _codecOverride; + final ValueCodec? _codecOverride; - const SettingsKey({_SettingsCodec? codec}) : _codecOverride = codec; + const SettingsKey({ValueCodec? codec}) : _codecOverride = codec; - _SettingsCodec get _codec => _codecOverride ?? _SettingsCodec.forType(T); + ValueCodec get _codec => _codecOverride ?? ValueCodec.forType(T); String encode(T value) => _codec.encode(value); T decode(String raw) => _codec.decode(raw); } - -sealed class _SettingsCodec { - const _SettingsCodec(); - - String encode(T value); - T decode(String raw); - - static final Map> _primitives = { - ..._register(_PrimitiveCodec.integer), - ..._register(_PrimitiveCodec.real), - ..._register(_PrimitiveCodec.boolean), - ..._register(_PrimitiveCodec.string), - ..._register(const _DateTimeCodec()), - }; - - static Map> _register(_SettingsCodec codec) => { - T: codec, - // Reifies the nullable type T so it can be used as a key in the _primitives map - _typeOf(): codec, - }; - - static Type _typeOf() => T; - - static _SettingsCodec forType(Type runtimeType) { - final codec = _primitives[runtimeType]; - if (codec == null) { - throw StateError('No primitive codec for $runtimeType. Provide an explicit codec when defining the SettingsKey.'); - } - return codec as _SettingsCodec; - } -} - -final class _EnumCodec extends _SettingsCodec { - final List values; - - const _EnumCodec(this.values); - - @override - String encode(T value) => value.name; - - @override - T decode(String raw) => values.firstWhere((v) => v.name == raw); -} - -final class _DateTimeCodec extends _SettingsCodec { - const _DateTimeCodec(); - - @override - String encode(DateTime value) => value.toIso8601String(); - - @override - DateTime decode(String raw) => DateTime.parse(raw); -} - -final class _SemVerCodec extends _SettingsCodec { - const _SemVerCodec(); - - @override - String encode(SemVer value) => value.toString(); - - @override - SemVer decode(String raw) => SemVer.fromString(raw); -} - -final class _MapCodec extends _SettingsCodec> { - final _SettingsCodec _keyCodec; - final _SettingsCodec _valueCodec; - - const _MapCodec(this._keyCodec, this._valueCodec); - - @override - String encode(Map value) { - final entries = {}; - value.forEach((k, v) => entries[_keyCodec.encode(k)] = _valueCodec.encode(v)); - return jsonEncode(entries); - } - - @override - Map decode(String raw) { - try { - final decoded = jsonDecode(raw); - if (decoded is! Map) { - return {}; - } - final result = {}; - for (final entry in decoded.entries) { - final rawKey = entry.key; - final rawValue = entry.value; - if (rawKey is! String || rawValue is! String) { - return {}; - } - final k = _keyCodec.decode(rawKey); - final v = _valueCodec.decode(rawValue); - result[k] = v; - } - return result; - } on FormatException { - return {}; - } - } -} - -final class _ListCodec extends _SettingsCodec> { - final _SettingsCodec _elementCodec; - - const _ListCodec(this._elementCodec); - - @override - String encode(List value) => jsonEncode(value.map(_elementCodec.encode).toList()); - - @override - List decode(String raw) { - try { - final decoded = jsonDecode(raw); - if (decoded is! List) { - return []; - } - final result = []; - for (final item in decoded) { - if (item is! String) { - return []; - } - final element = _elementCodec.decode(item); - result.add(element); - } - return result; - } on FormatException { - return []; - } - } -} - -final class _PrimitiveCodec extends _SettingsCodec { - final T Function(String) _parse; - - const _PrimitiveCodec._(this._parse); - - @override - String encode(T value) => value.toString(); - - @override - T decode(String raw) => _parse(raw); - - static const integer = _PrimitiveCodec._(int.parse); - static const real = _PrimitiveCodec._(double.parse); - static const boolean = _PrimitiveCodec._(bool.parse); - static const string = _PrimitiveCodec._(_identity); - - static String _identity(String s) => s; -} diff --git a/mobile/lib/domain/models/value_codec.dart b/mobile/lib/domain/models/value_codec.dart new file mode 100644 index 0000000000..22132162f1 --- /dev/null +++ b/mobile/lib/domain/models/value_codec.dart @@ -0,0 +1,133 @@ +import 'dart:convert'; + +sealed class ValueCodec { + const ValueCodec(); + + String encode(T value); + T decode(String raw); + + static const Map> _primitives = { + int: PrimitiveCodec.integer, + double: PrimitiveCodec.real, + bool: PrimitiveCodec.boolean, + String: PrimitiveCodec.string, + DateTime: DateTimeCodec(), + }; + + static ValueCodec forType(Type runtimeType) { + final codec = _primitives[runtimeType]; + if (codec == null) { + throw StateError('No primitive codec for $runtimeType. Provide an explicit codec when defining the key.'); + } + return codec as ValueCodec; + } +} + +final class EnumCodec extends ValueCodec { + final List values; + + const EnumCodec(this.values); + + @override + String encode(T value) => value.name; + + @override + T decode(String raw) => values.firstWhere((v) => v.name == raw); +} + +final class DateTimeCodec extends ValueCodec { + const DateTimeCodec(); + + @override + String encode(DateTime value) => value.toIso8601String(); + + @override + DateTime decode(String raw) => DateTime.parse(raw); +} + +final class MapCodec extends ValueCodec> { + final ValueCodec _keyCodec; + final ValueCodec _valueCodec; + + const MapCodec(this._keyCodec, this._valueCodec); + + @override + String encode(Map value) { + final entries = {}; + value.forEach((k, v) => entries[_keyCodec.encode(k)] = _valueCodec.encode(v)); + return jsonEncode(entries); + } + + @override + Map decode(String raw) { + try { + final decoded = jsonDecode(raw); + if (decoded is! Map) { + return {}; + } + final result = {}; + for (final entry in decoded.entries) { + final rawKey = entry.key; + final rawValue = entry.value; + if (rawKey is! String || rawValue is! String) { + return {}; + } + final k = _keyCodec.decode(rawKey); + final v = _valueCodec.decode(rawValue); + result[k] = v; + } + return result; + } on FormatException { + return {}; + } + } +} + +final class ListCodec extends ValueCodec> { + final ValueCodec _elementCodec; + + const ListCodec(this._elementCodec); + + @override + String encode(List value) => jsonEncode(value.map(_elementCodec.encode).toList()); + + @override + List decode(String raw) { + try { + final decoded = jsonDecode(raw); + if (decoded is! List) { + return []; + } + final result = []; + for (final item in decoded) { + if (item is! String) { + return []; + } + final element = _elementCodec.decode(item); + result.add(element); + } + return result; + } on FormatException { + return []; + } + } +} + +final class PrimitiveCodec extends ValueCodec { + final T Function(String) _parse; + + const PrimitiveCodec._(this._parse); + + @override + String encode(T value) => value.toString(); + + @override + T decode(String raw) => _parse(raw); + + static const integer = PrimitiveCodec._(int.parse); + static const real = PrimitiveCodec._(double.parse); + static const boolean = PrimitiveCodec._(bool.parse); + static const string = PrimitiveCodec._(_identity); + + static String _identity(String s) => s; +} From 00542011fb7ff6af34fdc4d67ec8596de0268169 Mon Sep 17 00:00:00 2001 From: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Date: Wed, 3 Jun 2026 12:15:19 +0530 Subject: [PATCH 2/8] extract CachedKeyValueRepository --- .../cached_key_value_repository.dart | 37 ++++++++++++ .../repositories/settings.repository.dart | 56 ++++++++----------- 2 files changed, 61 insertions(+), 32 deletions(-) create mode 100644 mobile/lib/infrastructure/repositories/cached_key_value_repository.dart diff --git a/mobile/lib/infrastructure/repositories/cached_key_value_repository.dart b/mobile/lib/infrastructure/repositories/cached_key_value_repository.dart new file mode 100644 index 0000000000..92cb2e7c3b --- /dev/null +++ b/mobile/lib/infrastructure/repositories/cached_key_value_repository.dart @@ -0,0 +1,37 @@ +import 'package:collection/collection.dart'; +import 'package:drift/drift.dart'; +// ignore: depend_on_referenced_packages +import 'package:meta/meta.dart'; + +abstract class CachedKeyValueRepository { + CachedKeyValueRepository(this._snapshot); + + S _snapshot; + S get snapshot => _snapshot; + @protected + set snapshot(S value) => _snapshot = value; + + List get keys; + + Object decodeValue(K key, String raw); + + S buildSnapshot(Map overrides); + + Selectable<({String key, String value})> selectable(); + + Future refresh() async => _snapshot = _build(await selectable().get()); + + Stream watchSnapshot() => selectable().watch().map((rows) => _snapshot = _build(rows)); + + S _build(List<({String key, String value})> rows) { + final overrides = {}; + for (final row in rows) { + final key = keys.firstWhereOrNull((k) => k.name == row.key); + if (key == null) { + continue; + } + overrides[key] = decodeValue(key, row.value); + } + return buildSnapshot(overrides); + } +} diff --git a/mobile/lib/infrastructure/repositories/settings.repository.dart b/mobile/lib/infrastructure/repositories/settings.repository.dart index c974963f6a..6335b8e1a6 100644 --- a/mobile/lib/infrastructure/repositories/settings.repository.dart +++ b/mobile/lib/infrastructure/repositories/settings.repository.dart @@ -2,12 +2,13 @@ import 'package:collection/collection.dart'; import 'package:immich_mobile/domain/models/config/app_config.dart'; import 'package:immich_mobile/domain/models/settings_key.dart'; import 'package:immich_mobile/infrastructure/entities/settings.entity.drift.dart'; +import 'package:immich_mobile/infrastructure/repositories/cached_key_value_repository.dart'; import 'package:immich_mobile/infrastructure/repositories/db.repository.dart'; -class SettingsRepository extends DriftDatabaseRepository { +class SettingsRepository extends CachedKeyValueRepository { final Drift _db; - SettingsRepository._(this._db) : super(_db); + SettingsRepository._(this._db) : super(const .new()); static SettingsRepository? _instance; @@ -19,9 +20,6 @@ class SettingsRepository extends DriftDatabaseRepository { return instance; } - AppConfig _appConfig = const .new(); - AppConfig get appConfig => _appConfig; - static Future ensureInitialized(Drift db) async { if (_instance == null) { final instance = SettingsRepository._(db); @@ -31,7 +29,20 @@ class SettingsRepository extends DriftDatabaseRepository { return _instance!; } - Future refresh() async => _applyOverrides(await _db.select(_db.settingsEntity).get()); + @override + List get keys => SettingsKey.values; + + @override + Object decodeValue(SettingsKey key, String raw) => key.decode(raw); + + @override + AppConfig buildSnapshot(Map overrides) => AppConfig.fromEntries(overrides); + + @override + Selectable<({String key, String value})> selectable() => + _db.select(_db.settingsEntity).map((row) => (key: row.key, value: row.value)); + + AppConfig get appConfig => snapshot; Future clear(Iterable keys) async { if (keys.isEmpty) { @@ -41,13 +52,15 @@ class SettingsRepository extends DriftDatabaseRepository { final names = keys.map((key) => key.name).toList(); await (_db.delete(_db.settingsEntity)..where((row) => row.key.isIn(names))).go(); + var config = snapshot; for (final key in keys) { - _appConfig = _appConfig.write(key, defaultConfig.read(key)); + config = config.write(key, defaultConfig.read(key)); } + snapshot = config; } - Future write(SettingsKey key, U value) async { - if (value == _appConfig.read(key)) { + Future write(SettingsKey key, U value) async { + if (value == snapshot.read(key)) { return; } @@ -65,29 +78,8 @@ class SettingsRepository extends DriftDatabaseRepository { .insertOnConflictUpdate( SettingsEntityCompanion.insert(key: key.name, value: .new(resolvedValue), updatedAt: .new(DateTime.now())), ); - _appConfig = _appConfig.write(key, value); + snapshot = snapshot.write(key, value); } - Stream watchConfig() => _db.select(_db.settingsEntity).watch().map((rows) { - _applyOverrides(rows); - return _appConfig; - }); - - void _applyOverrides(List rows) { - _appConfig = AppConfig.fromEntries( - rows.fold({}, (overrides, row) { - final metadataKey = SettingsKey.values.firstWhereOrNull((key) => key.name == row.key); - if (metadataKey == null) { - return overrides; - } - - Object? decodedValue; - if (row.value != null) { - decodedValue = metadataKey.decode(row.value!); - } - - return {...overrides, metadataKey: decodedValue}; - }), - ); - } + Stream watchConfig() => watchSnapshot(); } From 5c5b41500b9aecd2d50e5aad5df866143201983e Mon Sep 17 00:00:00 2001 From: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Date: Thu, 11 Jun 2026 17:45:57 +0530 Subject: [PATCH 3/8] rebase over null store key --- mobile/lib/domain/models/settings_key.dart | 2 +- mobile/lib/domain/models/value_codec.dart | 24 +++++++++++------ .../cached_key_value_repository.dart | 26 +++++++++++-------- .../repositories/settings.repository.dart | 8 +++--- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/mobile/lib/domain/models/settings_key.dart b/mobile/lib/domain/models/settings_key.dart index e979f07f75..ec60bb966f 100644 --- a/mobile/lib/domain/models/settings_key.dart +++ b/mobile/lib/domain/models/settings_key.dart @@ -67,7 +67,7 @@ enum SettingsKey { cleanupDefaultsInitialized(), // Share - shareFileType(codec: _EnumCodec(ShareAssetType.values)), + shareFileType(codec: EnumCodec(ShareAssetType.values)), // Slideshow slideshowRepeat(), diff --git a/mobile/lib/domain/models/value_codec.dart b/mobile/lib/domain/models/value_codec.dart index 22132162f1..1e76d9713c 100644 --- a/mobile/lib/domain/models/value_codec.dart +++ b/mobile/lib/domain/models/value_codec.dart @@ -1,20 +1,28 @@ import 'dart:convert'; -sealed class ValueCodec { +sealed class ValueCodec { const ValueCodec(); String encode(T value); T decode(String raw); - static const Map> _primitives = { - int: PrimitiveCodec.integer, - double: PrimitiveCodec.real, - bool: PrimitiveCodec.boolean, - String: PrimitiveCodec.string, - DateTime: DateTimeCodec(), + static final Map> _primitives = { + ..._register(PrimitiveCodec.integer), + ..._register(PrimitiveCodec.real), + ..._register(PrimitiveCodec.boolean), + ..._register(PrimitiveCodec.string), + ..._register(const DateTimeCodec()), }; - static ValueCodec forType(Type runtimeType) { + static Map> _register(ValueCodec codec) => { + T: codec, + // Reifies the nullable type T so it can be used as a key in the _primitives map + _typeOf(): codec, + }; + + static Type _typeOf() => T; + + static ValueCodec forType(Type runtimeType) { final codec = _primitives[runtimeType]; if (codec == null) { throw StateError('No primitive codec for $runtimeType. Provide an explicit codec when defining the key.'); diff --git a/mobile/lib/infrastructure/repositories/cached_key_value_repository.dart b/mobile/lib/infrastructure/repositories/cached_key_value_repository.dart index 92cb2e7c3b..afeb31fa27 100644 --- a/mobile/lib/infrastructure/repositories/cached_key_value_repository.dart +++ b/mobile/lib/infrastructure/repositories/cached_key_value_repository.dart @@ -15,23 +15,27 @@ abstract class CachedKeyValueRepository { Object decodeValue(K key, String raw); - S buildSnapshot(Map overrides); + S buildSnapshot(Map overrides); - Selectable<({String key, String value})> selectable(); + Selectable<({String key, String? value})> selectable(); Future refresh() async => _snapshot = _build(await selectable().get()); Stream watchSnapshot() => selectable().watch().map((rows) => _snapshot = _build(rows)); - S _build(List<({String key, String value})> rows) { - final overrides = {}; - for (final row in rows) { - final key = keys.firstWhereOrNull((k) => k.name == row.key); + S _build(List<({String key, String? value})> rows) => buildSnapshot( + rows.fold({}, (overrides, row) { + final key = keys.firstWhereOrNull((key) => key.name == row.key); if (key == null) { - continue; + return overrides; } - overrides[key] = decodeValue(key, row.value); - } - return buildSnapshot(overrides); - } + + Object? decodedValue; + if (row.value != null) { + decodedValue = decodeValue(key, row.value!); + } + + return {...overrides, key: decodedValue}; + }), + ); } diff --git a/mobile/lib/infrastructure/repositories/settings.repository.dart b/mobile/lib/infrastructure/repositories/settings.repository.dart index 6335b8e1a6..7063779336 100644 --- a/mobile/lib/infrastructure/repositories/settings.repository.dart +++ b/mobile/lib/infrastructure/repositories/settings.repository.dart @@ -1,4 +1,4 @@ -import 'package:collection/collection.dart'; +import 'package:drift/drift.dart'; import 'package:immich_mobile/domain/models/config/app_config.dart'; import 'package:immich_mobile/domain/models/settings_key.dart'; import 'package:immich_mobile/infrastructure/entities/settings.entity.drift.dart'; @@ -36,10 +36,10 @@ class SettingsRepository extends CachedKeyValueRepository key.decode(raw); @override - AppConfig buildSnapshot(Map overrides) => AppConfig.fromEntries(overrides); + AppConfig buildSnapshot(Map overrides) => AppConfig.fromEntries(overrides); @override - Selectable<({String key, String value})> selectable() => + Selectable<({String key, String? value})> selectable() => _db.select(_db.settingsEntity).map((row) => (key: row.key, value: row.value)); AppConfig get appConfig => snapshot; @@ -59,7 +59,7 @@ class SettingsRepository extends CachedKeyValueRepository write(SettingsKey key, U value) async { + Future write(SettingsKey key, U value) async { if (value == snapshot.read(key)) { return; } From 1b1b14e3e471ebd61e210193eddac7a8bc92e884 Mon Sep 17 00:00:00 2001 From: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Date: Thu, 11 Jun 2026 18:38:12 +0530 Subject: [PATCH 4/8] add map codec tests --- mobile/lib/domain/models/settings_key.dart | 6 +++--- mobile/lib/domain/models/value_codec.dart | 14 +++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/mobile/lib/domain/models/settings_key.dart b/mobile/lib/domain/models/settings_key.dart index ec60bb966f..4308d69555 100644 --- a/mobile/lib/domain/models/settings_key.dart +++ b/mobile/lib/domain/models/settings_key.dart @@ -72,11 +72,11 @@ enum SettingsKey { // Slideshow slideshowRepeat(), slideshowDuration(), - slideshowLook(codec: _EnumCodec(SlideshowLook.values)), - slideshowDirection(codec: _EnumCodec(SlideshowDirection.values)), + slideshowLook(codec: EnumCodec(SlideshowLook.values)), + slideshowDirection(codec: EnumCodec(SlideshowDirection.values)), // Feature message - featureMessageSeenRelease(codec: _SemVerCodec()); + featureMessageSeenRelease(codec: SemVerCodec()); final ValueCodec? _codecOverride; diff --git a/mobile/lib/domain/models/value_codec.dart b/mobile/lib/domain/models/value_codec.dart index 1e76d9713c..814ef1b926 100644 --- a/mobile/lib/domain/models/value_codec.dart +++ b/mobile/lib/domain/models/value_codec.dart @@ -1,5 +1,7 @@ import 'dart:convert'; +import 'package:immich_mobile/utils/semver.dart'; + sealed class ValueCodec { const ValueCodec(); @@ -53,6 +55,16 @@ final class DateTimeCodec extends ValueCodec { DateTime decode(String raw) => DateTime.parse(raw); } +final class SemVerCodec extends ValueCodec { + const SemVerCodec(); + + @override + String encode(SemVer value) => value.toString(); + + @override + SemVer decode(String raw) => SemVer.fromString(raw); +} + final class MapCodec extends ValueCodec> { final ValueCodec _keyCodec; final ValueCodec _valueCodec; @@ -78,7 +90,7 @@ final class MapCodec extends ValueCodec Date: Thu, 11 Jun 2026 18:38:12 +0530 Subject: [PATCH 5/8] add map codec tests --- mobile/test/unit/utils/value_codec_test.dart | 99 ++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 mobile/test/unit/utils/value_codec_test.dart diff --git a/mobile/test/unit/utils/value_codec_test.dart b/mobile/test/unit/utils/value_codec_test.dart new file mode 100644 index 0000000000..8754af1e95 --- /dev/null +++ b/mobile/test/unit/utils/value_codec_test.dart @@ -0,0 +1,99 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:immich_mobile/domain/models/value_codec.dart'; + +enum _Fruit { apple, banana, cherry } + +void main() { + group('MapCodec', () { + group('encode', () { + test('serializes an empty map to an empty JSON object', () { + const codec = MapCodec(PrimitiveCodec.string, PrimitiveCodec.string); + expect(codec.encode({}), '{}'); + }); + + test('encodes a string-to-string map as a JSON object', () { + const codec = MapCodec(PrimitiveCodec.string, PrimitiveCodec.string); + expect(codec.encode({'a': '1', 'b': '2'}), '{"a":"1","b":"2"}'); + }); + + test('stringifies non-string values via the value codec', () { + const codec = MapCodec(PrimitiveCodec.string, PrimitiveCodec.integer); + expect(codec.encode({'x': 10, 'y': 20}), '{"x":"10","y":"20"}'); + }); + + test('stringifies non-string keys via the key codec', () { + const codec = MapCodec(PrimitiveCodec.integer, PrimitiveCodec.string); + expect(codec.encode({1: 'one', 2: 'two'}), '{"1":"one","2":"two"}'); + }); + }); + + group('decode', () { + test('reconstructs a string-to-string map', () { + const codec = MapCodec(PrimitiveCodec.string, PrimitiveCodec.string); + expect(codec.decode('{"a":"1","b":"2"}'), {'a': '1', 'b': '2'}); + }); + + test('parses values back to their domain type', () { + const codec = MapCodec(PrimitiveCodec.string, PrimitiveCodec.integer); + expect(codec.decode('{"x":"10","y":"20"}'), {'x': 10, 'y': 20}); + }); + + test('parses keys back to their domain type', () { + const codec = MapCodec(PrimitiveCodec.integer, PrimitiveCodec.string); + expect(codec.decode('{"1":"one","2":"two"}'), {1: 'one', 2: 'two'}); + }); + + test('returns an empty map for an empty JSON object', () { + const codec = MapCodec(PrimitiveCodec.string, PrimitiveCodec.string); + expect(codec.decode('{}'), isEmpty); + }); + + test('returns an empty map when the payload is not valid JSON', () { + const codec = MapCodec(PrimitiveCodec.string, PrimitiveCodec.string); + expect(codec.decode('not json'), isEmpty); + }); + + test('returns an empty map when the JSON root is not an object', () { + const codec = MapCodec(PrimitiveCodec.string, PrimitiveCodec.string); + expect(codec.decode('[]'), isEmpty); + expect(codec.decode('"a string"'), isEmpty); + expect(codec.decode('42'), isEmpty); + }); + + test('skips entries whose value is not a JSON string, keeping the rest', () { + const codec = MapCodec(PrimitiveCodec.string, PrimitiveCodec.integer); + expect(codec.decode('{"x":1,"y":"20"}'), {'y': 20}); + }); + + test('skips entries whose value is a nested object, keeping the rest', () { + const codec = MapCodec(PrimitiveCodec.string, PrimitiveCodec.string); + expect(codec.decode('{"a":{"nested":"value"},"b":"ok"}'), {'b': 'ok'}); + }); + + test('returns an empty map when every entry is malformed', () { + const codec = MapCodec(PrimitiveCodec.string, PrimitiveCodec.integer); + expect(codec.decode('{"x":1,"y":2}'), isEmpty); + }); + }); + + group('round trip', () { + test('preserves a primitive map through encode then decode', () { + const codec = MapCodec(PrimitiveCodec.string, PrimitiveCodec.integer); + const original = {'one': 1, 'two': 2, 'three': 3}; + expect(codec.decode(codec.encode(original)), original); + }); + + test('preserves an enum-valued map by composing with EnumCodec', () { + const codec = MapCodec(PrimitiveCodec.string, EnumCodec(_Fruit.values)); + const original = {'breakfast': _Fruit.banana, 'snack': _Fruit.apple}; + expect(codec.decode(codec.encode(original)), original); + }); + + test('preserves a DateTime-valued map by composing with DateTimeCodec', () { + const codec = MapCodec(PrimitiveCodec.string, DateTimeCodec()); + final original = {'created': DateTime.utc(2024, 1, 1, 12, 30)}; + expect(codec.decode(codec.encode(original)), original); + }); + }); + }); +} From 865adba8c1e5b52ca6ea7002d4f323b64327d404 Mon Sep 17 00:00:00 2001 From: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Date: Thu, 11 Jun 2026 23:32:35 +0530 Subject: [PATCH 6/8] migrate session config from store --- .../background_sync_teardown_test.dart | 6 +- mobile/lib/domain/models/session.model.dart | 63 +++ mobile/lib/domain/models/store.model.dart | 6 +- .../entities/session.entity.dart | 18 + .../entities/session.entity.drift.dart | 427 ++++++++++++++++++ .../cached_key_value_repository.dart | 1 + .../repositories/db.repository.dart | 97 ++-- .../repositories/session.repository.dart | 82 ++++ .../repositories/settings.repository.dart | 4 +- .../lib/pages/common/splash_screen.page.dart | 8 +- .../open_in_browser_action_button.widget.dart | 5 +- .../asset_viewer/video_viewer.widget.dart | 5 +- .../people/partner_user_avatar.widget.dart | 10 +- mobile/lib/providers/auth.provider.dart | 10 +- .../infrastructure/session.provider.dart | 12 + .../infrastructure/settings.provider.dart | 2 +- mobile/lib/providers/websocket.provider.dart | 5 +- .../lib/repositories/upload.repository.dart | 5 +- mobile/lib/routing/auth_guard.dart | 16 +- mobile/lib/services/api.service.dart | 10 +- mobile/lib/services/auth.service.dart | 8 +- .../services/background_upload.service.dart | 3 +- mobile/lib/utils/bootstrap.dart | 4 + mobile/lib/utils/image_url_builder.dart | 12 +- mobile/lib/utils/migration.dart | 104 +++-- mobile/lib/utils/url_helper.dart | 5 +- mobile/lib/widgets/common/user_avatar.dart | 5 +- .../widgets/common/user_circle_avatar.dart | 5 +- .../domain/services/store_service_test.dart | 36 +- .../repositories/store_repository_test.dart | 12 +- .../repositories/session_repository_test.dart | 118 +++++ .../settings_repository_test.dart | 4 +- mobile/test/services/auth.service_test.dart | 2 + .../background_upload.service_test.dart | 6 +- 34 files changed, 938 insertions(+), 178 deletions(-) create mode 100644 mobile/lib/domain/models/session.model.dart create mode 100644 mobile/lib/infrastructure/entities/session.entity.dart create mode 100644 mobile/lib/infrastructure/entities/session.entity.drift.dart create mode 100644 mobile/lib/infrastructure/repositories/session.repository.dart create mode 100644 mobile/lib/providers/infrastructure/session.provider.dart create mode 100644 mobile/test/medium/repositories/session_repository_test.dart diff --git a/mobile/integration_test/background_sync_teardown_test.dart b/mobile/integration_test/background_sync_teardown_test.dart index 3e88109c82..225ed371c4 100644 --- a/mobile/integration_test/background_sync_teardown_test.dart +++ b/mobile/integration_test/background_sync_teardown_test.dart @@ -40,7 +40,7 @@ void main() { tearDown(() async { await workerManagerPatch.dispose(); await server.close(); - await Store.delete(StoreKey.serverEndpoint); + await Store.delete(StoreKey.legacyServerEndpoint); await Store.delete(StoreKey.syncMigrationStatus); }); @@ -119,7 +119,9 @@ void main() { final releaseTxn = Completer(); final txnHeld = Completer(); final txn = drift.transaction(() async { - await drift.into(drift.userEntity).insert( + await drift + .into(drift.userEntity) + .insert( UserEntityCompanion.insert( id: 'holder', name: 'holder', diff --git a/mobile/lib/domain/models/session.model.dart b/mobile/lib/domain/models/session.model.dart new file mode 100644 index 0000000000..81e9b3efd3 --- /dev/null +++ b/mobile/lib/domain/models/session.model.dart @@ -0,0 +1,63 @@ +import 'package:immich_mobile/domain/models/value_codec.dart'; +import 'package:immich_mobile/utils/option.dart'; + +enum SessionKey { + serverUrl(), + accessToken(), + serverEndpoint(); + + ValueCodec get _codec => ValueCodec.forType(T); + + String encode(T value) => _codec.encode(value); + + T decode(String raw) => _codec.decode(raw); +} + +const defaultSession = Session(); + +class Session { + final String? serverUrl; + final String? accessToken; + final String? serverEndpoint; + + const Session({this.serverUrl, this.accessToken, this.serverEndpoint}); + + Session copyWith({Option? serverUrl, Option? accessToken, Option? serverEndpoint}) => .new( + serverUrl: serverUrl.patch(this.serverUrl), + accessToken: accessToken.patch(this.accessToken), + serverEndpoint: serverEndpoint.patch(this.serverEndpoint), + ); + + @override + bool operator ==(Object other) => + identical(this, other) || + (other is Session && + other.serverUrl == serverUrl && + other.accessToken == accessToken && + other.serverEndpoint == serverEndpoint); + + @override + int get hashCode => Object.hash(serverUrl, accessToken, serverEndpoint); + + @override + String toString() => 'Session(serverUrl: $serverUrl, accessToken: $accessToken, serverEndpoint: $serverEndpoint)'; + + T read(SessionKey key) => + (switch (key) { + .serverUrl => serverUrl, + .accessToken => accessToken, + .serverEndpoint => serverEndpoint, + }) + as T; + + factory Session.fromEntries(Map overrides) => + overrides.entries.fold(const Session(), (session, entry) => session.write(entry.key, entry.value)); + + Session write(SessionKey key, U value) { + return switch (key) { + .serverUrl => copyWith(serverUrl: .fromNullable(value as String?)), + .accessToken => copyWith(accessToken: .fromNullable(value as String?)), + .serverEndpoint => copyWith(serverEndpoint: .fromNullable(value as String?)), + }; + } +} diff --git a/mobile/lib/domain/models/store.model.dart b/mobile/lib/domain/models/store.model.dart index be1b0c5fb8..9a31e26f5f 100644 --- a/mobile/lib/domain/models/store.model.dart +++ b/mobile/lib/domain/models/store.model.dart @@ -6,9 +6,6 @@ enum StoreKey { version._(0), currentUser._(2), deviceId._(4), - serverUrl._(10), - accessToken._(11), - serverEndpoint._(12), advancedTroubleshooting._(114), enableHapticFeedback._(126), @@ -19,6 +16,9 @@ enum StoreKey { syncMigrationStatus._(1013), // Legacy keys that have been migrated to the new metadata store + legacyServerUrl._(10), + legacyAccessToken._(11), + legacyServerEndpoint._(12), legacyBackupRequireCharging._(7), legacyBackupTriggerDelay._(8), legacySyncAlbums._(131), diff --git a/mobile/lib/infrastructure/entities/session.entity.dart b/mobile/lib/infrastructure/entities/session.entity.dart new file mode 100644 index 0000000000..ddf89004fb --- /dev/null +++ b/mobile/lib/infrastructure/entities/session.entity.dart @@ -0,0 +1,18 @@ +import 'package:drift/drift.dart'; +import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart'; + +class SessionEntity extends Table with DriftDefaultsMixin { + const SessionEntity(); + + TextColumn get key => text()(); + + TextColumn get value => text().nullable()(); + + DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)(); + + @override + Set get primaryKey => {key}; + + @override + String get tableName => "session"; +} diff --git a/mobile/lib/infrastructure/entities/session.entity.drift.dart b/mobile/lib/infrastructure/entities/session.entity.drift.dart new file mode 100644 index 0000000000..0f18ca516b --- /dev/null +++ b/mobile/lib/infrastructure/entities/session.entity.drift.dart @@ -0,0 +1,427 @@ +// dart format width=80 +// ignore_for_file: type=lint +import 'package:drift/drift.dart' as i0; +import 'package:immich_mobile/infrastructure/entities/session.entity.drift.dart' + as i1; +import 'package:immich_mobile/infrastructure/entities/session.entity.dart' + as i2; +import 'package:drift/src/runtime/query_builder/query_builder.dart' as i3; + +typedef $$SessionEntityTableCreateCompanionBuilder = + i1.SessionEntityCompanion Function({ + required String key, + i0.Value value, + i0.Value updatedAt, + }); +typedef $$SessionEntityTableUpdateCompanionBuilder = + i1.SessionEntityCompanion Function({ + i0.Value key, + i0.Value value, + i0.Value updatedAt, + }); + +class $$SessionEntityTableFilterComposer + extends i0.Composer { + $$SessionEntityTableFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + i0.ColumnFilters get key => $composableBuilder( + column: $table.key, + builder: (column) => i0.ColumnFilters(column), + ); + + i0.ColumnFilters get value => $composableBuilder( + column: $table.value, + builder: (column) => i0.ColumnFilters(column), + ); + + i0.ColumnFilters get updatedAt => $composableBuilder( + column: $table.updatedAt, + builder: (column) => i0.ColumnFilters(column), + ); +} + +class $$SessionEntityTableOrderingComposer + extends i0.Composer { + $$SessionEntityTableOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + i0.ColumnOrderings get key => $composableBuilder( + column: $table.key, + builder: (column) => i0.ColumnOrderings(column), + ); + + i0.ColumnOrderings get value => $composableBuilder( + column: $table.value, + builder: (column) => i0.ColumnOrderings(column), + ); + + i0.ColumnOrderings get updatedAt => $composableBuilder( + column: $table.updatedAt, + builder: (column) => i0.ColumnOrderings(column), + ); +} + +class $$SessionEntityTableAnnotationComposer + extends i0.Composer { + $$SessionEntityTableAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + i0.GeneratedColumn get key => + $composableBuilder(column: $table.key, builder: (column) => column); + + i0.GeneratedColumn get value => + $composableBuilder(column: $table.value, builder: (column) => column); + + i0.GeneratedColumn get updatedAt => + $composableBuilder(column: $table.updatedAt, builder: (column) => column); +} + +class $$SessionEntityTableTableManager + extends + i0.RootTableManager< + i0.GeneratedDatabase, + i1.$SessionEntityTable, + i1.SessionEntityData, + i1.$$SessionEntityTableFilterComposer, + i1.$$SessionEntityTableOrderingComposer, + i1.$$SessionEntityTableAnnotationComposer, + $$SessionEntityTableCreateCompanionBuilder, + $$SessionEntityTableUpdateCompanionBuilder, + ( + i1.SessionEntityData, + i0.BaseReferences< + i0.GeneratedDatabase, + i1.$SessionEntityTable, + i1.SessionEntityData + >, + ), + i1.SessionEntityData, + i0.PrefetchHooks Function() + > { + $$SessionEntityTableTableManager( + i0.GeneratedDatabase db, + i1.$SessionEntityTable table, + ) : super( + i0.TableManagerState( + db: db, + table: table, + createFilteringComposer: () => + i1.$$SessionEntityTableFilterComposer($db: db, $table: table), + createOrderingComposer: () => + i1.$$SessionEntityTableOrderingComposer($db: db, $table: table), + createComputedFieldComposer: () => + i1.$$SessionEntityTableAnnotationComposer($db: db, $table: table), + updateCompanionCallback: + ({ + i0.Value key = const i0.Value.absent(), + i0.Value value = const i0.Value.absent(), + i0.Value updatedAt = const i0.Value.absent(), + }) => i1.SessionEntityCompanion( + key: key, + value: value, + updatedAt: updatedAt, + ), + createCompanionCallback: + ({ + required String key, + i0.Value value = const i0.Value.absent(), + i0.Value updatedAt = const i0.Value.absent(), + }) => i1.SessionEntityCompanion.insert( + key: key, + value: value, + updatedAt: updatedAt, + ), + withReferenceMapper: (p0) => p0 + .map((e) => (e.readTable(table), i0.BaseReferences(db, table, e))) + .toList(), + prefetchHooksCallback: null, + ), + ); +} + +typedef $$SessionEntityTableProcessedTableManager = + i0.ProcessedTableManager< + i0.GeneratedDatabase, + i1.$SessionEntityTable, + i1.SessionEntityData, + i1.$$SessionEntityTableFilterComposer, + i1.$$SessionEntityTableOrderingComposer, + i1.$$SessionEntityTableAnnotationComposer, + $$SessionEntityTableCreateCompanionBuilder, + $$SessionEntityTableUpdateCompanionBuilder, + ( + i1.SessionEntityData, + i0.BaseReferences< + i0.GeneratedDatabase, + i1.$SessionEntityTable, + i1.SessionEntityData + >, + ), + i1.SessionEntityData, + i0.PrefetchHooks Function() + >; + +class $SessionEntityTable extends i2.SessionEntity + with i0.TableInfo<$SessionEntityTable, i1.SessionEntityData> { + @override + final i0.GeneratedDatabase attachedDatabase; + final String? _alias; + $SessionEntityTable(this.attachedDatabase, [this._alias]); + static const i0.VerificationMeta _keyMeta = const i0.VerificationMeta('key'); + @override + late final i0.GeneratedColumn key = i0.GeneratedColumn( + 'key', + aliasedName, + false, + type: i0.DriftSqlType.string, + requiredDuringInsert: true, + ); + static const i0.VerificationMeta _valueMeta = const i0.VerificationMeta( + 'value', + ); + @override + late final i0.GeneratedColumn value = i0.GeneratedColumn( + 'value', + aliasedName, + true, + type: i0.DriftSqlType.string, + requiredDuringInsert: false, + ); + 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: i3.currentDateAndTime, + ); + @override + List get $columns => [key, value, updatedAt]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'session'; + @override + i0.VerificationContext validateIntegrity( + i0.Insertable instance, { + bool isInserting = false, + }) { + final context = i0.VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('key')) { + context.handle( + _keyMeta, + key.isAcceptableOrUnknown(data['key']!, _keyMeta), + ); + } else if (isInserting) { + context.missing(_keyMeta); + } + if (data.containsKey('value')) { + context.handle( + _valueMeta, + value.isAcceptableOrUnknown(data['value']!, _valueMeta), + ); + } + if (data.containsKey('updated_at')) { + context.handle( + _updatedAtMeta, + updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta), + ); + } + return context; + } + + @override + Set get $primaryKey => {key}; + @override + i1.SessionEntityData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return i1.SessionEntityData( + key: attachedDatabase.typeMapping.read( + i0.DriftSqlType.string, + data['${effectivePrefix}key'], + )!, + value: attachedDatabase.typeMapping.read( + i0.DriftSqlType.string, + data['${effectivePrefix}value'], + ), + updatedAt: attachedDatabase.typeMapping.read( + i0.DriftSqlType.dateTime, + data['${effectivePrefix}updated_at'], + )!, + ); + } + + @override + $SessionEntityTable createAlias(String alias) { + return $SessionEntityTable(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; +} + +class SessionEntityData extends i0.DataClass + implements i0.Insertable { + final String key; + final String? value; + final DateTime updatedAt; + const SessionEntityData({ + required this.key, + this.value, + required this.updatedAt, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['key'] = i0.Variable(key); + if (!nullToAbsent || value != null) { + map['value'] = i0.Variable(value); + } + map['updated_at'] = i0.Variable(updatedAt); + return map; + } + + factory SessionEntityData.fromJson( + Map json, { + i0.ValueSerializer? serializer, + }) { + serializer ??= i0.driftRuntimeOptions.defaultSerializer; + return SessionEntityData( + key: serializer.fromJson(json['key']), + value: serializer.fromJson(json['value']), + updatedAt: serializer.fromJson(json['updatedAt']), + ); + } + @override + Map toJson({i0.ValueSerializer? serializer}) { + serializer ??= i0.driftRuntimeOptions.defaultSerializer; + return { + 'key': serializer.toJson(key), + 'value': serializer.toJson(value), + 'updatedAt': serializer.toJson(updatedAt), + }; + } + + i1.SessionEntityData copyWith({ + String? key, + i0.Value value = const i0.Value.absent(), + DateTime? updatedAt, + }) => i1.SessionEntityData( + key: key ?? this.key, + value: value.present ? value.value : this.value, + updatedAt: updatedAt ?? this.updatedAt, + ); + SessionEntityData copyWithCompanion(i1.SessionEntityCompanion data) { + return SessionEntityData( + key: data.key.present ? data.key.value : this.key, + value: data.value.present ? data.value.value : this.value, + updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, + ); + } + + @override + String toString() { + return (StringBuffer('SessionEntityData(') + ..write('key: $key, ') + ..write('value: $value, ') + ..write('updatedAt: $updatedAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(key, value, updatedAt); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is i1.SessionEntityData && + other.key == this.key && + other.value == this.value && + other.updatedAt == this.updatedAt); +} + +class SessionEntityCompanion extends i0.UpdateCompanion { + final i0.Value key; + final i0.Value value; + final i0.Value updatedAt; + const SessionEntityCompanion({ + this.key = const i0.Value.absent(), + this.value = const i0.Value.absent(), + this.updatedAt = const i0.Value.absent(), + }); + SessionEntityCompanion.insert({ + required String key, + this.value = const i0.Value.absent(), + this.updatedAt = const i0.Value.absent(), + }) : key = i0.Value(key); + static i0.Insertable custom({ + i0.Expression? key, + i0.Expression? value, + i0.Expression? updatedAt, + }) { + return i0.RawValuesInsertable({ + if (key != null) 'key': key, + if (value != null) 'value': value, + if (updatedAt != null) 'updated_at': updatedAt, + }); + } + + i1.SessionEntityCompanion copyWith({ + i0.Value? key, + i0.Value? value, + i0.Value? updatedAt, + }) { + return i1.SessionEntityCompanion( + key: key ?? this.key, + value: value ?? this.value, + updatedAt: updatedAt ?? this.updatedAt, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (key.present) { + map['key'] = i0.Variable(key.value); + } + if (value.present) { + map['value'] = i0.Variable(value.value); + } + if (updatedAt.present) { + map['updated_at'] = i0.Variable(updatedAt.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('SessionEntityCompanion(') + ..write('key: $key, ') + ..write('value: $value, ') + ..write('updatedAt: $updatedAt') + ..write(')')) + .toString(); + } +} diff --git a/mobile/lib/infrastructure/repositories/cached_key_value_repository.dart b/mobile/lib/infrastructure/repositories/cached_key_value_repository.dart index afeb31fa27..ed50a9dfd8 100644 --- a/mobile/lib/infrastructure/repositories/cached_key_value_repository.dart +++ b/mobile/lib/infrastructure/repositories/cached_key_value_repository.dart @@ -21,6 +21,7 @@ abstract class CachedKeyValueRepository { Future refresh() async => _snapshot = _build(await selectable().get()); + @protected Stream watchSnapshot() => selectable().watch().map((rows) => _snapshot = _build(rows)); S _build(List<({String key, String? value})> rows) => buildSnapshot( diff --git a/mobile/lib/infrastructure/repositories/db.repository.dart b/mobile/lib/infrastructure/repositories/db.repository.dart index 69e45685de..b54237597e 100644 --- a/mobile/lib/infrastructure/repositories/db.repository.dart +++ b/mobile/lib/infrastructure/repositories/db.repository.dart @@ -25,6 +25,7 @@ import 'package:immich_mobile/infrastructure/entities/remote_album_user.entity.d import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.dart'; import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.drift.dart'; import 'package:immich_mobile/infrastructure/entities/remote_asset_cloud_id.entity.dart'; +import 'package:immich_mobile/infrastructure/entities/session.entity.dart'; import 'package:immich_mobile/infrastructure/entities/settings.entity.dart'; import 'package:immich_mobile/infrastructure/entities/stack.entity.dart'; import 'package:immich_mobile/infrastructure/entities/store.entity.dart'; @@ -67,6 +68,7 @@ import 'package:sqlite_async/sqlite_async.dart'; AssetEditEntity, SettingsEntity, AssetOcrEntity, + SessionEntity, ], include: {'package:immich_mobile/infrastructure/entities/merged_asset.drift'}, ) @@ -272,55 +274,52 @@ class Drift extends $Drift { v23.trashedLocalAssetEntity.durationMs, ); - await localAssetEntity.update().write( - LocalAssetEntityCompanion.custom(durationMs: v23.localAssetEntity.durationMs * const Constant(1000)), - ); - await remoteAssetEntity.update().write( - RemoteAssetEntityCompanion.custom( - durationMs: v23.remoteAssetEntity.durationMs * const Constant(1000), - ), - ); - await trashedLocalAssetEntity.update().write( - TrashedLocalAssetEntityCompanion.custom( - durationMs: v23.trashedLocalAssetEntity.durationMs * const Constant(1000), - ), - ); - }, - from23To24: (m, v24) async { - await customStatement('DROP INDEX IF EXISTS idx_remote_album_owner_id'); - await m.alterTable(TableMigration(v24.remoteAlbumEntity)); - }, - from24To25: (m, v25) async { - await m.createTable(v25.metadata); - await customStatement('DROP INDEX IF EXISTS idx_remote_asset_owner_checksum'); - await customStatement('DROP INDEX IF EXISTS idx_remote_asset_local_date_time_day'); - await customStatement('DROP INDEX IF EXISTS idx_remote_asset_local_date_time_month'); - await m.createIndex(v25.idxRemoteAssetOwnerVisibilityDeletedCreated); - await m.createIndex(v25.idxRemoteExifCity); - await m.createIndex(v25.idxAssetFaceVisiblePerson); - }, - from25To26: (m, v26) async { - await m.addColumn(v26.remoteAssetEntity, v26.remoteAssetEntity.uploadedAt); - }, - from26To27: (m, v27) async { - await customStatement('ALTER TABLE metadata RENAME TO settings'); - }, - from27To28: (m, v28) async { - await m.createIndex(v28.idxLocalAssetCreatedAt); - }, - from28To29: (m, v29) async { - await m.createTable(v29.assetOcrEntity); - await m.createIndex(v29.idxAssetOcrAssetId); - }, - from29To30: (m, v30) async { - await m.alterTable(TableMigration(v30.settings)); - }, - from30To31: (m, v31) async { - await m.createIndex(v31.idxRemoteAssetUploaded); - }, - ), - ), - ); + await localAssetEntity.update().write( + LocalAssetEntityCompanion.custom(durationMs: v23.localAssetEntity.durationMs * const Constant(1000)), + ); + await remoteAssetEntity.update().write( + RemoteAssetEntityCompanion.custom(durationMs: v23.remoteAssetEntity.durationMs * const Constant(1000)), + ); + await trashedLocalAssetEntity.update().write( + TrashedLocalAssetEntityCompanion.custom( + durationMs: v23.trashedLocalAssetEntity.durationMs * const Constant(1000), + ), + ); + }, + from23To24: (m, v24) async { + await customStatement('DROP INDEX IF EXISTS idx_remote_album_owner_id'); + await m.alterTable(TableMigration(v24.remoteAlbumEntity)); + }, + from24To25: (m, v25) async { + await m.createTable(v25.metadata); + await customStatement('DROP INDEX IF EXISTS idx_remote_asset_owner_checksum'); + await customStatement('DROP INDEX IF EXISTS idx_remote_asset_local_date_time_day'); + await customStatement('DROP INDEX IF EXISTS idx_remote_asset_local_date_time_month'); + await m.createIndex(v25.idxRemoteAssetOwnerVisibilityDeletedCreated); + await m.createIndex(v25.idxRemoteExifCity); + await m.createIndex(v25.idxAssetFaceVisiblePerson); + }, + from25To26: (m, v26) async { + await m.addColumn(v26.remoteAssetEntity, v26.remoteAssetEntity.uploadedAt); + }, + from26To27: (m, v27) async { + await customStatement('ALTER TABLE metadata RENAME TO settings'); + }, + from27To28: (m, v28) async { + await m.createIndex(v28.idxLocalAssetCreatedAt); + }, + from28To29: (m, v29) async { + await m.createTable(v29.assetOcrEntity); + await m.createIndex(v29.idxAssetOcrAssetId); + }, + from29To30: (m, v30) async { + await m.alterTable(TableMigration(v30.settings)); + }, + from30To31: (m, v31) async { + await m.createTable(v31.session); + }, + ), + ); if (kDebugMode) { // Fail if the migration broke foreign keys diff --git a/mobile/lib/infrastructure/repositories/session.repository.dart b/mobile/lib/infrastructure/repositories/session.repository.dart new file mode 100644 index 0000000000..44653d12f5 --- /dev/null +++ b/mobile/lib/infrastructure/repositories/session.repository.dart @@ -0,0 +1,82 @@ +import 'package:drift/drift.dart'; +import 'package:flutter/material.dart'; +import 'package:immich_mobile/domain/models/session.model.dart'; +import 'package:immich_mobile/infrastructure/entities/session.entity.drift.dart'; +import 'package:immich_mobile/infrastructure/repositories/cached_key_value_repository.dart'; +import 'package:immich_mobile/infrastructure/repositories/db.repository.dart'; + +class SessionRepository extends CachedKeyValueRepository { + final Drift _db; + + SessionRepository._(this._db) : super(const .new()); + + static SessionRepository? _instance; + + static SessionRepository get instance { + final instance = _instance; + if (instance == null) { + throw StateError('SessionRepository not initialized. Call ensureInitialized() first'); + } + return instance; + } + + static Future ensureInitialized(Drift db) async { + if (_instance == null) { + final instance = SessionRepository._(db); + await instance.refresh(); + _instance = instance; + } + return _instance!; + } + + @override + List get keys => SessionKey.values; + + @override + Object decodeValue(SessionKey key, String raw) => key.decode(raw); + + @override + Session buildSnapshot(Map overrides) => Session.fromEntries(overrides); + + @override + @protected + Selectable<({String key, String? value})> selectable() => + _db.select(_db.sessionEntity).map((row) => (key: row.key, value: row.value)); + + Session get session => snapshot; + + Future clear(Iterable keys) async { + if (keys.isEmpty) { + return; + } + + final names = keys.map((key) => key.name).toList(); + await (_db.delete(_db.sessionEntity)..where((row) => row.key.isIn(names))).go(); + + var session = snapshot; + for (final key in keys) { + session = session.write(key, defaultSession.read(key)); + } + snapshot = session; + } + + Future write(SessionKey key, U value) async { + if (value == snapshot.read(key)) { + return; + } + + String? resolvedValue; + if (value != null) { + resolvedValue = key.encode(value); + } + + await _db + .into(_db.sessionEntity) + .insertOnConflictUpdate( + SessionEntityCompanion.insert(key: key.name, value: .new(resolvedValue), updatedAt: .new(DateTime.now())), + ); + snapshot = snapshot.write(key, value); + } + + Stream watch() => watchSnapshot(); +} diff --git a/mobile/lib/infrastructure/repositories/settings.repository.dart b/mobile/lib/infrastructure/repositories/settings.repository.dart index 7063779336..de01e36768 100644 --- a/mobile/lib/infrastructure/repositories/settings.repository.dart +++ b/mobile/lib/infrastructure/repositories/settings.repository.dart @@ -1,4 +1,5 @@ import 'package:drift/drift.dart'; +import 'package:flutter/material.dart'; import 'package:immich_mobile/domain/models/config/app_config.dart'; import 'package:immich_mobile/domain/models/settings_key.dart'; import 'package:immich_mobile/infrastructure/entities/settings.entity.drift.dart'; @@ -39,6 +40,7 @@ class SettingsRepository extends CachedKeyValueRepository overrides) => AppConfig.fromEntries(overrides); @override + @protected Selectable<({String key, String? value})> selectable() => _db.select(_db.settingsEntity).map((row) => (key: row.key, value: row.value)); @@ -81,5 +83,5 @@ class SettingsRepository extends CachedKeyValueRepository watchConfig() => watchSnapshot(); + Stream watch() => watchSnapshot(); } diff --git a/mobile/lib/pages/common/splash_screen.page.dart b/mobile/lib/pages/common/splash_screen.page.dart index 0d423875cb..36458b4869 100644 --- a/mobile/lib/pages/common/splash_screen.page.dart +++ b/mobile/lib/pages/common/splash_screen.page.dart @@ -16,6 +16,7 @@ import 'package:immich_mobile/infrastructure/repositories/settings.repository.da import 'package:immich_mobile/providers/auth.provider.dart'; import 'package:immich_mobile/providers/background_sync.provider.dart'; import 'package:immich_mobile/providers/backup/drift_backup.provider.dart'; +import 'package:immich_mobile/providers/infrastructure/session.provider.dart'; import 'package:immich_mobile/providers/server_info.provider.dart'; import 'package:immich_mobile/providers/view_intent/view_intent_handler.provider.dart'; import 'package:immich_mobile/providers/websocket.provider.dart'; @@ -298,9 +299,10 @@ class SplashScreenPageState extends ConsumerState { } void resumeSession() async { - final serverUrl = Store.tryGet(StoreKey.serverUrl); - final endpoint = Store.tryGet(StoreKey.serverEndpoint); - final accessToken = Store.tryGet(StoreKey.accessToken); + final session = ref.read(sessionProvider); + final serverUrl = session.serverUrl; + final endpoint = session.serverEndpoint; + final accessToken = session.accessToken; if (accessToken != null && serverUrl != null && endpoint != null) { final infoProvider = ref.read(serverInfoProvider.notifier); diff --git a/mobile/lib/presentation/widgets/action_buttons/open_in_browser_action_button.widget.dart b/mobile/lib/presentation/widgets/action_buttons/open_in_browser_action_button.widget.dart index 541a9f8093..60e7e15673 100644 --- a/mobile/lib/presentation/widgets/action_buttons/open_in_browser_action_button.widget.dart +++ b/mobile/lib/presentation/widgets/action_buttons/open_in_browser_action_button.widget.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:immich_mobile/domain/models/store.model.dart'; import 'package:immich_mobile/domain/services/timeline.service.dart'; -import 'package:immich_mobile/entities/store.entity.dart'; import 'package:immich_mobile/extensions/translate_extensions.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; import 'package:immich_mobile/presentation/widgets/action_buttons/base_action_button.widget.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -22,7 +21,7 @@ class OpenInBrowserActionButton extends ConsumerWidget { }); void _onTap() async { - final serverEndpoint = Store.get(StoreKey.serverEndpoint).replaceFirst('/api', ''); + final serverEndpoint = SessionRepository.instance.session.serverEndpoint!.replaceFirst('/api', ''); String originPath = ''; switch (origin) { diff --git a/mobile/lib/presentation/widgets/asset_viewer/video_viewer.widget.dart b/mobile/lib/presentation/widgets/asset_viewer/video_viewer.widget.dart index ccbaf7660a..f40fa9601f 100644 --- a/mobile/lib/presentation/widgets/asset_viewer/video_viewer.widget.dart +++ b/mobile/lib/presentation/widgets/asset_viewer/video_viewer.widget.dart @@ -4,8 +4,6 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:immich_mobile/domain/models/asset/base_asset.model.dart'; -import 'package:immich_mobile/domain/models/store.model.dart'; -import 'package:immich_mobile/entities/store.entity.dart'; import 'package:immich_mobile/extensions/platform_extensions.dart'; import 'package:immich_mobile/infrastructure/repositories/storage.repository.dart'; import 'package:immich_mobile/providers/asset_viewer/asset_viewer.provider.dart'; @@ -13,6 +11,7 @@ import 'package:immich_mobile/providers/asset_viewer/is_motion_video_playing.pro import 'package:immich_mobile/providers/asset_viewer/video_player_provider.dart'; import 'package:immich_mobile/providers/cast.provider.dart'; import 'package:immich_mobile/providers/infrastructure/asset.provider.dart'; +import 'package:immich_mobile/providers/infrastructure/session.provider.dart'; import 'package:immich_mobile/providers/infrastructure/settings.provider.dart'; import 'package:immich_mobile/services/api.service.dart'; import 'package:logging/logging.dart'; @@ -148,7 +147,7 @@ class _NativeVideoViewerState extends ConsumerState with Widg final remoteAsset = videoAsset as RemoteAsset; - final serverEndpoint = Store.get(StoreKey.serverEndpoint); + final serverEndpoint = ref.read(sessionProvider).serverEndpoint!; final isOriginalVideo = ref.read(appConfigProvider).viewer.loadOriginalVideo; final String postfixUrl = isOriginalVideo ? 'original' : 'video/playback'; final String assetId = remoteAsset.livePhotoVideoId ?? remoteAsset.id; diff --git a/mobile/lib/presentation/widgets/people/partner_user_avatar.widget.dart b/mobile/lib/presentation/widgets/people/partner_user_avatar.widget.dart index 8618d78362..a07585a4b1 100644 --- a/mobile/lib/presentation/widgets/people/partner_user_avatar.widget.dart +++ b/mobile/lib/presentation/widgets/people/partner_user_avatar.widget.dart @@ -1,18 +1,18 @@ import 'package:flutter/material.dart'; -import 'package:immich_mobile/domain/models/store.model.dart'; -import 'package:immich_mobile/entities/store.entity.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:immich_mobile/extensions/build_context_extensions.dart'; import 'package:immich_mobile/presentation/widgets/images/remote_image_provider.dart'; +import 'package:immich_mobile/providers/infrastructure/session.provider.dart'; -class PartnerUserAvatar extends StatelessWidget { +class PartnerUserAvatar extends ConsumerWidget { const PartnerUserAvatar({super.key, required this.userId, required this.name}); final String userId; final String name; @override - Widget build(BuildContext context) { - final url = "${Store.get(StoreKey.serverEndpoint)}/users/$userId/profile-image"; + Widget build(BuildContext context, WidgetRef ref) { + final url = "${ref.read(sessionProvider).serverEndpoint}/users/$userId/profile-image"; final nameFirstLetter = name.isNotEmpty ? name[0] : ""; return CircleAvatar( radius: 16, diff --git a/mobile/lib/providers/auth.provider.dart b/mobile/lib/providers/auth.provider.dart index 23ccea8025..56dc4d2461 100644 --- a/mobile/lib/providers/auth.provider.dart +++ b/mobile/lib/providers/auth.provider.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:flutter_udid/flutter_udid.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:immich_mobile/constants/constants.dart'; +import 'package:immich_mobile/domain/models/session.model.dart'; import 'package:immich_mobile/domain/models/store.model.dart'; import 'package:immich_mobile/domain/models/user.model.dart'; import 'package:immich_mobile/domain/services/user.service.dart'; @@ -10,6 +11,7 @@ import 'package:immich_mobile/entities/store.entity.dart'; import 'package:immich_mobile/models/auth/auth_state.model.dart'; import 'package:immich_mobile/models/auth/login_response.model.dart'; import 'package:immich_mobile/providers/api.provider.dart'; +import 'package:immich_mobile/providers/infrastructure/session.provider.dart'; import 'package:immich_mobile/providers/infrastructure/settings.provider.dart'; import 'package:immich_mobile/providers/infrastructure/user.provider.dart'; import 'package:immich_mobile/services/api.service.dart'; @@ -125,10 +127,10 @@ class AuthNotifier extends StateNotifier { } Future saveAuthInfo({required String accessToken}) async { - await Store.put(StoreKey.accessToken, accessToken); + await _ref.read(sessionRepository).write(SessionKey.accessToken, accessToken); await _apiService.updateHeaders(); - final serverEndpoint = Store.get(StoreKey.serverEndpoint); + final serverEndpoint = _ref.read(sessionProvider).serverEndpoint!; final headerMap = _ref.read(appConfigProvider).network.customHeaders; final customHeaders = headerMap.isEmpty ? null : jsonEncode(headerMap); await _widgetService.writeCredentials(serverEndpoint, accessToken, customHeaders); @@ -194,9 +196,9 @@ class AuthNotifier extends StateNotifier { return _ref.read(appConfigProvider).network.localEndpoint; } - /// Returns the current server endpoint (with /api) URL from the store + /// Returns the current server endpoint (with /api) URL from the session String? getServerEndpoint() { - return Store.tryGet(StoreKey.serverEndpoint); + return _ref.read(sessionProvider).serverEndpoint; } Future setOpenApiServiceEndpoint() { diff --git a/mobile/lib/providers/infrastructure/session.provider.dart b/mobile/lib/providers/infrastructure/session.provider.dart new file mode 100644 index 0000000000..9b3feb7b07 --- /dev/null +++ b/mobile/lib/providers/infrastructure/session.provider.dart @@ -0,0 +1,12 @@ +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:immich_mobile/domain/models/session.model.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; + +final sessionRepository = Provider.autoDispose((_) => SessionRepository.instance); + +final sessionProvider = Provider.autoDispose((ref) { + final repo = ref.watch(sessionRepository); + final subscription = repo.watch().listen((event) => ref.state = event); + ref.onDispose(subscription.cancel); + return repo.session; +}); diff --git a/mobile/lib/providers/infrastructure/settings.provider.dart b/mobile/lib/providers/infrastructure/settings.provider.dart index d2b9dce1d6..8c67a68340 100644 --- a/mobile/lib/providers/infrastructure/settings.provider.dart +++ b/mobile/lib/providers/infrastructure/settings.provider.dart @@ -6,7 +6,7 @@ final settingsProvider = Provider.autoDispose((_) => Setting final appConfigProvider = Provider.autoDispose((ref) { final repo = ref.watch(settingsProvider); - final subscription = repo.watchConfig().listen((event) => ref.state = event); + final subscription = repo.watch().listen((event) => ref.state = event); ref.onDispose(subscription.cancel); return repo.appConfig; }); diff --git a/mobile/lib/providers/websocket.provider.dart b/mobile/lib/providers/websocket.provider.dart index 8d9bd5bfe3..30ea805d82 100644 --- a/mobile/lib/providers/websocket.provider.dart +++ b/mobile/lib/providers/websocket.provider.dart @@ -1,12 +1,11 @@ import 'dart:async'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:immich_mobile/domain/models/store.model.dart'; -import 'package:immich_mobile/entities/store.entity.dart'; import 'package:immich_mobile/infrastructure/repositories/network.repository.dart'; import 'package:immich_mobile/models/server_info/server_version.model.dart'; import 'package:immich_mobile/providers/auth.provider.dart'; import 'package:immich_mobile/providers/background_sync.provider.dart'; +import 'package:immich_mobile/providers/infrastructure/session.provider.dart'; import 'package:immich_mobile/providers/infrastructure/settings.provider.dart'; import 'package:immich_mobile/providers/server_info.provider.dart'; import 'package:immich_mobile/utils/debounce.dart'; @@ -68,7 +67,7 @@ class WebsocketNotifier extends StateNotifier { if (authenticationState.isAuthenticated) { try { - final endpoint = Uri.parse(Store.get(StoreKey.serverEndpoint)); + final endpoint = Uri.parse(_ref.read(sessionProvider).serverEndpoint!); dPrint(() => "Attempting to connect to websocket"); // Configure socket transports must be specified Socket socket = io( diff --git a/mobile/lib/repositories/upload.repository.dart b/mobile/lib/repositories/upload.repository.dart index 68522490d8..93dfe6f32e 100644 --- a/mobile/lib/repositories/upload.repository.dart +++ b/mobile/lib/repositories/upload.repository.dart @@ -5,9 +5,8 @@ import 'dart:io'; import 'package:background_downloader/background_downloader.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:immich_mobile/constants/constants.dart'; -import 'package:immich_mobile/domain/models/store.model.dart'; -import 'package:immich_mobile/entities/store.entity.dart'; import 'package:immich_mobile/infrastructure/repositories/network.repository.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; import 'package:logging/logging.dart'; import 'package:http/http.dart'; import 'package:immich_mobile/utils/debug_print.dart'; @@ -96,7 +95,7 @@ class UploadRepository { void Function(int bytes, int totalBytes)? onProgress, required String logContext, }) async { - final String savedEndpoint = Store.get(StoreKey.serverEndpoint); + final String savedEndpoint = SessionRepository.instance.session.serverEndpoint!; final baseRequest = ProgressMultipartRequest( 'POST', Uri.parse('$savedEndpoint/assets'), diff --git a/mobile/lib/routing/auth_guard.dart b/mobile/lib/routing/auth_guard.dart index 2fc27be4f4..59e4f0c6a7 100644 --- a/mobile/lib/routing/auth_guard.dart +++ b/mobile/lib/routing/auth_guard.dart @@ -2,9 +2,7 @@ import 'dart:async'; import 'dart:io'; import 'package:auto_route/auto_route.dart'; -import 'package:immich_mobile/domain/models/store.model.dart'; -import 'package:immich_mobile/domain/services/store.service.dart'; -import 'package:immich_mobile/entities/store.entity.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; import 'package:immich_mobile/routing/router.dart'; import 'package:immich_mobile/services/api.service.dart'; import 'package:immich_mobile/services/auth.service.dart'; @@ -23,10 +21,8 @@ class AuthGuard extends AutoRouteGuard { // guards, so we keep this function fully sync and validate the token in // the background — otherwise a slow validateAccessToken() request would // block the route transition for as long as the OS-level HTTP timeout. - try { - Store.get(StoreKey.accessToken); - } on StoreKeyNotFoundException catch (_) { - _log.warning('No access token in the store.'); + if (SessionRepository.instance.session.accessToken == null) { + _log.warning('No access token in the session.'); resolver.next(false); unawaited(router.replaceAll([const LoginRoute()])); return; @@ -40,7 +36,7 @@ class AuthGuard extends AutoRouteGuard { if (_validateInFlight) { return; } - final token = Store.tryGet(StoreKey.accessToken); + final token = SessionRepository.instance.session.accessToken; if (token == null) { return; } @@ -50,7 +46,7 @@ class AuthGuard extends AutoRouteGuard { if (res == null || res.authStatus != true) { // Token may have changed during validation (user logged out + logged in // again); only act if it still applies to the current session. - if (Store.tryGet(StoreKey.accessToken) != token) { + if (SessionRepository.instance.session.accessToken != token) { return; } _log.fine('User token is invalid. Redirecting to login'); @@ -61,7 +57,7 @@ class AuthGuard extends AutoRouteGuard { if (e.code != HttpStatus.unauthorized) { return; } - if (Store.tryGet(StoreKey.accessToken) != token) { + if (SessionRepository.instance.session.accessToken != token) { return; } _log.warning("Unauthorized access token."); diff --git a/mobile/lib/services/api.service.dart b/mobile/lib/services/api.service.dart index 59ef935f2f..cd2b485e3e 100644 --- a/mobile/lib/services/api.service.dart +++ b/mobile/lib/services/api.service.dart @@ -3,9 +3,9 @@ import 'dart:convert'; import 'dart:io'; import 'package:device_info_plus/device_info_plus.dart'; -import 'package:immich_mobile/domain/models/store.model.dart'; -import 'package:immich_mobile/entities/store.entity.dart'; +import 'package:immich_mobile/domain/models/session.model.dart'; import 'package:immich_mobile/infrastructure/repositories/network.repository.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/settings.repository.dart'; import 'package:immich_mobile/utils/debug_print.dart'; import 'package:immich_mobile/utils/url_helper.dart'; @@ -41,7 +41,7 @@ class ApiService { // The below line ensures that the api clients are initialized when the service is instantiated // This is required to avoid late initialization errors when the clients are access before the endpoint is resolved setEndpoint(''); - final endpoint = Store.tryGet(StoreKey.serverEndpoint); + final endpoint = SessionRepository.instance.session.serverEndpoint; if (endpoint != null && endpoint.isNotEmpty) { setEndpoint(endpoint); } @@ -84,7 +84,7 @@ class ApiService { setEndpoint(endpoint); // Save in local database for next startup - await Store.put(StoreKey.serverEndpoint, endpoint); + await SessionRepository.instance.write(SessionKey.serverEndpoint, endpoint); return endpoint; } @@ -173,7 +173,7 @@ class ApiService { static List getServerUrls() { final urls = []; - final serverEndpoint = Store.tryGet(StoreKey.serverEndpoint); + final serverEndpoint = SessionRepository.instance.session.serverEndpoint; if (serverEndpoint != null && serverEndpoint.isNotEmpty) { urls.add(serverEndpoint); } diff --git a/mobile/lib/services/auth.service.dart b/mobile/lib/services/auth.service.dart index 0de22fd124..218ea7199a 100644 --- a/mobile/lib/services/auth.service.dart +++ b/mobile/lib/services/auth.service.dart @@ -1,12 +1,14 @@ import 'dart:async'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:immich_mobile/domain/models/session.model.dart'; import 'package:immich_mobile/domain/models/settings_key.dart'; import 'package:immich_mobile/domain/models/store.model.dart'; import 'package:immich_mobile/domain/utils/background_sync.dart'; import 'package:immich_mobile/entities/store.entity.dart'; -import 'package:immich_mobile/infrastructure/repositories/settings.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/network.repository.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; +import 'package:immich_mobile/infrastructure/repositories/settings.repository.dart'; import 'package:immich_mobile/models/auth/auxilary_endpoint.model.dart'; import 'package:immich_mobile/models/auth/login_response.model.dart'; import 'package:immich_mobile/providers/api.provider.dart'; @@ -55,7 +57,7 @@ class AuthService { Future validateServerUrl(String url) async { final validUrl = await _apiService.resolveAndSetEndpoint(url); await _apiService.setDeviceInfoHeader(); - await Store.put(StoreKey.serverUrl, validUrl); + await SessionRepository.instance.write(SessionKey.serverUrl, validUrl); return validUrl; } @@ -119,7 +121,7 @@ class AuthService { await Future.wait([ _authRepository.clearLocalData(), Store.delete(StoreKey.currentUser), - Store.delete(StoreKey.accessToken), + SessionRepository.instance.clear([SessionKey.accessToken]), SettingsRepository.instance.clear(const [ .networkAutoEndpointSwitching, .networkPreferredWifiName, diff --git a/mobile/lib/services/background_upload.service.dart b/mobile/lib/services/background_upload.service.dart index fa0a41f17c..b59c692ace 100644 --- a/mobile/lib/services/background_upload.service.dart +++ b/mobile/lib/services/background_upload.service.dart @@ -13,6 +13,7 @@ import 'package:immich_mobile/entities/store.entity.dart'; import 'package:immich_mobile/extensions/platform_extensions.dart'; import 'package:immich_mobile/infrastructure/repositories/backup.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/local_asset.repository.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/settings.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/storage.repository.dart'; import 'package:immich_mobile/providers/infrastructure/asset.provider.dart'; @@ -389,7 +390,7 @@ class BackgroundUploadService { String? latitude, String? longitude, }) async { - final serverEndpoint = Store.get(StoreKey.serverEndpoint); + final serverEndpoint = SessionRepository.instance.session.serverEndpoint!; final url = Uri.parse('$serverEndpoint/assets').toString(); final headers = ApiService.getRequestHeaders(); final deviceId = Store.get(StoreKey.deviceId); diff --git a/mobile/lib/utils/bootstrap.dart b/mobile/lib/utils/bootstrap.dart index 37ad748a57..cfdd709026 100644 --- a/mobile/lib/utils/bootstrap.dart +++ b/mobile/lib/utils/bootstrap.dart @@ -6,6 +6,8 @@ import 'package:immich_mobile/extensions/translate_extensions.dart'; import 'package:immich_mobile/infrastructure/repositories/db.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/log.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/logger_db.repository.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; +import 'package:immich_mobile/infrastructure/repositories/settings.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/network.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/settings.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/store.repository.dart'; @@ -53,6 +55,8 @@ abstract final class Bootstrap { await StoreService.init(storeRepository: storeRepo, listenUpdates: listenStoreUpdates); + await SessionRepository.ensureInitialized(drift); + final settingsRepo = await SettingsRepository.ensureInitialized(drift); final logDb = await _initLogger(settingsRepository: settingsRepo, shouldBufferLogs: shouldBufferLogs); diff --git a/mobile/lib/utils/image_url_builder.dart b/mobile/lib/utils/image_url_builder.dart index 4635e5ec20..9ead566524 100644 --- a/mobile/lib/utils/image_url_builder.dart +++ b/mobile/lib/utils/image_url_builder.dart @@ -1,9 +1,8 @@ -import 'package:immich_mobile/domain/models/store.model.dart'; -import 'package:immich_mobile/entities/store.entity.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; import 'package:openapi/api.dart'; String getOriginalUrlForRemoteId(final String id, {bool edited = true}) { - return '${Store.get(StoreKey.serverEndpoint)}/assets/$id/original?edited=$edited'; + return '${SessionRepository.instance.session.serverEndpoint!}/assets/$id/original?edited=$edited'; } String getThumbnailUrlForRemoteId( @@ -12,14 +11,15 @@ String getThumbnailUrlForRemoteId( bool edited = true, String? thumbhash, }) { - final url = '${Store.get(StoreKey.serverEndpoint)}/assets/$id/thumbnail?size=${type.toString()}&edited=$edited'; + final url = + '${SessionRepository.instance.session.serverEndpoint!}/assets/$id/thumbnail?size=${type.value}&edited=$edited'; return thumbhash != null ? '$url&c=${Uri.encodeComponent(thumbhash)}' : url; } String getPlaybackUrlForRemoteId(final String id) { - return '${Store.get(StoreKey.serverEndpoint)}/assets/$id/video/playback?'; + return '${SessionRepository.instance.session.serverEndpoint!}/assets/$id/video/playback?'; } String getFaceThumbnailUrl(final String personId) { - return '${Store.get(StoreKey.serverEndpoint)}/people/$personId/thumbnail'; + return '${SessionRepository.instance.session.serverEndpoint!}/people/$personId/thumbnail'; } diff --git a/mobile/lib/utils/migration.dart b/mobile/lib/utils/migration.dart index 56fccf4610..e60d9e9e42 100644 --- a/mobile/lib/utils/migration.dart +++ b/mobile/lib/utils/migration.dart @@ -8,19 +8,21 @@ import 'package:immich_mobile/constants/colors.dart'; import 'package:immich_mobile/constants/enums.dart'; import 'package:immich_mobile/domain/models/config/app_config.dart'; import 'package:immich_mobile/domain/models/log.model.dart'; +import 'package:immich_mobile/domain/models/session.model.dart'; import 'package:immich_mobile/domain/models/settings_key.dart'; import 'package:immich_mobile/domain/models/store.model.dart'; import 'package:immich_mobile/domain/models/timeline.model.dart'; import 'package:immich_mobile/domain/services/feature_message.service.dart'; import 'package:immich_mobile/entities/store.entity.dart'; +import 'package:immich_mobile/infrastructure/entities/session.entity.drift.dart'; import 'package:immich_mobile/infrastructure/entities/settings.entity.drift.dart'; import 'package:immich_mobile/infrastructure/repositories/db.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/network.repository.dart'; -import 'package:immich_mobile/infrastructure/repositories/settings.repository.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; import 'package:immich_mobile/models/auth/auxilary_endpoint.model.dart'; import 'package:immich_mobile/providers/album/album_sort_by_options.provider.dart'; -const int targetVersion = 26; +const int targetVersion = 27; Future migrateDatabaseIfNeeded(Drift drift) async { final int? storedVersion = Store.tryGet(StoreKey.version); @@ -36,6 +38,9 @@ Future migrateDatabaseIfNeeded(Drift drift) async { if (storedVersion == null) { await FeatureMessageService(SettingsRepository.instance).markSeen(); +} + if (version < 27) { + await _migrateTo27(drift); } await Store.put(StoreKey.version, targetVersion); @@ -43,13 +48,13 @@ Future migrateDatabaseIfNeeded(Drift drift) async { } Future _migrateTo25() async { - final accessToken = Store.tryGet(StoreKey.accessToken); + final accessToken = Store.tryGet(StoreKey.legacyAccessToken); if (accessToken == null || accessToken.isEmpty) { return; } final urls = []; - final serverEndpoint = Store.tryGet(StoreKey.serverEndpoint); + final serverEndpoint = Store.tryGet(StoreKey.legacyServerEndpoint); if (serverEndpoint != null && serverEndpoint.isNotEmpty) { urls.add(serverEndpoint); } @@ -80,7 +85,7 @@ Future _migrateTo25() async { } Future _migrateTo26(Drift drift) async { - final migrator = _StoreMigrator(drift); + final migrator = _StoreMigrator.settings(drift); await migrator.migrateEnumIndex(StoreKey.legacyLogLevel, SettingsKey.logLevel, LogLevel.values); // Theme await migrator.migrateEnumName(StoreKey.legacyThemeMode, SettingsKey.themeMode, ThemeMode.values); @@ -145,7 +150,17 @@ Future _migrateTo26(Drift drift) async { await migrator.complete(); } -Future _migrateAlbumSortMode(_StoreMigrator migrator) async { +Future _migrateTo27(Drift drift) async { + final migrator = _StoreMigrator.session(drift); + await migrator.migrateString(StoreKey.legacyServerUrl, SessionKey.serverUrl); + await migrator.migrateString(StoreKey.legacyAccessToken, SessionKey.accessToken); + await migrator.migrateString(StoreKey.legacyServerEndpoint, SessionKey.serverEndpoint); + await migrator.complete(); + + await SessionRepository.instance.refresh(); +} + +Future _migrateAlbumSortMode(_StoreMigrator migrator) async { final raw = await migrator.readLegacyStoreInt(StoreKey.legacySelectedAlbumSortOrder.id); final mode = AlbumSortMode.values.firstWhereOrNull((e) => raw != null && e.storeIndex == raw); if (mode == null) { @@ -155,7 +170,7 @@ Future _migrateAlbumSortMode(_StoreMigrator migrator) async { migrator.stage(StoreKey.legacySelectedAlbumSortOrder, SettingsKey.albumSortMode, mode); } -Future _migrateExternalEndpointList(_StoreMigrator migrator) async { +Future _migrateExternalEndpointList(_StoreMigrator migrator) async { final raw = await migrator.readLegacyStoreString(StoreKey.legacyExternalEndpointList.id); if (raw == null) { return; @@ -179,7 +194,7 @@ Future _migrateExternalEndpointList(_StoreMigrator migrator) async { migrator.stage(StoreKey.legacyExternalEndpointList, SettingsKey.networkExternalEndpointList, urls); } -Future _migrateCustomHeaders(_StoreMigrator migrator) async { +Future _migrateCustomHeaders(_StoreMigrator migrator) async { final raw = await migrator.readLegacyStoreString(StoreKey.legacyCustomHeaders.id); if (raw == null) { return; @@ -202,14 +217,39 @@ Future _migrateCustomHeaders(_StoreMigrator migrator) async { migrator.stage(StoreKey.legacyCustomHeaders, SettingsKey.networkCustomHeaders, headers); } -class _StoreMigrator { +class _StoreMigrator { + _StoreMigrator._(this._db, {required this.encode, required this.readDefault, required this.insertRow}); + + static _StoreMigrator settings(Drift db) => _StoreMigrator._( + db, + encode: (key, value) => key.encode(value), + readDefault: (key) => defaultConfig.read(key), + insertRow: (batch, name, value) => batch.insert( + db.settingsEntity, + SettingsEntityCompanion(key: Value(name), value: Value(value)), + mode: InsertMode.insertOrReplace, + ), + ); + + static _StoreMigrator session(Drift db) => _StoreMigrator._( + db, + encode: (key, value) => key.encode(value), + readDefault: (key) => defaultSession.read(key), + insertRow: (batch, name, value) => batch.insert( + db.sessionEntity, + SessionEntityCompanion(key: Value(name), value: Value(value)), + mode: InsertMode.insertOrReplace, + ), + ); + final Drift _db; - final Map _cache = {}; + final String Function(K key, Object value) encode; + final Object? Function(K key) readDefault; + final void Function(Batch batch, String name, String? value) insertRow; + final Map _cache = {}; final List _migratedStoreIds = []; - _StoreMigrator(this._db); - - Future migrateEnumIndex(StoreKey legacyKey, SettingsKey newKey, List values) async { + Future migrateEnumIndex(StoreKey legacyKey, K newKey, List values) async { final index = await readLegacyStoreInt(legacyKey.id); if (index == null) { return; @@ -224,11 +264,7 @@ class _StoreMigrator { _migratedStoreIds.add(legacyKey.id); } - Future migrateEnumName( - StoreKey legacyKey, - SettingsKey newKey, - List values, - ) async { + Future migrateEnumName(StoreKey legacyKey, K newKey, List values) async { final name = await readLegacyStoreString(legacyKey.id); if (name == null) { return; @@ -243,18 +279,17 @@ class _StoreMigrator { _migratedStoreIds.add(legacyKey.id); } - Future migrateBool(StoreKey legacyKey, SettingsKey newKey) async { + Future migrateBool(StoreKey legacyKey, K newKey) async { final intValue = await readLegacyStoreInt(legacyKey.id); if (intValue == null) { return; } - final boolValue = intValue != 0; - _cache[newKey] = boolValue; + _cache[newKey] = intValue != 0; _migratedStoreIds.add(legacyKey.id); } - Future migrateInt(StoreKey legacyKey, SettingsKey newKey) async { + Future migrateInt(StoreKey legacyKey, K newKey) async { final intValue = await readLegacyStoreInt(legacyKey.id); if (intValue == null) { return; @@ -264,9 +299,9 @@ class _StoreMigrator { _migratedStoreIds.add(legacyKey.id); } - Future migrateString(StoreKey legacyKey, SettingsKey newKey) async { + Future migrateString(StoreKey legacyKey, K newKey) async { final value = await readLegacyStoreString(legacyKey.id); - if (value == null) { + if (value == null || value.isEmpty) { return; } @@ -274,7 +309,12 @@ class _StoreMigrator { _migratedStoreIds.add(legacyKey.id); } - void stage(StoreKey legacyKey, SettingsKey newKey, U value) { + Future migrateNullableString(StoreKey legacyKey, K newKey) async { + _cache[newKey] = await readLegacyStoreString(legacyKey.id); + _migratedStoreIds.add(legacyKey.id); + } + + void stage(StoreKey legacyKey, K newKey, Object? value) { _cache[newKey] = value; _migratedStoreIds.add(legacyKey.id); } @@ -282,20 +322,12 @@ class _StoreMigrator { Future complete() async { await _db.batch((batch) { for (final entry in _cache.entries) { - if (entry.value == defaultConfig.read(entry.key)) { + if (entry.value == readDefault(entry.key)) { continue; } - String? resolvedValue; - if (entry.value != null) { - resolvedValue = entry.key.encode(entry.value); - } - - batch.insert( - _db.settingsEntity, - SettingsEntityCompanion(key: Value(entry.key.name), value: Value(resolvedValue)), - mode: InsertMode.insertOrReplace, - ); + final value = entry.value; + insertRow(batch, entry.key.name, value == null ? null : encode(entry.key, value)); } }); await deleteLegacyStoreRows(_migratedStoreIds); diff --git a/mobile/lib/utils/url_helper.dart b/mobile/lib/utils/url_helper.dart index b7dc41c4cf..4fed30b69b 100644 --- a/mobile/lib/utils/url_helper.dart +++ b/mobile/lib/utils/url_helper.dart @@ -1,5 +1,4 @@ -import 'package:immich_mobile/domain/models/store.model.dart'; -import 'package:immich_mobile/entities/store.entity.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; import 'package:punycode/punycode.dart'; String sanitizeUrl(String url) { @@ -11,7 +10,7 @@ String sanitizeUrl(String url) { } String? getServerUrl() { - final serverUrl = punycodeDecodeUrl(Store.tryGet(StoreKey.serverEndpoint)); + final serverUrl = punycodeDecodeUrl(SessionRepository.instance.session.serverEndpoint); final serverUri = serverUrl != null ? Uri.tryParse(serverUrl) : null; if (serverUri == null) { return null; diff --git a/mobile/lib/widgets/common/user_avatar.dart b/mobile/lib/widgets/common/user_avatar.dart index 911d6a9f10..6dfb2b0d04 100644 --- a/mobile/lib/widgets/common/user_avatar.dart +++ b/mobile/lib/widgets/common/user_avatar.dart @@ -1,12 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:immich_mobile/domain/models/store.model.dart'; import 'package:immich_mobile/domain/models/user.model.dart'; -import 'package:immich_mobile/entities/store.entity.dart'; import 'package:immich_mobile/extensions/build_context_extensions.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; import 'package:immich_mobile/presentation/widgets/images/remote_image_provider.dart'; Widget userAvatar(BuildContext context, UserDto u, {double? radius}) { - final url = "${Store.get(StoreKey.serverEndpoint)}/users/${u.id}/profile-image"; + final url = "${SessionRepository.instance.session.serverEndpoint!}/users/${u.id}/profile-image"; final nameFirstLetter = u.name.isNotEmpty ? u.name[0] : ""; return CircleAvatar( radius: radius, diff --git a/mobile/lib/widgets/common/user_circle_avatar.dart b/mobile/lib/widgets/common/user_circle_avatar.dart index c6e4f4719e..4e6090c15e 100644 --- a/mobile/lib/widgets/common/user_circle_avatar.dart +++ b/mobile/lib/widgets/common/user_circle_avatar.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:immich_mobile/domain/models/store.model.dart'; import 'package:immich_mobile/domain/models/user.model.dart'; -import 'package:immich_mobile/entities/store.entity.dart'; import 'package:immich_mobile/presentation/widgets/images/remote_image_provider.dart'; +import 'package:immich_mobile/providers/infrastructure/session.provider.dart'; // ignore: must_be_immutable class UserCircleAvatar extends ConsumerWidget { @@ -18,7 +17,7 @@ class UserCircleAvatar extends ConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final userAvatarColor = user.avatarColor.toColor().withValues(alpha: opacity); final profileImageUrl = - '${Store.get(StoreKey.serverEndpoint)}/users/${user.id}/profile-image?d=${user.profileChangedAt.millisecondsSinceEpoch}'; + '${ref.read(sessionProvider).serverEndpoint}/users/${user.id}/profile-image?d=${user.profileChangedAt.millisecondsSinceEpoch}'; final textColor = (user.avatarColor.toColor().computeLuminance() > 0.5 ? Colors.black : Colors.white).withValues( alpha: opacity, diff --git a/mobile/test/domain/services/store_service_test.dart b/mobile/test/domain/services/store_service_test.dart index bb439b3d72..090faed0dc 100644 --- a/mobile/test/domain/services/store_service_test.dart +++ b/mobile/test/domain/services/store_service_test.dart @@ -21,13 +21,13 @@ void main() { controller = StreamController>>.broadcast(); mockDriftStoreRepo = MockDriftStoreRepository(); // For generics, we need to provide fallback to each concrete type to avoid runtime errors - registerFallbackValue(StoreKey.accessToken); + registerFallbackValue(StoreKey.legacyAccessToken); registerFallbackValue(StoreKey.version); registerFallbackValue(StoreKey.advancedTroubleshooting); when(() => mockDriftStoreRepo.getAll()).thenAnswer( (_) async => [ - const StoreDto(StoreKey.accessToken, _kAccessToken), + const StoreDto(StoreKey.legacyAccessToken, _kAccessToken), const StoreDto(StoreKey.advancedTroubleshooting, _kAdvancedTroubleshooting), const StoreDto(StoreKey.version, _kVersion), ], @@ -45,7 +45,7 @@ void main() { group("Store Service Init:", () { test('Populates the internal cache on init', () { verify(() => mockDriftStoreRepo.getAll()).called(1); - expect(sut.tryGet(StoreKey.accessToken), _kAccessToken); + expect(sut.tryGet(StoreKey.legacyAccessToken), _kAccessToken); expect(sut.tryGet(StoreKey.advancedTroubleshooting), _kAdvancedTroubleshooting); expect(sut.tryGet(StoreKey.version), _kVersion); // Other keys should be null @@ -53,19 +53,19 @@ void main() { }); test('Listens to stream of store updates', () async { - final event = StoreDto(StoreKey.accessToken, _kAccessToken.toUpperCase()); + final event = StoreDto(StoreKey.legacyAccessToken, _kAccessToken.toUpperCase()); controller.add([event]); await pumpEventQueue(); verify(() => mockDriftStoreRepo.watchAll()).called(1); - expect(sut.tryGet(StoreKey.accessToken), _kAccessToken.toUpperCase()); + expect(sut.tryGet(StoreKey.legacyAccessToken), _kAccessToken.toUpperCase()); }); }); group('Store Service get:', () { test('Returns the stored value for the given key', () { - expect(sut.get(StoreKey.accessToken), _kAccessToken); + expect(sut.get(StoreKey.legacyAccessToken), _kAccessToken); }); test('Throws StoreKeyNotFoundException for nonexistent keys', () { @@ -83,15 +83,15 @@ void main() { }); test('Skip insert when value is not modified', () async { - await sut.put(StoreKey.accessToken, _kAccessToken); - verifyNever(() => mockDriftStoreRepo.upsert(StoreKey.accessToken, any())); + await sut.put(StoreKey.legacyAccessToken, _kAccessToken); + verifyNever(() => mockDriftStoreRepo.upsert(StoreKey.legacyAccessToken, any())); }); test('Insert value when modified', () async { final newAccessToken = _kAccessToken.toUpperCase(); - await sut.put(StoreKey.accessToken, newAccessToken); - verify(() => mockDriftStoreRepo.upsert(StoreKey.accessToken, newAccessToken)).called(1); - expect(sut.tryGet(StoreKey.accessToken), newAccessToken); + await sut.put(StoreKey.legacyAccessToken, newAccessToken); + verify(() => mockDriftStoreRepo.upsert(StoreKey.legacyAccessToken, newAccessToken)).called(1); + expect(sut.tryGet(StoreKey.legacyAccessToken), newAccessToken); }); }); @@ -108,7 +108,7 @@ void main() { }); test('Watches a specific key for changes', () async { - final stream = sut.watch(StoreKey.accessToken); + final stream = sut.watch(StoreKey.legacyAccessToken); final events = [_kAccessToken, _kAccessToken.toUpperCase(), null, _kAccessToken.toLowerCase()]; unawaited(expectLater(stream, emitsInOrder(events))); @@ -118,7 +118,7 @@ void main() { } await pumpEventQueue(); - verify(() => mockDriftStoreRepo.watch(StoreKey.accessToken)).called(1); + verify(() => mockDriftStoreRepo.watch(StoreKey.legacyAccessToken)).called(1); }); }); @@ -128,13 +128,13 @@ void main() { }); test('Removes the value from the DB', () async { - await sut.delete(StoreKey.accessToken); - verify(() => mockDriftStoreRepo.delete(StoreKey.accessToken)).called(1); + await sut.delete(StoreKey.legacyAccessToken); + verify(() => mockDriftStoreRepo.delete(StoreKey.legacyAccessToken)).called(1); }); test('Removes the value from the cache', () async { - await sut.delete(StoreKey.accessToken); - expect(sut.tryGet(StoreKey.accessToken), isNull); + await sut.delete(StoreKey.legacyAccessToken); + expect(sut.tryGet(StoreKey.legacyAccessToken), isNull); }); }); @@ -146,7 +146,7 @@ void main() { test('Clears all values from the store', () async { await sut.clear(); verify(() => mockDriftStoreRepo.deleteAll()).called(1); - expect(sut.tryGet(StoreKey.accessToken), isNull); + expect(sut.tryGet(StoreKey.legacyAccessToken), isNull); expect(sut.tryGet(StoreKey.advancedTroubleshooting), isNull); expect(sut.tryGet(StoreKey.version), isNull); }); diff --git a/mobile/test/infrastructure/repositories/store_repository_test.dart b/mobile/test/infrastructure/repositories/store_repository_test.dart index 3e160c29ca..b8baab614c 100644 --- a/mobile/test/infrastructure/repositories/store_repository_test.dart +++ b/mobile/test/infrastructure/repositories/store_repository_test.dart @@ -29,7 +29,7 @@ Future _populateStore(Drift db) async { batch.insert( db.storeEntity, StoreEntityCompanion( - id: Value(StoreKey.accessToken.id), + id: Value(StoreKey.legacyAccessToken.id), intValue: const Value(null), stringValue: const Value(_kTestAccessToken), ), @@ -68,10 +68,10 @@ void main() { }); test('converts string', () async { - String? accessToken = await sut.tryGet(StoreKey.accessToken); + String? accessToken = await sut.tryGet(StoreKey.legacyAccessToken); expect(accessToken, isNull); - await sut.upsert(StoreKey.accessToken, _kTestAccessToken); - accessToken = await sut.tryGet(StoreKey.accessToken); + await sut.upsert(StoreKey.legacyAccessToken, _kTestAccessToken); + accessToken = await sut.tryGet(StoreKey.legacyAccessToken); expect(accessToken, _kTestAccessToken); }); @@ -147,12 +147,12 @@ void main() { emitsInOrder([ [ const StoreDto(StoreKey.version, _kTestVersion), - const StoreDto(StoreKey.accessToken, _kTestAccessToken), + const StoreDto(StoreKey.legacyAccessToken, _kTestAccessToken), const StoreDto(StoreKey.advancedTroubleshooting, _kTestAdvancedTroubleshooting), ], [ const StoreDto(StoreKey.version, _kTestVersion + 10), - const StoreDto(StoreKey.accessToken, _kTestAccessToken), + const StoreDto(StoreKey.legacyAccessToken, _kTestAccessToken), const StoreDto(StoreKey.advancedTroubleshooting, _kTestAdvancedTroubleshooting), ], ]), diff --git a/mobile/test/medium/repositories/session_repository_test.dart b/mobile/test/medium/repositories/session_repository_test.dart new file mode 100644 index 0000000000..d645556b98 --- /dev/null +++ b/mobile/test/medium/repositories/session_repository_test.dart @@ -0,0 +1,118 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:immich_mobile/domain/models/session.model.dart'; +import 'package:immich_mobile/infrastructure/entities/session.entity.drift.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; + +import '../repository_context.dart'; + +void main() { + late MediumRepositoryContext ctx; + late SessionRepository sut; + + setUpAll(() async { + ctx = MediumRepositoryContext(); + sut = await SessionRepository.ensureInitialized(ctx.db); + }); + + tearDownAll(() async { + await ctx.dispose(); + }); + + setUp(() async { + await ctx.db.delete(ctx.db.sessionEntity).go(); + await SessionRepository.instance.refresh(); + }); + + group('defaults', () { + test('session returns null fields when DB is empty', () { + expect(sut.session.serverUrl, isNull); + expect(sut.session.accessToken, isNull); + expect(sut.session.serverEndpoint, isNull); + }); + }); + + group('write', () { + test('persists a value and reflects it in the composed view', () async { + await sut.write(.serverEndpoint, 'https://demo.immich.app/api'); + expect(sut.session.serverEndpoint, 'https://demo.immich.app/api'); + }); + + test('persists across keys independently', () async { + await sut.write(.serverUrl, 'https://demo.immich.app'); + await sut.write(.accessToken, 'token-123'); + expect(sut.session.serverUrl, 'https://demo.immich.app'); + expect(sut.session.accessToken, 'token-123'); + expect(sut.session.serverEndpoint, isNull); + }); + }); + + group('null values', () { + test('a stored NULL value column decodes to null on refresh', () async { + await ctx.db + .into(ctx.db.sessionEntity) + .insert( + SessionEntityCompanion.insert( + key: SessionKey.accessToken.name, + value: const .new(null), + updatedAt: .new(DateTime.now()), + ), + ); + + await SessionRepository.instance.refresh(); + expect(sut.session.accessToken, isNull); + }); + }); + + group('sync', () { + test('picks up rows that were inserted directly into the DB', () async { + await ctx.db + .into(ctx.db.sessionEntity) + .insert( + SessionEntityCompanion.insert( + key: SessionKey.serverEndpoint.name, + value: const .new('https://demo.immich.app/api'), + updatedAt: .new(DateTime.now()), + ), + ); + expect(sut.session.serverEndpoint, isNull); + + await SessionRepository.instance.refresh(); + expect(sut.session.serverEndpoint, 'https://demo.immich.app/api'); + }); + + test('drops cached values for rows that were deleted out from under the repo', () async { + await sut.write(.serverEndpoint, 'https://demo.immich.app/api'); + await ctx.db.delete(ctx.db.sessionEntity).go(); + expect(sut.session.serverEndpoint, 'https://demo.immich.app/api'); + + await SessionRepository.instance.refresh(); + expect(sut.session.serverEndpoint, isNull); + }); + + test('skips rows whose key is unknown to SessionKey', () async { + await ctx.db + .into(ctx.db.sessionEntity) + .insert( + SessionEntityCompanion.insert( + key: 'session.unknown.future-key', + value: const .new('unknown'), + updatedAt: .new(DateTime.now()), + ), + ); + + await SessionRepository.instance.refresh(); + expect(sut.session.serverEndpoint, isNull); + }); + }); + + group('watch', () { + test('watchSession emits the new value after a write', () async { + final expectation = expectLater( + sut.watch().map((s) => s.serverEndpoint), + emitsThrough('https://demo.immich.app/api/watch'), + ); + await sut.write(SessionKey.serverEndpoint, 'https://demo.immich.app/api/watch'); + await expectation; + }); + }); +} diff --git a/mobile/test/medium/repositories/settings_repository_test.dart b/mobile/test/medium/repositories/settings_repository_test.dart index 087b3aece4..c63f59e6a3 100644 --- a/mobile/test/medium/repositories/settings_repository_test.dart +++ b/mobile/test/medium/repositories/settings_repository_test.dart @@ -142,13 +142,13 @@ void main() { group('watch', () { test('watchAppConfig emits the new value after a write', () async { - final expectation = expectLater(sut.watchConfig().map((c) => c.theme.mode), emitsThrough(ThemeMode.dark)); + final expectation = expectLater(sut.watch().map((c) => c.theme.mode), emitsThrough(ThemeMode.dark)); await sut.write(SettingsKey.themeMode, ThemeMode.dark); await expectation; }); test('watchConfig emits the new value after a write', () async { - final expectation = expectLater(sut.watchConfig().map((c) => c.logLevel), emitsThrough(LogLevel.warning)); + final expectation = expectLater(sut.watch().map((c) => c.logLevel), emitsThrough(LogLevel.warning)); await sut.write(SettingsKey.logLevel, LogLevel.warning); await expectation; }); diff --git a/mobile/test/services/auth.service_test.dart b/mobile/test/services/auth.service_test.dart index 584ea57027..82eec5b52f 100644 --- a/mobile/test/services/auth.service_test.dart +++ b/mobile/test/services/auth.service_test.dart @@ -4,6 +4,7 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:immich_mobile/domain/services/store.service.dart'; import 'package:immich_mobile/infrastructure/repositories/db.repository.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/store.repository.dart'; import 'package:immich_mobile/models/auth/auxilary_endpoint.model.dart'; import 'package:immich_mobile/services/auth.service.dart'; @@ -44,6 +45,7 @@ void main() { WidgetsFlutterBinding.ensureInitialized(); db = Drift(DatabaseConnection(NativeDatabase.memory(), closeStreamsSynchronously: true)); await StoreService.init(storeRepository: DriftStoreRepository(db)); + await SessionRepository.ensureInitialized(db); }); tearDownAll(() async { diff --git a/mobile/test/services/background_upload.service_test.dart b/mobile/test/services/background_upload.service_test.dart index 527da1bf1b..1b0d746fc7 100644 --- a/mobile/test/services/background_upload.service_test.dart +++ b/mobile/test/services/background_upload.service_test.dart @@ -7,10 +7,12 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:immich_mobile/domain/models/asset/base_asset.model.dart'; +import 'package:immich_mobile/domain/models/session.model.dart'; import 'package:immich_mobile/domain/models/store.model.dart'; import 'package:immich_mobile/domain/services/store.service.dart'; import 'package:immich_mobile/entities/store.entity.dart'; import 'package:immich_mobile/infrastructure/repositories/db.repository.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/settings.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/store.repository.dart'; import 'package:immich_mobile/services/background_upload.service.dart'; @@ -39,8 +41,8 @@ void main() { db = Drift(DatabaseConnection(NativeDatabase.memory(), closeStreamsSynchronously: true)); await StoreService.init(storeRepository: DriftStoreRepository(db)); await SettingsRepository.ensureInitialized(db); - - await Store.put(StoreKey.serverEndpoint, 'http://test-server.com'); + await SessionRepository.ensureInitialized(db); + await SessionRepository.instance.write(SessionKey.serverEndpoint, 'https://demo.immich.app'); await Store.put(StoreKey.deviceId, 'test-device-id'); }); From 3ab8c6e3dbe80a4f5ffbb19475c60aaf1647b6ad Mon Sep 17 00:00:00 2001 From: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Date: Wed, 22 Jul 2026 00:36:02 +0530 Subject: [PATCH 7/8] rebase --- .../drift_schemas/main/drift_schema_v32.json | 3683 ++++++ .../repositories/db.repository.dart | 101 +- .../repositories/db.repository.drift.dart | 16 +- .../repositories/db.repository.steps.dart | 605 + mobile/lib/utils/bootstrap.dart | 3 +- mobile/lib/utils/image_url_builder.dart | 3 +- mobile/lib/utils/migration.dart | 3 +- mobile/test/drift/main/generated/schema.dart | 4 + .../test/drift/main/generated/schema_v32.dart | 10246 ++++++++++++++++ .../widgets/timeline/timeline_args_test.dart | 2 + .../foreground_upload.service_test.dart | 5 +- .../presentation/presentation_context.dart | 5 +- 12 files changed, 14616 insertions(+), 60 deletions(-) create mode 100644 mobile/drift_schemas/main/drift_schema_v32.json create mode 100644 mobile/test/drift/main/generated/schema_v32.dart diff --git a/mobile/drift_schemas/main/drift_schema_v32.json b/mobile/drift_schemas/main/drift_schema_v32.json new file mode 100644 index 0000000000..86bda4401e --- /dev/null +++ b/mobile/drift_schemas/main/drift_schema_v32.json @@ -0,0 +1,3683 @@ +{ + "_meta": { + "description": "This file contains a serialized version of schema entities for drift.", + "version": "1.3.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": "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": "email", + "getter_name": "email", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "has_profile_image", + "getter_name": "hasProfileImage", + "moor_type": "bool", + "nullable": false, + "customConstraints": null, + "defaultConstraints": "CHECK (\"has_profile_image\" IN (0, 1))", + "dialectAwareDefaultConstraints": { + "sqlite": "CHECK (\"has_profile_image\" IN (0, 1))" + }, + "default_dart": "const CustomExpression('0')", + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "profile_changed_at", + "getter_name": "profileChangedAt", + "moor_type": "dateTime", + "nullable": false, + "customConstraints": null, + "default_dart": "const CustomExpression('CURRENT_TIMESTAMP')", + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "avatar_color", + "getter_name": "avatarColor", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": "const CustomExpression('0')", + "default_client_dart": null, + "dsl_features": [], + "type_converter": { + "dart_expr": "const EnumIndexConverter(AvatarColor.values)", + "dart_type_name": "AvatarColor" + } + } + ], + "is_virtual": false, + "without_rowid": true, + "constraints": [], + "strict": true, + "explicit_pk": [ + "id" + ] + } + }, + { + "id": 1, + "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": "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_ms", + "getter_name": "durationMs", + "moor_type": "int", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "id", + "getter_name": "id", + "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": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "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": "string", + "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": [ + { + "foreign_key": { + "to": { + "table": "user_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + }, + { + "name": "local_date_time", + "getter_name": "localDateTime", + "moor_type": "dateTime", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "thumb_hash", + "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": [] + }, + { + "name": "uploaded_at", + "getter_name": "uploadedAt", + "moor_type": "dateTime", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "live_photo_video_id", + "getter_name": "livePhotoVideoId", + "moor_type": "string", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "visibility", + "getter_name": "visibility", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [], + "type_converter": { + "dart_expr": "const EnumIndexConverter(AssetVisibility.values)", + "dart_type_name": "AssetVisibility" + } + }, + { + "name": "stack_id", + "getter_name": "stackId", + "moor_type": "string", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "library_id", + "getter_name": "libraryId", + "moor_type": "string", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "is_edited", + "getter_name": "isEdited", + "moor_type": "bool", + "nullable": false, + "customConstraints": null, + "defaultConstraints": "CHECK (\"is_edited\" IN (0, 1))", + "dialectAwareDefaultConstraints": { + "sqlite": "CHECK (\"is_edited\" 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": 2, + "references": [ + 0 + ], + "type": "table", + "data": { + "name": "stack_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": "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": "owner_id", + "getter_name": "ownerId", + "moor_type": "string", + "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": [ + { + "foreign_key": { + "to": { + "table": "user_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + }, + { + "name": "primary_asset_id", + "getter_name": "primaryAssetId", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + } + ], + "is_virtual": false, + "without_rowid": true, + "constraints": [], + "strict": true, + "explicit_pk": [ + "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_ms", + "getter_name": "durationMs", + "moor_type": "int", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "id", + "getter_name": "id", + "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": "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": "orientation", + "getter_name": "orientation", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": "const CustomExpression('0')", + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "i_cloud_id", + "getter_name": "iCloudId", + "moor_type": "string", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "adjustment_time", + "getter_name": "adjustmentTime", + "moor_type": "dateTime", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "latitude", + "getter_name": "latitude", + "moor_type": "double", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "longitude", + "getter_name": "longitude", + "moor_type": "double", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "playback_style", + "getter_name": "playbackStyle", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": "const CustomExpression('0')", + "default_client_dart": null, + "dsl_features": [], + "type_converter": { + "dart_expr": "const EnumIndexConverter(AssetPlaybackStyle.values)", + "dart_type_name": "AssetPlaybackStyle" + } + } + ], + "is_virtual": false, + "without_rowid": true, + "constraints": [], + "strict": true, + "explicit_pk": [ + "id" + ] + } + }, + { + "id": 4, + "references": [ + 1 + ], + "type": "table", + "data": { + "name": "remote_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": "description", + "getter_name": "description", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "default_dart": "const CustomExpression('\\'\\'')", + "default_client_dart": null, + "dsl_features": [] + }, + { + "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": "thumbnail_asset_id", + "getter_name": "thumbnailAssetId", + "moor_type": "string", + "nullable": true, + "customConstraints": null, + "defaultConstraints": "REFERENCES remote_asset_entity (id) ON DELETE SET NULL", + "dialectAwareDefaultConstraints": { + "sqlite": "REFERENCES remote_asset_entity (id) ON DELETE SET NULL" + }, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [ + { + "foreign_key": { + "to": { + "table": "remote_asset_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "setNull" + } + } + ] + }, + { + "name": "is_activity_enabled", + "getter_name": "isActivityEnabled", + "moor_type": "bool", + "nullable": false, + "customConstraints": null, + "defaultConstraints": "CHECK (\"is_activity_enabled\" IN (0, 1))", + "dialectAwareDefaultConstraints": { + "sqlite": "CHECK (\"is_activity_enabled\" IN (0, 1))" + }, + "default_dart": "const CustomExpression('1')", + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "order", + "getter_name": "order", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [], + "type_converter": { + "dart_expr": "const EnumIndexConverter(AlbumAssetOrder.values)", + "dart_type_name": "AlbumAssetOrder" + } + } + ], + "is_virtual": false, + "without_rowid": true, + "constraints": [], + "strict": true, + "explicit_pk": [ + "id" + ] + } + }, + { + "id": 5, + "references": [ + 4 + ], + "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": "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_ios_shared_album", + "getter_name": "isIosSharedAlbum", + "moor_type": "bool", + "nullable": false, + "customConstraints": null, + "defaultConstraints": "CHECK (\"is_ios_shared_album\" IN (0, 1))", + "dialectAwareDefaultConstraints": { + "sqlite": "CHECK (\"is_ios_shared_album\" IN (0, 1))" + }, + "default_dart": "const CustomExpression('0')", + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "linked_remote_album_id", + "getter_name": "linkedRemoteAlbumId", + "moor_type": "string", + "nullable": true, + "customConstraints": null, + "defaultConstraints": "REFERENCES remote_album_entity (id) ON DELETE SET NULL", + "dialectAwareDefaultConstraints": { + "sqlite": "REFERENCES remote_album_entity (id) ON DELETE SET NULL" + }, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [ + { + "foreign_key": { + "to": { + "table": "remote_album_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "setNull" + } + } + ] + }, + { + "name": "marker", + "getter_name": "marker_", + "moor_type": "bool", + "nullable": true, + "customConstraints": null, + "defaultConstraints": "CHECK (\"marker\" IN (0, 1))", + "dialectAwareDefaultConstraints": { + "sqlite": "CHECK (\"marker\" IN (0, 1))" + }, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + } + ], + "is_virtual": false, + "without_rowid": true, + "constraints": [], + "strict": true, + "explicit_pk": [ + "id" + ] + } + }, + { + "id": 6, + "references": [ + 3, + 5 + ], + "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 (id) ON DELETE CASCADE", + "dialectAwareDefaultConstraints": { + "sqlite": "REFERENCES local_asset_entity (id) ON DELETE CASCADE" + }, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [ + { + "foreign_key": { + "to": { + "table": "local_asset_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + }, + { + "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": [ + { + "foreign_key": { + "to": { + "table": "local_album_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + }, + { + "name": "marker", + "getter_name": "marker_", + "moor_type": "bool", + "nullable": true, + "customConstraints": null, + "defaultConstraints": "CHECK (\"marker\" IN (0, 1))", + "dialectAwareDefaultConstraints": { + "sqlite": "CHECK (\"marker\" IN (0, 1))" + }, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + } + ], + "is_virtual": false, + "without_rowid": true, + "constraints": [], + "strict": true, + "explicit_pk": [ + "asset_id", + "album_id" + ] + } + }, + { + "id": 7, + "references": [ + 6 + ], + "type": "index", + "data": { + "on": 6, + "name": "idx_local_album_asset_album_asset", + "sql": "CREATE INDEX IF NOT EXISTS idx_local_album_asset_album_asset ON local_album_asset_entity (album_id, asset_id)", + "unique": false, + "columns": [] + } + }, + { + "id": 8, + "references": [ + 3 + ], + "type": "index", + "data": { + "on": 3, + "name": "idx_local_asset_checksum", + "sql": "CREATE INDEX IF NOT EXISTS idx_local_asset_checksum ON local_asset_entity (checksum)", + "unique": false, + "columns": [] + } + }, + { + "id": 9, + "references": [ + 3 + ], + "type": "index", + "data": { + "on": 3, + "name": "idx_local_asset_cloud_id", + "sql": "CREATE INDEX IF NOT EXISTS idx_local_asset_cloud_id ON local_asset_entity (i_cloud_id)", + "unique": false, + "columns": [] + } + }, + { + "id": 10, + "references": [ + 3 + ], + "type": "index", + "data": { + "on": 3, + "name": "idx_local_asset_created_at", + "sql": "CREATE INDEX IF NOT EXISTS idx_local_asset_created_at ON local_asset_entity (created_at)", + "unique": false, + "columns": [] + } + }, + { + "id": 11, + "references": [ + 2 + ], + "type": "index", + "data": { + "on": 2, + "name": "idx_stack_primary_asset_id", + "sql": "CREATE INDEX IF NOT EXISTS idx_stack_primary_asset_id ON stack_entity (primary_asset_id)", + "unique": false, + "columns": [] + } + }, + { + "id": 12, + "references": [ + 1 + ], + "type": "index", + "data": { + "on": 1, + "name": "UQ_remote_assets_owner_checksum", + "sql": "CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_checksum\nON remote_asset_entity (owner_id, checksum)\nWHERE (library_id IS NULL);\n", + "unique": true, + "columns": [] + } + }, + { + "id": 13, + "references": [ + 1 + ], + "type": "index", + "data": { + "on": 1, + "name": "UQ_remote_assets_owner_library_checksum", + "sql": "CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_library_checksum\nON remote_asset_entity (owner_id, library_id, checksum)\nWHERE (library_id IS NOT NULL);\n", + "unique": true, + "columns": [] + } + }, + { + "id": 14, + "references": [ + 1 + ], + "type": "index", + "data": { + "on": 1, + "name": "idx_remote_asset_checksum", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_checksum ON remote_asset_entity (checksum)", + "unique": false, + "columns": [] + } + }, + { + "id": 15, + "references": [ + 1 + ], + "type": "index", + "data": { + "on": 1, + "name": "idx_remote_asset_stack_id", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_stack_id ON remote_asset_entity (stack_id)", + "unique": false, + "columns": [] + } + }, + { + "id": 16, + "references": [ + 1 + ], + "type": "index", + "data": { + "on": 1, + "name": "idx_remote_asset_owner_visibility_deleted_created", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_visibility_deleted_created\nON remote_asset_entity (owner_id, visibility, deleted_at, created_at DESC)\n", + "unique": false, + "columns": [] + } + }, + { + "id": 17, + "references": [ + 1 + ], + "type": "index", + "data": { + "on": 1, + "name": "idx_remote_asset_uploaded", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_uploaded ON remote_asset_entity (uploaded_at)", + "unique": false, + "columns": [] + } + }, + { + "id": 18, + "references": [], + "type": "table", + "data": { + "name": "auth_user_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": "email", + "getter_name": "email", + "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": "has_profile_image", + "getter_name": "hasProfileImage", + "moor_type": "bool", + "nullable": false, + "customConstraints": null, + "defaultConstraints": "CHECK (\"has_profile_image\" IN (0, 1))", + "dialectAwareDefaultConstraints": { + "sqlite": "CHECK (\"has_profile_image\" IN (0, 1))" + }, + "default_dart": "const CustomExpression('0')", + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "profile_changed_at", + "getter_name": "profileChangedAt", + "moor_type": "dateTime", + "nullable": false, + "customConstraints": null, + "default_dart": "const CustomExpression('CURRENT_TIMESTAMP')", + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "avatar_color", + "getter_name": "avatarColor", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [], + "type_converter": { + "dart_expr": "const EnumIndexConverter(AvatarColor.values)", + "dart_type_name": "AvatarColor" + } + }, + { + "name": "quota_size_in_bytes", + "getter_name": "quotaSizeInBytes", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": "const CustomExpression('0')", + "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": [] + }, + { + "name": "pin_code", + "getter_name": "pinCode", + "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": [ + "id" + ] + } + }, + { + "id": 19, + "references": [ + 0 + ], + "type": "table", + "data": { + "name": "user_metadata_entity", + "was_declared_in_moor": false, + "columns": [ + { + "name": "user_id", + "getter_name": "userId", + "moor_type": "string", + "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": [ + { + "foreign_key": { + "to": { + "table": "user_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + }, + { + "name": "key", + "getter_name": "key", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [], + "type_converter": { + "dart_expr": "const EnumIndexConverter(UserMetadataKey.values)", + "dart_type_name": "UserMetadataKey" + } + }, + { + "name": "value", + "getter_name": "value", + "moor_type": "blob", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [], + "type_converter": { + "dart_expr": "userMetadataConverter", + "dart_type_name": "Map" + } + } + ], + "is_virtual": false, + "without_rowid": true, + "constraints": [], + "strict": true, + "explicit_pk": [ + "user_id", + "key" + ] + } + }, + { + "id": 20, + "references": [ + 0 + ], + "type": "table", + "data": { + "name": "partner_entity", + "was_declared_in_moor": false, + "columns": [ + { + "name": "shared_by_id", + "getter_name": "sharedById", + "moor_type": "string", + "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": [ + { + "foreign_key": { + "to": { + "table": "user_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + }, + { + "name": "shared_with_id", + "getter_name": "sharedWithId", + "moor_type": "string", + "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": [ + { + "foreign_key": { + "to": { + "table": "user_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + }, + { + "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": 21, + "references": [ + 1 + ], + "type": "table", + "data": { + "name": "remote_exif_entity", + "was_declared_in_moor": false, + "columns": [ + { + "name": "asset_id", + "getter_name": "assetId", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "defaultConstraints": "REFERENCES remote_asset_entity (id) ON DELETE CASCADE", + "dialectAwareDefaultConstraints": { + "sqlite": "REFERENCES remote_asset_entity (id) ON DELETE CASCADE" + }, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [ + { + "foreign_key": { + "to": { + "table": "remote_asset_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + }, + { + "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": "double", + "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": "double", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "latitude", + "getter_name": "latitude", + "moor_type": "double", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "longitude", + "getter_name": "longitude", + "moor_type": "double", + "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": "lens", + "getter_name": "lens", + "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": 22, + "references": [ + 1, + 4 + ], + "type": "table", + "data": { + "name": "remote_album_asset_entity", + "was_declared_in_moor": false, + "columns": [ + { + "name": "asset_id", + "getter_name": "assetId", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "defaultConstraints": "REFERENCES remote_asset_entity (id) ON DELETE CASCADE", + "dialectAwareDefaultConstraints": { + "sqlite": "REFERENCES remote_asset_entity (id) ON DELETE CASCADE" + }, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [ + { + "foreign_key": { + "to": { + "table": "remote_asset_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + }, + { + "name": "album_id", + "getter_name": "albumId", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "defaultConstraints": "REFERENCES remote_album_entity (id) ON DELETE CASCADE", + "dialectAwareDefaultConstraints": { + "sqlite": "REFERENCES remote_album_entity (id) ON DELETE CASCADE" + }, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [ + { + "foreign_key": { + "to": { + "table": "remote_album_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + } + ], + "is_virtual": false, + "without_rowid": true, + "constraints": [], + "strict": true, + "explicit_pk": [ + "asset_id", + "album_id" + ] + } + }, + { + "id": 23, + "references": [ + 4, + 0 + ], + "type": "table", + "data": { + "name": "remote_album_user_entity", + "was_declared_in_moor": false, + "columns": [ + { + "name": "album_id", + "getter_name": "albumId", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "defaultConstraints": "REFERENCES remote_album_entity (id) ON DELETE CASCADE", + "dialectAwareDefaultConstraints": { + "sqlite": "REFERENCES remote_album_entity (id) ON DELETE CASCADE" + }, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [ + { + "foreign_key": { + "to": { + "table": "remote_album_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + }, + { + "name": "user_id", + "getter_name": "userId", + "moor_type": "string", + "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": [ + { + "foreign_key": { + "to": { + "table": "user_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + }, + { + "name": "role", + "getter_name": "role", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [], + "type_converter": { + "dart_expr": "const EnumIndexConverter(AlbumUserRole.values)", + "dart_type_name": "AlbumUserRole" + } + } + ], + "is_virtual": false, + "without_rowid": true, + "constraints": [], + "strict": true, + "explicit_pk": [ + "album_id", + "user_id" + ] + } + }, + { + "id": 24, + "references": [ + 1 + ], + "type": "table", + "data": { + "name": "remote_asset_cloud_id_entity", + "was_declared_in_moor": false, + "columns": [ + { + "name": "asset_id", + "getter_name": "assetId", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "defaultConstraints": "REFERENCES remote_asset_entity (id) ON DELETE CASCADE", + "dialectAwareDefaultConstraints": { + "sqlite": "REFERENCES remote_asset_entity (id) ON DELETE CASCADE" + }, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [ + { + "foreign_key": { + "to": { + "table": "remote_asset_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + }, + { + "name": "cloud_id", + "getter_name": "cloudId", + "moor_type": "string", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "created_at", + "getter_name": "createdAt", + "moor_type": "dateTime", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "adjustment_time", + "getter_name": "adjustmentTime", + "moor_type": "dateTime", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "latitude", + "getter_name": "latitude", + "moor_type": "double", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "longitude", + "getter_name": "longitude", + "moor_type": "double", + "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": 25, + "references": [ + 0 + ], + "type": "table", + "data": { + "name": "memory_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": "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": "deleted_at", + "getter_name": "deletedAt", + "moor_type": "dateTime", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "owner_id", + "getter_name": "ownerId", + "moor_type": "string", + "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": [ + { + "foreign_key": { + "to": { + "table": "user_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + }, + { + "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(MemoryTypeEnum.values)", + "dart_type_name": "MemoryTypeEnum" + } + }, + { + "name": "data", + "getter_name": "data", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "is_saved", + "getter_name": "isSaved", + "moor_type": "bool", + "nullable": false, + "customConstraints": null, + "defaultConstraints": "CHECK (\"is_saved\" IN (0, 1))", + "dialectAwareDefaultConstraints": { + "sqlite": "CHECK (\"is_saved\" IN (0, 1))" + }, + "default_dart": "const CustomExpression('0')", + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "memory_at", + "getter_name": "memoryAt", + "moor_type": "dateTime", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "seen_at", + "getter_name": "seenAt", + "moor_type": "dateTime", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "show_at", + "getter_name": "showAt", + "moor_type": "dateTime", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "hide_at", + "getter_name": "hideAt", + "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": [ + "id" + ] + } + }, + { + "id": 26, + "references": [ + 1, + 25 + ], + "type": "table", + "data": { + "name": "memory_asset_entity", + "was_declared_in_moor": false, + "columns": [ + { + "name": "asset_id", + "getter_name": "assetId", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "defaultConstraints": "REFERENCES remote_asset_entity (id) ON DELETE CASCADE", + "dialectAwareDefaultConstraints": { + "sqlite": "REFERENCES remote_asset_entity (id) ON DELETE CASCADE" + }, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [ + { + "foreign_key": { + "to": { + "table": "remote_asset_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + }, + { + "name": "memory_id", + "getter_name": "memoryId", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "defaultConstraints": "REFERENCES memory_entity (id) ON DELETE CASCADE", + "dialectAwareDefaultConstraints": { + "sqlite": "REFERENCES memory_entity (id) ON DELETE CASCADE" + }, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [ + { + "foreign_key": { + "to": { + "table": "memory_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + } + ], + "is_virtual": false, + "without_rowid": true, + "constraints": [], + "strict": true, + "explicit_pk": [ + "asset_id", + "memory_id" + ] + } + }, + { + "id": 27, + "references": [ + 0 + ], + "type": "table", + "data": { + "name": "person_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": "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": "owner_id", + "getter_name": "ownerId", + "moor_type": "string", + "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": [ + { + "foreign_key": { + "to": { + "table": "user_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + }, + { + "name": "name", + "getter_name": "name", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "face_asset_id", + "getter_name": "faceAssetId", + "moor_type": "string", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "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": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "is_hidden", + "getter_name": "isHidden", + "moor_type": "bool", + "nullable": false, + "customConstraints": null, + "defaultConstraints": "CHECK (\"is_hidden\" IN (0, 1))", + "dialectAwareDefaultConstraints": { + "sqlite": "CHECK (\"is_hidden\" IN (0, 1))" + }, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "color", + "getter_name": "color", + "moor_type": "string", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "birth_date", + "getter_name": "birthDate", + "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": [ + "id" + ] + } + }, + { + "id": 28, + "references": [ + 1, + 27 + ], + "type": "table", + "data": { + "name": "asset_face_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": "asset_id", + "getter_name": "assetId", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "defaultConstraints": "REFERENCES remote_asset_entity (id) ON DELETE CASCADE", + "dialectAwareDefaultConstraints": { + "sqlite": "REFERENCES remote_asset_entity (id) ON DELETE CASCADE" + }, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [ + { + "foreign_key": { + "to": { + "table": "remote_asset_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + }, + { + "name": "person_id", + "getter_name": "personId", + "moor_type": "string", + "nullable": true, + "customConstraints": null, + "defaultConstraints": "REFERENCES person_entity (id) ON DELETE SET NULL", + "dialectAwareDefaultConstraints": { + "sqlite": "REFERENCES person_entity (id) ON DELETE SET NULL" + }, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [ + { + "foreign_key": { + "to": { + "table": "person_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "setNull" + } + } + ] + }, + { + "name": "image_width", + "getter_name": "imageWidth", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "image_height", + "getter_name": "imageHeight", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "bounding_box_x1", + "getter_name": "boundingBoxX1", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "bounding_box_y1", + "getter_name": "boundingBoxY1", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "bounding_box_x2", + "getter_name": "boundingBoxX2", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "bounding_box_y2", + "getter_name": "boundingBoxY2", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "source_type", + "getter_name": "sourceType", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "is_visible", + "getter_name": "isVisible", + "moor_type": "bool", + "nullable": false, + "customConstraints": null, + "defaultConstraints": "CHECK (\"is_visible\" IN (0, 1))", + "dialectAwareDefaultConstraints": { + "sqlite": "CHECK (\"is_visible\" IN (0, 1))" + }, + "default_dart": "const CustomExpression('1')", + "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": [ + "id" + ] + } + }, + { + "id": 29, + "references": [], + "type": "table", + "data": { + "name": "store_entity", + "was_declared_in_moor": false, + "columns": [ + { + "name": "id", + "getter_name": "id", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "string_value", + "getter_name": "stringValue", + "moor_type": "string", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "int_value", + "getter_name": "intValue", + "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": [ + "id" + ] + } + }, + { + "id": 30, + "references": [], + "type": "table", + "data": { + "name": "trashed_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_ms", + "getter_name": "durationMs", + "moor_type": "int", + "nullable": true, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "id", + "getter_name": "id", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "album_id", + "getter_name": "albumId", + "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": "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": "orientation", + "getter_name": "orientation", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": "const CustomExpression('0')", + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "source", + "getter_name": "source", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [], + "type_converter": { + "dart_expr": "const EnumIndexConverter(TrashOrigin.values)", + "dart_type_name": "TrashOrigin" + } + }, + { + "name": "playback_style", + "getter_name": "playbackStyle", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": "const CustomExpression('0')", + "default_client_dart": null, + "dsl_features": [], + "type_converter": { + "dart_expr": "const EnumIndexConverter(AssetPlaybackStyle.values)", + "dart_type_name": "AssetPlaybackStyle" + } + } + ], + "is_virtual": false, + "without_rowid": true, + "constraints": [], + "strict": true, + "explicit_pk": [ + "id", + "album_id" + ] + } + }, + { + "id": 31, + "references": [ + 1 + ], + "type": "table", + "data": { + "name": "asset_edit_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": "asset_id", + "getter_name": "assetId", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "defaultConstraints": "REFERENCES remote_asset_entity (id) ON DELETE CASCADE", + "dialectAwareDefaultConstraints": { + "sqlite": "REFERENCES remote_asset_entity (id) ON DELETE CASCADE" + }, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [ + { + "foreign_key": { + "to": { + "table": "remote_asset_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + }, + { + "name": "action", + "getter_name": "action", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [], + "type_converter": { + "dart_expr": "const EnumIndexConverter(AssetEditAction.values)", + "dart_type_name": "AssetEditAction" + } + }, + { + "name": "parameters", + "getter_name": "parameters", + "moor_type": "blob", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [], + "type_converter": { + "dart_expr": "editParameterConverter", + "dart_type_name": "Map" + } + }, + { + "name": "sequence", + "getter_name": "sequence", + "moor_type": "int", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + } + ], + "is_virtual": false, + "without_rowid": true, + "constraints": [], + "strict": true, + "explicit_pk": [ + "id" + ] + } + }, + { + "id": 32, + "references": [], + "type": "table", + "data": { + "name": "settings", + "was_declared_in_moor": false, + "columns": [ + { + "name": "key", + "getter_name": "key", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "value", + "getter_name": "value", + "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": [] + } + ], + "is_virtual": false, + "without_rowid": true, + "constraints": [], + "strict": true, + "explicit_pk": [ + "key" + ] + } + }, + { + "id": 33, + "references": [ + 1 + ], + "type": "table", + "data": { + "name": "asset_ocr_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": "asset_id", + "getter_name": "assetId", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "defaultConstraints": "REFERENCES remote_asset_entity (id) ON DELETE CASCADE", + "dialectAwareDefaultConstraints": { + "sqlite": "REFERENCES remote_asset_entity (id) ON DELETE CASCADE" + }, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [ + { + "foreign_key": { + "to": { + "table": "remote_asset_entity", + "column": "id" + }, + "initially_deferred": false, + "on_update": null, + "on_delete": "cascade" + } + } + ] + }, + { + "name": "x1", + "getter_name": "x1", + "moor_type": "double", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "y1", + "getter_name": "y1", + "moor_type": "double", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "x2", + "getter_name": "x2", + "moor_type": "double", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "y2", + "getter_name": "y2", + "moor_type": "double", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "x3", + "getter_name": "x3", + "moor_type": "double", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "y3", + "getter_name": "y3", + "moor_type": "double", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "x4", + "getter_name": "x4", + "moor_type": "double", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "y4", + "getter_name": "y4", + "moor_type": "double", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "box_score", + "getter_name": "boxScore", + "moor_type": "double", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "text_score", + "getter_name": "textScore", + "moor_type": "double", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "recognized_text", + "getter_name": "recognizedText", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "is_visible", + "getter_name": "isVisible", + "moor_type": "bool", + "nullable": false, + "customConstraints": null, + "defaultConstraints": "CHECK (\"is_visible\" IN (0, 1))", + "dialectAwareDefaultConstraints": { + "sqlite": "CHECK (\"is_visible\" IN (0, 1))" + }, + "default_dart": "const CustomExpression('1')", + "default_client_dart": null, + "dsl_features": [] + } + ], + "is_virtual": false, + "without_rowid": true, + "constraints": [], + "strict": true, + "explicit_pk": [ + "id" + ] + } + }, + { + "id": 34, + "references": [], + "type": "table", + "data": { + "name": "session", + "was_declared_in_moor": false, + "columns": [ + { + "name": "key", + "getter_name": "key", + "moor_type": "string", + "nullable": false, + "customConstraints": null, + "default_dart": null, + "default_client_dart": null, + "dsl_features": [] + }, + { + "name": "value", + "getter_name": "value", + "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": [] + } + ], + "is_virtual": false, + "without_rowid": true, + "constraints": [], + "strict": true, + "explicit_pk": [ + "key" + ] + } + }, + { + "id": 35, + "references": [ + 20 + ], + "type": "index", + "data": { + "on": 20, + "name": "idx_partner_shared_with_id", + "sql": "CREATE INDEX IF NOT EXISTS idx_partner_shared_with_id ON partner_entity (shared_with_id)", + "unique": false, + "columns": [] + } + }, + { + "id": 36, + "references": [ + 21 + ], + "type": "index", + "data": { + "on": 21, + "name": "idx_lat_lng", + "sql": "CREATE INDEX IF NOT EXISTS idx_lat_lng ON remote_exif_entity (latitude, longitude)", + "unique": false, + "columns": [] + } + }, + { + "id": 37, + "references": [ + 21 + ], + "type": "index", + "data": { + "on": 21, + "name": "idx_remote_exif_city", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_exif_city\nON remote_exif_entity (city) WHERE city IS NOT NULL\n", + "unique": false, + "columns": [] + } + }, + { + "id": 38, + "references": [ + 22 + ], + "type": "index", + "data": { + "on": 22, + "name": "idx_remote_album_asset_album_asset", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_album_asset_album_asset ON remote_album_asset_entity (album_id, asset_id)", + "unique": false, + "columns": [] + } + }, + { + "id": 39, + "references": [ + 24 + ], + "type": "index", + "data": { + "on": 24, + "name": "idx_remote_asset_cloud_id", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_cloud_id ON remote_asset_cloud_id_entity (cloud_id)", + "unique": false, + "columns": [] + } + }, + { + "id": 40, + "references": [ + 27 + ], + "type": "index", + "data": { + "on": 27, + "name": "idx_person_owner_id", + "sql": "CREATE INDEX IF NOT EXISTS idx_person_owner_id ON person_entity (owner_id)", + "unique": false, + "columns": [] + } + }, + { + "id": 41, + "references": [ + 28 + ], + "type": "index", + "data": { + "on": 28, + "name": "idx_asset_face_person_id", + "sql": "CREATE INDEX IF NOT EXISTS idx_asset_face_person_id ON asset_face_entity (person_id)", + "unique": false, + "columns": [] + } + }, + { + "id": 42, + "references": [ + 28 + ], + "type": "index", + "data": { + "on": 28, + "name": "idx_asset_face_asset_id", + "sql": "CREATE INDEX IF NOT EXISTS idx_asset_face_asset_id ON asset_face_entity (asset_id)", + "unique": false, + "columns": [] + } + }, + { + "id": 43, + "references": [ + 28 + ], + "type": "index", + "data": { + "on": 28, + "name": "idx_asset_face_visible_person", + "sql": "CREATE INDEX IF NOT EXISTS idx_asset_face_visible_person\nON asset_face_entity (person_id, asset_id)\nWHERE is_visible = 1 AND deleted_at IS NULL\n", + "unique": false, + "columns": [] + } + }, + { + "id": 44, + "references": [ + 30 + ], + "type": "index", + "data": { + "on": 30, + "name": "idx_trashed_local_asset_checksum", + "sql": "CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_checksum ON trashed_local_asset_entity (checksum)", + "unique": false, + "columns": [] + } + }, + { + "id": 45, + "references": [ + 30 + ], + "type": "index", + "data": { + "on": 30, + "name": "idx_trashed_local_asset_album", + "sql": "CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_album ON trashed_local_asset_entity (album_id)", + "unique": false, + "columns": [] + } + }, + { + "id": 46, + "references": [ + 31 + ], + "type": "index", + "data": { + "on": 31, + "name": "idx_asset_edit_asset_id", + "sql": "CREATE INDEX IF NOT EXISTS idx_asset_edit_asset_id ON asset_edit_entity (asset_id)", + "unique": false, + "columns": [] + } + }, + { + "id": 47, + "references": [ + 33 + ], + "type": "index", + "data": { + "on": 33, + "name": "idx_asset_ocr_asset_id", + "sql": "CREATE INDEX IF NOT EXISTS idx_asset_ocr_asset_id ON asset_ocr_entity (asset_id)", + "unique": false, + "columns": [] + } + } + ], + "fixed_sql": [ + { + "name": "user_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"user_entity\" (\"id\" TEXT NOT NULL, \"name\" TEXT NOT NULL, \"email\" TEXT NOT NULL, \"has_profile_image\" INTEGER NOT NULL DEFAULT 0 CHECK (\"has_profile_image\" IN (0, 1)), \"profile_changed_at\" TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), \"avatar_color\" INTEGER NOT NULL DEFAULT 0, PRIMARY KEY (\"id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "remote_asset_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"remote_asset_entity\" (\"name\" TEXT NOT NULL, \"type\" INTEGER NOT NULL, \"created_at\" TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), \"updated_at\" TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), \"width\" INTEGER NULL, \"height\" INTEGER NULL, \"duration_ms\" INTEGER NULL, \"id\" TEXT NOT NULL, \"checksum\" TEXT NOT NULL, \"is_favorite\" INTEGER NOT NULL DEFAULT 0 CHECK (\"is_favorite\" IN (0, 1)), \"owner_id\" TEXT NOT NULL REFERENCES user_entity (id) ON DELETE CASCADE, \"local_date_time\" TEXT NULL, \"thumb_hash\" TEXT NULL, \"deleted_at\" TEXT NULL, \"uploaded_at\" TEXT NULL, \"live_photo_video_id\" TEXT NULL, \"visibility\" INTEGER NOT NULL, \"stack_id\" TEXT NULL, \"library_id\" TEXT NULL, \"is_edited\" INTEGER NOT NULL DEFAULT 0 CHECK (\"is_edited\" IN (0, 1)), PRIMARY KEY (\"id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "stack_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"stack_entity\" (\"id\" TEXT NOT NULL, \"created_at\" TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), \"updated_at\" TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), \"owner_id\" TEXT NOT NULL REFERENCES user_entity (id) ON DELETE CASCADE, \"primary_asset_id\" TEXT NOT NULL, PRIMARY KEY (\"id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "local_asset_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"local_asset_entity\" (\"name\" TEXT NOT NULL, \"type\" INTEGER NOT NULL, \"created_at\" TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), \"updated_at\" TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), \"width\" INTEGER NULL, \"height\" INTEGER NULL, \"duration_ms\" INTEGER NULL, \"id\" TEXT NOT NULL, \"checksum\" TEXT NULL, \"is_favorite\" INTEGER NOT NULL DEFAULT 0 CHECK (\"is_favorite\" IN (0, 1)), \"orientation\" INTEGER NOT NULL DEFAULT 0, \"i_cloud_id\" TEXT NULL, \"adjustment_time\" TEXT NULL, \"latitude\" REAL NULL, \"longitude\" REAL NULL, \"playback_style\" INTEGER NOT NULL DEFAULT 0, PRIMARY KEY (\"id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "remote_album_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"remote_album_entity\" (\"id\" TEXT NOT NULL, \"name\" TEXT NOT NULL, \"description\" TEXT NOT NULL DEFAULT '', \"created_at\" TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), \"updated_at\" TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), \"thumbnail_asset_id\" TEXT NULL REFERENCES remote_asset_entity (id) ON DELETE SET NULL, \"is_activity_enabled\" INTEGER NOT NULL DEFAULT 1 CHECK (\"is_activity_enabled\" IN (0, 1)), \"order\" INTEGER NOT NULL, PRIMARY KEY (\"id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "local_album_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"local_album_entity\" (\"id\" TEXT NOT NULL, \"name\" TEXT NOT NULL, \"updated_at\" TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), \"backup_selection\" INTEGER NOT NULL, \"is_ios_shared_album\" INTEGER NOT NULL DEFAULT 0 CHECK (\"is_ios_shared_album\" IN (0, 1)), \"linked_remote_album_id\" TEXT NULL REFERENCES remote_album_entity (id) ON DELETE SET NULL, \"marker\" INTEGER NULL CHECK (\"marker\" IN (0, 1)), PRIMARY KEY (\"id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "local_album_asset_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"local_album_asset_entity\" (\"asset_id\" TEXT NOT NULL REFERENCES local_asset_entity (id) ON DELETE CASCADE, \"album_id\" TEXT NOT NULL REFERENCES local_album_entity (id) ON DELETE CASCADE, \"marker\" INTEGER NULL CHECK (\"marker\" IN (0, 1)), PRIMARY KEY (\"asset_id\", \"album_id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "idx_local_album_asset_album_asset", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_local_album_asset_album_asset ON local_album_asset_entity (album_id, asset_id)" + } + ] + }, + { + "name": "idx_local_asset_checksum", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_local_asset_checksum ON local_asset_entity (checksum)" + } + ] + }, + { + "name": "idx_local_asset_cloud_id", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_local_asset_cloud_id ON local_asset_entity (i_cloud_id)" + } + ] + }, + { + "name": "idx_local_asset_created_at", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_local_asset_created_at ON local_asset_entity (created_at)" + } + ] + }, + { + "name": "idx_stack_primary_asset_id", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_stack_primary_asset_id ON stack_entity (primary_asset_id)" + } + ] + }, + { + "name": "UQ_remote_assets_owner_checksum", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_checksum ON remote_asset_entity (owner_id, checksum) WHERE(library_id IS NULL)" + } + ] + }, + { + "name": "UQ_remote_assets_owner_library_checksum", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_library_checksum ON remote_asset_entity (owner_id, library_id, checksum) WHERE(library_id IS NOT NULL)" + } + ] + }, + { + "name": "idx_remote_asset_checksum", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_checksum ON remote_asset_entity (checksum)" + } + ] + }, + { + "name": "idx_remote_asset_stack_id", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_stack_id ON remote_asset_entity (stack_id)" + } + ] + }, + { + "name": "idx_remote_asset_owner_visibility_deleted_created", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_visibility_deleted_created ON remote_asset_entity (owner_id, visibility, deleted_at, created_at DESC)" + } + ] + }, + { + "name": "idx_remote_asset_uploaded", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_uploaded ON remote_asset_entity (uploaded_at)" + } + ] + }, + { + "name": "auth_user_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"auth_user_entity\" (\"id\" TEXT NOT NULL, \"name\" TEXT NOT NULL, \"email\" TEXT NOT NULL, \"is_admin\" INTEGER NOT NULL DEFAULT 0 CHECK (\"is_admin\" IN (0, 1)), \"has_profile_image\" INTEGER NOT NULL DEFAULT 0 CHECK (\"has_profile_image\" IN (0, 1)), \"profile_changed_at\" TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), \"avatar_color\" INTEGER NOT NULL, \"quota_size_in_bytes\" INTEGER NOT NULL DEFAULT 0, \"quota_usage_in_bytes\" INTEGER NOT NULL DEFAULT 0, \"pin_code\" TEXT NULL, PRIMARY KEY (\"id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "user_metadata_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"user_metadata_entity\" (\"user_id\" TEXT NOT NULL REFERENCES user_entity (id) ON DELETE CASCADE, \"key\" INTEGER NOT NULL, \"value\" BLOB NOT NULL, PRIMARY KEY (\"user_id\", \"key\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "partner_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"partner_entity\" (\"shared_by_id\" TEXT NOT NULL REFERENCES user_entity (id) ON DELETE CASCADE, \"shared_with_id\" TEXT NOT NULL REFERENCES user_entity (id) ON DELETE CASCADE, \"in_timeline\" INTEGER NOT NULL DEFAULT 0 CHECK (\"in_timeline\" IN (0, 1)), PRIMARY KEY (\"shared_by_id\", \"shared_with_id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "remote_exif_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"remote_exif_entity\" (\"asset_id\" TEXT NOT NULL REFERENCES remote_asset_entity (id) ON DELETE CASCADE, \"city\" TEXT NULL, \"state\" TEXT NULL, \"country\" TEXT NULL, \"date_time_original\" TEXT NULL, \"description\" TEXT NULL, \"height\" INTEGER NULL, \"width\" INTEGER NULL, \"exposure_time\" TEXT NULL, \"f_number\" REAL NULL, \"file_size\" INTEGER NULL, \"focal_length\" REAL NULL, \"latitude\" REAL NULL, \"longitude\" REAL NULL, \"iso\" INTEGER NULL, \"make\" TEXT NULL, \"model\" TEXT NULL, \"lens\" TEXT NULL, \"orientation\" TEXT NULL, \"time_zone\" TEXT NULL, \"rating\" INTEGER NULL, \"projection_type\" TEXT NULL, PRIMARY KEY (\"asset_id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "remote_album_asset_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"remote_album_asset_entity\" (\"asset_id\" TEXT NOT NULL REFERENCES remote_asset_entity (id) ON DELETE CASCADE, \"album_id\" TEXT NOT NULL REFERENCES remote_album_entity (id) ON DELETE CASCADE, PRIMARY KEY (\"asset_id\", \"album_id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "remote_album_user_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"remote_album_user_entity\" (\"album_id\" TEXT NOT NULL REFERENCES remote_album_entity (id) ON DELETE CASCADE, \"user_id\" TEXT NOT NULL REFERENCES user_entity (id) ON DELETE CASCADE, \"role\" INTEGER NOT NULL, PRIMARY KEY (\"album_id\", \"user_id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "remote_asset_cloud_id_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"remote_asset_cloud_id_entity\" (\"asset_id\" TEXT NOT NULL REFERENCES remote_asset_entity (id) ON DELETE CASCADE, \"cloud_id\" TEXT NULL, \"created_at\" TEXT NULL, \"adjustment_time\" TEXT NULL, \"latitude\" REAL NULL, \"longitude\" REAL NULL, PRIMARY KEY (\"asset_id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "memory_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"memory_entity\" (\"id\" TEXT NOT NULL, \"created_at\" TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), \"updated_at\" TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), \"deleted_at\" TEXT NULL, \"owner_id\" TEXT NOT NULL REFERENCES user_entity (id) ON DELETE CASCADE, \"type\" INTEGER NOT NULL, \"data\" TEXT NOT NULL, \"is_saved\" INTEGER NOT NULL DEFAULT 0 CHECK (\"is_saved\" IN (0, 1)), \"memory_at\" TEXT NOT NULL, \"seen_at\" TEXT NULL, \"show_at\" TEXT NULL, \"hide_at\" TEXT NULL, PRIMARY KEY (\"id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "memory_asset_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"memory_asset_entity\" (\"asset_id\" TEXT NOT NULL REFERENCES remote_asset_entity (id) ON DELETE CASCADE, \"memory_id\" TEXT NOT NULL REFERENCES memory_entity (id) ON DELETE CASCADE, PRIMARY KEY (\"asset_id\", \"memory_id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "person_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"person_entity\" (\"id\" TEXT NOT NULL, \"created_at\" TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), \"updated_at\" TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), \"owner_id\" TEXT NOT NULL REFERENCES user_entity (id) ON DELETE CASCADE, \"name\" TEXT NOT NULL, \"face_asset_id\" TEXT NULL, \"is_favorite\" INTEGER NOT NULL CHECK (\"is_favorite\" IN (0, 1)), \"is_hidden\" INTEGER NOT NULL CHECK (\"is_hidden\" IN (0, 1)), \"color\" TEXT NULL, \"birth_date\" TEXT NULL, PRIMARY KEY (\"id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "asset_face_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"asset_face_entity\" (\"id\" TEXT NOT NULL, \"asset_id\" TEXT NOT NULL REFERENCES remote_asset_entity (id) ON DELETE CASCADE, \"person_id\" TEXT NULL REFERENCES person_entity (id) ON DELETE SET NULL, \"image_width\" INTEGER NOT NULL, \"image_height\" INTEGER NOT NULL, \"bounding_box_x1\" INTEGER NOT NULL, \"bounding_box_y1\" INTEGER NOT NULL, \"bounding_box_x2\" INTEGER NOT NULL, \"bounding_box_y2\" INTEGER NOT NULL, \"source_type\" TEXT NOT NULL, \"is_visible\" INTEGER NOT NULL DEFAULT 1 CHECK (\"is_visible\" IN (0, 1)), \"deleted_at\" TEXT NULL, PRIMARY KEY (\"id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "store_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"store_entity\" (\"id\" INTEGER NOT NULL, \"string_value\" TEXT NULL, \"int_value\" INTEGER NULL, PRIMARY KEY (\"id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "trashed_local_asset_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"trashed_local_asset_entity\" (\"name\" TEXT NOT NULL, \"type\" INTEGER NOT NULL, \"created_at\" TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), \"updated_at\" TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), \"width\" INTEGER NULL, \"height\" INTEGER NULL, \"duration_ms\" INTEGER NULL, \"id\" TEXT NOT NULL, \"album_id\" TEXT NOT NULL, \"checksum\" TEXT NULL, \"is_favorite\" INTEGER NOT NULL DEFAULT 0 CHECK (\"is_favorite\" IN (0, 1)), \"orientation\" INTEGER NOT NULL DEFAULT 0, \"source\" INTEGER NOT NULL, \"playback_style\" INTEGER NOT NULL DEFAULT 0, PRIMARY KEY (\"id\", \"album_id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "asset_edit_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"asset_edit_entity\" (\"id\" TEXT NOT NULL, \"asset_id\" TEXT NOT NULL REFERENCES remote_asset_entity (id) ON DELETE CASCADE, \"action\" INTEGER NOT NULL, \"parameters\" BLOB NOT NULL, \"sequence\" INTEGER NOT NULL, PRIMARY KEY (\"id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "settings", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"settings\" (\"key\" TEXT NOT NULL, \"value\" TEXT NULL, \"updated_at\" TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), PRIMARY KEY (\"key\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "asset_ocr_entity", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"asset_ocr_entity\" (\"id\" TEXT NOT NULL, \"asset_id\" TEXT NOT NULL REFERENCES remote_asset_entity (id) ON DELETE CASCADE, \"x1\" REAL NOT NULL, \"y1\" REAL NOT NULL, \"x2\" REAL NOT NULL, \"y2\" REAL NOT NULL, \"x3\" REAL NOT NULL, \"y3\" REAL NOT NULL, \"x4\" REAL NOT NULL, \"y4\" REAL NOT NULL, \"box_score\" REAL NOT NULL, \"text_score\" REAL NOT NULL, \"recognized_text\" TEXT NOT NULL, \"is_visible\" INTEGER NOT NULL DEFAULT 1 CHECK (\"is_visible\" IN (0, 1)), PRIMARY KEY (\"id\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "session", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE TABLE IF NOT EXISTS \"session\" (\"key\" TEXT NOT NULL, \"value\" TEXT NULL, \"updated_at\" TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP), PRIMARY KEY (\"key\")) WITHOUT ROWID, STRICT;" + } + ] + }, + { + "name": "idx_partner_shared_with_id", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_partner_shared_with_id ON partner_entity (shared_with_id)" + } + ] + }, + { + "name": "idx_lat_lng", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_lat_lng ON remote_exif_entity (latitude, longitude)" + } + ] + }, + { + "name": "idx_remote_exif_city", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_exif_city ON remote_exif_entity (city) WHERE city IS NOT NULL" + } + ] + }, + { + "name": "idx_remote_album_asset_album_asset", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_album_asset_album_asset ON remote_album_asset_entity (album_id, asset_id)" + } + ] + }, + { + "name": "idx_remote_asset_cloud_id", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_remote_asset_cloud_id ON remote_asset_cloud_id_entity (cloud_id)" + } + ] + }, + { + "name": "idx_person_owner_id", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_person_owner_id ON person_entity (owner_id)" + } + ] + }, + { + "name": "idx_asset_face_person_id", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_asset_face_person_id ON asset_face_entity (person_id)" + } + ] + }, + { + "name": "idx_asset_face_asset_id", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_asset_face_asset_id ON asset_face_entity (asset_id)" + } + ] + }, + { + "name": "idx_asset_face_visible_person", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_asset_face_visible_person ON asset_face_entity (person_id, asset_id) WHERE is_visible = 1 AND deleted_at IS NULL" + } + ] + }, + { + "name": "idx_trashed_local_asset_checksum", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_checksum ON trashed_local_asset_entity (checksum)" + } + ] + }, + { + "name": "idx_trashed_local_asset_album", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_album ON trashed_local_asset_entity (album_id)" + } + ] + }, + { + "name": "idx_asset_edit_asset_id", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_asset_edit_asset_id ON asset_edit_entity (asset_id)" + } + ] + }, + { + "name": "idx_asset_ocr_asset_id", + "sql": [ + { + "dialect": "sqlite", + "sql": "CREATE INDEX IF NOT EXISTS idx_asset_ocr_asset_id ON asset_ocr_entity (asset_id)" + } + ] + } + ] +} \ No newline at end of file diff --git a/mobile/lib/infrastructure/repositories/db.repository.dart b/mobile/lib/infrastructure/repositories/db.repository.dart index b54237597e..a2ccc88d22 100644 --- a/mobile/lib/infrastructure/repositories/db.repository.dart +++ b/mobile/lib/infrastructure/repositories/db.repository.dart @@ -122,7 +122,7 @@ class Drift extends $Drift { } @override - int get schemaVersion => 31; + int get schemaVersion => 32; @override MigrationStrategy get migration => MigrationStrategy( @@ -274,52 +274,59 @@ class Drift extends $Drift { v23.trashedLocalAssetEntity.durationMs, ); - await localAssetEntity.update().write( - LocalAssetEntityCompanion.custom(durationMs: v23.localAssetEntity.durationMs * const Constant(1000)), - ); - await remoteAssetEntity.update().write( - RemoteAssetEntityCompanion.custom(durationMs: v23.remoteAssetEntity.durationMs * const Constant(1000)), - ); - await trashedLocalAssetEntity.update().write( - TrashedLocalAssetEntityCompanion.custom( - durationMs: v23.trashedLocalAssetEntity.durationMs * const Constant(1000), - ), - ); - }, - from23To24: (m, v24) async { - await customStatement('DROP INDEX IF EXISTS idx_remote_album_owner_id'); - await m.alterTable(TableMigration(v24.remoteAlbumEntity)); - }, - from24To25: (m, v25) async { - await m.createTable(v25.metadata); - await customStatement('DROP INDEX IF EXISTS idx_remote_asset_owner_checksum'); - await customStatement('DROP INDEX IF EXISTS idx_remote_asset_local_date_time_day'); - await customStatement('DROP INDEX IF EXISTS idx_remote_asset_local_date_time_month'); - await m.createIndex(v25.idxRemoteAssetOwnerVisibilityDeletedCreated); - await m.createIndex(v25.idxRemoteExifCity); - await m.createIndex(v25.idxAssetFaceVisiblePerson); - }, - from25To26: (m, v26) async { - await m.addColumn(v26.remoteAssetEntity, v26.remoteAssetEntity.uploadedAt); - }, - from26To27: (m, v27) async { - await customStatement('ALTER TABLE metadata RENAME TO settings'); - }, - from27To28: (m, v28) async { - await m.createIndex(v28.idxLocalAssetCreatedAt); - }, - from28To29: (m, v29) async { - await m.createTable(v29.assetOcrEntity); - await m.createIndex(v29.idxAssetOcrAssetId); - }, - from29To30: (m, v30) async { - await m.alterTable(TableMigration(v30.settings)); - }, - from30To31: (m, v31) async { - await m.createTable(v31.session); - }, - ), - ); + await localAssetEntity.update().write( + LocalAssetEntityCompanion.custom(durationMs: v23.localAssetEntity.durationMs * const Constant(1000)), + ); + await remoteAssetEntity.update().write( + RemoteAssetEntityCompanion.custom( + durationMs: v23.remoteAssetEntity.durationMs * const Constant(1000), + ), + ); + await trashedLocalAssetEntity.update().write( + TrashedLocalAssetEntityCompanion.custom( + durationMs: v23.trashedLocalAssetEntity.durationMs * const Constant(1000), + ), + ); + }, + from23To24: (m, v24) async { + await customStatement('DROP INDEX IF EXISTS idx_remote_album_owner_id'); + await m.alterTable(TableMigration(v24.remoteAlbumEntity)); + }, + from24To25: (m, v25) async { + await m.createTable(v25.metadata); + await customStatement('DROP INDEX IF EXISTS idx_remote_asset_owner_checksum'); + await customStatement('DROP INDEX IF EXISTS idx_remote_asset_local_date_time_day'); + await customStatement('DROP INDEX IF EXISTS idx_remote_asset_local_date_time_month'); + await m.createIndex(v25.idxRemoteAssetOwnerVisibilityDeletedCreated); + await m.createIndex(v25.idxRemoteExifCity); + await m.createIndex(v25.idxAssetFaceVisiblePerson); + }, + from25To26: (m, v26) async { + await m.addColumn(v26.remoteAssetEntity, v26.remoteAssetEntity.uploadedAt); + }, + from26To27: (m, v27) async { + await customStatement('ALTER TABLE metadata RENAME TO settings'); + }, + from27To28: (m, v28) async { + await m.createIndex(v28.idxLocalAssetCreatedAt); + }, + from28To29: (m, v29) async { + await m.createTable(v29.assetOcrEntity); + await m.createIndex(v29.idxAssetOcrAssetId); + }, + from29To30: (m, v30) async { + await m.alterTable(TableMigration(v30.settings)); + }, + from30To31: (m, v31) async { + await m.createIndex(v31.idxRemoteAssetUploaded); + // await m.createTable(v31.session); + }, + from31To32: (m, v32) async { + await m.createTable(v32.session); + }, + ), + ), + ); if (kDebugMode) { // Fail if the migration broke foreign keys diff --git a/mobile/lib/infrastructure/repositories/db.repository.drift.dart b/mobile/lib/infrastructure/repositories/db.repository.drift.dart index a5996716ed..5348036c0b 100644 --- a/mobile/lib/infrastructure/repositories/db.repository.drift.dart +++ b/mobile/lib/infrastructure/repositories/db.repository.drift.dart @@ -47,9 +47,11 @@ import 'package:immich_mobile/infrastructure/entities/settings.entity.drift.dart as i22; import 'package:immich_mobile/infrastructure/entities/asset_ocr.entity.drift.dart' as i23; -import 'package:immich_mobile/infrastructure/entities/merged_asset.drift.dart' +import 'package:immich_mobile/infrastructure/entities/session.entity.drift.dart' as i24; -import 'package:drift/internal/modular.dart' as i25; +import 'package:immich_mobile/infrastructure/entities/merged_asset.drift.dart' + as i25; +import 'package:drift/internal/modular.dart' as i26; abstract class $Drift extends i0.GeneratedDatabase { $Drift(i0.QueryExecutor e) : super(e); @@ -99,9 +101,12 @@ abstract class $Drift extends i0.GeneratedDatabase { late final i23.$AssetOcrEntityTable assetOcrEntity = i23.$AssetOcrEntityTable( this, ); - i24.MergedAssetDrift get mergedAssetDrift => i25.ReadDatabaseContainer( + late final i24.$SessionEntityTable sessionEntity = i24.$SessionEntityTable( this, - ).accessor(i24.MergedAssetDrift.new); + ); + i25.MergedAssetDrift get mergedAssetDrift => i26.ReadDatabaseContainer( + this, + ).accessor(i25.MergedAssetDrift.new); @override Iterable> get allTables => allSchemaEntities.whereType>(); @@ -141,6 +146,7 @@ abstract class $Drift extends i0.GeneratedDatabase { assetEditEntity, settingsEntity, assetOcrEntity, + sessionEntity, i10.idxPartnerSharedWithId, i11.idxLatLng, i11.idxRemoteExifCity, @@ -415,4 +421,6 @@ class $DriftManager { i22.$$SettingsEntityTableTableManager(_db, _db.settingsEntity); i23.$$AssetOcrEntityTableTableManager get assetOcrEntity => i23.$$AssetOcrEntityTableTableManager(_db, _db.assetOcrEntity); + i24.$$SessionEntityTableTableManager get sessionEntity => + i24.$$SessionEntityTableTableManager(_db, _db.sessionEntity); } diff --git a/mobile/lib/infrastructure/repositories/db.repository.steps.dart b/mobile/lib/infrastructure/repositories/db.repository.steps.dart index 39f9c2ea04..8104ba04c8 100644 --- a/mobile/lib/infrastructure/repositories/db.repository.steps.dart +++ b/mobile/lib/infrastructure/repositories/db.repository.steps.dart @@ -16506,6 +16506,603 @@ final class Schema31 extends i0.VersionedSchema { ); } +final class Schema32 extends i0.VersionedSchema { + Schema32({required super.database}) : super(version: 32); + @override + late final List entities = [ + userEntity, + remoteAssetEntity, + stackEntity, + localAssetEntity, + remoteAlbumEntity, + localAlbumEntity, + localAlbumAssetEntity, + idxLocalAlbumAssetAlbumAsset, + idxLocalAssetChecksum, + idxLocalAssetCloudId, + idxLocalAssetCreatedAt, + idxStackPrimaryAssetId, + uQRemoteAssetsOwnerChecksum, + uQRemoteAssetsOwnerLibraryChecksum, + idxRemoteAssetChecksum, + idxRemoteAssetStackId, + idxRemoteAssetOwnerVisibilityDeletedCreated, + idxRemoteAssetUploaded, + authUserEntity, + userMetadataEntity, + partnerEntity, + remoteExifEntity, + remoteAlbumAssetEntity, + remoteAlbumUserEntity, + remoteAssetCloudIdEntity, + memoryEntity, + memoryAssetEntity, + personEntity, + assetFaceEntity, + storeEntity, + trashedLocalAssetEntity, + assetEditEntity, + settings, + assetOcrEntity, + session, + idxPartnerSharedWithId, + idxLatLng, + idxRemoteExifCity, + idxRemoteAlbumAssetAlbumAsset, + idxRemoteAssetCloudId, + idxPersonOwnerId, + idxAssetFacePersonId, + idxAssetFaceAssetId, + idxAssetFaceVisiblePerson, + idxTrashedLocalAssetChecksum, + idxTrashedLocalAssetAlbum, + idxAssetEditAssetId, + idxAssetOcrAssetId, + ]; + late final Shape33 userEntity = Shape33( + source: i0.VersionedTable( + entityName: 'user_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(id)'], + columns: [ + _column_107, + _column_108, + _column_109, + _column_110, + _column_111, + _column_112, + ], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape50 remoteAssetEntity = Shape50( + source: i0.VersionedTable( + entityName: 'remote_asset_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(id)'], + columns: [ + _column_108, + _column_113, + _column_114, + _column_115, + _column_116, + _column_117, + _column_118, + _column_107, + _column_119, + _column_120, + _column_121, + _column_122, + _column_123, + _column_124, + _column_212, + _column_125, + _column_126, + _column_127, + _column_128, + _column_129, + ], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape35 stackEntity = Shape35( + source: i0.VersionedTable( + entityName: 'stack_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(id)'], + columns: [ + _column_107, + _column_114, + _column_115, + _column_121, + _column_130, + ], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape36 localAssetEntity = Shape36( + source: i0.VersionedTable( + entityName: 'local_asset_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(id)'], + columns: [ + _column_108, + _column_113, + _column_114, + _column_115, + _column_116, + _column_117, + _column_118, + _column_107, + _column_131, + _column_120, + _column_132, + _column_133, + _column_134, + _column_135, + _column_136, + _column_137, + ], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape48 remoteAlbumEntity = Shape48( + source: i0.VersionedTable( + entityName: 'remote_album_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(id)'], + columns: [ + _column_107, + _column_108, + _column_138, + _column_114, + _column_115, + _column_139, + _column_140, + _column_141, + ], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape38 localAlbumEntity = Shape38( + source: i0.VersionedTable( + entityName: 'local_album_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(id)'], + columns: [ + _column_107, + _column_108, + _column_115, + _column_142, + _column_143, + _column_144, + _column_145, + ], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape39 localAlbumAssetEntity = Shape39( + source: i0.VersionedTable( + entityName: 'local_album_asset_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(asset_id, album_id)'], + columns: [_column_146, _column_147, _column_145], + attachedDatabase: database, + ), + alias: null, + ); + final i1.Index idxLocalAlbumAssetAlbumAsset = i1.Index( + 'idx_local_album_asset_album_asset', + 'CREATE INDEX IF NOT EXISTS idx_local_album_asset_album_asset ON local_album_asset_entity (album_id, asset_id)', + ); + final i1.Index idxLocalAssetChecksum = i1.Index( + 'idx_local_asset_checksum', + 'CREATE INDEX IF NOT EXISTS idx_local_asset_checksum ON local_asset_entity (checksum)', + ); + final i1.Index idxLocalAssetCloudId = i1.Index( + 'idx_local_asset_cloud_id', + 'CREATE INDEX IF NOT EXISTS idx_local_asset_cloud_id ON local_asset_entity (i_cloud_id)', + ); + final i1.Index idxLocalAssetCreatedAt = i1.Index( + 'idx_local_asset_created_at', + 'CREATE INDEX IF NOT EXISTS idx_local_asset_created_at ON local_asset_entity (created_at)', + ); + final i1.Index idxStackPrimaryAssetId = i1.Index( + 'idx_stack_primary_asset_id', + 'CREATE INDEX IF NOT EXISTS idx_stack_primary_asset_id ON stack_entity (primary_asset_id)', + ); + final i1.Index uQRemoteAssetsOwnerChecksum = i1.Index( + 'UQ_remote_assets_owner_checksum', + 'CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_checksum ON remote_asset_entity (owner_id, checksum) WHERE(library_id IS NULL)', + ); + final i1.Index uQRemoteAssetsOwnerLibraryChecksum = i1.Index( + 'UQ_remote_assets_owner_library_checksum', + 'CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_library_checksum ON remote_asset_entity (owner_id, library_id, checksum) WHERE(library_id IS NOT NULL)', + ); + final i1.Index idxRemoteAssetChecksum = i1.Index( + 'idx_remote_asset_checksum', + 'CREATE INDEX IF NOT EXISTS idx_remote_asset_checksum ON remote_asset_entity (checksum)', + ); + final i1.Index idxRemoteAssetStackId = i1.Index( + 'idx_remote_asset_stack_id', + 'CREATE INDEX IF NOT EXISTS idx_remote_asset_stack_id ON remote_asset_entity (stack_id)', + ); + final i1.Index idxRemoteAssetOwnerVisibilityDeletedCreated = i1.Index( + 'idx_remote_asset_owner_visibility_deleted_created', + 'CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_visibility_deleted_created ON remote_asset_entity (owner_id, visibility, deleted_at, created_at DESC)', + ); + final i1.Index idxRemoteAssetUploaded = i1.Index( + 'idx_remote_asset_uploaded', + 'CREATE INDEX IF NOT EXISTS idx_remote_asset_uploaded ON remote_asset_entity (uploaded_at)', + ); + late final Shape40 authUserEntity = Shape40( + source: i0.VersionedTable( + entityName: 'auth_user_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(id)'], + columns: [ + _column_107, + _column_108, + _column_109, + _column_148, + _column_110, + _column_111, + _column_149, + _column_150, + _column_151, + _column_152, + ], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape4 userMetadataEntity = Shape4( + source: i0.VersionedTable( + entityName: 'user_metadata_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(user_id, "key")'], + columns: [_column_153, _column_154, _column_155], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape41 partnerEntity = Shape41( + source: i0.VersionedTable( + entityName: 'partner_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(shared_by_id, shared_with_id)'], + columns: [_column_156, _column_157, _column_158], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape42 remoteExifEntity = Shape42( + source: i0.VersionedTable( + entityName: 'remote_exif_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(asset_id)'], + columns: [ + _column_159, + _column_160, + _column_161, + _column_162, + _column_163, + _column_164, + _column_117, + _column_116, + _column_165, + _column_166, + _column_167, + _column_168, + _column_135, + _column_136, + _column_169, + _column_170, + _column_171, + _column_172, + _column_173, + _column_174, + _column_175, + _column_176, + ], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape7 remoteAlbumAssetEntity = Shape7( + source: i0.VersionedTable( + entityName: 'remote_album_asset_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(asset_id, album_id)'], + columns: [_column_159, _column_177], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape10 remoteAlbumUserEntity = Shape10( + source: i0.VersionedTable( + entityName: 'remote_album_user_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(album_id, user_id)'], + columns: [_column_177, _column_153, _column_178], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape43 remoteAssetCloudIdEntity = Shape43( + source: i0.VersionedTable( + entityName: 'remote_asset_cloud_id_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(asset_id)'], + columns: [ + _column_159, + _column_179, + _column_180, + _column_134, + _column_135, + _column_136, + ], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape44 memoryEntity = Shape44( + source: i0.VersionedTable( + entityName: 'memory_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(id)'], + columns: [ + _column_107, + _column_114, + _column_115, + _column_124, + _column_121, + _column_113, + _column_181, + _column_182, + _column_183, + _column_184, + _column_185, + _column_186, + ], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape12 memoryAssetEntity = Shape12( + source: i0.VersionedTable( + entityName: 'memory_asset_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(asset_id, memory_id)'], + columns: [_column_159, _column_187], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape45 personEntity = Shape45( + source: i0.VersionedTable( + entityName: 'person_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(id)'], + columns: [ + _column_107, + _column_114, + _column_115, + _column_121, + _column_108, + _column_188, + _column_189, + _column_190, + _column_191, + _column_192, + ], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape46 assetFaceEntity = Shape46( + source: i0.VersionedTable( + entityName: 'asset_face_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(id)'], + columns: [ + _column_107, + _column_159, + _column_193, + _column_194, + _column_195, + _column_196, + _column_197, + _column_198, + _column_199, + _column_200, + _column_201, + _column_124, + ], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape18 storeEntity = Shape18( + source: i0.VersionedTable( + entityName: 'store_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(id)'], + columns: [_column_202, _column_203, _column_204], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape47 trashedLocalAssetEntity = Shape47( + source: i0.VersionedTable( + entityName: 'trashed_local_asset_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(id, album_id)'], + columns: [ + _column_108, + _column_113, + _column_114, + _column_115, + _column_116, + _column_117, + _column_118, + _column_107, + _column_205, + _column_131, + _column_120, + _column_132, + _column_206, + _column_137, + ], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape32 assetEditEntity = Shape32( + source: i0.VersionedTable( + entityName: 'asset_edit_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(id)'], + columns: [ + _column_107, + _column_159, + _column_207, + _column_208, + _column_209, + ], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape49 settings = Shape49( + source: i0.VersionedTable( + entityName: 'settings', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY("key")'], + columns: [_column_210, _column_224, _column_115], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape51 assetOcrEntity = Shape51( + source: i0.VersionedTable( + entityName: 'asset_ocr_entity', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY(id)'], + columns: [ + _column_107, + _column_159, + _column_213, + _column_214, + _column_215, + _column_216, + _column_217, + _column_218, + _column_219, + _column_220, + _column_221, + _column_222, + _column_223, + _column_201, + ], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape49 session = Shape49( + source: i0.VersionedTable( + entityName: 'session', + withoutRowId: true, + isStrict: true, + tableConstraints: ['PRIMARY KEY("key")'], + columns: [_column_210, _column_224, _column_115], + attachedDatabase: database, + ), + alias: null, + ); + final i1.Index idxPartnerSharedWithId = i1.Index( + 'idx_partner_shared_with_id', + 'CREATE INDEX IF NOT EXISTS idx_partner_shared_with_id ON partner_entity (shared_with_id)', + ); + final i1.Index idxLatLng = i1.Index( + 'idx_lat_lng', + 'CREATE INDEX IF NOT EXISTS idx_lat_lng ON remote_exif_entity (latitude, longitude)', + ); + final i1.Index idxRemoteExifCity = i1.Index( + 'idx_remote_exif_city', + 'CREATE INDEX IF NOT EXISTS idx_remote_exif_city ON remote_exif_entity (city) WHERE city IS NOT NULL', + ); + final i1.Index idxRemoteAlbumAssetAlbumAsset = i1.Index( + 'idx_remote_album_asset_album_asset', + 'CREATE INDEX IF NOT EXISTS idx_remote_album_asset_album_asset ON remote_album_asset_entity (album_id, asset_id)', + ); + final i1.Index idxRemoteAssetCloudId = i1.Index( + 'idx_remote_asset_cloud_id', + 'CREATE INDEX IF NOT EXISTS idx_remote_asset_cloud_id ON remote_asset_cloud_id_entity (cloud_id)', + ); + final i1.Index idxPersonOwnerId = i1.Index( + 'idx_person_owner_id', + 'CREATE INDEX IF NOT EXISTS idx_person_owner_id ON person_entity (owner_id)', + ); + final i1.Index idxAssetFacePersonId = i1.Index( + 'idx_asset_face_person_id', + 'CREATE INDEX IF NOT EXISTS idx_asset_face_person_id ON asset_face_entity (person_id)', + ); + final i1.Index idxAssetFaceAssetId = i1.Index( + 'idx_asset_face_asset_id', + 'CREATE INDEX IF NOT EXISTS idx_asset_face_asset_id ON asset_face_entity (asset_id)', + ); + final i1.Index idxAssetFaceVisiblePerson = i1.Index( + 'idx_asset_face_visible_person', + 'CREATE INDEX IF NOT EXISTS idx_asset_face_visible_person ON asset_face_entity (person_id, asset_id) WHERE is_visible = 1 AND deleted_at IS NULL', + ); + final i1.Index idxTrashedLocalAssetChecksum = i1.Index( + 'idx_trashed_local_asset_checksum', + 'CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_checksum ON trashed_local_asset_entity (checksum)', + ); + final i1.Index idxTrashedLocalAssetAlbum = i1.Index( + 'idx_trashed_local_asset_album', + 'CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_album ON trashed_local_asset_entity (album_id)', + ); + final i1.Index idxAssetEditAssetId = i1.Index( + 'idx_asset_edit_asset_id', + 'CREATE INDEX IF NOT EXISTS idx_asset_edit_asset_id ON asset_edit_entity (asset_id)', + ); + final i1.Index idxAssetOcrAssetId = i1.Index( + 'idx_asset_ocr_asset_id', + 'CREATE INDEX IF NOT EXISTS idx_asset_ocr_asset_id ON asset_ocr_entity (asset_id)', + ); +} + i0.MigrationStepWithVersion migrationSteps({ required Future Function(i1.Migrator m, Schema2 schema) from1To2, required Future Function(i1.Migrator m, Schema3 schema) from2To3, @@ -16537,6 +17134,7 @@ i0.MigrationStepWithVersion migrationSteps({ required Future Function(i1.Migrator m, Schema29 schema) from28To29, required Future Function(i1.Migrator m, Schema30 schema) from29To30, required Future Function(i1.Migrator m, Schema31 schema) from30To31, + required Future Function(i1.Migrator m, Schema32 schema) from31To32, }) { return (currentVersion, database) async { switch (currentVersion) { @@ -16690,6 +17288,11 @@ i0.MigrationStepWithVersion migrationSteps({ final migrator = i1.Migrator(database, schema); await from30To31(migrator, schema); return 31; + case 31: + final schema = Schema32(database: database); + final migrator = i1.Migrator(database, schema); + await from31To32(migrator, schema); + return 32; default: throw ArgumentError.value('Unknown migration from $currentVersion'); } @@ -16727,6 +17330,7 @@ i1.OnUpgrade stepByStep({ required Future Function(i1.Migrator m, Schema29 schema) from28To29, required Future Function(i1.Migrator m, Schema30 schema) from29To30, required Future Function(i1.Migrator m, Schema31 schema) from30To31, + required Future Function(i1.Migrator m, Schema32 schema) from31To32, }) => i0.VersionedSchema.stepByStepHelper( step: migrationSteps( from1To2: from1To2, @@ -16759,5 +17363,6 @@ i1.OnUpgrade stepByStep({ from28To29: from28To29, from29To30: from29To30, from30To31: from30To31, + from31To32: from31To32, ), ); diff --git a/mobile/lib/utils/bootstrap.dart b/mobile/lib/utils/bootstrap.dart index cfdd709026..2365ab6575 100644 --- a/mobile/lib/utils/bootstrap.dart +++ b/mobile/lib/utils/bootstrap.dart @@ -6,9 +6,8 @@ import 'package:immich_mobile/extensions/translate_extensions.dart'; import 'package:immich_mobile/infrastructure/repositories/db.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/log.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/logger_db.repository.dart'; -import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; -import 'package:immich_mobile/infrastructure/repositories/settings.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/network.repository.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/settings.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/store.repository.dart'; import 'package:immich_mobile/utils/debug_print.dart'; diff --git a/mobile/lib/utils/image_url_builder.dart b/mobile/lib/utils/image_url_builder.dart index 9ead566524..2b670eda1f 100644 --- a/mobile/lib/utils/image_url_builder.dart +++ b/mobile/lib/utils/image_url_builder.dart @@ -11,8 +11,7 @@ String getThumbnailUrlForRemoteId( bool edited = true, String? thumbhash, }) { - final url = - '${SessionRepository.instance.session.serverEndpoint!}/assets/$id/thumbnail?size=${type.value}&edited=$edited'; + final url = '${SessionRepository.instance.session.serverEndpoint!}/assets/$id/thumbnail?size=$type&edited=$edited'; return thumbhash != null ? '$url&c=${Uri.encodeComponent(thumbhash)}' : url; } diff --git a/mobile/lib/utils/migration.dart b/mobile/lib/utils/migration.dart index e60d9e9e42..6a67fea899 100644 --- a/mobile/lib/utils/migration.dart +++ b/mobile/lib/utils/migration.dart @@ -19,6 +19,7 @@ import 'package:immich_mobile/infrastructure/entities/settings.entity.drift.dart import 'package:immich_mobile/infrastructure/repositories/db.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/network.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; +import 'package:immich_mobile/infrastructure/repositories/settings.repository.dart'; import 'package:immich_mobile/models/auth/auxilary_endpoint.model.dart'; import 'package:immich_mobile/providers/album/album_sort_by_options.provider.dart'; @@ -38,7 +39,7 @@ Future migrateDatabaseIfNeeded(Drift drift) async { if (storedVersion == null) { await FeatureMessageService(SettingsRepository.instance).markSeen(); -} + } if (version < 27) { await _migrateTo27(drift); } diff --git a/mobile/test/drift/main/generated/schema.dart b/mobile/test/drift/main/generated/schema.dart index ee5900c1d1..94913560da 100644 --- a/mobile/test/drift/main/generated/schema.dart +++ b/mobile/test/drift/main/generated/schema.dart @@ -35,6 +35,7 @@ import 'schema_v28.dart' as v28; import 'schema_v29.dart' as v29; import 'schema_v30.dart' as v30; import 'schema_v31.dart' as v31; +import 'schema_v32.dart' as v32; class GeneratedHelper implements SchemaInstantiationHelper { @override @@ -102,6 +103,8 @@ class GeneratedHelper implements SchemaInstantiationHelper { return v30.DatabaseAtV30(db); case 31: return v31.DatabaseAtV31(db); + case 32: + return v32.DatabaseAtV32(db); default: throw MissingSchemaException(version, versions); } @@ -139,5 +142,6 @@ class GeneratedHelper implements SchemaInstantiationHelper { 29, 30, 31, + 32, ]; } diff --git a/mobile/test/drift/main/generated/schema_v32.dart b/mobile/test/drift/main/generated/schema_v32.dart new file mode 100644 index 0000000000..25018a2a2c --- /dev/null +++ b/mobile/test/drift/main/generated/schema_v32.dart @@ -0,0 +1,10246 @@ +// dart format width=80 +import 'dart:typed_data' as i2; +// GENERATED BY drift_dev, DO NOT MODIFY. +// ignore_for_file: type=lint,unused_import +// +import 'package:drift/drift.dart'; + +class UserEntity extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + UserEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn name = GeneratedColumn( + 'name', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn email = GeneratedColumn( + 'email', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn hasProfileImage = GeneratedColumn( + 'has_profile_image', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: + 'NOT NULL DEFAULT 0 CHECK (has_profile_image IN (0, 1))', + defaultValue: const CustomExpression('0'), + ); + late final GeneratedColumn profileChangedAt = GeneratedColumn( + 'profile_changed_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', + defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), + ); + late final GeneratedColumn avatarColor = GeneratedColumn( + 'avatar_color', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 0', + defaultValue: const CustomExpression('0'), + ); + @override + List get $columns => [ + id, + name, + email, + hasProfileImage, + profileChangedAt, + avatarColor, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'user_entity'; + @override + Set get $primaryKey => {id}; + @override + UserEntityData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return UserEntityData( + id: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + name: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}name'], + )!, + email: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}email'], + )!, + hasProfileImage: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}has_profile_image'], + )!, + profileChangedAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}profile_changed_at'], + )!, + avatarColor: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}avatar_color'], + )!, + ); + } + + @override + UserEntity createAlias(String alias) { + return UserEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const ['PRIMARY KEY(id)']; + @override + bool get dontWriteConstraints => true; +} + +class UserEntityData extends DataClass implements Insertable { + final String id; + final String name; + final String email; + final int hasProfileImage; + final String profileChangedAt; + final int avatarColor; + const UserEntityData({ + required this.id, + required this.name, + required this.email, + required this.hasProfileImage, + required this.profileChangedAt, + required this.avatarColor, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['name'] = Variable(name); + map['email'] = Variable(email); + map['has_profile_image'] = Variable(hasProfileImage); + map['profile_changed_at'] = Variable(profileChangedAt); + map['avatar_color'] = Variable(avatarColor); + return map; + } + + factory UserEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return UserEntityData( + id: serializer.fromJson(json['id']), + name: serializer.fromJson(json['name']), + email: serializer.fromJson(json['email']), + hasProfileImage: serializer.fromJson(json['hasProfileImage']), + profileChangedAt: serializer.fromJson(json['profileChangedAt']), + avatarColor: serializer.fromJson(json['avatarColor']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'name': serializer.toJson(name), + 'email': serializer.toJson(email), + 'hasProfileImage': serializer.toJson(hasProfileImage), + 'profileChangedAt': serializer.toJson(profileChangedAt), + 'avatarColor': serializer.toJson(avatarColor), + }; + } + + UserEntityData copyWith({ + String? id, + String? name, + String? email, + int? hasProfileImage, + String? profileChangedAt, + int? avatarColor, + }) => UserEntityData( + id: id ?? this.id, + name: name ?? this.name, + email: email ?? this.email, + hasProfileImage: hasProfileImage ?? this.hasProfileImage, + profileChangedAt: profileChangedAt ?? this.profileChangedAt, + avatarColor: avatarColor ?? this.avatarColor, + ); + UserEntityData copyWithCompanion(UserEntityCompanion data) { + return UserEntityData( + id: data.id.present ? data.id.value : this.id, + name: data.name.present ? data.name.value : this.name, + email: data.email.present ? data.email.value : this.email, + hasProfileImage: data.hasProfileImage.present + ? data.hasProfileImage.value + : this.hasProfileImage, + profileChangedAt: data.profileChangedAt.present + ? data.profileChangedAt.value + : this.profileChangedAt, + avatarColor: data.avatarColor.present + ? data.avatarColor.value + : this.avatarColor, + ); + } + + @override + String toString() { + return (StringBuffer('UserEntityData(') + ..write('id: $id, ') + ..write('name: $name, ') + ..write('email: $email, ') + ..write('hasProfileImage: $hasProfileImage, ') + ..write('profileChangedAt: $profileChangedAt, ') + ..write('avatarColor: $avatarColor') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + name, + email, + hasProfileImage, + profileChangedAt, + avatarColor, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is UserEntityData && + other.id == this.id && + other.name == this.name && + other.email == this.email && + other.hasProfileImage == this.hasProfileImage && + other.profileChangedAt == this.profileChangedAt && + other.avatarColor == this.avatarColor); +} + +class UserEntityCompanion extends UpdateCompanion { + final Value id; + final Value name; + final Value email; + final Value hasProfileImage; + final Value profileChangedAt; + final Value avatarColor; + const UserEntityCompanion({ + this.id = const Value.absent(), + this.name = const Value.absent(), + this.email = const Value.absent(), + this.hasProfileImage = const Value.absent(), + this.profileChangedAt = const Value.absent(), + this.avatarColor = const Value.absent(), + }); + UserEntityCompanion.insert({ + required String id, + required String name, + required String email, + this.hasProfileImage = const Value.absent(), + this.profileChangedAt = const Value.absent(), + this.avatarColor = const Value.absent(), + }) : id = Value(id), + name = Value(name), + email = Value(email); + static Insertable custom({ + Expression? id, + Expression? name, + Expression? email, + Expression? hasProfileImage, + Expression? profileChangedAt, + Expression? avatarColor, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (name != null) 'name': name, + if (email != null) 'email': email, + if (hasProfileImage != null) 'has_profile_image': hasProfileImage, + if (profileChangedAt != null) 'profile_changed_at': profileChangedAt, + if (avatarColor != null) 'avatar_color': avatarColor, + }); + } + + UserEntityCompanion copyWith({ + Value? id, + Value? name, + Value? email, + Value? hasProfileImage, + Value? profileChangedAt, + Value? avatarColor, + }) { + return UserEntityCompanion( + id: id ?? this.id, + name: name ?? this.name, + email: email ?? this.email, + hasProfileImage: hasProfileImage ?? this.hasProfileImage, + profileChangedAt: profileChangedAt ?? this.profileChangedAt, + avatarColor: avatarColor ?? this.avatarColor, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (name.present) { + map['name'] = Variable(name.value); + } + if (email.present) { + map['email'] = Variable(email.value); + } + if (hasProfileImage.present) { + map['has_profile_image'] = Variable(hasProfileImage.value); + } + if (profileChangedAt.present) { + map['profile_changed_at'] = Variable(profileChangedAt.value); + } + if (avatarColor.present) { + map['avatar_color'] = Variable(avatarColor.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('UserEntityCompanion(') + ..write('id: $id, ') + ..write('name: $name, ') + ..write('email: $email, ') + ..write('hasProfileImage: $hasProfileImage, ') + ..write('profileChangedAt: $profileChangedAt, ') + ..write('avatarColor: $avatarColor') + ..write(')')) + .toString(); + } +} + +class RemoteAssetEntity extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + RemoteAssetEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn name = GeneratedColumn( + 'name', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn type = GeneratedColumn( + 'type', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', + defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), + ); + late final GeneratedColumn updatedAt = GeneratedColumn( + 'updated_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', + defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), + ); + late final GeneratedColumn width = GeneratedColumn( + 'width', + aliasedName, + true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn height = GeneratedColumn( + 'height', + aliasedName, + true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn durationMs = GeneratedColumn( + 'duration_ms', + aliasedName, + true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn checksum = GeneratedColumn( + 'checksum', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn isFavorite = GeneratedColumn( + 'is_favorite', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 0 CHECK (is_favorite IN (0, 1))', + defaultValue: const CustomExpression('0'), + ); + late final GeneratedColumn ownerId = GeneratedColumn( + 'owner_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL REFERENCES user_entity(id)ON DELETE CASCADE', + ); + late final GeneratedColumn localDateTime = GeneratedColumn( + 'local_date_time', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn thumbHash = GeneratedColumn( + 'thumb_hash', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn deletedAt = GeneratedColumn( + 'deleted_at', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn uploadedAt = GeneratedColumn( + 'uploaded_at', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn livePhotoVideoId = GeneratedColumn( + 'live_photo_video_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn visibility = GeneratedColumn( + 'visibility', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn stackId = GeneratedColumn( + 'stack_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn libraryId = GeneratedColumn( + 'library_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn isEdited = GeneratedColumn( + 'is_edited', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 0 CHECK (is_edited IN (0, 1))', + defaultValue: const CustomExpression('0'), + ); + @override + List get $columns => [ + name, + type, + createdAt, + updatedAt, + width, + height, + durationMs, + id, + checksum, + isFavorite, + ownerId, + localDateTime, + thumbHash, + deletedAt, + uploadedAt, + livePhotoVideoId, + visibility, + stackId, + libraryId, + isEdited, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'remote_asset_entity'; + @override + Set get $primaryKey => {id}; + @override + RemoteAssetEntityData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return RemoteAssetEntityData( + name: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}name'], + )!, + type: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}type'], + )!, + createdAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}created_at'], + )!, + updatedAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}updated_at'], + )!, + width: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}width'], + ), + height: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}height'], + ), + durationMs: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}duration_ms'], + ), + id: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + checksum: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}checksum'], + )!, + isFavorite: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}is_favorite'], + )!, + ownerId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}owner_id'], + )!, + localDateTime: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}local_date_time'], + ), + thumbHash: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}thumb_hash'], + ), + deletedAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}deleted_at'], + ), + uploadedAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}uploaded_at'], + ), + livePhotoVideoId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}live_photo_video_id'], + ), + visibility: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}visibility'], + )!, + stackId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}stack_id'], + ), + libraryId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}library_id'], + ), + isEdited: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}is_edited'], + )!, + ); + } + + @override + RemoteAssetEntity createAlias(String alias) { + return RemoteAssetEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const ['PRIMARY KEY(id)']; + @override + bool get dontWriteConstraints => true; +} + +class RemoteAssetEntityData extends DataClass + implements Insertable { + final String name; + final int type; + final String createdAt; + final String updatedAt; + final int? width; + final int? height; + final int? durationMs; + final String id; + final String checksum; + final int isFavorite; + final String ownerId; + final String? localDateTime; + final String? thumbHash; + final String? deletedAt; + final String? uploadedAt; + final String? livePhotoVideoId; + final int visibility; + final String? stackId; + final String? libraryId; + final int isEdited; + const RemoteAssetEntityData({ + required this.name, + required this.type, + required this.createdAt, + required this.updatedAt, + this.width, + this.height, + this.durationMs, + required this.id, + required this.checksum, + required this.isFavorite, + required this.ownerId, + this.localDateTime, + this.thumbHash, + this.deletedAt, + this.uploadedAt, + this.livePhotoVideoId, + required this.visibility, + this.stackId, + this.libraryId, + required this.isEdited, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['name'] = Variable(name); + map['type'] = Variable(type); + map['created_at'] = Variable(createdAt); + map['updated_at'] = Variable(updatedAt); + if (!nullToAbsent || width != null) { + map['width'] = Variable(width); + } + if (!nullToAbsent || height != null) { + map['height'] = Variable(height); + } + if (!nullToAbsent || durationMs != null) { + map['duration_ms'] = Variable(durationMs); + } + map['id'] = Variable(id); + map['checksum'] = Variable(checksum); + map['is_favorite'] = Variable(isFavorite); + map['owner_id'] = Variable(ownerId); + if (!nullToAbsent || localDateTime != null) { + map['local_date_time'] = Variable(localDateTime); + } + if (!nullToAbsent || thumbHash != null) { + map['thumb_hash'] = Variable(thumbHash); + } + if (!nullToAbsent || deletedAt != null) { + map['deleted_at'] = Variable(deletedAt); + } + if (!nullToAbsent || uploadedAt != null) { + map['uploaded_at'] = Variable(uploadedAt); + } + if (!nullToAbsent || livePhotoVideoId != null) { + map['live_photo_video_id'] = Variable(livePhotoVideoId); + } + map['visibility'] = Variable(visibility); + if (!nullToAbsent || stackId != null) { + map['stack_id'] = Variable(stackId); + } + if (!nullToAbsent || libraryId != null) { + map['library_id'] = Variable(libraryId); + } + map['is_edited'] = Variable(isEdited); + return map; + } + + factory RemoteAssetEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return RemoteAssetEntityData( + name: serializer.fromJson(json['name']), + type: serializer.fromJson(json['type']), + createdAt: serializer.fromJson(json['createdAt']), + updatedAt: serializer.fromJson(json['updatedAt']), + width: serializer.fromJson(json['width']), + height: serializer.fromJson(json['height']), + durationMs: serializer.fromJson(json['durationMs']), + id: serializer.fromJson(json['id']), + 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']), + uploadedAt: serializer.fromJson(json['uploadedAt']), + livePhotoVideoId: serializer.fromJson(json['livePhotoVideoId']), + visibility: serializer.fromJson(json['visibility']), + stackId: serializer.fromJson(json['stackId']), + libraryId: serializer.fromJson(json['libraryId']), + isEdited: serializer.fromJson(json['isEdited']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'name': serializer.toJson(name), + 'type': serializer.toJson(type), + 'createdAt': serializer.toJson(createdAt), + 'updatedAt': serializer.toJson(updatedAt), + 'width': serializer.toJson(width), + 'height': serializer.toJson(height), + 'durationMs': serializer.toJson(durationMs), + 'id': serializer.toJson(id), + 'checksum': serializer.toJson(checksum), + 'isFavorite': serializer.toJson(isFavorite), + 'ownerId': serializer.toJson(ownerId), + 'localDateTime': serializer.toJson(localDateTime), + 'thumbHash': serializer.toJson(thumbHash), + 'deletedAt': serializer.toJson(deletedAt), + 'uploadedAt': serializer.toJson(uploadedAt), + 'livePhotoVideoId': serializer.toJson(livePhotoVideoId), + 'visibility': serializer.toJson(visibility), + 'stackId': serializer.toJson(stackId), + 'libraryId': serializer.toJson(libraryId), + 'isEdited': serializer.toJson(isEdited), + }; + } + + RemoteAssetEntityData copyWith({ + String? name, + int? type, + String? createdAt, + String? updatedAt, + Value width = const Value.absent(), + Value height = const Value.absent(), + Value durationMs = const Value.absent(), + String? id, + String? checksum, + int? isFavorite, + String? ownerId, + Value localDateTime = const Value.absent(), + Value thumbHash = const Value.absent(), + Value deletedAt = const Value.absent(), + Value uploadedAt = const Value.absent(), + Value livePhotoVideoId = const Value.absent(), + int? visibility, + Value stackId = const Value.absent(), + Value libraryId = const Value.absent(), + int? isEdited, + }) => RemoteAssetEntityData( + 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, + durationMs: durationMs.present ? durationMs.value : this.durationMs, + id: id ?? this.id, + 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, + uploadedAt: uploadedAt.present ? uploadedAt.value : this.uploadedAt, + livePhotoVideoId: livePhotoVideoId.present + ? livePhotoVideoId.value + : this.livePhotoVideoId, + visibility: visibility ?? this.visibility, + stackId: stackId.present ? stackId.value : this.stackId, + libraryId: libraryId.present ? libraryId.value : this.libraryId, + isEdited: isEdited ?? this.isEdited, + ); + RemoteAssetEntityData copyWithCompanion(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, + width: data.width.present ? data.width.value : this.width, + height: data.height.present ? data.height.value : this.height, + durationMs: data.durationMs.present + ? data.durationMs.value + : this.durationMs, + id: data.id.present ? data.id.value : this.id, + 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, + uploadedAt: data.uploadedAt.present + ? data.uploadedAt.value + : this.uploadedAt, + livePhotoVideoId: data.livePhotoVideoId.present + ? data.livePhotoVideoId.value + : this.livePhotoVideoId, + visibility: data.visibility.present + ? data.visibility.value + : this.visibility, + stackId: data.stackId.present ? data.stackId.value : this.stackId, + libraryId: data.libraryId.present ? data.libraryId.value : this.libraryId, + isEdited: data.isEdited.present ? data.isEdited.value : this.isEdited, + ); + } + + @override + String toString() { + return (StringBuffer('RemoteAssetEntityData(') + ..write('name: $name, ') + ..write('type: $type, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt, ') + ..write('width: $width, ') + ..write('height: $height, ') + ..write('durationMs: $durationMs, ') + ..write('id: $id, ') + ..write('checksum: $checksum, ') + ..write('isFavorite: $isFavorite, ') + ..write('ownerId: $ownerId, ') + ..write('localDateTime: $localDateTime, ') + ..write('thumbHash: $thumbHash, ') + ..write('deletedAt: $deletedAt, ') + ..write('uploadedAt: $uploadedAt, ') + ..write('livePhotoVideoId: $livePhotoVideoId, ') + ..write('visibility: $visibility, ') + ..write('stackId: $stackId, ') + ..write('libraryId: $libraryId, ') + ..write('isEdited: $isEdited') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + name, + type, + createdAt, + updatedAt, + width, + height, + durationMs, + id, + checksum, + isFavorite, + ownerId, + localDateTime, + thumbHash, + deletedAt, + uploadedAt, + livePhotoVideoId, + visibility, + stackId, + libraryId, + isEdited, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is RemoteAssetEntityData && + other.name == this.name && + other.type == this.type && + other.createdAt == this.createdAt && + other.updatedAt == this.updatedAt && + other.width == this.width && + other.height == this.height && + other.durationMs == this.durationMs && + other.id == this.id && + other.checksum == this.checksum && + other.isFavorite == this.isFavorite && + other.ownerId == this.ownerId && + other.localDateTime == this.localDateTime && + other.thumbHash == this.thumbHash && + other.deletedAt == this.deletedAt && + other.uploadedAt == this.uploadedAt && + other.livePhotoVideoId == this.livePhotoVideoId && + other.visibility == this.visibility && + other.stackId == this.stackId && + other.libraryId == this.libraryId && + other.isEdited == this.isEdited); +} + +class RemoteAssetEntityCompanion + extends UpdateCompanion { + final Value name; + final Value type; + final Value createdAt; + final Value updatedAt; + final Value width; + final Value height; + final Value durationMs; + final Value id; + final Value checksum; + final Value isFavorite; + final Value ownerId; + final Value localDateTime; + final Value thumbHash; + final Value deletedAt; + final Value uploadedAt; + final Value livePhotoVideoId; + final Value visibility; + final Value stackId; + final Value libraryId; + final Value isEdited; + const RemoteAssetEntityCompanion({ + this.name = const Value.absent(), + this.type = const Value.absent(), + this.createdAt = const Value.absent(), + this.updatedAt = const Value.absent(), + this.width = const Value.absent(), + this.height = const Value.absent(), + this.durationMs = const Value.absent(), + this.id = const Value.absent(), + this.checksum = const Value.absent(), + this.isFavorite = const Value.absent(), + this.ownerId = const Value.absent(), + this.localDateTime = const Value.absent(), + this.thumbHash = const Value.absent(), + this.deletedAt = const Value.absent(), + this.uploadedAt = const Value.absent(), + this.livePhotoVideoId = const Value.absent(), + this.visibility = const Value.absent(), + this.stackId = const Value.absent(), + this.libraryId = const Value.absent(), + this.isEdited = const Value.absent(), + }); + RemoteAssetEntityCompanion.insert({ + required String name, + required int type, + this.createdAt = const Value.absent(), + this.updatedAt = const Value.absent(), + this.width = const Value.absent(), + this.height = const Value.absent(), + this.durationMs = const Value.absent(), + required String id, + required String checksum, + this.isFavorite = const Value.absent(), + required String ownerId, + this.localDateTime = const Value.absent(), + this.thumbHash = const Value.absent(), + this.deletedAt = const Value.absent(), + this.uploadedAt = const Value.absent(), + this.livePhotoVideoId = const Value.absent(), + required int visibility, + this.stackId = const Value.absent(), + this.libraryId = const Value.absent(), + this.isEdited = const Value.absent(), + }) : name = Value(name), + type = Value(type), + id = Value(id), + checksum = Value(checksum), + ownerId = Value(ownerId), + visibility = Value(visibility); + static Insertable custom({ + Expression? name, + Expression? type, + Expression? createdAt, + Expression? updatedAt, + Expression? width, + Expression? height, + Expression? durationMs, + Expression? id, + Expression? checksum, + Expression? isFavorite, + Expression? ownerId, + Expression? localDateTime, + Expression? thumbHash, + Expression? deletedAt, + Expression? uploadedAt, + Expression? livePhotoVideoId, + Expression? visibility, + Expression? stackId, + Expression? libraryId, + Expression? isEdited, + }) { + return 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 (durationMs != null) 'duration_ms': durationMs, + if (id != null) 'id': id, + 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) 'thumb_hash': thumbHash, + if (deletedAt != null) 'deleted_at': deletedAt, + if (uploadedAt != null) 'uploaded_at': uploadedAt, + if (livePhotoVideoId != null) 'live_photo_video_id': livePhotoVideoId, + if (visibility != null) 'visibility': visibility, + if (stackId != null) 'stack_id': stackId, + if (libraryId != null) 'library_id': libraryId, + if (isEdited != null) 'is_edited': isEdited, + }); + } + + RemoteAssetEntityCompanion copyWith({ + Value? name, + Value? type, + Value? createdAt, + Value? updatedAt, + Value? width, + Value? height, + Value? durationMs, + Value? id, + Value? checksum, + Value? isFavorite, + Value? ownerId, + Value? localDateTime, + Value? thumbHash, + Value? deletedAt, + Value? uploadedAt, + Value? livePhotoVideoId, + Value? visibility, + Value? stackId, + Value? libraryId, + Value? isEdited, + }) { + return RemoteAssetEntityCompanion( + name: name ?? this.name, + type: type ?? this.type, + createdAt: createdAt ?? this.createdAt, + updatedAt: updatedAt ?? this.updatedAt, + width: width ?? this.width, + height: height ?? this.height, + durationMs: durationMs ?? this.durationMs, + id: id ?? this.id, + checksum: checksum ?? this.checksum, + isFavorite: isFavorite ?? this.isFavorite, + ownerId: ownerId ?? this.ownerId, + localDateTime: localDateTime ?? this.localDateTime, + thumbHash: thumbHash ?? this.thumbHash, + deletedAt: deletedAt ?? this.deletedAt, + uploadedAt: uploadedAt ?? this.uploadedAt, + livePhotoVideoId: livePhotoVideoId ?? this.livePhotoVideoId, + visibility: visibility ?? this.visibility, + stackId: stackId ?? this.stackId, + libraryId: libraryId ?? this.libraryId, + isEdited: isEdited ?? this.isEdited, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (name.present) { + map['name'] = Variable(name.value); + } + if (type.present) { + map['type'] = Variable(type.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + if (updatedAt.present) { + map['updated_at'] = Variable(updatedAt.value); + } + if (width.present) { + map['width'] = Variable(width.value); + } + if (height.present) { + map['height'] = Variable(height.value); + } + if (durationMs.present) { + map['duration_ms'] = Variable(durationMs.value); + } + if (id.present) { + map['id'] = Variable(id.value); + } + if (checksum.present) { + map['checksum'] = Variable(checksum.value); + } + if (isFavorite.present) { + map['is_favorite'] = Variable(isFavorite.value); + } + if (ownerId.present) { + map['owner_id'] = Variable(ownerId.value); + } + if (localDateTime.present) { + map['local_date_time'] = Variable(localDateTime.value); + } + if (thumbHash.present) { + map['thumb_hash'] = Variable(thumbHash.value); + } + if (deletedAt.present) { + map['deleted_at'] = Variable(deletedAt.value); + } + if (uploadedAt.present) { + map['uploaded_at'] = Variable(uploadedAt.value); + } + if (livePhotoVideoId.present) { + map['live_photo_video_id'] = Variable(livePhotoVideoId.value); + } + if (visibility.present) { + map['visibility'] = Variable(visibility.value); + } + if (stackId.present) { + map['stack_id'] = Variable(stackId.value); + } + if (libraryId.present) { + map['library_id'] = Variable(libraryId.value); + } + if (isEdited.present) { + map['is_edited'] = Variable(isEdited.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('RemoteAssetEntityCompanion(') + ..write('name: $name, ') + ..write('type: $type, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt, ') + ..write('width: $width, ') + ..write('height: $height, ') + ..write('durationMs: $durationMs, ') + ..write('id: $id, ') + ..write('checksum: $checksum, ') + ..write('isFavorite: $isFavorite, ') + ..write('ownerId: $ownerId, ') + ..write('localDateTime: $localDateTime, ') + ..write('thumbHash: $thumbHash, ') + ..write('deletedAt: $deletedAt, ') + ..write('uploadedAt: $uploadedAt, ') + ..write('livePhotoVideoId: $livePhotoVideoId, ') + ..write('visibility: $visibility, ') + ..write('stackId: $stackId, ') + ..write('libraryId: $libraryId, ') + ..write('isEdited: $isEdited') + ..write(')')) + .toString(); + } +} + +class StackEntity extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + StackEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', + defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), + ); + late final GeneratedColumn updatedAt = GeneratedColumn( + 'updated_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', + defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), + ); + late final GeneratedColumn ownerId = GeneratedColumn( + 'owner_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL REFERENCES user_entity(id)ON DELETE CASCADE', + ); + late final GeneratedColumn primaryAssetId = GeneratedColumn( + 'primary_asset_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + @override + List get $columns => [ + id, + createdAt, + updatedAt, + ownerId, + primaryAssetId, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'stack_entity'; + @override + Set get $primaryKey => {id}; + @override + StackEntityData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return StackEntityData( + id: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + createdAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}created_at'], + )!, + updatedAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}updated_at'], + )!, + ownerId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}owner_id'], + )!, + primaryAssetId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}primary_asset_id'], + )!, + ); + } + + @override + StackEntity createAlias(String alias) { + return StackEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const ['PRIMARY KEY(id)']; + @override + bool get dontWriteConstraints => true; +} + +class StackEntityData extends DataClass implements Insertable { + final String id; + final String createdAt; + final String updatedAt; + final String ownerId; + final String primaryAssetId; + const StackEntityData({ + required this.id, + required this.createdAt, + required this.updatedAt, + required this.ownerId, + required this.primaryAssetId, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['created_at'] = Variable(createdAt); + map['updated_at'] = Variable(updatedAt); + map['owner_id'] = Variable(ownerId); + map['primary_asset_id'] = Variable(primaryAssetId); + return map; + } + + factory StackEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return StackEntityData( + id: serializer.fromJson(json['id']), + createdAt: serializer.fromJson(json['createdAt']), + updatedAt: serializer.fromJson(json['updatedAt']), + ownerId: serializer.fromJson(json['ownerId']), + primaryAssetId: serializer.fromJson(json['primaryAssetId']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'createdAt': serializer.toJson(createdAt), + 'updatedAt': serializer.toJson(updatedAt), + 'ownerId': serializer.toJson(ownerId), + 'primaryAssetId': serializer.toJson(primaryAssetId), + }; + } + + StackEntityData copyWith({ + String? id, + String? createdAt, + String? updatedAt, + String? ownerId, + String? primaryAssetId, + }) => StackEntityData( + id: id ?? this.id, + createdAt: createdAt ?? this.createdAt, + updatedAt: updatedAt ?? this.updatedAt, + ownerId: ownerId ?? this.ownerId, + primaryAssetId: primaryAssetId ?? this.primaryAssetId, + ); + StackEntityData copyWithCompanion(StackEntityCompanion data) { + return StackEntityData( + id: data.id.present ? data.id.value : this.id, + createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, + updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, + ownerId: data.ownerId.present ? data.ownerId.value : this.ownerId, + primaryAssetId: data.primaryAssetId.present + ? data.primaryAssetId.value + : this.primaryAssetId, + ); + } + + @override + String toString() { + return (StringBuffer('StackEntityData(') + ..write('id: $id, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt, ') + ..write('ownerId: $ownerId, ') + ..write('primaryAssetId: $primaryAssetId') + ..write(')')) + .toString(); + } + + @override + int get hashCode => + Object.hash(id, createdAt, updatedAt, ownerId, primaryAssetId); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is StackEntityData && + other.id == this.id && + other.createdAt == this.createdAt && + other.updatedAt == this.updatedAt && + other.ownerId == this.ownerId && + other.primaryAssetId == this.primaryAssetId); +} + +class StackEntityCompanion extends UpdateCompanion { + final Value id; + final Value createdAt; + final Value updatedAt; + final Value ownerId; + final Value primaryAssetId; + const StackEntityCompanion({ + this.id = const Value.absent(), + this.createdAt = const Value.absent(), + this.updatedAt = const Value.absent(), + this.ownerId = const Value.absent(), + this.primaryAssetId = const Value.absent(), + }); + StackEntityCompanion.insert({ + required String id, + this.createdAt = const Value.absent(), + this.updatedAt = const Value.absent(), + required String ownerId, + required String primaryAssetId, + }) : id = Value(id), + ownerId = Value(ownerId), + primaryAssetId = Value(primaryAssetId); + static Insertable custom({ + Expression? id, + Expression? createdAt, + Expression? updatedAt, + Expression? ownerId, + Expression? primaryAssetId, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (createdAt != null) 'created_at': createdAt, + if (updatedAt != null) 'updated_at': updatedAt, + if (ownerId != null) 'owner_id': ownerId, + if (primaryAssetId != null) 'primary_asset_id': primaryAssetId, + }); + } + + StackEntityCompanion copyWith({ + Value? id, + Value? createdAt, + Value? updatedAt, + Value? ownerId, + Value? primaryAssetId, + }) { + return StackEntityCompanion( + id: id ?? this.id, + createdAt: createdAt ?? this.createdAt, + updatedAt: updatedAt ?? this.updatedAt, + ownerId: ownerId ?? this.ownerId, + primaryAssetId: primaryAssetId ?? this.primaryAssetId, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + if (updatedAt.present) { + map['updated_at'] = Variable(updatedAt.value); + } + if (ownerId.present) { + map['owner_id'] = Variable(ownerId.value); + } + if (primaryAssetId.present) { + map['primary_asset_id'] = Variable(primaryAssetId.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('StackEntityCompanion(') + ..write('id: $id, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt, ') + ..write('ownerId: $ownerId, ') + ..write('primaryAssetId: $primaryAssetId') + ..write(')')) + .toString(); + } +} + +class LocalAssetEntity extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + LocalAssetEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn name = GeneratedColumn( + 'name', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn type = GeneratedColumn( + 'type', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', + defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), + ); + late final GeneratedColumn updatedAt = GeneratedColumn( + 'updated_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', + defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), + ); + late final GeneratedColumn width = GeneratedColumn( + 'width', + aliasedName, + true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn height = GeneratedColumn( + 'height', + aliasedName, + true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn durationMs = GeneratedColumn( + 'duration_ms', + aliasedName, + true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn checksum = GeneratedColumn( + 'checksum', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn isFavorite = GeneratedColumn( + 'is_favorite', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 0 CHECK (is_favorite IN (0, 1))', + defaultValue: const CustomExpression('0'), + ); + late final GeneratedColumn orientation = GeneratedColumn( + 'orientation', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 0', + defaultValue: const CustomExpression('0'), + ); + late final GeneratedColumn iCloudId = GeneratedColumn( + 'i_cloud_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn adjustmentTime = GeneratedColumn( + 'adjustment_time', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn latitude = GeneratedColumn( + 'latitude', + aliasedName, + true, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn longitude = GeneratedColumn( + 'longitude', + aliasedName, + true, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn playbackStyle = GeneratedColumn( + 'playback_style', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 0', + defaultValue: const CustomExpression('0'), + ); + @override + List get $columns => [ + name, + type, + createdAt, + updatedAt, + width, + height, + durationMs, + id, + checksum, + isFavorite, + orientation, + iCloudId, + adjustmentTime, + latitude, + longitude, + playbackStyle, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'local_asset_entity'; + @override + Set get $primaryKey => {id}; + @override + LocalAssetEntityData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return LocalAssetEntityData( + name: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}name'], + )!, + type: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}type'], + )!, + createdAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}created_at'], + )!, + updatedAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}updated_at'], + )!, + width: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}width'], + ), + height: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}height'], + ), + durationMs: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}duration_ms'], + ), + id: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + checksum: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}checksum'], + ), + isFavorite: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}is_favorite'], + )!, + orientation: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}orientation'], + )!, + iCloudId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}i_cloud_id'], + ), + adjustmentTime: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}adjustment_time'], + ), + latitude: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}latitude'], + ), + longitude: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}longitude'], + ), + playbackStyle: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}playback_style'], + )!, + ); + } + + @override + LocalAssetEntity createAlias(String alias) { + return LocalAssetEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const ['PRIMARY KEY(id)']; + @override + bool get dontWriteConstraints => true; +} + +class LocalAssetEntityData extends DataClass + implements Insertable { + final String name; + final int type; + final String createdAt; + final String updatedAt; + final int? width; + final int? height; + final int? durationMs; + final String id; + final String? checksum; + final int isFavorite; + final int orientation; + final String? iCloudId; + final String? adjustmentTime; + final double? latitude; + final double? longitude; + final int playbackStyle; + const LocalAssetEntityData({ + required this.name, + required this.type, + required this.createdAt, + required this.updatedAt, + this.width, + this.height, + this.durationMs, + required this.id, + this.checksum, + required this.isFavorite, + required this.orientation, + this.iCloudId, + this.adjustmentTime, + this.latitude, + this.longitude, + required this.playbackStyle, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['name'] = Variable(name); + map['type'] = Variable(type); + map['created_at'] = Variable(createdAt); + map['updated_at'] = Variable(updatedAt); + if (!nullToAbsent || width != null) { + map['width'] = Variable(width); + } + if (!nullToAbsent || height != null) { + map['height'] = Variable(height); + } + if (!nullToAbsent || durationMs != null) { + map['duration_ms'] = Variable(durationMs); + } + map['id'] = Variable(id); + if (!nullToAbsent || checksum != null) { + map['checksum'] = Variable(checksum); + } + map['is_favorite'] = Variable(isFavorite); + map['orientation'] = Variable(orientation); + if (!nullToAbsent || iCloudId != null) { + map['i_cloud_id'] = Variable(iCloudId); + } + if (!nullToAbsent || adjustmentTime != null) { + map['adjustment_time'] = Variable(adjustmentTime); + } + if (!nullToAbsent || latitude != null) { + map['latitude'] = Variable(latitude); + } + if (!nullToAbsent || longitude != null) { + map['longitude'] = Variable(longitude); + } + map['playback_style'] = Variable(playbackStyle); + return map; + } + + factory LocalAssetEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return LocalAssetEntityData( + name: serializer.fromJson(json['name']), + type: serializer.fromJson(json['type']), + createdAt: serializer.fromJson(json['createdAt']), + updatedAt: serializer.fromJson(json['updatedAt']), + width: serializer.fromJson(json['width']), + height: serializer.fromJson(json['height']), + durationMs: serializer.fromJson(json['durationMs']), + id: serializer.fromJson(json['id']), + checksum: serializer.fromJson(json['checksum']), + isFavorite: serializer.fromJson(json['isFavorite']), + orientation: serializer.fromJson(json['orientation']), + iCloudId: serializer.fromJson(json['iCloudId']), + adjustmentTime: serializer.fromJson(json['adjustmentTime']), + latitude: serializer.fromJson(json['latitude']), + longitude: serializer.fromJson(json['longitude']), + playbackStyle: serializer.fromJson(json['playbackStyle']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'name': serializer.toJson(name), + 'type': serializer.toJson(type), + 'createdAt': serializer.toJson(createdAt), + 'updatedAt': serializer.toJson(updatedAt), + 'width': serializer.toJson(width), + 'height': serializer.toJson(height), + 'durationMs': serializer.toJson(durationMs), + 'id': serializer.toJson(id), + 'checksum': serializer.toJson(checksum), + 'isFavorite': serializer.toJson(isFavorite), + 'orientation': serializer.toJson(orientation), + 'iCloudId': serializer.toJson(iCloudId), + 'adjustmentTime': serializer.toJson(adjustmentTime), + 'latitude': serializer.toJson(latitude), + 'longitude': serializer.toJson(longitude), + 'playbackStyle': serializer.toJson(playbackStyle), + }; + } + + LocalAssetEntityData copyWith({ + String? name, + int? type, + String? createdAt, + String? updatedAt, + Value width = const Value.absent(), + Value height = const Value.absent(), + Value durationMs = const Value.absent(), + String? id, + Value checksum = const Value.absent(), + int? isFavorite, + int? orientation, + Value iCloudId = const Value.absent(), + Value adjustmentTime = const Value.absent(), + Value latitude = const Value.absent(), + Value longitude = const Value.absent(), + int? playbackStyle, + }) => 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, + durationMs: durationMs.present ? durationMs.value : this.durationMs, + id: id ?? this.id, + checksum: checksum.present ? checksum.value : this.checksum, + isFavorite: isFavorite ?? this.isFavorite, + orientation: orientation ?? this.orientation, + iCloudId: iCloudId.present ? iCloudId.value : this.iCloudId, + adjustmentTime: adjustmentTime.present + ? adjustmentTime.value + : this.adjustmentTime, + latitude: latitude.present ? latitude.value : this.latitude, + longitude: longitude.present ? longitude.value : this.longitude, + playbackStyle: playbackStyle ?? this.playbackStyle, + ); + LocalAssetEntityData copyWithCompanion(LocalAssetEntityCompanion data) { + return LocalAssetEntityData( + 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, + width: data.width.present ? data.width.value : this.width, + height: data.height.present ? data.height.value : this.height, + durationMs: data.durationMs.present + ? data.durationMs.value + : this.durationMs, + id: data.id.present ? data.id.value : this.id, + checksum: data.checksum.present ? data.checksum.value : this.checksum, + isFavorite: data.isFavorite.present + ? data.isFavorite.value + : this.isFavorite, + orientation: data.orientation.present + ? data.orientation.value + : this.orientation, + iCloudId: data.iCloudId.present ? data.iCloudId.value : this.iCloudId, + adjustmentTime: data.adjustmentTime.present + ? data.adjustmentTime.value + : this.adjustmentTime, + latitude: data.latitude.present ? data.latitude.value : this.latitude, + longitude: data.longitude.present ? data.longitude.value : this.longitude, + playbackStyle: data.playbackStyle.present + ? data.playbackStyle.value + : this.playbackStyle, + ); + } + + @override + String toString() { + return (StringBuffer('LocalAssetEntityData(') + ..write('name: $name, ') + ..write('type: $type, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt, ') + ..write('width: $width, ') + ..write('height: $height, ') + ..write('durationMs: $durationMs, ') + ..write('id: $id, ') + ..write('checksum: $checksum, ') + ..write('isFavorite: $isFavorite, ') + ..write('orientation: $orientation, ') + ..write('iCloudId: $iCloudId, ') + ..write('adjustmentTime: $adjustmentTime, ') + ..write('latitude: $latitude, ') + ..write('longitude: $longitude, ') + ..write('playbackStyle: $playbackStyle') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + name, + type, + createdAt, + updatedAt, + width, + height, + durationMs, + id, + checksum, + isFavorite, + orientation, + iCloudId, + adjustmentTime, + latitude, + longitude, + playbackStyle, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is LocalAssetEntityData && + other.name == this.name && + other.type == this.type && + other.createdAt == this.createdAt && + other.updatedAt == this.updatedAt && + other.width == this.width && + other.height == this.height && + other.durationMs == this.durationMs && + other.id == this.id && + other.checksum == this.checksum && + other.isFavorite == this.isFavorite && + other.orientation == this.orientation && + other.iCloudId == this.iCloudId && + other.adjustmentTime == this.adjustmentTime && + other.latitude == this.latitude && + other.longitude == this.longitude && + other.playbackStyle == this.playbackStyle); +} + +class LocalAssetEntityCompanion extends UpdateCompanion { + final Value name; + final Value type; + final Value createdAt; + final Value updatedAt; + final Value width; + final Value height; + final Value durationMs; + final Value id; + final Value checksum; + final Value isFavorite; + final Value orientation; + final Value iCloudId; + final Value adjustmentTime; + final Value latitude; + final Value longitude; + final Value playbackStyle; + const LocalAssetEntityCompanion({ + this.name = const Value.absent(), + this.type = const Value.absent(), + this.createdAt = const Value.absent(), + this.updatedAt = const Value.absent(), + this.width = const Value.absent(), + this.height = const Value.absent(), + this.durationMs = const Value.absent(), + this.id = const Value.absent(), + this.checksum = const Value.absent(), + this.isFavorite = const Value.absent(), + this.orientation = const Value.absent(), + this.iCloudId = const Value.absent(), + this.adjustmentTime = const Value.absent(), + this.latitude = const Value.absent(), + this.longitude = const Value.absent(), + this.playbackStyle = const Value.absent(), + }); + LocalAssetEntityCompanion.insert({ + required String name, + required int type, + this.createdAt = const Value.absent(), + this.updatedAt = const Value.absent(), + this.width = const Value.absent(), + this.height = const Value.absent(), + this.durationMs = const Value.absent(), + required String id, + this.checksum = const Value.absent(), + this.isFavorite = const Value.absent(), + this.orientation = const Value.absent(), + this.iCloudId = const Value.absent(), + this.adjustmentTime = const Value.absent(), + this.latitude = const Value.absent(), + this.longitude = const Value.absent(), + this.playbackStyle = const Value.absent(), + }) : name = Value(name), + type = Value(type), + id = Value(id); + static Insertable custom({ + Expression? name, + Expression? type, + Expression? createdAt, + Expression? updatedAt, + Expression? width, + Expression? height, + Expression? durationMs, + Expression? id, + Expression? checksum, + Expression? isFavorite, + Expression? orientation, + Expression? iCloudId, + Expression? adjustmentTime, + Expression? latitude, + Expression? longitude, + Expression? playbackStyle, + }) { + return 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 (durationMs != null) 'duration_ms': durationMs, + if (id != null) 'id': id, + if (checksum != null) 'checksum': checksum, + if (isFavorite != null) 'is_favorite': isFavorite, + if (orientation != null) 'orientation': orientation, + if (iCloudId != null) 'i_cloud_id': iCloudId, + if (adjustmentTime != null) 'adjustment_time': adjustmentTime, + if (latitude != null) 'latitude': latitude, + if (longitude != null) 'longitude': longitude, + if (playbackStyle != null) 'playback_style': playbackStyle, + }); + } + + LocalAssetEntityCompanion copyWith({ + Value? name, + Value? type, + Value? createdAt, + Value? updatedAt, + Value? width, + Value? height, + Value? durationMs, + Value? id, + Value? checksum, + Value? isFavorite, + Value? orientation, + Value? iCloudId, + Value? adjustmentTime, + Value? latitude, + Value? longitude, + Value? playbackStyle, + }) { + return 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, + durationMs: durationMs ?? this.durationMs, + id: id ?? this.id, + checksum: checksum ?? this.checksum, + isFavorite: isFavorite ?? this.isFavorite, + orientation: orientation ?? this.orientation, + iCloudId: iCloudId ?? this.iCloudId, + adjustmentTime: adjustmentTime ?? this.adjustmentTime, + latitude: latitude ?? this.latitude, + longitude: longitude ?? this.longitude, + playbackStyle: playbackStyle ?? this.playbackStyle, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (name.present) { + map['name'] = Variable(name.value); + } + if (type.present) { + map['type'] = Variable(type.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + if (updatedAt.present) { + map['updated_at'] = Variable(updatedAt.value); + } + if (width.present) { + map['width'] = Variable(width.value); + } + if (height.present) { + map['height'] = Variable(height.value); + } + if (durationMs.present) { + map['duration_ms'] = Variable(durationMs.value); + } + if (id.present) { + map['id'] = Variable(id.value); + } + if (checksum.present) { + map['checksum'] = Variable(checksum.value); + } + if (isFavorite.present) { + map['is_favorite'] = Variable(isFavorite.value); + } + if (orientation.present) { + map['orientation'] = Variable(orientation.value); + } + if (iCloudId.present) { + map['i_cloud_id'] = Variable(iCloudId.value); + } + if (adjustmentTime.present) { + map['adjustment_time'] = Variable(adjustmentTime.value); + } + if (latitude.present) { + map['latitude'] = Variable(latitude.value); + } + if (longitude.present) { + map['longitude'] = Variable(longitude.value); + } + if (playbackStyle.present) { + map['playback_style'] = Variable(playbackStyle.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('LocalAssetEntityCompanion(') + ..write('name: $name, ') + ..write('type: $type, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt, ') + ..write('width: $width, ') + ..write('height: $height, ') + ..write('durationMs: $durationMs, ') + ..write('id: $id, ') + ..write('checksum: $checksum, ') + ..write('isFavorite: $isFavorite, ') + ..write('orientation: $orientation, ') + ..write('iCloudId: $iCloudId, ') + ..write('adjustmentTime: $adjustmentTime, ') + ..write('latitude: $latitude, ') + ..write('longitude: $longitude, ') + ..write('playbackStyle: $playbackStyle') + ..write(')')) + .toString(); + } +} + +class RemoteAlbumEntity extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + RemoteAlbumEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn name = GeneratedColumn( + 'name', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn description = GeneratedColumn( + 'description', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT \'\'', + defaultValue: const CustomExpression('\'\''), + ); + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', + defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), + ); + late final GeneratedColumn updatedAt = GeneratedColumn( + 'updated_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', + defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), + ); + late final GeneratedColumn thumbnailAssetId = GeneratedColumn( + 'thumbnail_asset_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: + 'NULL REFERENCES remote_asset_entity(id)ON DELETE SET NULL', + ); + late final GeneratedColumn isActivityEnabled = GeneratedColumn( + 'is_activity_enabled', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: + 'NOT NULL DEFAULT 1 CHECK (is_activity_enabled IN (0, 1))', + defaultValue: const CustomExpression('1'), + ); + late final GeneratedColumn order = GeneratedColumn( + 'order', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + @override + List get $columns => [ + id, + name, + description, + createdAt, + updatedAt, + thumbnailAssetId, + isActivityEnabled, + order, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'remote_album_entity'; + @override + Set get $primaryKey => {id}; + @override + RemoteAlbumEntityData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return RemoteAlbumEntityData( + id: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + name: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}name'], + )!, + description: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}description'], + )!, + createdAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}created_at'], + )!, + updatedAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}updated_at'], + )!, + thumbnailAssetId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}thumbnail_asset_id'], + ), + isActivityEnabled: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}is_activity_enabled'], + )!, + order: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}order'], + )!, + ); + } + + @override + RemoteAlbumEntity createAlias(String alias) { + return RemoteAlbumEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const ['PRIMARY KEY(id)']; + @override + bool get dontWriteConstraints => true; +} + +class RemoteAlbumEntityData extends DataClass + implements Insertable { + final String id; + final String name; + final String description; + final String createdAt; + final String updatedAt; + final String? thumbnailAssetId; + final int isActivityEnabled; + final int order; + const RemoteAlbumEntityData({ + required this.id, + required this.name, + required this.description, + required this.createdAt, + required this.updatedAt, + this.thumbnailAssetId, + required this.isActivityEnabled, + required this.order, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['name'] = Variable(name); + map['description'] = Variable(description); + map['created_at'] = Variable(createdAt); + map['updated_at'] = Variable(updatedAt); + if (!nullToAbsent || thumbnailAssetId != null) { + map['thumbnail_asset_id'] = Variable(thumbnailAssetId); + } + map['is_activity_enabled'] = Variable(isActivityEnabled); + map['order'] = Variable(order); + return map; + } + + factory RemoteAlbumEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return RemoteAlbumEntityData( + id: serializer.fromJson(json['id']), + name: serializer.fromJson(json['name']), + description: serializer.fromJson(json['description']), + createdAt: serializer.fromJson(json['createdAt']), + updatedAt: serializer.fromJson(json['updatedAt']), + thumbnailAssetId: serializer.fromJson(json['thumbnailAssetId']), + isActivityEnabled: serializer.fromJson(json['isActivityEnabled']), + order: serializer.fromJson(json['order']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'name': serializer.toJson(name), + 'description': serializer.toJson(description), + 'createdAt': serializer.toJson(createdAt), + 'updatedAt': serializer.toJson(updatedAt), + 'thumbnailAssetId': serializer.toJson(thumbnailAssetId), + 'isActivityEnabled': serializer.toJson(isActivityEnabled), + 'order': serializer.toJson(order), + }; + } + + RemoteAlbumEntityData copyWith({ + String? id, + String? name, + String? description, + String? createdAt, + String? updatedAt, + Value thumbnailAssetId = const Value.absent(), + int? isActivityEnabled, + int? order, + }) => RemoteAlbumEntityData( + id: id ?? this.id, + name: name ?? this.name, + description: description ?? this.description, + createdAt: createdAt ?? this.createdAt, + updatedAt: updatedAt ?? this.updatedAt, + thumbnailAssetId: thumbnailAssetId.present + ? thumbnailAssetId.value + : this.thumbnailAssetId, + isActivityEnabled: isActivityEnabled ?? this.isActivityEnabled, + order: order ?? this.order, + ); + RemoteAlbumEntityData copyWithCompanion(RemoteAlbumEntityCompanion data) { + return RemoteAlbumEntityData( + id: data.id.present ? data.id.value : this.id, + name: data.name.present ? data.name.value : this.name, + description: data.description.present + ? data.description.value + : this.description, + createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, + updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, + thumbnailAssetId: data.thumbnailAssetId.present + ? data.thumbnailAssetId.value + : this.thumbnailAssetId, + isActivityEnabled: data.isActivityEnabled.present + ? data.isActivityEnabled.value + : this.isActivityEnabled, + order: data.order.present ? data.order.value : this.order, + ); + } + + @override + String toString() { + return (StringBuffer('RemoteAlbumEntityData(') + ..write('id: $id, ') + ..write('name: $name, ') + ..write('description: $description, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt, ') + ..write('thumbnailAssetId: $thumbnailAssetId, ') + ..write('isActivityEnabled: $isActivityEnabled, ') + ..write('order: $order') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + name, + description, + createdAt, + updatedAt, + thumbnailAssetId, + isActivityEnabled, + order, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is RemoteAlbumEntityData && + other.id == this.id && + other.name == this.name && + other.description == this.description && + other.createdAt == this.createdAt && + other.updatedAt == this.updatedAt && + other.thumbnailAssetId == this.thumbnailAssetId && + other.isActivityEnabled == this.isActivityEnabled && + other.order == this.order); +} + +class RemoteAlbumEntityCompanion + extends UpdateCompanion { + final Value id; + final Value name; + final Value description; + final Value createdAt; + final Value updatedAt; + final Value thumbnailAssetId; + final Value isActivityEnabled; + final Value order; + const RemoteAlbumEntityCompanion({ + this.id = const Value.absent(), + this.name = const Value.absent(), + this.description = const Value.absent(), + this.createdAt = const Value.absent(), + this.updatedAt = const Value.absent(), + this.thumbnailAssetId = const Value.absent(), + this.isActivityEnabled = const Value.absent(), + this.order = const Value.absent(), + }); + RemoteAlbumEntityCompanion.insert({ + required String id, + required String name, + this.description = const Value.absent(), + this.createdAt = const Value.absent(), + this.updatedAt = const Value.absent(), + this.thumbnailAssetId = const Value.absent(), + this.isActivityEnabled = const Value.absent(), + required int order, + }) : id = Value(id), + name = Value(name), + order = Value(order); + static Insertable custom({ + Expression? id, + Expression? name, + Expression? description, + Expression? createdAt, + Expression? updatedAt, + Expression? thumbnailAssetId, + Expression? isActivityEnabled, + Expression? order, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (name != null) 'name': name, + if (description != null) 'description': description, + if (createdAt != null) 'created_at': createdAt, + if (updatedAt != null) 'updated_at': updatedAt, + if (thumbnailAssetId != null) 'thumbnail_asset_id': thumbnailAssetId, + if (isActivityEnabled != null) 'is_activity_enabled': isActivityEnabled, + if (order != null) 'order': order, + }); + } + + RemoteAlbumEntityCompanion copyWith({ + Value? id, + Value? name, + Value? description, + Value? createdAt, + Value? updatedAt, + Value? thumbnailAssetId, + Value? isActivityEnabled, + Value? order, + }) { + return RemoteAlbumEntityCompanion( + id: id ?? this.id, + name: name ?? this.name, + description: description ?? this.description, + createdAt: createdAt ?? this.createdAt, + updatedAt: updatedAt ?? this.updatedAt, + thumbnailAssetId: thumbnailAssetId ?? this.thumbnailAssetId, + isActivityEnabled: isActivityEnabled ?? this.isActivityEnabled, + order: order ?? this.order, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (name.present) { + map['name'] = Variable(name.value); + } + if (description.present) { + map['description'] = Variable(description.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + if (updatedAt.present) { + map['updated_at'] = Variable(updatedAt.value); + } + if (thumbnailAssetId.present) { + map['thumbnail_asset_id'] = Variable(thumbnailAssetId.value); + } + if (isActivityEnabled.present) { + map['is_activity_enabled'] = Variable(isActivityEnabled.value); + } + if (order.present) { + map['order'] = Variable(order.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('RemoteAlbumEntityCompanion(') + ..write('id: $id, ') + ..write('name: $name, ') + ..write('description: $description, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt, ') + ..write('thumbnailAssetId: $thumbnailAssetId, ') + ..write('isActivityEnabled: $isActivityEnabled, ') + ..write('order: $order') + ..write(')')) + .toString(); + } +} + +class LocalAlbumEntity extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + LocalAlbumEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn name = GeneratedColumn( + 'name', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn updatedAt = GeneratedColumn( + 'updated_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', + defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), + ); + late final GeneratedColumn backupSelection = GeneratedColumn( + 'backup_selection', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn isIosSharedAlbum = GeneratedColumn( + 'is_ios_shared_album', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: + 'NOT NULL DEFAULT 0 CHECK (is_ios_shared_album IN (0, 1))', + defaultValue: const CustomExpression('0'), + ); + late final GeneratedColumn linkedRemoteAlbumId = + GeneratedColumn( + 'linked_remote_album_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: + 'NULL REFERENCES remote_album_entity(id)ON DELETE SET NULL', + ); + late final GeneratedColumn marker = GeneratedColumn( + 'marker', + aliasedName, + true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NULL CHECK (marker IN (0, 1))', + ); + @override + List get $columns => [ + id, + name, + updatedAt, + backupSelection, + isIosSharedAlbum, + linkedRemoteAlbumId, + marker, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'local_album_entity'; + @override + Set get $primaryKey => {id}; + @override + LocalAlbumEntityData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return LocalAlbumEntityData( + id: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + name: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}name'], + )!, + updatedAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}updated_at'], + )!, + backupSelection: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}backup_selection'], + )!, + isIosSharedAlbum: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}is_ios_shared_album'], + )!, + linkedRemoteAlbumId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}linked_remote_album_id'], + ), + marker: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}marker'], + ), + ); + } + + @override + LocalAlbumEntity createAlias(String alias) { + return LocalAlbumEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const ['PRIMARY KEY(id)']; + @override + bool get dontWriteConstraints => true; +} + +class LocalAlbumEntityData extends DataClass + implements Insertable { + final String id; + final String name; + final String updatedAt; + final int backupSelection; + final int isIosSharedAlbum; + final String? linkedRemoteAlbumId; + final int? marker; + const LocalAlbumEntityData({ + required this.id, + required this.name, + required this.updatedAt, + required this.backupSelection, + required this.isIosSharedAlbum, + this.linkedRemoteAlbumId, + this.marker, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['name'] = Variable(name); + map['updated_at'] = Variable(updatedAt); + map['backup_selection'] = Variable(backupSelection); + map['is_ios_shared_album'] = Variable(isIosSharedAlbum); + if (!nullToAbsent || linkedRemoteAlbumId != null) { + map['linked_remote_album_id'] = Variable(linkedRemoteAlbumId); + } + if (!nullToAbsent || marker != null) { + map['marker'] = Variable(marker); + } + return map; + } + + factory LocalAlbumEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return LocalAlbumEntityData( + id: serializer.fromJson(json['id']), + name: serializer.fromJson(json['name']), + updatedAt: serializer.fromJson(json['updatedAt']), + backupSelection: serializer.fromJson(json['backupSelection']), + isIosSharedAlbum: serializer.fromJson(json['isIosSharedAlbum']), + linkedRemoteAlbumId: serializer.fromJson( + json['linkedRemoteAlbumId'], + ), + marker: serializer.fromJson(json['marker']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'name': serializer.toJson(name), + 'updatedAt': serializer.toJson(updatedAt), + 'backupSelection': serializer.toJson(backupSelection), + 'isIosSharedAlbum': serializer.toJson(isIosSharedAlbum), + 'linkedRemoteAlbumId': serializer.toJson(linkedRemoteAlbumId), + 'marker': serializer.toJson(marker), + }; + } + + LocalAlbumEntityData copyWith({ + String? id, + String? name, + String? updatedAt, + int? backupSelection, + int? isIosSharedAlbum, + Value linkedRemoteAlbumId = const Value.absent(), + Value marker = const Value.absent(), + }) => LocalAlbumEntityData( + id: id ?? this.id, + name: name ?? this.name, + updatedAt: updatedAt ?? this.updatedAt, + backupSelection: backupSelection ?? this.backupSelection, + isIosSharedAlbum: isIosSharedAlbum ?? this.isIosSharedAlbum, + linkedRemoteAlbumId: linkedRemoteAlbumId.present + ? linkedRemoteAlbumId.value + : this.linkedRemoteAlbumId, + marker: marker.present ? marker.value : this.marker, + ); + LocalAlbumEntityData copyWithCompanion(LocalAlbumEntityCompanion data) { + return LocalAlbumEntityData( + id: data.id.present ? data.id.value : this.id, + name: data.name.present ? data.name.value : this.name, + updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, + backupSelection: data.backupSelection.present + ? data.backupSelection.value + : this.backupSelection, + isIosSharedAlbum: data.isIosSharedAlbum.present + ? data.isIosSharedAlbum.value + : this.isIosSharedAlbum, + linkedRemoteAlbumId: data.linkedRemoteAlbumId.present + ? data.linkedRemoteAlbumId.value + : this.linkedRemoteAlbumId, + marker: data.marker.present ? data.marker.value : this.marker, + ); + } + + @override + String toString() { + return (StringBuffer('LocalAlbumEntityData(') + ..write('id: $id, ') + ..write('name: $name, ') + ..write('updatedAt: $updatedAt, ') + ..write('backupSelection: $backupSelection, ') + ..write('isIosSharedAlbum: $isIosSharedAlbum, ') + ..write('linkedRemoteAlbumId: $linkedRemoteAlbumId, ') + ..write('marker: $marker') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + name, + updatedAt, + backupSelection, + isIosSharedAlbum, + linkedRemoteAlbumId, + marker, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is LocalAlbumEntityData && + other.id == this.id && + other.name == this.name && + other.updatedAt == this.updatedAt && + other.backupSelection == this.backupSelection && + other.isIosSharedAlbum == this.isIosSharedAlbum && + other.linkedRemoteAlbumId == this.linkedRemoteAlbumId && + other.marker == this.marker); +} + +class LocalAlbumEntityCompanion extends UpdateCompanion { + final Value id; + final Value name; + final Value updatedAt; + final Value backupSelection; + final Value isIosSharedAlbum; + final Value linkedRemoteAlbumId; + final Value marker; + const LocalAlbumEntityCompanion({ + this.id = const Value.absent(), + this.name = const Value.absent(), + this.updatedAt = const Value.absent(), + this.backupSelection = const Value.absent(), + this.isIosSharedAlbum = const Value.absent(), + this.linkedRemoteAlbumId = const Value.absent(), + this.marker = const Value.absent(), + }); + LocalAlbumEntityCompanion.insert({ + required String id, + required String name, + this.updatedAt = const Value.absent(), + required int backupSelection, + this.isIosSharedAlbum = const Value.absent(), + this.linkedRemoteAlbumId = const Value.absent(), + this.marker = const Value.absent(), + }) : id = Value(id), + name = Value(name), + backupSelection = Value(backupSelection); + static Insertable custom({ + Expression? id, + Expression? name, + Expression? updatedAt, + Expression? backupSelection, + Expression? isIosSharedAlbum, + Expression? linkedRemoteAlbumId, + Expression? marker, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (name != null) 'name': name, + if (updatedAt != null) 'updated_at': updatedAt, + if (backupSelection != null) 'backup_selection': backupSelection, + if (isIosSharedAlbum != null) 'is_ios_shared_album': isIosSharedAlbum, + if (linkedRemoteAlbumId != null) + 'linked_remote_album_id': linkedRemoteAlbumId, + if (marker != null) 'marker': marker, + }); + } + + LocalAlbumEntityCompanion copyWith({ + Value? id, + Value? name, + Value? updatedAt, + Value? backupSelection, + Value? isIosSharedAlbum, + Value? linkedRemoteAlbumId, + Value? marker, + }) { + return LocalAlbumEntityCompanion( + id: id ?? this.id, + name: name ?? this.name, + updatedAt: updatedAt ?? this.updatedAt, + backupSelection: backupSelection ?? this.backupSelection, + isIosSharedAlbum: isIosSharedAlbum ?? this.isIosSharedAlbum, + linkedRemoteAlbumId: linkedRemoteAlbumId ?? this.linkedRemoteAlbumId, + marker: marker ?? this.marker, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (name.present) { + map['name'] = Variable(name.value); + } + if (updatedAt.present) { + map['updated_at'] = Variable(updatedAt.value); + } + if (backupSelection.present) { + map['backup_selection'] = Variable(backupSelection.value); + } + if (isIosSharedAlbum.present) { + map['is_ios_shared_album'] = Variable(isIosSharedAlbum.value); + } + if (linkedRemoteAlbumId.present) { + map['linked_remote_album_id'] = Variable( + linkedRemoteAlbumId.value, + ); + } + if (marker.present) { + map['marker'] = Variable(marker.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('LocalAlbumEntityCompanion(') + ..write('id: $id, ') + ..write('name: $name, ') + ..write('updatedAt: $updatedAt, ') + ..write('backupSelection: $backupSelection, ') + ..write('isIosSharedAlbum: $isIosSharedAlbum, ') + ..write('linkedRemoteAlbumId: $linkedRemoteAlbumId, ') + ..write('marker: $marker') + ..write(')')) + .toString(); + } +} + +class LocalAlbumAssetEntity extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + LocalAlbumAssetEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn assetId = GeneratedColumn( + 'asset_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL REFERENCES local_asset_entity(id)ON DELETE CASCADE', + ); + late final GeneratedColumn albumId = GeneratedColumn( + 'album_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL REFERENCES local_album_entity(id)ON DELETE CASCADE', + ); + late final GeneratedColumn marker = GeneratedColumn( + 'marker', + aliasedName, + true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NULL CHECK (marker IN (0, 1))', + ); + @override + List get $columns => [assetId, albumId, marker]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'local_album_asset_entity'; + @override + Set get $primaryKey => {assetId, albumId}; + @override + LocalAlbumAssetEntityData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return LocalAlbumAssetEntityData( + assetId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}asset_id'], + )!, + albumId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}album_id'], + )!, + marker: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}marker'], + ), + ); + } + + @override + LocalAlbumAssetEntity createAlias(String alias) { + return LocalAlbumAssetEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const [ + 'PRIMARY KEY(asset_id, album_id)', + ]; + @override + bool get dontWriteConstraints => true; +} + +class LocalAlbumAssetEntityData extends DataClass + implements Insertable { + final String assetId; + final String albumId; + final int? marker; + const LocalAlbumAssetEntityData({ + required this.assetId, + required this.albumId, + this.marker, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['asset_id'] = Variable(assetId); + map['album_id'] = Variable(albumId); + if (!nullToAbsent || marker != null) { + map['marker'] = Variable(marker); + } + return map; + } + + factory LocalAlbumAssetEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return LocalAlbumAssetEntityData( + assetId: serializer.fromJson(json['assetId']), + albumId: serializer.fromJson(json['albumId']), + marker: serializer.fromJson(json['marker']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'assetId': serializer.toJson(assetId), + 'albumId': serializer.toJson(albumId), + 'marker': serializer.toJson(marker), + }; + } + + LocalAlbumAssetEntityData copyWith({ + String? assetId, + String? albumId, + Value marker = const Value.absent(), + }) => LocalAlbumAssetEntityData( + assetId: assetId ?? this.assetId, + albumId: albumId ?? this.albumId, + marker: marker.present ? marker.value : this.marker, + ); + LocalAlbumAssetEntityData copyWithCompanion( + LocalAlbumAssetEntityCompanion data, + ) { + return LocalAlbumAssetEntityData( + assetId: data.assetId.present ? data.assetId.value : this.assetId, + albumId: data.albumId.present ? data.albumId.value : this.albumId, + marker: data.marker.present ? data.marker.value : this.marker, + ); + } + + @override + String toString() { + return (StringBuffer('LocalAlbumAssetEntityData(') + ..write('assetId: $assetId, ') + ..write('albumId: $albumId, ') + ..write('marker: $marker') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(assetId, albumId, marker); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is LocalAlbumAssetEntityData && + other.assetId == this.assetId && + other.albumId == this.albumId && + other.marker == this.marker); +} + +class LocalAlbumAssetEntityCompanion + extends UpdateCompanion { + final Value assetId; + final Value albumId; + final Value marker; + const LocalAlbumAssetEntityCompanion({ + this.assetId = const Value.absent(), + this.albumId = const Value.absent(), + this.marker = const Value.absent(), + }); + LocalAlbumAssetEntityCompanion.insert({ + required String assetId, + required String albumId, + this.marker = const Value.absent(), + }) : assetId = Value(assetId), + albumId = Value(albumId); + static Insertable custom({ + Expression? assetId, + Expression? albumId, + Expression? marker, + }) { + return RawValuesInsertable({ + if (assetId != null) 'asset_id': assetId, + if (albumId != null) 'album_id': albumId, + if (marker != null) 'marker': marker, + }); + } + + LocalAlbumAssetEntityCompanion copyWith({ + Value? assetId, + Value? albumId, + Value? marker, + }) { + return LocalAlbumAssetEntityCompanion( + assetId: assetId ?? this.assetId, + albumId: albumId ?? this.albumId, + marker: marker ?? this.marker, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (assetId.present) { + map['asset_id'] = Variable(assetId.value); + } + if (albumId.present) { + map['album_id'] = Variable(albumId.value); + } + if (marker.present) { + map['marker'] = Variable(marker.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('LocalAlbumAssetEntityCompanion(') + ..write('assetId: $assetId, ') + ..write('albumId: $albumId, ') + ..write('marker: $marker') + ..write(')')) + .toString(); + } +} + +class AuthUserEntity extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + AuthUserEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn name = GeneratedColumn( + 'name', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn email = GeneratedColumn( + 'email', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn isAdmin = GeneratedColumn( + 'is_admin', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 0 CHECK (is_admin IN (0, 1))', + defaultValue: const CustomExpression('0'), + ); + late final GeneratedColumn hasProfileImage = GeneratedColumn( + 'has_profile_image', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: + 'NOT NULL DEFAULT 0 CHECK (has_profile_image IN (0, 1))', + defaultValue: const CustomExpression('0'), + ); + late final GeneratedColumn profileChangedAt = GeneratedColumn( + 'profile_changed_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', + defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), + ); + late final GeneratedColumn avatarColor = GeneratedColumn( + 'avatar_color', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn quotaSizeInBytes = GeneratedColumn( + 'quota_size_in_bytes', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 0', + defaultValue: const CustomExpression('0'), + ); + late final GeneratedColumn quotaUsageInBytes = GeneratedColumn( + 'quota_usage_in_bytes', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 0', + defaultValue: const CustomExpression('0'), + ); + late final GeneratedColumn pinCode = GeneratedColumn( + 'pin_code', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + @override + List get $columns => [ + id, + name, + email, + isAdmin, + hasProfileImage, + profileChangedAt, + avatarColor, + quotaSizeInBytes, + quotaUsageInBytes, + pinCode, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'auth_user_entity'; + @override + Set get $primaryKey => {id}; + @override + AuthUserEntityData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return AuthUserEntityData( + id: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + name: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}name'], + )!, + email: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}email'], + )!, + isAdmin: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}is_admin'], + )!, + hasProfileImage: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}has_profile_image'], + )!, + profileChangedAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}profile_changed_at'], + )!, + avatarColor: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}avatar_color'], + )!, + quotaSizeInBytes: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}quota_size_in_bytes'], + )!, + quotaUsageInBytes: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}quota_usage_in_bytes'], + )!, + pinCode: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}pin_code'], + ), + ); + } + + @override + AuthUserEntity createAlias(String alias) { + return AuthUserEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const ['PRIMARY KEY(id)']; + @override + bool get dontWriteConstraints => true; +} + +class AuthUserEntityData extends DataClass + implements Insertable { + final String id; + final String name; + final String email; + final int isAdmin; + final int hasProfileImage; + final String profileChangedAt; + final int avatarColor; + final int quotaSizeInBytes; + final int quotaUsageInBytes; + final String? pinCode; + const AuthUserEntityData({ + required this.id, + required this.name, + required this.email, + required this.isAdmin, + required this.hasProfileImage, + required this.profileChangedAt, + required this.avatarColor, + required this.quotaSizeInBytes, + required this.quotaUsageInBytes, + this.pinCode, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['name'] = Variable(name); + map['email'] = Variable(email); + map['is_admin'] = Variable(isAdmin); + map['has_profile_image'] = Variable(hasProfileImage); + map['profile_changed_at'] = Variable(profileChangedAt); + map['avatar_color'] = Variable(avatarColor); + map['quota_size_in_bytes'] = Variable(quotaSizeInBytes); + map['quota_usage_in_bytes'] = Variable(quotaUsageInBytes); + if (!nullToAbsent || pinCode != null) { + map['pin_code'] = Variable(pinCode); + } + return map; + } + + factory AuthUserEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return AuthUserEntityData( + id: serializer.fromJson(json['id']), + name: serializer.fromJson(json['name']), + email: serializer.fromJson(json['email']), + isAdmin: serializer.fromJson(json['isAdmin']), + hasProfileImage: serializer.fromJson(json['hasProfileImage']), + profileChangedAt: serializer.fromJson(json['profileChangedAt']), + avatarColor: serializer.fromJson(json['avatarColor']), + quotaSizeInBytes: serializer.fromJson(json['quotaSizeInBytes']), + quotaUsageInBytes: serializer.fromJson(json['quotaUsageInBytes']), + pinCode: serializer.fromJson(json['pinCode']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'name': serializer.toJson(name), + 'email': serializer.toJson(email), + 'isAdmin': serializer.toJson(isAdmin), + 'hasProfileImage': serializer.toJson(hasProfileImage), + 'profileChangedAt': serializer.toJson(profileChangedAt), + 'avatarColor': serializer.toJson(avatarColor), + 'quotaSizeInBytes': serializer.toJson(quotaSizeInBytes), + 'quotaUsageInBytes': serializer.toJson(quotaUsageInBytes), + 'pinCode': serializer.toJson(pinCode), + }; + } + + AuthUserEntityData copyWith({ + String? id, + String? name, + String? email, + int? isAdmin, + int? hasProfileImage, + String? profileChangedAt, + int? avatarColor, + int? quotaSizeInBytes, + int? quotaUsageInBytes, + Value pinCode = const Value.absent(), + }) => AuthUserEntityData( + id: id ?? this.id, + name: name ?? this.name, + email: email ?? this.email, + isAdmin: isAdmin ?? this.isAdmin, + hasProfileImage: hasProfileImage ?? this.hasProfileImage, + profileChangedAt: profileChangedAt ?? this.profileChangedAt, + avatarColor: avatarColor ?? this.avatarColor, + quotaSizeInBytes: quotaSizeInBytes ?? this.quotaSizeInBytes, + quotaUsageInBytes: quotaUsageInBytes ?? this.quotaUsageInBytes, + pinCode: pinCode.present ? pinCode.value : this.pinCode, + ); + AuthUserEntityData copyWithCompanion(AuthUserEntityCompanion data) { + return AuthUserEntityData( + id: data.id.present ? data.id.value : this.id, + name: data.name.present ? data.name.value : this.name, + email: data.email.present ? data.email.value : this.email, + isAdmin: data.isAdmin.present ? data.isAdmin.value : this.isAdmin, + hasProfileImage: data.hasProfileImage.present + ? data.hasProfileImage.value + : this.hasProfileImage, + profileChangedAt: data.profileChangedAt.present + ? data.profileChangedAt.value + : this.profileChangedAt, + avatarColor: data.avatarColor.present + ? data.avatarColor.value + : this.avatarColor, + quotaSizeInBytes: data.quotaSizeInBytes.present + ? data.quotaSizeInBytes.value + : this.quotaSizeInBytes, + quotaUsageInBytes: data.quotaUsageInBytes.present + ? data.quotaUsageInBytes.value + : this.quotaUsageInBytes, + pinCode: data.pinCode.present ? data.pinCode.value : this.pinCode, + ); + } + + @override + String toString() { + return (StringBuffer('AuthUserEntityData(') + ..write('id: $id, ') + ..write('name: $name, ') + ..write('email: $email, ') + ..write('isAdmin: $isAdmin, ') + ..write('hasProfileImage: $hasProfileImage, ') + ..write('profileChangedAt: $profileChangedAt, ') + ..write('avatarColor: $avatarColor, ') + ..write('quotaSizeInBytes: $quotaSizeInBytes, ') + ..write('quotaUsageInBytes: $quotaUsageInBytes, ') + ..write('pinCode: $pinCode') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + name, + email, + isAdmin, + hasProfileImage, + profileChangedAt, + avatarColor, + quotaSizeInBytes, + quotaUsageInBytes, + pinCode, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is AuthUserEntityData && + other.id == this.id && + other.name == this.name && + other.email == this.email && + other.isAdmin == this.isAdmin && + other.hasProfileImage == this.hasProfileImage && + other.profileChangedAt == this.profileChangedAt && + other.avatarColor == this.avatarColor && + other.quotaSizeInBytes == this.quotaSizeInBytes && + other.quotaUsageInBytes == this.quotaUsageInBytes && + other.pinCode == this.pinCode); +} + +class AuthUserEntityCompanion extends UpdateCompanion { + final Value id; + final Value name; + final Value email; + final Value isAdmin; + final Value hasProfileImage; + final Value profileChangedAt; + final Value avatarColor; + final Value quotaSizeInBytes; + final Value quotaUsageInBytes; + final Value pinCode; + const AuthUserEntityCompanion({ + this.id = const Value.absent(), + this.name = const Value.absent(), + this.email = const Value.absent(), + this.isAdmin = const Value.absent(), + this.hasProfileImage = const Value.absent(), + this.profileChangedAt = const Value.absent(), + this.avatarColor = const Value.absent(), + this.quotaSizeInBytes = const Value.absent(), + this.quotaUsageInBytes = const Value.absent(), + this.pinCode = const Value.absent(), + }); + AuthUserEntityCompanion.insert({ + required String id, + required String name, + required String email, + this.isAdmin = const Value.absent(), + this.hasProfileImage = const Value.absent(), + this.profileChangedAt = const Value.absent(), + required int avatarColor, + this.quotaSizeInBytes = const Value.absent(), + this.quotaUsageInBytes = const Value.absent(), + this.pinCode = const Value.absent(), + }) : id = Value(id), + name = Value(name), + email = Value(email), + avatarColor = Value(avatarColor); + static Insertable custom({ + Expression? id, + Expression? name, + Expression? email, + Expression? isAdmin, + Expression? hasProfileImage, + Expression? profileChangedAt, + Expression? avatarColor, + Expression? quotaSizeInBytes, + Expression? quotaUsageInBytes, + Expression? pinCode, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (name != null) 'name': name, + if (email != null) 'email': email, + if (isAdmin != null) 'is_admin': isAdmin, + if (hasProfileImage != null) 'has_profile_image': hasProfileImage, + if (profileChangedAt != null) 'profile_changed_at': profileChangedAt, + if (avatarColor != null) 'avatar_color': avatarColor, + if (quotaSizeInBytes != null) 'quota_size_in_bytes': quotaSizeInBytes, + if (quotaUsageInBytes != null) 'quota_usage_in_bytes': quotaUsageInBytes, + if (pinCode != null) 'pin_code': pinCode, + }); + } + + AuthUserEntityCompanion copyWith({ + Value? id, + Value? name, + Value? email, + Value? isAdmin, + Value? hasProfileImage, + Value? profileChangedAt, + Value? avatarColor, + Value? quotaSizeInBytes, + Value? quotaUsageInBytes, + Value? pinCode, + }) { + return AuthUserEntityCompanion( + id: id ?? this.id, + name: name ?? this.name, + email: email ?? this.email, + isAdmin: isAdmin ?? this.isAdmin, + hasProfileImage: hasProfileImage ?? this.hasProfileImage, + profileChangedAt: profileChangedAt ?? this.profileChangedAt, + avatarColor: avatarColor ?? this.avatarColor, + quotaSizeInBytes: quotaSizeInBytes ?? this.quotaSizeInBytes, + quotaUsageInBytes: quotaUsageInBytes ?? this.quotaUsageInBytes, + pinCode: pinCode ?? this.pinCode, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (name.present) { + map['name'] = Variable(name.value); + } + if (email.present) { + map['email'] = Variable(email.value); + } + if (isAdmin.present) { + map['is_admin'] = Variable(isAdmin.value); + } + if (hasProfileImage.present) { + map['has_profile_image'] = Variable(hasProfileImage.value); + } + if (profileChangedAt.present) { + map['profile_changed_at'] = Variable(profileChangedAt.value); + } + if (avatarColor.present) { + map['avatar_color'] = Variable(avatarColor.value); + } + if (quotaSizeInBytes.present) { + map['quota_size_in_bytes'] = Variable(quotaSizeInBytes.value); + } + if (quotaUsageInBytes.present) { + map['quota_usage_in_bytes'] = Variable(quotaUsageInBytes.value); + } + if (pinCode.present) { + map['pin_code'] = Variable(pinCode.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('AuthUserEntityCompanion(') + ..write('id: $id, ') + ..write('name: $name, ') + ..write('email: $email, ') + ..write('isAdmin: $isAdmin, ') + ..write('hasProfileImage: $hasProfileImage, ') + ..write('profileChangedAt: $profileChangedAt, ') + ..write('avatarColor: $avatarColor, ') + ..write('quotaSizeInBytes: $quotaSizeInBytes, ') + ..write('quotaUsageInBytes: $quotaUsageInBytes, ') + ..write('pinCode: $pinCode') + ..write(')')) + .toString(); + } +} + +class UserMetadataEntity extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + UserMetadataEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL REFERENCES user_entity(id)ON DELETE CASCADE', + ); + late final GeneratedColumn key = GeneratedColumn( + 'key', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn value = + GeneratedColumn( + 'value', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + @override + List get $columns => [userId, key, value]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'user_metadata_entity'; + @override + Set get $primaryKey => {userId, key}; + @override + UserMetadataEntityData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return UserMetadataEntityData( + userId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}user_id'], + )!, + key: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}key'], + )!, + value: attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}value'], + )!, + ); + } + + @override + UserMetadataEntity createAlias(String alias) { + return UserMetadataEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const ['PRIMARY KEY(user_id, "key")']; + @override + bool get dontWriteConstraints => true; +} + +class UserMetadataEntityData extends DataClass + implements Insertable { + final String userId; + final int key; + final i2.Uint8List value; + const UserMetadataEntityData({ + required this.userId, + required this.key, + required this.value, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['user_id'] = Variable(userId); + map['key'] = Variable(key); + map['value'] = Variable(value); + return map; + } + + factory UserMetadataEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return UserMetadataEntityData( + userId: serializer.fromJson(json['userId']), + key: serializer.fromJson(json['key']), + value: serializer.fromJson(json['value']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'userId': serializer.toJson(userId), + 'key': serializer.toJson(key), + 'value': serializer.toJson(value), + }; + } + + UserMetadataEntityData copyWith({ + String? userId, + int? key, + i2.Uint8List? value, + }) => UserMetadataEntityData( + userId: userId ?? this.userId, + key: key ?? this.key, + value: value ?? this.value, + ); + UserMetadataEntityData copyWithCompanion(UserMetadataEntityCompanion data) { + return UserMetadataEntityData( + userId: data.userId.present ? data.userId.value : this.userId, + key: data.key.present ? data.key.value : this.key, + value: data.value.present ? data.value.value : this.value, + ); + } + + @override + String toString() { + return (StringBuffer('UserMetadataEntityData(') + ..write('userId: $userId, ') + ..write('key: $key, ') + ..write('value: $value') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(userId, key, $driftBlobEquality.hash(value)); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is UserMetadataEntityData && + other.userId == this.userId && + other.key == this.key && + $driftBlobEquality.equals(other.value, this.value)); +} + +class UserMetadataEntityCompanion + extends UpdateCompanion { + final Value userId; + final Value key; + final Value value; + const UserMetadataEntityCompanion({ + this.userId = const Value.absent(), + this.key = const Value.absent(), + this.value = const Value.absent(), + }); + UserMetadataEntityCompanion.insert({ + required String userId, + required int key, + required i2.Uint8List value, + }) : userId = Value(userId), + key = Value(key), + value = Value(value); + static Insertable custom({ + Expression? userId, + Expression? key, + Expression? value, + }) { + return RawValuesInsertable({ + if (userId != null) 'user_id': userId, + if (key != null) 'key': key, + if (value != null) 'value': value, + }); + } + + UserMetadataEntityCompanion copyWith({ + Value? userId, + Value? key, + Value? value, + }) { + return UserMetadataEntityCompanion( + userId: userId ?? this.userId, + key: key ?? this.key, + value: value ?? this.value, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (userId.present) { + map['user_id'] = Variable(userId.value); + } + if (key.present) { + map['key'] = Variable(key.value); + } + if (value.present) { + map['value'] = Variable(value.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('UserMetadataEntityCompanion(') + ..write('userId: $userId, ') + ..write('key: $key, ') + ..write('value: $value') + ..write(')')) + .toString(); + } +} + +class PartnerEntity extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + PartnerEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn sharedById = GeneratedColumn( + 'shared_by_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL REFERENCES user_entity(id)ON DELETE CASCADE', + ); + late final GeneratedColumn sharedWithId = GeneratedColumn( + 'shared_with_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL REFERENCES user_entity(id)ON DELETE CASCADE', + ); + late final GeneratedColumn inTimeline = GeneratedColumn( + 'in_timeline', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 0 CHECK (in_timeline IN (0, 1))', + defaultValue: const CustomExpression('0'), + ); + @override + List get $columns => [sharedById, sharedWithId, inTimeline]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'partner_entity'; + @override + Set get $primaryKey => {sharedById, sharedWithId}; + @override + PartnerEntityData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return PartnerEntityData( + sharedById: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}shared_by_id'], + )!, + sharedWithId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}shared_with_id'], + )!, + inTimeline: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}in_timeline'], + )!, + ); + } + + @override + PartnerEntity createAlias(String alias) { + return PartnerEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const [ + 'PRIMARY KEY(shared_by_id, shared_with_id)', + ]; + @override + bool get dontWriteConstraints => true; +} + +class PartnerEntityData extends DataClass + implements Insertable { + final String sharedById; + final String sharedWithId; + final int inTimeline; + const PartnerEntityData({ + required this.sharedById, + required this.sharedWithId, + required this.inTimeline, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['shared_by_id'] = Variable(sharedById); + map['shared_with_id'] = Variable(sharedWithId); + map['in_timeline'] = Variable(inTimeline); + return map; + } + + factory PartnerEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return PartnerEntityData( + sharedById: serializer.fromJson(json['sharedById']), + sharedWithId: serializer.fromJson(json['sharedWithId']), + inTimeline: serializer.fromJson(json['inTimeline']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'sharedById': serializer.toJson(sharedById), + 'sharedWithId': serializer.toJson(sharedWithId), + 'inTimeline': serializer.toJson(inTimeline), + }; + } + + PartnerEntityData copyWith({ + String? sharedById, + String? sharedWithId, + int? inTimeline, + }) => PartnerEntityData( + sharedById: sharedById ?? this.sharedById, + sharedWithId: sharedWithId ?? this.sharedWithId, + inTimeline: inTimeline ?? this.inTimeline, + ); + PartnerEntityData copyWithCompanion(PartnerEntityCompanion data) { + return PartnerEntityData( + sharedById: data.sharedById.present + ? data.sharedById.value + : this.sharedById, + sharedWithId: data.sharedWithId.present + ? data.sharedWithId.value + : this.sharedWithId, + inTimeline: data.inTimeline.present + ? data.inTimeline.value + : this.inTimeline, + ); + } + + @override + String toString() { + return (StringBuffer('PartnerEntityData(') + ..write('sharedById: $sharedById, ') + ..write('sharedWithId: $sharedWithId, ') + ..write('inTimeline: $inTimeline') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(sharedById, sharedWithId, inTimeline); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is PartnerEntityData && + other.sharedById == this.sharedById && + other.sharedWithId == this.sharedWithId && + other.inTimeline == this.inTimeline); +} + +class PartnerEntityCompanion extends UpdateCompanion { + final Value sharedById; + final Value sharedWithId; + final Value inTimeline; + const PartnerEntityCompanion({ + this.sharedById = const Value.absent(), + this.sharedWithId = const Value.absent(), + this.inTimeline = const Value.absent(), + }); + PartnerEntityCompanion.insert({ + required String sharedById, + required String sharedWithId, + this.inTimeline = const Value.absent(), + }) : sharedById = Value(sharedById), + sharedWithId = Value(sharedWithId); + static Insertable custom({ + Expression? sharedById, + Expression? sharedWithId, + Expression? inTimeline, + }) { + return RawValuesInsertable({ + if (sharedById != null) 'shared_by_id': sharedById, + if (sharedWithId != null) 'shared_with_id': sharedWithId, + if (inTimeline != null) 'in_timeline': inTimeline, + }); + } + + PartnerEntityCompanion copyWith({ + Value? sharedById, + Value? sharedWithId, + Value? inTimeline, + }) { + return PartnerEntityCompanion( + sharedById: sharedById ?? this.sharedById, + sharedWithId: sharedWithId ?? this.sharedWithId, + inTimeline: inTimeline ?? this.inTimeline, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (sharedById.present) { + map['shared_by_id'] = Variable(sharedById.value); + } + if (sharedWithId.present) { + map['shared_with_id'] = Variable(sharedWithId.value); + } + if (inTimeline.present) { + map['in_timeline'] = Variable(inTimeline.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('PartnerEntityCompanion(') + ..write('sharedById: $sharedById, ') + ..write('sharedWithId: $sharedWithId, ') + ..write('inTimeline: $inTimeline') + ..write(')')) + .toString(); + } +} + +class RemoteExifEntity extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + RemoteExifEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn assetId = GeneratedColumn( + 'asset_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL REFERENCES remote_asset_entity(id)ON DELETE CASCADE', + ); + late final GeneratedColumn city = GeneratedColumn( + 'city', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn state = GeneratedColumn( + 'state', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn country = GeneratedColumn( + 'country', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn dateTimeOriginal = GeneratedColumn( + 'date_time_original', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn description = GeneratedColumn( + 'description', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn height = GeneratedColumn( + 'height', + aliasedName, + true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn width = GeneratedColumn( + 'width', + aliasedName, + true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn exposureTime = GeneratedColumn( + 'exposure_time', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn fNumber = GeneratedColumn( + 'f_number', + aliasedName, + true, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn fileSize = GeneratedColumn( + 'file_size', + aliasedName, + true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn focalLength = GeneratedColumn( + 'focal_length', + aliasedName, + true, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn latitude = GeneratedColumn( + 'latitude', + aliasedName, + true, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn longitude = GeneratedColumn( + 'longitude', + aliasedName, + true, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn iso = GeneratedColumn( + 'iso', + aliasedName, + true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn make = GeneratedColumn( + 'make', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn model = GeneratedColumn( + 'model', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn lens = GeneratedColumn( + 'lens', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn orientation = GeneratedColumn( + 'orientation', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn timeZone = GeneratedColumn( + 'time_zone', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn rating = GeneratedColumn( + 'rating', + aliasedName, + true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn projectionType = GeneratedColumn( + 'projection_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + @override + List get $columns => [ + assetId, + city, + state, + country, + dateTimeOriginal, + description, + height, + width, + exposureTime, + fNumber, + fileSize, + focalLength, + latitude, + longitude, + iso, + make, + model, + lens, + orientation, + timeZone, + rating, + projectionType, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'remote_exif_entity'; + @override + Set get $primaryKey => {assetId}; + @override + RemoteExifEntityData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return RemoteExifEntityData( + assetId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}asset_id'], + )!, + city: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}city'], + ), + state: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}state'], + ), + country: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}country'], + ), + dateTimeOriginal: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}date_time_original'], + ), + description: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}description'], + ), + height: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}height'], + ), + width: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}width'], + ), + exposureTime: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}exposure_time'], + ), + fNumber: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}f_number'], + ), + fileSize: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}file_size'], + ), + focalLength: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}focal_length'], + ), + latitude: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}latitude'], + ), + longitude: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}longitude'], + ), + iso: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}iso'], + ), + make: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}make'], + ), + model: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}model'], + ), + lens: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}lens'], + ), + orientation: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}orientation'], + ), + timeZone: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}time_zone'], + ), + rating: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}rating'], + ), + projectionType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}projection_type'], + ), + ); + } + + @override + RemoteExifEntity createAlias(String alias) { + return RemoteExifEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const ['PRIMARY KEY(asset_id)']; + @override + bool get dontWriteConstraints => true; +} + +class RemoteExifEntityData extends DataClass + implements Insertable { + final String assetId; + final String? city; + final String? state; + final String? country; + final String? dateTimeOriginal; + final String? description; + final int? height; + final int? width; + final String? exposureTime; + final double? fNumber; + final int? fileSize; + final double? focalLength; + final double? latitude; + final double? longitude; + final int? iso; + final String? make; + final String? model; + final String? lens; + final String? orientation; + final String? timeZone; + final int? rating; + final String? projectionType; + const RemoteExifEntityData({ + 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.lens, + this.orientation, + this.timeZone, + this.rating, + this.projectionType, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['asset_id'] = Variable(assetId); + if (!nullToAbsent || city != null) { + map['city'] = Variable(city); + } + if (!nullToAbsent || state != null) { + map['state'] = Variable(state); + } + if (!nullToAbsent || country != null) { + map['country'] = Variable(country); + } + if (!nullToAbsent || dateTimeOriginal != null) { + map['date_time_original'] = Variable(dateTimeOriginal); + } + if (!nullToAbsent || description != null) { + map['description'] = Variable(description); + } + if (!nullToAbsent || height != null) { + map['height'] = Variable(height); + } + if (!nullToAbsent || width != null) { + map['width'] = Variable(width); + } + if (!nullToAbsent || exposureTime != null) { + map['exposure_time'] = Variable(exposureTime); + } + if (!nullToAbsent || fNumber != null) { + map['f_number'] = Variable(fNumber); + } + if (!nullToAbsent || fileSize != null) { + map['file_size'] = Variable(fileSize); + } + if (!nullToAbsent || focalLength != null) { + map['focal_length'] = Variable(focalLength); + } + if (!nullToAbsent || latitude != null) { + map['latitude'] = Variable(latitude); + } + if (!nullToAbsent || longitude != null) { + map['longitude'] = Variable(longitude); + } + if (!nullToAbsent || iso != null) { + map['iso'] = Variable(iso); + } + if (!nullToAbsent || make != null) { + map['make'] = Variable(make); + } + if (!nullToAbsent || model != null) { + map['model'] = Variable(model); + } + if (!nullToAbsent || lens != null) { + map['lens'] = Variable(lens); + } + if (!nullToAbsent || orientation != null) { + map['orientation'] = Variable(orientation); + } + if (!nullToAbsent || timeZone != null) { + map['time_zone'] = Variable(timeZone); + } + if (!nullToAbsent || rating != null) { + map['rating'] = Variable(rating); + } + if (!nullToAbsent || projectionType != null) { + map['projection_type'] = Variable(projectionType); + } + return map; + } + + factory RemoteExifEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return RemoteExifEntityData( + 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']), + lens: serializer.fromJson(json['lens']), + orientation: serializer.fromJson(json['orientation']), + timeZone: serializer.fromJson(json['timeZone']), + rating: serializer.fromJson(json['rating']), + projectionType: serializer.fromJson(json['projectionType']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= 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), + 'lens': serializer.toJson(lens), + 'orientation': serializer.toJson(orientation), + 'timeZone': serializer.toJson(timeZone), + 'rating': serializer.toJson(rating), + 'projectionType': serializer.toJson(projectionType), + }; + } + + RemoteExifEntityData copyWith({ + String? assetId, + Value city = const Value.absent(), + Value state = const Value.absent(), + Value country = const Value.absent(), + Value dateTimeOriginal = const Value.absent(), + Value description = const Value.absent(), + Value height = const Value.absent(), + Value width = const Value.absent(), + Value exposureTime = const Value.absent(), + Value fNumber = const Value.absent(), + Value fileSize = const Value.absent(), + Value focalLength = const Value.absent(), + Value latitude = const Value.absent(), + Value longitude = const Value.absent(), + Value iso = const Value.absent(), + Value make = const Value.absent(), + Value model = const Value.absent(), + Value lens = const Value.absent(), + Value orientation = const Value.absent(), + Value timeZone = const Value.absent(), + Value rating = const Value.absent(), + Value projectionType = const Value.absent(), + }) => RemoteExifEntityData( + 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, + lens: lens.present ? lens.value : this.lens, + 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, + ); + RemoteExifEntityData copyWithCompanion(RemoteExifEntityCompanion data) { + return RemoteExifEntityData( + 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, + lens: data.lens.present ? data.lens.value : this.lens, + 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('RemoteExifEntityData(') + ..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('lens: $lens, ') + ..write('orientation: $orientation, ') + ..write('timeZone: $timeZone, ') + ..write('rating: $rating, ') + ..write('projectionType: $projectionType') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hashAll([ + assetId, + city, + state, + country, + dateTimeOriginal, + description, + height, + width, + exposureTime, + fNumber, + fileSize, + focalLength, + latitude, + longitude, + iso, + make, + model, + lens, + orientation, + timeZone, + rating, + projectionType, + ]); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is RemoteExifEntityData && + 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.lens == this.lens && + other.orientation == this.orientation && + other.timeZone == this.timeZone && + other.rating == this.rating && + other.projectionType == this.projectionType); +} + +class RemoteExifEntityCompanion extends UpdateCompanion { + final Value assetId; + final Value city; + final Value state; + final Value country; + final Value dateTimeOriginal; + final Value description; + final Value height; + final Value width; + final Value exposureTime; + final Value fNumber; + final Value fileSize; + final Value focalLength; + final Value latitude; + final Value longitude; + final Value iso; + final Value make; + final Value model; + final Value lens; + final Value orientation; + final Value timeZone; + final Value rating; + final Value projectionType; + const RemoteExifEntityCompanion({ + this.assetId = const Value.absent(), + this.city = const Value.absent(), + this.state = const Value.absent(), + this.country = const Value.absent(), + this.dateTimeOriginal = const Value.absent(), + this.description = const Value.absent(), + this.height = const Value.absent(), + this.width = const Value.absent(), + this.exposureTime = const Value.absent(), + this.fNumber = const Value.absent(), + this.fileSize = const Value.absent(), + this.focalLength = const Value.absent(), + this.latitude = const Value.absent(), + this.longitude = const Value.absent(), + this.iso = const Value.absent(), + this.make = const Value.absent(), + this.model = const Value.absent(), + this.lens = const Value.absent(), + this.orientation = const Value.absent(), + this.timeZone = const Value.absent(), + this.rating = const Value.absent(), + this.projectionType = const Value.absent(), + }); + RemoteExifEntityCompanion.insert({ + required String assetId, + this.city = const Value.absent(), + this.state = const Value.absent(), + this.country = const Value.absent(), + this.dateTimeOriginal = const Value.absent(), + this.description = const Value.absent(), + this.height = const Value.absent(), + this.width = const Value.absent(), + this.exposureTime = const Value.absent(), + this.fNumber = const Value.absent(), + this.fileSize = const Value.absent(), + this.focalLength = const Value.absent(), + this.latitude = const Value.absent(), + this.longitude = const Value.absent(), + this.iso = const Value.absent(), + this.make = const Value.absent(), + this.model = const Value.absent(), + this.lens = const Value.absent(), + this.orientation = const Value.absent(), + this.timeZone = const Value.absent(), + this.rating = const Value.absent(), + this.projectionType = const Value.absent(), + }) : assetId = Value(assetId); + static Insertable custom({ + Expression? assetId, + Expression? city, + Expression? state, + Expression? country, + Expression? dateTimeOriginal, + Expression? description, + Expression? height, + Expression? width, + Expression? exposureTime, + Expression? fNumber, + Expression? fileSize, + Expression? focalLength, + Expression? latitude, + Expression? longitude, + Expression? iso, + Expression? make, + Expression? model, + Expression? lens, + Expression? orientation, + Expression? timeZone, + Expression? rating, + Expression? projectionType, + }) { + return 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 (lens != null) 'lens': lens, + if (orientation != null) 'orientation': orientation, + if (timeZone != null) 'time_zone': timeZone, + if (rating != null) 'rating': rating, + if (projectionType != null) 'projection_type': projectionType, + }); + } + + RemoteExifEntityCompanion copyWith({ + Value? assetId, + Value? city, + Value? state, + Value? country, + Value? dateTimeOriginal, + Value? description, + Value? height, + Value? width, + Value? exposureTime, + Value? fNumber, + Value? fileSize, + Value? focalLength, + Value? latitude, + Value? longitude, + Value? iso, + Value? make, + Value? model, + Value? lens, + Value? orientation, + Value? timeZone, + Value? rating, + Value? projectionType, + }) { + return RemoteExifEntityCompanion( + 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, + lens: lens ?? this.lens, + 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'] = Variable(assetId.value); + } + if (city.present) { + map['city'] = Variable(city.value); + } + if (state.present) { + map['state'] = Variable(state.value); + } + if (country.present) { + map['country'] = Variable(country.value); + } + if (dateTimeOriginal.present) { + map['date_time_original'] = Variable(dateTimeOriginal.value); + } + if (description.present) { + map['description'] = Variable(description.value); + } + if (height.present) { + map['height'] = Variable(height.value); + } + if (width.present) { + map['width'] = Variable(width.value); + } + if (exposureTime.present) { + map['exposure_time'] = Variable(exposureTime.value); + } + if (fNumber.present) { + map['f_number'] = Variable(fNumber.value); + } + if (fileSize.present) { + map['file_size'] = Variable(fileSize.value); + } + if (focalLength.present) { + map['focal_length'] = Variable(focalLength.value); + } + if (latitude.present) { + map['latitude'] = Variable(latitude.value); + } + if (longitude.present) { + map['longitude'] = Variable(longitude.value); + } + if (iso.present) { + map['iso'] = Variable(iso.value); + } + if (make.present) { + map['make'] = Variable(make.value); + } + if (model.present) { + map['model'] = Variable(model.value); + } + if (lens.present) { + map['lens'] = Variable(lens.value); + } + if (orientation.present) { + map['orientation'] = Variable(orientation.value); + } + if (timeZone.present) { + map['time_zone'] = Variable(timeZone.value); + } + if (rating.present) { + map['rating'] = Variable(rating.value); + } + if (projectionType.present) { + map['projection_type'] = Variable(projectionType.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('RemoteExifEntityCompanion(') + ..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('lens: $lens, ') + ..write('orientation: $orientation, ') + ..write('timeZone: $timeZone, ') + ..write('rating: $rating, ') + ..write('projectionType: $projectionType') + ..write(')')) + .toString(); + } +} + +class RemoteAlbumAssetEntity extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + RemoteAlbumAssetEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn assetId = GeneratedColumn( + 'asset_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL REFERENCES remote_asset_entity(id)ON DELETE CASCADE', + ); + late final GeneratedColumn albumId = GeneratedColumn( + 'album_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL REFERENCES remote_album_entity(id)ON DELETE CASCADE', + ); + @override + List get $columns => [assetId, albumId]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'remote_album_asset_entity'; + @override + Set get $primaryKey => {assetId, albumId}; + @override + RemoteAlbumAssetEntityData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return RemoteAlbumAssetEntityData( + assetId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}asset_id'], + )!, + albumId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}album_id'], + )!, + ); + } + + @override + RemoteAlbumAssetEntity createAlias(String alias) { + return RemoteAlbumAssetEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const [ + 'PRIMARY KEY(asset_id, album_id)', + ]; + @override + bool get dontWriteConstraints => true; +} + +class RemoteAlbumAssetEntityData extends DataClass + implements Insertable { + final String assetId; + final String albumId; + const RemoteAlbumAssetEntityData({ + required this.assetId, + required this.albumId, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['asset_id'] = Variable(assetId); + map['album_id'] = Variable(albumId); + return map; + } + + factory RemoteAlbumAssetEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return RemoteAlbumAssetEntityData( + assetId: serializer.fromJson(json['assetId']), + albumId: serializer.fromJson(json['albumId']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'assetId': serializer.toJson(assetId), + 'albumId': serializer.toJson(albumId), + }; + } + + RemoteAlbumAssetEntityData copyWith({String? assetId, String? albumId}) => + RemoteAlbumAssetEntityData( + assetId: assetId ?? this.assetId, + albumId: albumId ?? this.albumId, + ); + RemoteAlbumAssetEntityData copyWithCompanion( + RemoteAlbumAssetEntityCompanion data, + ) { + return RemoteAlbumAssetEntityData( + assetId: data.assetId.present ? data.assetId.value : this.assetId, + albumId: data.albumId.present ? data.albumId.value : this.albumId, + ); + } + + @override + String toString() { + return (StringBuffer('RemoteAlbumAssetEntityData(') + ..write('assetId: $assetId, ') + ..write('albumId: $albumId') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(assetId, albumId); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is RemoteAlbumAssetEntityData && + other.assetId == this.assetId && + other.albumId == this.albumId); +} + +class RemoteAlbumAssetEntityCompanion + extends UpdateCompanion { + final Value assetId; + final Value albumId; + const RemoteAlbumAssetEntityCompanion({ + this.assetId = const Value.absent(), + this.albumId = const Value.absent(), + }); + RemoteAlbumAssetEntityCompanion.insert({ + required String assetId, + required String albumId, + }) : assetId = Value(assetId), + albumId = Value(albumId); + static Insertable custom({ + Expression? assetId, + Expression? albumId, + }) { + return RawValuesInsertable({ + if (assetId != null) 'asset_id': assetId, + if (albumId != null) 'album_id': albumId, + }); + } + + RemoteAlbumAssetEntityCompanion copyWith({ + Value? assetId, + Value? albumId, + }) { + return RemoteAlbumAssetEntityCompanion( + assetId: assetId ?? this.assetId, + albumId: albumId ?? this.albumId, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (assetId.present) { + map['asset_id'] = Variable(assetId.value); + } + if (albumId.present) { + map['album_id'] = Variable(albumId.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('RemoteAlbumAssetEntityCompanion(') + ..write('assetId: $assetId, ') + ..write('albumId: $albumId') + ..write(')')) + .toString(); + } +} + +class RemoteAlbumUserEntity extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + RemoteAlbumUserEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn albumId = GeneratedColumn( + 'album_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL REFERENCES remote_album_entity(id)ON DELETE CASCADE', + ); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL REFERENCES user_entity(id)ON DELETE CASCADE', + ); + late final GeneratedColumn role = GeneratedColumn( + 'role', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + @override + List get $columns => [albumId, userId, role]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'remote_album_user_entity'; + @override + Set get $primaryKey => {albumId, userId}; + @override + RemoteAlbumUserEntityData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return RemoteAlbumUserEntityData( + albumId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}album_id'], + )!, + userId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}user_id'], + )!, + role: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}role'], + )!, + ); + } + + @override + RemoteAlbumUserEntity createAlias(String alias) { + return RemoteAlbumUserEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const [ + 'PRIMARY KEY(album_id, user_id)', + ]; + @override + bool get dontWriteConstraints => true; +} + +class RemoteAlbumUserEntityData extends DataClass + implements Insertable { + final String albumId; + final String userId; + final int role; + const RemoteAlbumUserEntityData({ + required this.albumId, + required this.userId, + required this.role, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['album_id'] = Variable(albumId); + map['user_id'] = Variable(userId); + map['role'] = Variable(role); + return map; + } + + factory RemoteAlbumUserEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return RemoteAlbumUserEntityData( + albumId: serializer.fromJson(json['albumId']), + userId: serializer.fromJson(json['userId']), + role: serializer.fromJson(json['role']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'albumId': serializer.toJson(albumId), + 'userId': serializer.toJson(userId), + 'role': serializer.toJson(role), + }; + } + + RemoteAlbumUserEntityData copyWith({ + String? albumId, + String? userId, + int? role, + }) => RemoteAlbumUserEntityData( + albumId: albumId ?? this.albumId, + userId: userId ?? this.userId, + role: role ?? this.role, + ); + RemoteAlbumUserEntityData copyWithCompanion( + RemoteAlbumUserEntityCompanion data, + ) { + return RemoteAlbumUserEntityData( + albumId: data.albumId.present ? data.albumId.value : this.albumId, + userId: data.userId.present ? data.userId.value : this.userId, + role: data.role.present ? data.role.value : this.role, + ); + } + + @override + String toString() { + return (StringBuffer('RemoteAlbumUserEntityData(') + ..write('albumId: $albumId, ') + ..write('userId: $userId, ') + ..write('role: $role') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(albumId, userId, role); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is RemoteAlbumUserEntityData && + other.albumId == this.albumId && + other.userId == this.userId && + other.role == this.role); +} + +class RemoteAlbumUserEntityCompanion + extends UpdateCompanion { + final Value albumId; + final Value userId; + final Value role; + const RemoteAlbumUserEntityCompanion({ + this.albumId = const Value.absent(), + this.userId = const Value.absent(), + this.role = const Value.absent(), + }); + RemoteAlbumUserEntityCompanion.insert({ + required String albumId, + required String userId, + required int role, + }) : albumId = Value(albumId), + userId = Value(userId), + role = Value(role); + static Insertable custom({ + Expression? albumId, + Expression? userId, + Expression? role, + }) { + return RawValuesInsertable({ + if (albumId != null) 'album_id': albumId, + if (userId != null) 'user_id': userId, + if (role != null) 'role': role, + }); + } + + RemoteAlbumUserEntityCompanion copyWith({ + Value? albumId, + Value? userId, + Value? role, + }) { + return RemoteAlbumUserEntityCompanion( + albumId: albumId ?? this.albumId, + userId: userId ?? this.userId, + role: role ?? this.role, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (albumId.present) { + map['album_id'] = Variable(albumId.value); + } + if (userId.present) { + map['user_id'] = Variable(userId.value); + } + if (role.present) { + map['role'] = Variable(role.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('RemoteAlbumUserEntityCompanion(') + ..write('albumId: $albumId, ') + ..write('userId: $userId, ') + ..write('role: $role') + ..write(')')) + .toString(); + } +} + +class RemoteAssetCloudIdEntity extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + RemoteAssetCloudIdEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn assetId = GeneratedColumn( + 'asset_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL REFERENCES remote_asset_entity(id)ON DELETE CASCADE', + ); + late final GeneratedColumn cloudId = GeneratedColumn( + 'cloud_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn adjustmentTime = GeneratedColumn( + 'adjustment_time', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn latitude = GeneratedColumn( + 'latitude', + aliasedName, + true, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn longitude = GeneratedColumn( + 'longitude', + aliasedName, + true, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + @override + List get $columns => [ + assetId, + cloudId, + createdAt, + adjustmentTime, + latitude, + longitude, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'remote_asset_cloud_id_entity'; + @override + Set get $primaryKey => {assetId}; + @override + RemoteAssetCloudIdEntityData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return RemoteAssetCloudIdEntityData( + assetId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}asset_id'], + )!, + cloudId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}cloud_id'], + ), + createdAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}created_at'], + ), + adjustmentTime: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}adjustment_time'], + ), + latitude: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}latitude'], + ), + longitude: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}longitude'], + ), + ); + } + + @override + RemoteAssetCloudIdEntity createAlias(String alias) { + return RemoteAssetCloudIdEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const ['PRIMARY KEY(asset_id)']; + @override + bool get dontWriteConstraints => true; +} + +class RemoteAssetCloudIdEntityData extends DataClass + implements Insertable { + final String assetId; + final String? cloudId; + final String? createdAt; + final String? adjustmentTime; + final double? latitude; + final double? longitude; + const RemoteAssetCloudIdEntityData({ + required this.assetId, + this.cloudId, + this.createdAt, + this.adjustmentTime, + this.latitude, + this.longitude, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['asset_id'] = Variable(assetId); + if (!nullToAbsent || cloudId != null) { + map['cloud_id'] = Variable(cloudId); + } + if (!nullToAbsent || createdAt != null) { + map['created_at'] = Variable(createdAt); + } + if (!nullToAbsent || adjustmentTime != null) { + map['adjustment_time'] = Variable(adjustmentTime); + } + if (!nullToAbsent || latitude != null) { + map['latitude'] = Variable(latitude); + } + if (!nullToAbsent || longitude != null) { + map['longitude'] = Variable(longitude); + } + return map; + } + + factory RemoteAssetCloudIdEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return RemoteAssetCloudIdEntityData( + assetId: serializer.fromJson(json['assetId']), + cloudId: serializer.fromJson(json['cloudId']), + createdAt: serializer.fromJson(json['createdAt']), + adjustmentTime: serializer.fromJson(json['adjustmentTime']), + latitude: serializer.fromJson(json['latitude']), + longitude: serializer.fromJson(json['longitude']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'assetId': serializer.toJson(assetId), + 'cloudId': serializer.toJson(cloudId), + 'createdAt': serializer.toJson(createdAt), + 'adjustmentTime': serializer.toJson(adjustmentTime), + 'latitude': serializer.toJson(latitude), + 'longitude': serializer.toJson(longitude), + }; + } + + RemoteAssetCloudIdEntityData copyWith({ + String? assetId, + Value cloudId = const Value.absent(), + Value createdAt = const Value.absent(), + Value adjustmentTime = const Value.absent(), + Value latitude = const Value.absent(), + Value longitude = const Value.absent(), + }) => RemoteAssetCloudIdEntityData( + assetId: assetId ?? this.assetId, + cloudId: cloudId.present ? cloudId.value : this.cloudId, + createdAt: createdAt.present ? createdAt.value : this.createdAt, + adjustmentTime: adjustmentTime.present + ? adjustmentTime.value + : this.adjustmentTime, + latitude: latitude.present ? latitude.value : this.latitude, + longitude: longitude.present ? longitude.value : this.longitude, + ); + RemoteAssetCloudIdEntityData copyWithCompanion( + RemoteAssetCloudIdEntityCompanion data, + ) { + return RemoteAssetCloudIdEntityData( + assetId: data.assetId.present ? data.assetId.value : this.assetId, + cloudId: data.cloudId.present ? data.cloudId.value : this.cloudId, + createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, + adjustmentTime: data.adjustmentTime.present + ? data.adjustmentTime.value + : this.adjustmentTime, + latitude: data.latitude.present ? data.latitude.value : this.latitude, + longitude: data.longitude.present ? data.longitude.value : this.longitude, + ); + } + + @override + String toString() { + return (StringBuffer('RemoteAssetCloudIdEntityData(') + ..write('assetId: $assetId, ') + ..write('cloudId: $cloudId, ') + ..write('createdAt: $createdAt, ') + ..write('adjustmentTime: $adjustmentTime, ') + ..write('latitude: $latitude, ') + ..write('longitude: $longitude') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + assetId, + cloudId, + createdAt, + adjustmentTime, + latitude, + longitude, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is RemoteAssetCloudIdEntityData && + other.assetId == this.assetId && + other.cloudId == this.cloudId && + other.createdAt == this.createdAt && + other.adjustmentTime == this.adjustmentTime && + other.latitude == this.latitude && + other.longitude == this.longitude); +} + +class RemoteAssetCloudIdEntityCompanion + extends UpdateCompanion { + final Value assetId; + final Value cloudId; + final Value createdAt; + final Value adjustmentTime; + final Value latitude; + final Value longitude; + const RemoteAssetCloudIdEntityCompanion({ + this.assetId = const Value.absent(), + this.cloudId = const Value.absent(), + this.createdAt = const Value.absent(), + this.adjustmentTime = const Value.absent(), + this.latitude = const Value.absent(), + this.longitude = const Value.absent(), + }); + RemoteAssetCloudIdEntityCompanion.insert({ + required String assetId, + this.cloudId = const Value.absent(), + this.createdAt = const Value.absent(), + this.adjustmentTime = const Value.absent(), + this.latitude = const Value.absent(), + this.longitude = const Value.absent(), + }) : assetId = Value(assetId); + static Insertable custom({ + Expression? assetId, + Expression? cloudId, + Expression? createdAt, + Expression? adjustmentTime, + Expression? latitude, + Expression? longitude, + }) { + return RawValuesInsertable({ + if (assetId != null) 'asset_id': assetId, + if (cloudId != null) 'cloud_id': cloudId, + if (createdAt != null) 'created_at': createdAt, + if (adjustmentTime != null) 'adjustment_time': adjustmentTime, + if (latitude != null) 'latitude': latitude, + if (longitude != null) 'longitude': longitude, + }); + } + + RemoteAssetCloudIdEntityCompanion copyWith({ + Value? assetId, + Value? cloudId, + Value? createdAt, + Value? adjustmentTime, + Value? latitude, + Value? longitude, + }) { + return RemoteAssetCloudIdEntityCompanion( + assetId: assetId ?? this.assetId, + cloudId: cloudId ?? this.cloudId, + createdAt: createdAt ?? this.createdAt, + adjustmentTime: adjustmentTime ?? this.adjustmentTime, + latitude: latitude ?? this.latitude, + longitude: longitude ?? this.longitude, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (assetId.present) { + map['asset_id'] = Variable(assetId.value); + } + if (cloudId.present) { + map['cloud_id'] = Variable(cloudId.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + if (adjustmentTime.present) { + map['adjustment_time'] = Variable(adjustmentTime.value); + } + if (latitude.present) { + map['latitude'] = Variable(latitude.value); + } + if (longitude.present) { + map['longitude'] = Variable(longitude.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('RemoteAssetCloudIdEntityCompanion(') + ..write('assetId: $assetId, ') + ..write('cloudId: $cloudId, ') + ..write('createdAt: $createdAt, ') + ..write('adjustmentTime: $adjustmentTime, ') + ..write('latitude: $latitude, ') + ..write('longitude: $longitude') + ..write(')')) + .toString(); + } +} + +class MemoryEntity extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + MemoryEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', + defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), + ); + late final GeneratedColumn updatedAt = GeneratedColumn( + 'updated_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', + defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), + ); + late final GeneratedColumn deletedAt = GeneratedColumn( + 'deleted_at', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn ownerId = GeneratedColumn( + 'owner_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL REFERENCES user_entity(id)ON DELETE CASCADE', + ); + late final GeneratedColumn type = GeneratedColumn( + 'type', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn data = GeneratedColumn( + 'data', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn isSaved = GeneratedColumn( + 'is_saved', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 0 CHECK (is_saved IN (0, 1))', + defaultValue: const CustomExpression('0'), + ); + late final GeneratedColumn memoryAt = GeneratedColumn( + 'memory_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn seenAt = GeneratedColumn( + 'seen_at', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn showAt = GeneratedColumn( + 'show_at', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn hideAt = GeneratedColumn( + 'hide_at', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + @override + List get $columns => [ + id, + createdAt, + updatedAt, + deletedAt, + ownerId, + type, + data, + isSaved, + memoryAt, + seenAt, + showAt, + hideAt, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'memory_entity'; + @override + Set get $primaryKey => {id}; + @override + MemoryEntityData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return MemoryEntityData( + id: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + createdAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}created_at'], + )!, + updatedAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}updated_at'], + )!, + deletedAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}deleted_at'], + ), + ownerId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}owner_id'], + )!, + type: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}type'], + )!, + data: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}data'], + )!, + isSaved: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}is_saved'], + )!, + memoryAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}memory_at'], + )!, + seenAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}seen_at'], + ), + showAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}show_at'], + ), + hideAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}hide_at'], + ), + ); + } + + @override + MemoryEntity createAlias(String alias) { + return MemoryEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const ['PRIMARY KEY(id)']; + @override + bool get dontWriteConstraints => true; +} + +class MemoryEntityData extends DataClass + implements Insertable { + final String id; + final String createdAt; + final String updatedAt; + final String? deletedAt; + final String ownerId; + final int type; + final String data; + final int isSaved; + final String memoryAt; + final String? seenAt; + final String? showAt; + final String? hideAt; + const MemoryEntityData({ + required this.id, + required this.createdAt, + required this.updatedAt, + this.deletedAt, + required this.ownerId, + required this.type, + required this.data, + required this.isSaved, + required this.memoryAt, + this.seenAt, + this.showAt, + this.hideAt, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['created_at'] = Variable(createdAt); + map['updated_at'] = Variable(updatedAt); + if (!nullToAbsent || deletedAt != null) { + map['deleted_at'] = Variable(deletedAt); + } + map['owner_id'] = Variable(ownerId); + map['type'] = Variable(type); + map['data'] = Variable(data); + map['is_saved'] = Variable(isSaved); + map['memory_at'] = Variable(memoryAt); + if (!nullToAbsent || seenAt != null) { + map['seen_at'] = Variable(seenAt); + } + if (!nullToAbsent || showAt != null) { + map['show_at'] = Variable(showAt); + } + if (!nullToAbsent || hideAt != null) { + map['hide_at'] = Variable(hideAt); + } + return map; + } + + factory MemoryEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return MemoryEntityData( + id: serializer.fromJson(json['id']), + createdAt: serializer.fromJson(json['createdAt']), + updatedAt: serializer.fromJson(json['updatedAt']), + deletedAt: serializer.fromJson(json['deletedAt']), + ownerId: serializer.fromJson(json['ownerId']), + type: serializer.fromJson(json['type']), + data: serializer.fromJson(json['data']), + isSaved: serializer.fromJson(json['isSaved']), + memoryAt: serializer.fromJson(json['memoryAt']), + seenAt: serializer.fromJson(json['seenAt']), + showAt: serializer.fromJson(json['showAt']), + hideAt: serializer.fromJson(json['hideAt']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'createdAt': serializer.toJson(createdAt), + 'updatedAt': serializer.toJson(updatedAt), + 'deletedAt': serializer.toJson(deletedAt), + 'ownerId': serializer.toJson(ownerId), + 'type': serializer.toJson(type), + 'data': serializer.toJson(data), + 'isSaved': serializer.toJson(isSaved), + 'memoryAt': serializer.toJson(memoryAt), + 'seenAt': serializer.toJson(seenAt), + 'showAt': serializer.toJson(showAt), + 'hideAt': serializer.toJson(hideAt), + }; + } + + MemoryEntityData copyWith({ + String? id, + String? createdAt, + String? updatedAt, + Value deletedAt = const Value.absent(), + String? ownerId, + int? type, + String? data, + int? isSaved, + String? memoryAt, + Value seenAt = const Value.absent(), + Value showAt = const Value.absent(), + Value hideAt = const Value.absent(), + }) => MemoryEntityData( + id: id ?? this.id, + createdAt: createdAt ?? this.createdAt, + updatedAt: updatedAt ?? this.updatedAt, + deletedAt: deletedAt.present ? deletedAt.value : this.deletedAt, + ownerId: ownerId ?? this.ownerId, + type: type ?? this.type, + data: data ?? this.data, + isSaved: isSaved ?? this.isSaved, + memoryAt: memoryAt ?? this.memoryAt, + seenAt: seenAt.present ? seenAt.value : this.seenAt, + showAt: showAt.present ? showAt.value : this.showAt, + hideAt: hideAt.present ? hideAt.value : this.hideAt, + ); + MemoryEntityData copyWithCompanion(MemoryEntityCompanion data) { + return MemoryEntityData( + id: data.id.present ? data.id.value : this.id, + createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, + updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, + deletedAt: data.deletedAt.present ? data.deletedAt.value : this.deletedAt, + ownerId: data.ownerId.present ? data.ownerId.value : this.ownerId, + type: data.type.present ? data.type.value : this.type, + data: data.data.present ? data.data.value : this.data, + isSaved: data.isSaved.present ? data.isSaved.value : this.isSaved, + memoryAt: data.memoryAt.present ? data.memoryAt.value : this.memoryAt, + seenAt: data.seenAt.present ? data.seenAt.value : this.seenAt, + showAt: data.showAt.present ? data.showAt.value : this.showAt, + hideAt: data.hideAt.present ? data.hideAt.value : this.hideAt, + ); + } + + @override + String toString() { + return (StringBuffer('MemoryEntityData(') + ..write('id: $id, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt, ') + ..write('deletedAt: $deletedAt, ') + ..write('ownerId: $ownerId, ') + ..write('type: $type, ') + ..write('data: $data, ') + ..write('isSaved: $isSaved, ') + ..write('memoryAt: $memoryAt, ') + ..write('seenAt: $seenAt, ') + ..write('showAt: $showAt, ') + ..write('hideAt: $hideAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + createdAt, + updatedAt, + deletedAt, + ownerId, + type, + data, + isSaved, + memoryAt, + seenAt, + showAt, + hideAt, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is MemoryEntityData && + other.id == this.id && + other.createdAt == this.createdAt && + other.updatedAt == this.updatedAt && + other.deletedAt == this.deletedAt && + other.ownerId == this.ownerId && + other.type == this.type && + other.data == this.data && + other.isSaved == this.isSaved && + other.memoryAt == this.memoryAt && + other.seenAt == this.seenAt && + other.showAt == this.showAt && + other.hideAt == this.hideAt); +} + +class MemoryEntityCompanion extends UpdateCompanion { + final Value id; + final Value createdAt; + final Value updatedAt; + final Value deletedAt; + final Value ownerId; + final Value type; + final Value data; + final Value isSaved; + final Value memoryAt; + final Value seenAt; + final Value showAt; + final Value hideAt; + const MemoryEntityCompanion({ + this.id = const Value.absent(), + this.createdAt = const Value.absent(), + this.updatedAt = const Value.absent(), + this.deletedAt = const Value.absent(), + this.ownerId = const Value.absent(), + this.type = const Value.absent(), + this.data = const Value.absent(), + this.isSaved = const Value.absent(), + this.memoryAt = const Value.absent(), + this.seenAt = const Value.absent(), + this.showAt = const Value.absent(), + this.hideAt = const Value.absent(), + }); + MemoryEntityCompanion.insert({ + required String id, + this.createdAt = const Value.absent(), + this.updatedAt = const Value.absent(), + this.deletedAt = const Value.absent(), + required String ownerId, + required int type, + required String data, + this.isSaved = const Value.absent(), + required String memoryAt, + this.seenAt = const Value.absent(), + this.showAt = const Value.absent(), + this.hideAt = const Value.absent(), + }) : id = Value(id), + ownerId = Value(ownerId), + type = Value(type), + data = Value(data), + memoryAt = Value(memoryAt); + static Insertable custom({ + Expression? id, + Expression? createdAt, + Expression? updatedAt, + Expression? deletedAt, + Expression? ownerId, + Expression? type, + Expression? data, + Expression? isSaved, + Expression? memoryAt, + Expression? seenAt, + Expression? showAt, + Expression? hideAt, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (createdAt != null) 'created_at': createdAt, + if (updatedAt != null) 'updated_at': updatedAt, + if (deletedAt != null) 'deleted_at': deletedAt, + if (ownerId != null) 'owner_id': ownerId, + if (type != null) 'type': type, + if (data != null) 'data': data, + if (isSaved != null) 'is_saved': isSaved, + if (memoryAt != null) 'memory_at': memoryAt, + if (seenAt != null) 'seen_at': seenAt, + if (showAt != null) 'show_at': showAt, + if (hideAt != null) 'hide_at': hideAt, + }); + } + + MemoryEntityCompanion copyWith({ + Value? id, + Value? createdAt, + Value? updatedAt, + Value? deletedAt, + Value? ownerId, + Value? type, + Value? data, + Value? isSaved, + Value? memoryAt, + Value? seenAt, + Value? showAt, + Value? hideAt, + }) { + return MemoryEntityCompanion( + id: id ?? this.id, + createdAt: createdAt ?? this.createdAt, + updatedAt: updatedAt ?? this.updatedAt, + deletedAt: deletedAt ?? this.deletedAt, + ownerId: ownerId ?? this.ownerId, + type: type ?? this.type, + data: data ?? this.data, + isSaved: isSaved ?? this.isSaved, + memoryAt: memoryAt ?? this.memoryAt, + seenAt: seenAt ?? this.seenAt, + showAt: showAt ?? this.showAt, + hideAt: hideAt ?? this.hideAt, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + if (updatedAt.present) { + map['updated_at'] = Variable(updatedAt.value); + } + if (deletedAt.present) { + map['deleted_at'] = Variable(deletedAt.value); + } + if (ownerId.present) { + map['owner_id'] = Variable(ownerId.value); + } + if (type.present) { + map['type'] = Variable(type.value); + } + if (data.present) { + map['data'] = Variable(data.value); + } + if (isSaved.present) { + map['is_saved'] = Variable(isSaved.value); + } + if (memoryAt.present) { + map['memory_at'] = Variable(memoryAt.value); + } + if (seenAt.present) { + map['seen_at'] = Variable(seenAt.value); + } + if (showAt.present) { + map['show_at'] = Variable(showAt.value); + } + if (hideAt.present) { + map['hide_at'] = Variable(hideAt.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('MemoryEntityCompanion(') + ..write('id: $id, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt, ') + ..write('deletedAt: $deletedAt, ') + ..write('ownerId: $ownerId, ') + ..write('type: $type, ') + ..write('data: $data, ') + ..write('isSaved: $isSaved, ') + ..write('memoryAt: $memoryAt, ') + ..write('seenAt: $seenAt, ') + ..write('showAt: $showAt, ') + ..write('hideAt: $hideAt') + ..write(')')) + .toString(); + } +} + +class MemoryAssetEntity extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + MemoryAssetEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn assetId = GeneratedColumn( + 'asset_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL REFERENCES remote_asset_entity(id)ON DELETE CASCADE', + ); + late final GeneratedColumn memoryId = GeneratedColumn( + 'memory_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL REFERENCES memory_entity(id)ON DELETE CASCADE', + ); + @override + List get $columns => [assetId, memoryId]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'memory_asset_entity'; + @override + Set get $primaryKey => {assetId, memoryId}; + @override + MemoryAssetEntityData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return MemoryAssetEntityData( + assetId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}asset_id'], + )!, + memoryId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}memory_id'], + )!, + ); + } + + @override + MemoryAssetEntity createAlias(String alias) { + return MemoryAssetEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const [ + 'PRIMARY KEY(asset_id, memory_id)', + ]; + @override + bool get dontWriteConstraints => true; +} + +class MemoryAssetEntityData extends DataClass + implements Insertable { + final String assetId; + final String memoryId; + const MemoryAssetEntityData({required this.assetId, required this.memoryId}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['asset_id'] = Variable(assetId); + map['memory_id'] = Variable(memoryId); + return map; + } + + factory MemoryAssetEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return MemoryAssetEntityData( + assetId: serializer.fromJson(json['assetId']), + memoryId: serializer.fromJson(json['memoryId']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'assetId': serializer.toJson(assetId), + 'memoryId': serializer.toJson(memoryId), + }; + } + + MemoryAssetEntityData copyWith({String? assetId, String? memoryId}) => + MemoryAssetEntityData( + assetId: assetId ?? this.assetId, + memoryId: memoryId ?? this.memoryId, + ); + MemoryAssetEntityData copyWithCompanion(MemoryAssetEntityCompanion data) { + return MemoryAssetEntityData( + assetId: data.assetId.present ? data.assetId.value : this.assetId, + memoryId: data.memoryId.present ? data.memoryId.value : this.memoryId, + ); + } + + @override + String toString() { + return (StringBuffer('MemoryAssetEntityData(') + ..write('assetId: $assetId, ') + ..write('memoryId: $memoryId') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(assetId, memoryId); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is MemoryAssetEntityData && + other.assetId == this.assetId && + other.memoryId == this.memoryId); +} + +class MemoryAssetEntityCompanion + extends UpdateCompanion { + final Value assetId; + final Value memoryId; + const MemoryAssetEntityCompanion({ + this.assetId = const Value.absent(), + this.memoryId = const Value.absent(), + }); + MemoryAssetEntityCompanion.insert({ + required String assetId, + required String memoryId, + }) : assetId = Value(assetId), + memoryId = Value(memoryId); + static Insertable custom({ + Expression? assetId, + Expression? memoryId, + }) { + return RawValuesInsertable({ + if (assetId != null) 'asset_id': assetId, + if (memoryId != null) 'memory_id': memoryId, + }); + } + + MemoryAssetEntityCompanion copyWith({ + Value? assetId, + Value? memoryId, + }) { + return MemoryAssetEntityCompanion( + assetId: assetId ?? this.assetId, + memoryId: memoryId ?? this.memoryId, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (assetId.present) { + map['asset_id'] = Variable(assetId.value); + } + if (memoryId.present) { + map['memory_id'] = Variable(memoryId.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('MemoryAssetEntityCompanion(') + ..write('assetId: $assetId, ') + ..write('memoryId: $memoryId') + ..write(')')) + .toString(); + } +} + +class PersonEntity extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + PersonEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', + defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), + ); + late final GeneratedColumn updatedAt = GeneratedColumn( + 'updated_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', + defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), + ); + late final GeneratedColumn ownerId = GeneratedColumn( + 'owner_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL REFERENCES user_entity(id)ON DELETE CASCADE', + ); + late final GeneratedColumn name = GeneratedColumn( + 'name', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn faceAssetId = GeneratedColumn( + 'face_asset_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn isFavorite = GeneratedColumn( + 'is_favorite', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL CHECK (is_favorite IN (0, 1))', + ); + late final GeneratedColumn isHidden = GeneratedColumn( + 'is_hidden', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL CHECK (is_hidden IN (0, 1))', + ); + late final GeneratedColumn color = GeneratedColumn( + 'color', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn birthDate = GeneratedColumn( + 'birth_date', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + @override + List get $columns => [ + id, + createdAt, + updatedAt, + ownerId, + name, + faceAssetId, + isFavorite, + isHidden, + color, + birthDate, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'person_entity'; + @override + Set get $primaryKey => {id}; + @override + PersonEntityData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return PersonEntityData( + id: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + createdAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}created_at'], + )!, + updatedAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}updated_at'], + )!, + ownerId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}owner_id'], + )!, + name: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}name'], + )!, + faceAssetId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}face_asset_id'], + ), + isFavorite: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}is_favorite'], + )!, + isHidden: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}is_hidden'], + )!, + color: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}color'], + ), + birthDate: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}birth_date'], + ), + ); + } + + @override + PersonEntity createAlias(String alias) { + return PersonEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const ['PRIMARY KEY(id)']; + @override + bool get dontWriteConstraints => true; +} + +class PersonEntityData extends DataClass + implements Insertable { + final String id; + final String createdAt; + final String updatedAt; + final String ownerId; + final String name; + final String? faceAssetId; + final int isFavorite; + final int isHidden; + final String? color; + final String? birthDate; + const PersonEntityData({ + required this.id, + required this.createdAt, + required this.updatedAt, + required this.ownerId, + required this.name, + this.faceAssetId, + required this.isFavorite, + required this.isHidden, + this.color, + this.birthDate, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['created_at'] = Variable(createdAt); + map['updated_at'] = Variable(updatedAt); + map['owner_id'] = Variable(ownerId); + map['name'] = Variable(name); + if (!nullToAbsent || faceAssetId != null) { + map['face_asset_id'] = Variable(faceAssetId); + } + map['is_favorite'] = Variable(isFavorite); + map['is_hidden'] = Variable(isHidden); + if (!nullToAbsent || color != null) { + map['color'] = Variable(color); + } + if (!nullToAbsent || birthDate != null) { + map['birth_date'] = Variable(birthDate); + } + return map; + } + + factory PersonEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return PersonEntityData( + id: serializer.fromJson(json['id']), + createdAt: serializer.fromJson(json['createdAt']), + updatedAt: serializer.fromJson(json['updatedAt']), + ownerId: serializer.fromJson(json['ownerId']), + name: serializer.fromJson(json['name']), + faceAssetId: serializer.fromJson(json['faceAssetId']), + isFavorite: serializer.fromJson(json['isFavorite']), + isHidden: serializer.fromJson(json['isHidden']), + color: serializer.fromJson(json['color']), + birthDate: serializer.fromJson(json['birthDate']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'createdAt': serializer.toJson(createdAt), + 'updatedAt': serializer.toJson(updatedAt), + 'ownerId': serializer.toJson(ownerId), + 'name': serializer.toJson(name), + 'faceAssetId': serializer.toJson(faceAssetId), + 'isFavorite': serializer.toJson(isFavorite), + 'isHidden': serializer.toJson(isHidden), + 'color': serializer.toJson(color), + 'birthDate': serializer.toJson(birthDate), + }; + } + + PersonEntityData copyWith({ + String? id, + String? createdAt, + String? updatedAt, + String? ownerId, + String? name, + Value faceAssetId = const Value.absent(), + int? isFavorite, + int? isHidden, + Value color = const Value.absent(), + Value birthDate = const Value.absent(), + }) => PersonEntityData( + id: id ?? this.id, + createdAt: createdAt ?? this.createdAt, + updatedAt: updatedAt ?? this.updatedAt, + ownerId: ownerId ?? this.ownerId, + name: name ?? this.name, + faceAssetId: faceAssetId.present ? faceAssetId.value : this.faceAssetId, + isFavorite: isFavorite ?? this.isFavorite, + isHidden: isHidden ?? this.isHidden, + color: color.present ? color.value : this.color, + birthDate: birthDate.present ? birthDate.value : this.birthDate, + ); + PersonEntityData copyWithCompanion(PersonEntityCompanion data) { + return PersonEntityData( + id: data.id.present ? data.id.value : this.id, + createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, + updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, + ownerId: data.ownerId.present ? data.ownerId.value : this.ownerId, + name: data.name.present ? data.name.value : this.name, + faceAssetId: data.faceAssetId.present + ? data.faceAssetId.value + : this.faceAssetId, + isFavorite: data.isFavorite.present + ? data.isFavorite.value + : this.isFavorite, + isHidden: data.isHidden.present ? data.isHidden.value : this.isHidden, + color: data.color.present ? data.color.value : this.color, + birthDate: data.birthDate.present ? data.birthDate.value : this.birthDate, + ); + } + + @override + String toString() { + return (StringBuffer('PersonEntityData(') + ..write('id: $id, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt, ') + ..write('ownerId: $ownerId, ') + ..write('name: $name, ') + ..write('faceAssetId: $faceAssetId, ') + ..write('isFavorite: $isFavorite, ') + ..write('isHidden: $isHidden, ') + ..write('color: $color, ') + ..write('birthDate: $birthDate') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + createdAt, + updatedAt, + ownerId, + name, + faceAssetId, + isFavorite, + isHidden, + color, + birthDate, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is PersonEntityData && + other.id == this.id && + other.createdAt == this.createdAt && + other.updatedAt == this.updatedAt && + other.ownerId == this.ownerId && + other.name == this.name && + other.faceAssetId == this.faceAssetId && + other.isFavorite == this.isFavorite && + other.isHidden == this.isHidden && + other.color == this.color && + other.birthDate == this.birthDate); +} + +class PersonEntityCompanion extends UpdateCompanion { + final Value id; + final Value createdAt; + final Value updatedAt; + final Value ownerId; + final Value name; + final Value faceAssetId; + final Value isFavorite; + final Value isHidden; + final Value color; + final Value birthDate; + const PersonEntityCompanion({ + this.id = const Value.absent(), + this.createdAt = const Value.absent(), + this.updatedAt = const Value.absent(), + this.ownerId = const Value.absent(), + this.name = const Value.absent(), + this.faceAssetId = const Value.absent(), + this.isFavorite = const Value.absent(), + this.isHidden = const Value.absent(), + this.color = const Value.absent(), + this.birthDate = const Value.absent(), + }); + PersonEntityCompanion.insert({ + required String id, + this.createdAt = const Value.absent(), + this.updatedAt = const Value.absent(), + required String ownerId, + required String name, + this.faceAssetId = const Value.absent(), + required int isFavorite, + required int isHidden, + this.color = const Value.absent(), + this.birthDate = const Value.absent(), + }) : id = Value(id), + ownerId = Value(ownerId), + name = Value(name), + isFavorite = Value(isFavorite), + isHidden = Value(isHidden); + static Insertable custom({ + Expression? id, + Expression? createdAt, + Expression? updatedAt, + Expression? ownerId, + Expression? name, + Expression? faceAssetId, + Expression? isFavorite, + Expression? isHidden, + Expression? color, + Expression? birthDate, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (createdAt != null) 'created_at': createdAt, + if (updatedAt != null) 'updated_at': updatedAt, + if (ownerId != null) 'owner_id': ownerId, + if (name != null) 'name': name, + if (faceAssetId != null) 'face_asset_id': faceAssetId, + if (isFavorite != null) 'is_favorite': isFavorite, + if (isHidden != null) 'is_hidden': isHidden, + if (color != null) 'color': color, + if (birthDate != null) 'birth_date': birthDate, + }); + } + + PersonEntityCompanion copyWith({ + Value? id, + Value? createdAt, + Value? updatedAt, + Value? ownerId, + Value? name, + Value? faceAssetId, + Value? isFavorite, + Value? isHidden, + Value? color, + Value? birthDate, + }) { + return PersonEntityCompanion( + id: id ?? this.id, + createdAt: createdAt ?? this.createdAt, + updatedAt: updatedAt ?? this.updatedAt, + ownerId: ownerId ?? this.ownerId, + name: name ?? this.name, + faceAssetId: faceAssetId ?? this.faceAssetId, + isFavorite: isFavorite ?? this.isFavorite, + isHidden: isHidden ?? this.isHidden, + color: color ?? this.color, + birthDate: birthDate ?? this.birthDate, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + if (updatedAt.present) { + map['updated_at'] = Variable(updatedAt.value); + } + if (ownerId.present) { + map['owner_id'] = Variable(ownerId.value); + } + if (name.present) { + map['name'] = Variable(name.value); + } + if (faceAssetId.present) { + map['face_asset_id'] = Variable(faceAssetId.value); + } + if (isFavorite.present) { + map['is_favorite'] = Variable(isFavorite.value); + } + if (isHidden.present) { + map['is_hidden'] = Variable(isHidden.value); + } + if (color.present) { + map['color'] = Variable(color.value); + } + if (birthDate.present) { + map['birth_date'] = Variable(birthDate.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('PersonEntityCompanion(') + ..write('id: $id, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt, ') + ..write('ownerId: $ownerId, ') + ..write('name: $name, ') + ..write('faceAssetId: $faceAssetId, ') + ..write('isFavorite: $isFavorite, ') + ..write('isHidden: $isHidden, ') + ..write('color: $color, ') + ..write('birthDate: $birthDate') + ..write(')')) + .toString(); + } +} + +class AssetFaceEntity extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + AssetFaceEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn assetId = GeneratedColumn( + 'asset_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL REFERENCES remote_asset_entity(id)ON DELETE CASCADE', + ); + late final GeneratedColumn personId = GeneratedColumn( + 'person_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL REFERENCES person_entity(id)ON DELETE SET NULL', + ); + late final GeneratedColumn imageWidth = GeneratedColumn( + 'image_width', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn imageHeight = GeneratedColumn( + 'image_height', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn boundingBoxX1 = GeneratedColumn( + 'bounding_box_x1', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn boundingBoxY1 = GeneratedColumn( + 'bounding_box_y1', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn boundingBoxX2 = GeneratedColumn( + 'bounding_box_x2', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn boundingBoxY2 = GeneratedColumn( + 'bounding_box_y2', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn sourceType = GeneratedColumn( + 'source_type', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn isVisible = GeneratedColumn( + 'is_visible', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 1 CHECK (is_visible IN (0, 1))', + defaultValue: const CustomExpression('1'), + ); + late final GeneratedColumn deletedAt = GeneratedColumn( + 'deleted_at', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + @override + List get $columns => [ + id, + assetId, + personId, + imageWidth, + imageHeight, + boundingBoxX1, + boundingBoxY1, + boundingBoxX2, + boundingBoxY2, + sourceType, + isVisible, + deletedAt, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'asset_face_entity'; + @override + Set get $primaryKey => {id}; + @override + AssetFaceEntityData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return AssetFaceEntityData( + id: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + assetId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}asset_id'], + )!, + personId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}person_id'], + ), + imageWidth: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}image_width'], + )!, + imageHeight: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}image_height'], + )!, + boundingBoxX1: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}bounding_box_x1'], + )!, + boundingBoxY1: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}bounding_box_y1'], + )!, + boundingBoxX2: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}bounding_box_x2'], + )!, + boundingBoxY2: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}bounding_box_y2'], + )!, + sourceType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}source_type'], + )!, + isVisible: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}is_visible'], + )!, + deletedAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}deleted_at'], + ), + ); + } + + @override + AssetFaceEntity createAlias(String alias) { + return AssetFaceEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const ['PRIMARY KEY(id)']; + @override + bool get dontWriteConstraints => true; +} + +class AssetFaceEntityData extends DataClass + implements Insertable { + final String id; + final String assetId; + final String? personId; + final int imageWidth; + final int imageHeight; + final int boundingBoxX1; + final int boundingBoxY1; + final int boundingBoxX2; + final int boundingBoxY2; + final String sourceType; + final int isVisible; + final String? deletedAt; + const AssetFaceEntityData({ + required this.id, + required this.assetId, + this.personId, + required this.imageWidth, + required this.imageHeight, + required this.boundingBoxX1, + required this.boundingBoxY1, + required this.boundingBoxX2, + required this.boundingBoxY2, + required this.sourceType, + required this.isVisible, + this.deletedAt, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['asset_id'] = Variable(assetId); + if (!nullToAbsent || personId != null) { + map['person_id'] = Variable(personId); + } + map['image_width'] = Variable(imageWidth); + map['image_height'] = Variable(imageHeight); + map['bounding_box_x1'] = Variable(boundingBoxX1); + map['bounding_box_y1'] = Variable(boundingBoxY1); + map['bounding_box_x2'] = Variable(boundingBoxX2); + map['bounding_box_y2'] = Variable(boundingBoxY2); + map['source_type'] = Variable(sourceType); + map['is_visible'] = Variable(isVisible); + if (!nullToAbsent || deletedAt != null) { + map['deleted_at'] = Variable(deletedAt); + } + return map; + } + + factory AssetFaceEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return AssetFaceEntityData( + id: serializer.fromJson(json['id']), + assetId: serializer.fromJson(json['assetId']), + personId: serializer.fromJson(json['personId']), + imageWidth: serializer.fromJson(json['imageWidth']), + imageHeight: serializer.fromJson(json['imageHeight']), + boundingBoxX1: serializer.fromJson(json['boundingBoxX1']), + boundingBoxY1: serializer.fromJson(json['boundingBoxY1']), + boundingBoxX2: serializer.fromJson(json['boundingBoxX2']), + boundingBoxY2: serializer.fromJson(json['boundingBoxY2']), + sourceType: serializer.fromJson(json['sourceType']), + isVisible: serializer.fromJson(json['isVisible']), + deletedAt: serializer.fromJson(json['deletedAt']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'assetId': serializer.toJson(assetId), + 'personId': serializer.toJson(personId), + 'imageWidth': serializer.toJson(imageWidth), + 'imageHeight': serializer.toJson(imageHeight), + 'boundingBoxX1': serializer.toJson(boundingBoxX1), + 'boundingBoxY1': serializer.toJson(boundingBoxY1), + 'boundingBoxX2': serializer.toJson(boundingBoxX2), + 'boundingBoxY2': serializer.toJson(boundingBoxY2), + 'sourceType': serializer.toJson(sourceType), + 'isVisible': serializer.toJson(isVisible), + 'deletedAt': serializer.toJson(deletedAt), + }; + } + + AssetFaceEntityData copyWith({ + String? id, + String? assetId, + Value personId = const Value.absent(), + int? imageWidth, + int? imageHeight, + int? boundingBoxX1, + int? boundingBoxY1, + int? boundingBoxX2, + int? boundingBoxY2, + String? sourceType, + int? isVisible, + Value deletedAt = const Value.absent(), + }) => AssetFaceEntityData( + id: id ?? this.id, + assetId: assetId ?? this.assetId, + personId: personId.present ? personId.value : this.personId, + imageWidth: imageWidth ?? this.imageWidth, + imageHeight: imageHeight ?? this.imageHeight, + boundingBoxX1: boundingBoxX1 ?? this.boundingBoxX1, + boundingBoxY1: boundingBoxY1 ?? this.boundingBoxY1, + boundingBoxX2: boundingBoxX2 ?? this.boundingBoxX2, + boundingBoxY2: boundingBoxY2 ?? this.boundingBoxY2, + sourceType: sourceType ?? this.sourceType, + isVisible: isVisible ?? this.isVisible, + deletedAt: deletedAt.present ? deletedAt.value : this.deletedAt, + ); + AssetFaceEntityData copyWithCompanion(AssetFaceEntityCompanion data) { + return AssetFaceEntityData( + id: data.id.present ? data.id.value : this.id, + assetId: data.assetId.present ? data.assetId.value : this.assetId, + personId: data.personId.present ? data.personId.value : this.personId, + imageWidth: data.imageWidth.present + ? data.imageWidth.value + : this.imageWidth, + imageHeight: data.imageHeight.present + ? data.imageHeight.value + : this.imageHeight, + boundingBoxX1: data.boundingBoxX1.present + ? data.boundingBoxX1.value + : this.boundingBoxX1, + boundingBoxY1: data.boundingBoxY1.present + ? data.boundingBoxY1.value + : this.boundingBoxY1, + boundingBoxX2: data.boundingBoxX2.present + ? data.boundingBoxX2.value + : this.boundingBoxX2, + boundingBoxY2: data.boundingBoxY2.present + ? data.boundingBoxY2.value + : this.boundingBoxY2, + sourceType: data.sourceType.present + ? data.sourceType.value + : this.sourceType, + isVisible: data.isVisible.present ? data.isVisible.value : this.isVisible, + deletedAt: data.deletedAt.present ? data.deletedAt.value : this.deletedAt, + ); + } + + @override + String toString() { + return (StringBuffer('AssetFaceEntityData(') + ..write('id: $id, ') + ..write('assetId: $assetId, ') + ..write('personId: $personId, ') + ..write('imageWidth: $imageWidth, ') + ..write('imageHeight: $imageHeight, ') + ..write('boundingBoxX1: $boundingBoxX1, ') + ..write('boundingBoxY1: $boundingBoxY1, ') + ..write('boundingBoxX2: $boundingBoxX2, ') + ..write('boundingBoxY2: $boundingBoxY2, ') + ..write('sourceType: $sourceType, ') + ..write('isVisible: $isVisible, ') + ..write('deletedAt: $deletedAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + assetId, + personId, + imageWidth, + imageHeight, + boundingBoxX1, + boundingBoxY1, + boundingBoxX2, + boundingBoxY2, + sourceType, + isVisible, + deletedAt, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is AssetFaceEntityData && + other.id == this.id && + other.assetId == this.assetId && + other.personId == this.personId && + other.imageWidth == this.imageWidth && + other.imageHeight == this.imageHeight && + other.boundingBoxX1 == this.boundingBoxX1 && + other.boundingBoxY1 == this.boundingBoxY1 && + other.boundingBoxX2 == this.boundingBoxX2 && + other.boundingBoxY2 == this.boundingBoxY2 && + other.sourceType == this.sourceType && + other.isVisible == this.isVisible && + other.deletedAt == this.deletedAt); +} + +class AssetFaceEntityCompanion extends UpdateCompanion { + final Value id; + final Value assetId; + final Value personId; + final Value imageWidth; + final Value imageHeight; + final Value boundingBoxX1; + final Value boundingBoxY1; + final Value boundingBoxX2; + final Value boundingBoxY2; + final Value sourceType; + final Value isVisible; + final Value deletedAt; + const AssetFaceEntityCompanion({ + this.id = const Value.absent(), + this.assetId = const Value.absent(), + this.personId = const Value.absent(), + this.imageWidth = const Value.absent(), + this.imageHeight = const Value.absent(), + this.boundingBoxX1 = const Value.absent(), + this.boundingBoxY1 = const Value.absent(), + this.boundingBoxX2 = const Value.absent(), + this.boundingBoxY2 = const Value.absent(), + this.sourceType = const Value.absent(), + this.isVisible = const Value.absent(), + this.deletedAt = const Value.absent(), + }); + AssetFaceEntityCompanion.insert({ + required String id, + required String assetId, + this.personId = const Value.absent(), + required int imageWidth, + required int imageHeight, + required int boundingBoxX1, + required int boundingBoxY1, + required int boundingBoxX2, + required int boundingBoxY2, + required String sourceType, + this.isVisible = const Value.absent(), + this.deletedAt = const Value.absent(), + }) : id = Value(id), + assetId = Value(assetId), + imageWidth = Value(imageWidth), + imageHeight = Value(imageHeight), + boundingBoxX1 = Value(boundingBoxX1), + boundingBoxY1 = Value(boundingBoxY1), + boundingBoxX2 = Value(boundingBoxX2), + boundingBoxY2 = Value(boundingBoxY2), + sourceType = Value(sourceType); + static Insertable custom({ + Expression? id, + Expression? assetId, + Expression? personId, + Expression? imageWidth, + Expression? imageHeight, + Expression? boundingBoxX1, + Expression? boundingBoxY1, + Expression? boundingBoxX2, + Expression? boundingBoxY2, + Expression? sourceType, + Expression? isVisible, + Expression? deletedAt, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (assetId != null) 'asset_id': assetId, + if (personId != null) 'person_id': personId, + if (imageWidth != null) 'image_width': imageWidth, + if (imageHeight != null) 'image_height': imageHeight, + if (boundingBoxX1 != null) 'bounding_box_x1': boundingBoxX1, + if (boundingBoxY1 != null) 'bounding_box_y1': boundingBoxY1, + if (boundingBoxX2 != null) 'bounding_box_x2': boundingBoxX2, + if (boundingBoxY2 != null) 'bounding_box_y2': boundingBoxY2, + if (sourceType != null) 'source_type': sourceType, + if (isVisible != null) 'is_visible': isVisible, + if (deletedAt != null) 'deleted_at': deletedAt, + }); + } + + AssetFaceEntityCompanion copyWith({ + Value? id, + Value? assetId, + Value? personId, + Value? imageWidth, + Value? imageHeight, + Value? boundingBoxX1, + Value? boundingBoxY1, + Value? boundingBoxX2, + Value? boundingBoxY2, + Value? sourceType, + Value? isVisible, + Value? deletedAt, + }) { + return AssetFaceEntityCompanion( + id: id ?? this.id, + assetId: assetId ?? this.assetId, + personId: personId ?? this.personId, + imageWidth: imageWidth ?? this.imageWidth, + imageHeight: imageHeight ?? this.imageHeight, + boundingBoxX1: boundingBoxX1 ?? this.boundingBoxX1, + boundingBoxY1: boundingBoxY1 ?? this.boundingBoxY1, + boundingBoxX2: boundingBoxX2 ?? this.boundingBoxX2, + boundingBoxY2: boundingBoxY2 ?? this.boundingBoxY2, + sourceType: sourceType ?? this.sourceType, + isVisible: isVisible ?? this.isVisible, + deletedAt: deletedAt ?? this.deletedAt, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (assetId.present) { + map['asset_id'] = Variable(assetId.value); + } + if (personId.present) { + map['person_id'] = Variable(personId.value); + } + if (imageWidth.present) { + map['image_width'] = Variable(imageWidth.value); + } + if (imageHeight.present) { + map['image_height'] = Variable(imageHeight.value); + } + if (boundingBoxX1.present) { + map['bounding_box_x1'] = Variable(boundingBoxX1.value); + } + if (boundingBoxY1.present) { + map['bounding_box_y1'] = Variable(boundingBoxY1.value); + } + if (boundingBoxX2.present) { + map['bounding_box_x2'] = Variable(boundingBoxX2.value); + } + if (boundingBoxY2.present) { + map['bounding_box_y2'] = Variable(boundingBoxY2.value); + } + if (sourceType.present) { + map['source_type'] = Variable(sourceType.value); + } + if (isVisible.present) { + map['is_visible'] = Variable(isVisible.value); + } + if (deletedAt.present) { + map['deleted_at'] = Variable(deletedAt.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('AssetFaceEntityCompanion(') + ..write('id: $id, ') + ..write('assetId: $assetId, ') + ..write('personId: $personId, ') + ..write('imageWidth: $imageWidth, ') + ..write('imageHeight: $imageHeight, ') + ..write('boundingBoxX1: $boundingBoxX1, ') + ..write('boundingBoxY1: $boundingBoxY1, ') + ..write('boundingBoxX2: $boundingBoxX2, ') + ..write('boundingBoxY2: $boundingBoxY2, ') + ..write('sourceType: $sourceType, ') + ..write('isVisible: $isVisible, ') + ..write('deletedAt: $deletedAt') + ..write(')')) + .toString(); + } +} + +class StoreEntity extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + StoreEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn stringValue = GeneratedColumn( + 'string_value', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn intValue = GeneratedColumn( + 'int_value', + aliasedName, + true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + @override + List get $columns => [id, stringValue, intValue]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'store_entity'; + @override + Set get $primaryKey => {id}; + @override + StoreEntityData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return StoreEntityData( + id: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}id'], + )!, + stringValue: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}string_value'], + ), + intValue: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}int_value'], + ), + ); + } + + @override + StoreEntity createAlias(String alias) { + return StoreEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const ['PRIMARY KEY(id)']; + @override + bool get dontWriteConstraints => true; +} + +class StoreEntityData extends DataClass implements Insertable { + final int id; + final String? stringValue; + final int? intValue; + const StoreEntityData({required this.id, this.stringValue, this.intValue}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + if (!nullToAbsent || stringValue != null) { + map['string_value'] = Variable(stringValue); + } + if (!nullToAbsent || intValue != null) { + map['int_value'] = Variable(intValue); + } + return map; + } + + factory StoreEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return StoreEntityData( + id: serializer.fromJson(json['id']), + stringValue: serializer.fromJson(json['stringValue']), + intValue: serializer.fromJson(json['intValue']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'stringValue': serializer.toJson(stringValue), + 'intValue': serializer.toJson(intValue), + }; + } + + StoreEntityData copyWith({ + int? id, + Value stringValue = const Value.absent(), + Value intValue = const Value.absent(), + }) => StoreEntityData( + id: id ?? this.id, + stringValue: stringValue.present ? stringValue.value : this.stringValue, + intValue: intValue.present ? intValue.value : this.intValue, + ); + StoreEntityData copyWithCompanion(StoreEntityCompanion data) { + return StoreEntityData( + id: data.id.present ? data.id.value : this.id, + stringValue: data.stringValue.present + ? data.stringValue.value + : this.stringValue, + intValue: data.intValue.present ? data.intValue.value : this.intValue, + ); + } + + @override + String toString() { + return (StringBuffer('StoreEntityData(') + ..write('id: $id, ') + ..write('stringValue: $stringValue, ') + ..write('intValue: $intValue') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, stringValue, intValue); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is StoreEntityData && + other.id == this.id && + other.stringValue == this.stringValue && + other.intValue == this.intValue); +} + +class StoreEntityCompanion extends UpdateCompanion { + final Value id; + final Value stringValue; + final Value intValue; + const StoreEntityCompanion({ + this.id = const Value.absent(), + this.stringValue = const Value.absent(), + this.intValue = const Value.absent(), + }); + StoreEntityCompanion.insert({ + required int id, + this.stringValue = const Value.absent(), + this.intValue = const Value.absent(), + }) : id = Value(id); + static Insertable custom({ + Expression? id, + Expression? stringValue, + Expression? intValue, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (stringValue != null) 'string_value': stringValue, + if (intValue != null) 'int_value': intValue, + }); + } + + StoreEntityCompanion copyWith({ + Value? id, + Value? stringValue, + Value? intValue, + }) { + return StoreEntityCompanion( + id: id ?? this.id, + stringValue: stringValue ?? this.stringValue, + intValue: intValue ?? this.intValue, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (stringValue.present) { + map['string_value'] = Variable(stringValue.value); + } + if (intValue.present) { + map['int_value'] = Variable(intValue.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('StoreEntityCompanion(') + ..write('id: $id, ') + ..write('stringValue: $stringValue, ') + ..write('intValue: $intValue') + ..write(')')) + .toString(); + } +} + +class TrashedLocalAssetEntity extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + TrashedLocalAssetEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn name = GeneratedColumn( + 'name', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn type = GeneratedColumn( + 'type', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', + defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), + ); + late final GeneratedColumn updatedAt = GeneratedColumn( + 'updated_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', + defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), + ); + late final GeneratedColumn width = GeneratedColumn( + 'width', + aliasedName, + true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn height = GeneratedColumn( + 'height', + aliasedName, + true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn durationMs = GeneratedColumn( + 'duration_ms', + aliasedName, + true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn albumId = GeneratedColumn( + 'album_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn checksum = GeneratedColumn( + 'checksum', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn isFavorite = GeneratedColumn( + 'is_favorite', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 0 CHECK (is_favorite IN (0, 1))', + defaultValue: const CustomExpression('0'), + ); + late final GeneratedColumn orientation = GeneratedColumn( + 'orientation', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 0', + defaultValue: const CustomExpression('0'), + ); + late final GeneratedColumn source = GeneratedColumn( + 'source', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn playbackStyle = GeneratedColumn( + 'playback_style', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 0', + defaultValue: const CustomExpression('0'), + ); + @override + List get $columns => [ + name, + type, + createdAt, + updatedAt, + width, + height, + durationMs, + id, + albumId, + checksum, + isFavorite, + orientation, + source, + playbackStyle, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'trashed_local_asset_entity'; + @override + Set get $primaryKey => {id, albumId}; + @override + TrashedLocalAssetEntityData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return TrashedLocalAssetEntityData( + name: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}name'], + )!, + type: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}type'], + )!, + createdAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}created_at'], + )!, + updatedAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}updated_at'], + )!, + width: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}width'], + ), + height: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}height'], + ), + durationMs: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}duration_ms'], + ), + id: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + albumId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}album_id'], + )!, + checksum: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}checksum'], + ), + isFavorite: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}is_favorite'], + )!, + orientation: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}orientation'], + )!, + source: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}source'], + )!, + playbackStyle: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}playback_style'], + )!, + ); + } + + @override + TrashedLocalAssetEntity createAlias(String alias) { + return TrashedLocalAssetEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const ['PRIMARY KEY(id, album_id)']; + @override + bool get dontWriteConstraints => true; +} + +class TrashedLocalAssetEntityData extends DataClass + implements Insertable { + final String name; + final int type; + final String createdAt; + final String updatedAt; + final int? width; + final int? height; + final int? durationMs; + final String id; + final String albumId; + final String? checksum; + final int isFavorite; + final int orientation; + final int source; + final int playbackStyle; + const TrashedLocalAssetEntityData({ + required this.name, + required this.type, + required this.createdAt, + required this.updatedAt, + this.width, + this.height, + this.durationMs, + required this.id, + required this.albumId, + this.checksum, + required this.isFavorite, + required this.orientation, + required this.source, + required this.playbackStyle, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['name'] = Variable(name); + map['type'] = Variable(type); + map['created_at'] = Variable(createdAt); + map['updated_at'] = Variable(updatedAt); + if (!nullToAbsent || width != null) { + map['width'] = Variable(width); + } + if (!nullToAbsent || height != null) { + map['height'] = Variable(height); + } + if (!nullToAbsent || durationMs != null) { + map['duration_ms'] = Variable(durationMs); + } + map['id'] = Variable(id); + map['album_id'] = Variable(albumId); + if (!nullToAbsent || checksum != null) { + map['checksum'] = Variable(checksum); + } + map['is_favorite'] = Variable(isFavorite); + map['orientation'] = Variable(orientation); + map['source'] = Variable(source); + map['playback_style'] = Variable(playbackStyle); + return map; + } + + factory TrashedLocalAssetEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return TrashedLocalAssetEntityData( + name: serializer.fromJson(json['name']), + type: serializer.fromJson(json['type']), + createdAt: serializer.fromJson(json['createdAt']), + updatedAt: serializer.fromJson(json['updatedAt']), + width: serializer.fromJson(json['width']), + height: serializer.fromJson(json['height']), + durationMs: serializer.fromJson(json['durationMs']), + id: serializer.fromJson(json['id']), + albumId: serializer.fromJson(json['albumId']), + checksum: serializer.fromJson(json['checksum']), + isFavorite: serializer.fromJson(json['isFavorite']), + orientation: serializer.fromJson(json['orientation']), + source: serializer.fromJson(json['source']), + playbackStyle: serializer.fromJson(json['playbackStyle']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'name': serializer.toJson(name), + 'type': serializer.toJson(type), + 'createdAt': serializer.toJson(createdAt), + 'updatedAt': serializer.toJson(updatedAt), + 'width': serializer.toJson(width), + 'height': serializer.toJson(height), + 'durationMs': serializer.toJson(durationMs), + 'id': serializer.toJson(id), + 'albumId': serializer.toJson(albumId), + 'checksum': serializer.toJson(checksum), + 'isFavorite': serializer.toJson(isFavorite), + 'orientation': serializer.toJson(orientation), + 'source': serializer.toJson(source), + 'playbackStyle': serializer.toJson(playbackStyle), + }; + } + + TrashedLocalAssetEntityData copyWith({ + String? name, + int? type, + String? createdAt, + String? updatedAt, + Value width = const Value.absent(), + Value height = const Value.absent(), + Value durationMs = const Value.absent(), + String? id, + String? albumId, + Value checksum = const Value.absent(), + int? isFavorite, + int? orientation, + int? source, + int? playbackStyle, + }) => TrashedLocalAssetEntityData( + 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, + durationMs: durationMs.present ? durationMs.value : this.durationMs, + id: id ?? this.id, + albumId: albumId ?? this.albumId, + checksum: checksum.present ? checksum.value : this.checksum, + isFavorite: isFavorite ?? this.isFavorite, + orientation: orientation ?? this.orientation, + source: source ?? this.source, + playbackStyle: playbackStyle ?? this.playbackStyle, + ); + TrashedLocalAssetEntityData copyWithCompanion( + TrashedLocalAssetEntityCompanion data, + ) { + return TrashedLocalAssetEntityData( + 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, + width: data.width.present ? data.width.value : this.width, + height: data.height.present ? data.height.value : this.height, + durationMs: data.durationMs.present + ? data.durationMs.value + : this.durationMs, + id: data.id.present ? data.id.value : this.id, + albumId: data.albumId.present ? data.albumId.value : this.albumId, + checksum: data.checksum.present ? data.checksum.value : this.checksum, + isFavorite: data.isFavorite.present + ? data.isFavorite.value + : this.isFavorite, + orientation: data.orientation.present + ? data.orientation.value + : this.orientation, + source: data.source.present ? data.source.value : this.source, + playbackStyle: data.playbackStyle.present + ? data.playbackStyle.value + : this.playbackStyle, + ); + } + + @override + String toString() { + return (StringBuffer('TrashedLocalAssetEntityData(') + ..write('name: $name, ') + ..write('type: $type, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt, ') + ..write('width: $width, ') + ..write('height: $height, ') + ..write('durationMs: $durationMs, ') + ..write('id: $id, ') + ..write('albumId: $albumId, ') + ..write('checksum: $checksum, ') + ..write('isFavorite: $isFavorite, ') + ..write('orientation: $orientation, ') + ..write('source: $source, ') + ..write('playbackStyle: $playbackStyle') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + name, + type, + createdAt, + updatedAt, + width, + height, + durationMs, + id, + albumId, + checksum, + isFavorite, + orientation, + source, + playbackStyle, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is TrashedLocalAssetEntityData && + other.name == this.name && + other.type == this.type && + other.createdAt == this.createdAt && + other.updatedAt == this.updatedAt && + other.width == this.width && + other.height == this.height && + other.durationMs == this.durationMs && + other.id == this.id && + other.albumId == this.albumId && + other.checksum == this.checksum && + other.isFavorite == this.isFavorite && + other.orientation == this.orientation && + other.source == this.source && + other.playbackStyle == this.playbackStyle); +} + +class TrashedLocalAssetEntityCompanion + extends UpdateCompanion { + final Value name; + final Value type; + final Value createdAt; + final Value updatedAt; + final Value width; + final Value height; + final Value durationMs; + final Value id; + final Value albumId; + final Value checksum; + final Value isFavorite; + final Value orientation; + final Value source; + final Value playbackStyle; + const TrashedLocalAssetEntityCompanion({ + this.name = const Value.absent(), + this.type = const Value.absent(), + this.createdAt = const Value.absent(), + this.updatedAt = const Value.absent(), + this.width = const Value.absent(), + this.height = const Value.absent(), + this.durationMs = const Value.absent(), + this.id = const Value.absent(), + this.albumId = const Value.absent(), + this.checksum = const Value.absent(), + this.isFavorite = const Value.absent(), + this.orientation = const Value.absent(), + this.source = const Value.absent(), + this.playbackStyle = const Value.absent(), + }); + TrashedLocalAssetEntityCompanion.insert({ + required String name, + required int type, + this.createdAt = const Value.absent(), + this.updatedAt = const Value.absent(), + this.width = const Value.absent(), + this.height = const Value.absent(), + this.durationMs = const Value.absent(), + required String id, + required String albumId, + this.checksum = const Value.absent(), + this.isFavorite = const Value.absent(), + this.orientation = const Value.absent(), + required int source, + this.playbackStyle = const Value.absent(), + }) : name = Value(name), + type = Value(type), + id = Value(id), + albumId = Value(albumId), + source = Value(source); + static Insertable custom({ + Expression? name, + Expression? type, + Expression? createdAt, + Expression? updatedAt, + Expression? width, + Expression? height, + Expression? durationMs, + Expression? id, + Expression? albumId, + Expression? checksum, + Expression? isFavorite, + Expression? orientation, + Expression? source, + Expression? playbackStyle, + }) { + return 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 (durationMs != null) 'duration_ms': durationMs, + if (id != null) 'id': id, + if (albumId != null) 'album_id': albumId, + if (checksum != null) 'checksum': checksum, + if (isFavorite != null) 'is_favorite': isFavorite, + if (orientation != null) 'orientation': orientation, + if (source != null) 'source': source, + if (playbackStyle != null) 'playback_style': playbackStyle, + }); + } + + TrashedLocalAssetEntityCompanion copyWith({ + Value? name, + Value? type, + Value? createdAt, + Value? updatedAt, + Value? width, + Value? height, + Value? durationMs, + Value? id, + Value? albumId, + Value? checksum, + Value? isFavorite, + Value? orientation, + Value? source, + Value? playbackStyle, + }) { + return TrashedLocalAssetEntityCompanion( + name: name ?? this.name, + type: type ?? this.type, + createdAt: createdAt ?? this.createdAt, + updatedAt: updatedAt ?? this.updatedAt, + width: width ?? this.width, + height: height ?? this.height, + durationMs: durationMs ?? this.durationMs, + id: id ?? this.id, + albumId: albumId ?? this.albumId, + checksum: checksum ?? this.checksum, + isFavorite: isFavorite ?? this.isFavorite, + orientation: orientation ?? this.orientation, + source: source ?? this.source, + playbackStyle: playbackStyle ?? this.playbackStyle, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (name.present) { + map['name'] = Variable(name.value); + } + if (type.present) { + map['type'] = Variable(type.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + if (updatedAt.present) { + map['updated_at'] = Variable(updatedAt.value); + } + if (width.present) { + map['width'] = Variable(width.value); + } + if (height.present) { + map['height'] = Variable(height.value); + } + if (durationMs.present) { + map['duration_ms'] = Variable(durationMs.value); + } + if (id.present) { + map['id'] = Variable(id.value); + } + if (albumId.present) { + map['album_id'] = Variable(albumId.value); + } + if (checksum.present) { + map['checksum'] = Variable(checksum.value); + } + if (isFavorite.present) { + map['is_favorite'] = Variable(isFavorite.value); + } + if (orientation.present) { + map['orientation'] = Variable(orientation.value); + } + if (source.present) { + map['source'] = Variable(source.value); + } + if (playbackStyle.present) { + map['playback_style'] = Variable(playbackStyle.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('TrashedLocalAssetEntityCompanion(') + ..write('name: $name, ') + ..write('type: $type, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt, ') + ..write('width: $width, ') + ..write('height: $height, ') + ..write('durationMs: $durationMs, ') + ..write('id: $id, ') + ..write('albumId: $albumId, ') + ..write('checksum: $checksum, ') + ..write('isFavorite: $isFavorite, ') + ..write('orientation: $orientation, ') + ..write('source: $source, ') + ..write('playbackStyle: $playbackStyle') + ..write(')')) + .toString(); + } +} + +class AssetEditEntity extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + AssetEditEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn assetId = GeneratedColumn( + 'asset_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL REFERENCES remote_asset_entity(id)ON DELETE CASCADE', + ); + late final GeneratedColumn action = GeneratedColumn( + 'action', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn parameters = + GeneratedColumn( + 'parameters', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn sequence = GeneratedColumn( + 'sequence', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + @override + List get $columns => [ + id, + assetId, + action, + parameters, + sequence, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'asset_edit_entity'; + @override + Set get $primaryKey => {id}; + @override + AssetEditEntityData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return AssetEditEntityData( + id: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + assetId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}asset_id'], + )!, + action: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}action'], + )!, + parameters: attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}parameters'], + )!, + sequence: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}sequence'], + )!, + ); + } + + @override + AssetEditEntity createAlias(String alias) { + return AssetEditEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const ['PRIMARY KEY(id)']; + @override + bool get dontWriteConstraints => true; +} + +class AssetEditEntityData extends DataClass + implements Insertable { + final String id; + final String assetId; + final int action; + final i2.Uint8List parameters; + final int sequence; + const AssetEditEntityData({ + required this.id, + required this.assetId, + required this.action, + required this.parameters, + required this.sequence, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['asset_id'] = Variable(assetId); + map['action'] = Variable(action); + map['parameters'] = Variable(parameters); + map['sequence'] = Variable(sequence); + return map; + } + + factory AssetEditEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return AssetEditEntityData( + id: serializer.fromJson(json['id']), + assetId: serializer.fromJson(json['assetId']), + action: serializer.fromJson(json['action']), + parameters: serializer.fromJson(json['parameters']), + sequence: serializer.fromJson(json['sequence']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'assetId': serializer.toJson(assetId), + 'action': serializer.toJson(action), + 'parameters': serializer.toJson(parameters), + 'sequence': serializer.toJson(sequence), + }; + } + + AssetEditEntityData copyWith({ + String? id, + String? assetId, + int? action, + i2.Uint8List? parameters, + int? sequence, + }) => AssetEditEntityData( + id: id ?? this.id, + assetId: assetId ?? this.assetId, + action: action ?? this.action, + parameters: parameters ?? this.parameters, + sequence: sequence ?? this.sequence, + ); + AssetEditEntityData copyWithCompanion(AssetEditEntityCompanion data) { + return AssetEditEntityData( + id: data.id.present ? data.id.value : this.id, + assetId: data.assetId.present ? data.assetId.value : this.assetId, + action: data.action.present ? data.action.value : this.action, + parameters: data.parameters.present + ? data.parameters.value + : this.parameters, + sequence: data.sequence.present ? data.sequence.value : this.sequence, + ); + } + + @override + String toString() { + return (StringBuffer('AssetEditEntityData(') + ..write('id: $id, ') + ..write('assetId: $assetId, ') + ..write('action: $action, ') + ..write('parameters: $parameters, ') + ..write('sequence: $sequence') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + assetId, + action, + $driftBlobEquality.hash(parameters), + sequence, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is AssetEditEntityData && + other.id == this.id && + other.assetId == this.assetId && + other.action == this.action && + $driftBlobEquality.equals(other.parameters, this.parameters) && + other.sequence == this.sequence); +} + +class AssetEditEntityCompanion extends UpdateCompanion { + final Value id; + final Value assetId; + final Value action; + final Value parameters; + final Value sequence; + const AssetEditEntityCompanion({ + this.id = const Value.absent(), + this.assetId = const Value.absent(), + this.action = const Value.absent(), + this.parameters = const Value.absent(), + this.sequence = const Value.absent(), + }); + AssetEditEntityCompanion.insert({ + required String id, + required String assetId, + required int action, + required i2.Uint8List parameters, + required int sequence, + }) : id = Value(id), + assetId = Value(assetId), + action = Value(action), + parameters = Value(parameters), + sequence = Value(sequence); + static Insertable custom({ + Expression? id, + Expression? assetId, + Expression? action, + Expression? parameters, + Expression? sequence, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (assetId != null) 'asset_id': assetId, + if (action != null) 'action': action, + if (parameters != null) 'parameters': parameters, + if (sequence != null) 'sequence': sequence, + }); + } + + AssetEditEntityCompanion copyWith({ + Value? id, + Value? assetId, + Value? action, + Value? parameters, + Value? sequence, + }) { + return AssetEditEntityCompanion( + id: id ?? this.id, + assetId: assetId ?? this.assetId, + action: action ?? this.action, + parameters: parameters ?? this.parameters, + sequence: sequence ?? this.sequence, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (assetId.present) { + map['asset_id'] = Variable(assetId.value); + } + if (action.present) { + map['action'] = Variable(action.value); + } + if (parameters.present) { + map['parameters'] = Variable(parameters.value); + } + if (sequence.present) { + map['sequence'] = Variable(sequence.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('AssetEditEntityCompanion(') + ..write('id: $id, ') + ..write('assetId: $assetId, ') + ..write('action: $action, ') + ..write('parameters: $parameters, ') + ..write('sequence: $sequence') + ..write(')')) + .toString(); + } +} + +class Settings extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + Settings(this.attachedDatabase, [this._alias]); + late final GeneratedColumn key = GeneratedColumn( + 'key', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn value = GeneratedColumn( + 'value', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn updatedAt = GeneratedColumn( + 'updated_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', + defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), + ); + @override + List get $columns => [key, value, updatedAt]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'settings'; + @override + Set get $primaryKey => {key}; + @override + SettingsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return SettingsData( + key: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}key'], + )!, + value: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}value'], + ), + updatedAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}updated_at'], + )!, + ); + } + + @override + Settings createAlias(String alias) { + return Settings(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const ['PRIMARY KEY("key")']; + @override + bool get dontWriteConstraints => true; +} + +class SettingsData extends DataClass implements Insertable { + final String key; + final String? value; + final String updatedAt; + const SettingsData({required this.key, this.value, required this.updatedAt}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['key'] = Variable(key); + if (!nullToAbsent || value != null) { + map['value'] = Variable(value); + } + map['updated_at'] = Variable(updatedAt); + return map; + } + + factory SettingsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return SettingsData( + key: serializer.fromJson(json['key']), + value: serializer.fromJson(json['value']), + updatedAt: serializer.fromJson(json['updatedAt']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'key': serializer.toJson(key), + 'value': serializer.toJson(value), + 'updatedAt': serializer.toJson(updatedAt), + }; + } + + SettingsData copyWith({ + String? key, + Value value = const Value.absent(), + String? updatedAt, + }) => SettingsData( + key: key ?? this.key, + value: value.present ? value.value : this.value, + updatedAt: updatedAt ?? this.updatedAt, + ); + SettingsData copyWithCompanion(SettingsCompanion data) { + return SettingsData( + key: data.key.present ? data.key.value : this.key, + value: data.value.present ? data.value.value : this.value, + updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, + ); + } + + @override + String toString() { + return (StringBuffer('SettingsData(') + ..write('key: $key, ') + ..write('value: $value, ') + ..write('updatedAt: $updatedAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(key, value, updatedAt); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is SettingsData && + other.key == this.key && + other.value == this.value && + other.updatedAt == this.updatedAt); +} + +class SettingsCompanion extends UpdateCompanion { + final Value key; + final Value value; + final Value updatedAt; + const SettingsCompanion({ + this.key = const Value.absent(), + this.value = const Value.absent(), + this.updatedAt = const Value.absent(), + }); + SettingsCompanion.insert({ + required String key, + this.value = const Value.absent(), + this.updatedAt = const Value.absent(), + }) : key = Value(key); + static Insertable custom({ + Expression? key, + Expression? value, + Expression? updatedAt, + }) { + return RawValuesInsertable({ + if (key != null) 'key': key, + if (value != null) 'value': value, + if (updatedAt != null) 'updated_at': updatedAt, + }); + } + + SettingsCompanion copyWith({ + Value? key, + Value? value, + Value? updatedAt, + }) { + return SettingsCompanion( + key: key ?? this.key, + value: value ?? this.value, + updatedAt: updatedAt ?? this.updatedAt, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (key.present) { + map['key'] = Variable(key.value); + } + if (value.present) { + map['value'] = Variable(value.value); + } + if (updatedAt.present) { + map['updated_at'] = Variable(updatedAt.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('SettingsCompanion(') + ..write('key: $key, ') + ..write('value: $value, ') + ..write('updatedAt: $updatedAt') + ..write(')')) + .toString(); + } +} + +class AssetOcrEntity extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + AssetOcrEntity(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn assetId = GeneratedColumn( + 'asset_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL REFERENCES remote_asset_entity(id)ON DELETE CASCADE', + ); + late final GeneratedColumn x1 = GeneratedColumn( + 'x1', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn y1 = GeneratedColumn( + 'y1', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn x2 = GeneratedColumn( + 'x2', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn y2 = GeneratedColumn( + 'y2', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn x3 = GeneratedColumn( + 'x3', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn y3 = GeneratedColumn( + 'y3', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn x4 = GeneratedColumn( + 'x4', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn y4 = GeneratedColumn( + 'y4', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn boxScore = GeneratedColumn( + 'box_score', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn textScore = GeneratedColumn( + 'text_score', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn recognizedText = GeneratedColumn( + 'recognized_text', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn isVisible = GeneratedColumn( + 'is_visible', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 1 CHECK (is_visible IN (0, 1))', + defaultValue: const CustomExpression('1'), + ); + @override + List get $columns => [ + id, + assetId, + x1, + y1, + x2, + y2, + x3, + y3, + x4, + y4, + boxScore, + textScore, + recognizedText, + isVisible, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'asset_ocr_entity'; + @override + Set get $primaryKey => {id}; + @override + AssetOcrEntityData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return AssetOcrEntityData( + id: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + assetId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}asset_id'], + )!, + x1: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}x1'], + )!, + y1: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}y1'], + )!, + x2: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}x2'], + )!, + y2: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}y2'], + )!, + x3: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}x3'], + )!, + y3: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}y3'], + )!, + x4: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}x4'], + )!, + y4: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}y4'], + )!, + boxScore: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}box_score'], + )!, + textScore: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}text_score'], + )!, + recognizedText: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}recognized_text'], + )!, + isVisible: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}is_visible'], + )!, + ); + } + + @override + AssetOcrEntity createAlias(String alias) { + return AssetOcrEntity(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const ['PRIMARY KEY(id)']; + @override + bool get dontWriteConstraints => true; +} + +class AssetOcrEntityData extends DataClass + implements Insertable { + final String id; + final String assetId; + final double x1; + final double y1; + final double x2; + final double y2; + final double x3; + final double y3; + final double x4; + final double y4; + final double boxScore; + final double textScore; + final String recognizedText; + final int isVisible; + const AssetOcrEntityData({ + required this.id, + required this.assetId, + required this.x1, + required this.y1, + required this.x2, + required this.y2, + required this.x3, + required this.y3, + required this.x4, + required this.y4, + required this.boxScore, + required this.textScore, + required this.recognizedText, + required this.isVisible, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['asset_id'] = Variable(assetId); + map['x1'] = Variable(x1); + map['y1'] = Variable(y1); + map['x2'] = Variable(x2); + map['y2'] = Variable(y2); + map['x3'] = Variable(x3); + map['y3'] = Variable(y3); + map['x4'] = Variable(x4); + map['y4'] = Variable(y4); + map['box_score'] = Variable(boxScore); + map['text_score'] = Variable(textScore); + map['recognized_text'] = Variable(recognizedText); + map['is_visible'] = Variable(isVisible); + return map; + } + + factory AssetOcrEntityData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return AssetOcrEntityData( + id: serializer.fromJson(json['id']), + assetId: serializer.fromJson(json['assetId']), + x1: serializer.fromJson(json['x1']), + y1: serializer.fromJson(json['y1']), + x2: serializer.fromJson(json['x2']), + y2: serializer.fromJson(json['y2']), + x3: serializer.fromJson(json['x3']), + y3: serializer.fromJson(json['y3']), + x4: serializer.fromJson(json['x4']), + y4: serializer.fromJson(json['y4']), + boxScore: serializer.fromJson(json['boxScore']), + textScore: serializer.fromJson(json['textScore']), + recognizedText: serializer.fromJson(json['recognizedText']), + isVisible: serializer.fromJson(json['isVisible']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'assetId': serializer.toJson(assetId), + 'x1': serializer.toJson(x1), + 'y1': serializer.toJson(y1), + 'x2': serializer.toJson(x2), + 'y2': serializer.toJson(y2), + 'x3': serializer.toJson(x3), + 'y3': serializer.toJson(y3), + 'x4': serializer.toJson(x4), + 'y4': serializer.toJson(y4), + 'boxScore': serializer.toJson(boxScore), + 'textScore': serializer.toJson(textScore), + 'recognizedText': serializer.toJson(recognizedText), + 'isVisible': serializer.toJson(isVisible), + }; + } + + AssetOcrEntityData copyWith({ + String? id, + String? assetId, + double? x1, + double? y1, + double? x2, + double? y2, + double? x3, + double? y3, + double? x4, + double? y4, + double? boxScore, + double? textScore, + String? recognizedText, + int? isVisible, + }) => AssetOcrEntityData( + id: id ?? this.id, + assetId: assetId ?? this.assetId, + x1: x1 ?? this.x1, + y1: y1 ?? this.y1, + x2: x2 ?? this.x2, + y2: y2 ?? this.y2, + x3: x3 ?? this.x3, + y3: y3 ?? this.y3, + x4: x4 ?? this.x4, + y4: y4 ?? this.y4, + boxScore: boxScore ?? this.boxScore, + textScore: textScore ?? this.textScore, + recognizedText: recognizedText ?? this.recognizedText, + isVisible: isVisible ?? this.isVisible, + ); + AssetOcrEntityData copyWithCompanion(AssetOcrEntityCompanion data) { + return AssetOcrEntityData( + id: data.id.present ? data.id.value : this.id, + assetId: data.assetId.present ? data.assetId.value : this.assetId, + x1: data.x1.present ? data.x1.value : this.x1, + y1: data.y1.present ? data.y1.value : this.y1, + x2: data.x2.present ? data.x2.value : this.x2, + y2: data.y2.present ? data.y2.value : this.y2, + x3: data.x3.present ? data.x3.value : this.x3, + y3: data.y3.present ? data.y3.value : this.y3, + x4: data.x4.present ? data.x4.value : this.x4, + y4: data.y4.present ? data.y4.value : this.y4, + boxScore: data.boxScore.present ? data.boxScore.value : this.boxScore, + textScore: data.textScore.present ? data.textScore.value : this.textScore, + recognizedText: data.recognizedText.present + ? data.recognizedText.value + : this.recognizedText, + isVisible: data.isVisible.present ? data.isVisible.value : this.isVisible, + ); + } + + @override + String toString() { + return (StringBuffer('AssetOcrEntityData(') + ..write('id: $id, ') + ..write('assetId: $assetId, ') + ..write('x1: $x1, ') + ..write('y1: $y1, ') + ..write('x2: $x2, ') + ..write('y2: $y2, ') + ..write('x3: $x3, ') + ..write('y3: $y3, ') + ..write('x4: $x4, ') + ..write('y4: $y4, ') + ..write('boxScore: $boxScore, ') + ..write('textScore: $textScore, ') + ..write('recognizedText: $recognizedText, ') + ..write('isVisible: $isVisible') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + assetId, + x1, + y1, + x2, + y2, + x3, + y3, + x4, + y4, + boxScore, + textScore, + recognizedText, + isVisible, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is AssetOcrEntityData && + other.id == this.id && + other.assetId == this.assetId && + other.x1 == this.x1 && + other.y1 == this.y1 && + other.x2 == this.x2 && + other.y2 == this.y2 && + other.x3 == this.x3 && + other.y3 == this.y3 && + other.x4 == this.x4 && + other.y4 == this.y4 && + other.boxScore == this.boxScore && + other.textScore == this.textScore && + other.recognizedText == this.recognizedText && + other.isVisible == this.isVisible); +} + +class AssetOcrEntityCompanion extends UpdateCompanion { + final Value id; + final Value assetId; + final Value x1; + final Value y1; + final Value x2; + final Value y2; + final Value x3; + final Value y3; + final Value x4; + final Value y4; + final Value boxScore; + final Value textScore; + final Value recognizedText; + final Value isVisible; + const AssetOcrEntityCompanion({ + this.id = const Value.absent(), + this.assetId = const Value.absent(), + this.x1 = const Value.absent(), + this.y1 = const Value.absent(), + this.x2 = const Value.absent(), + this.y2 = const Value.absent(), + this.x3 = const Value.absent(), + this.y3 = const Value.absent(), + this.x4 = const Value.absent(), + this.y4 = const Value.absent(), + this.boxScore = const Value.absent(), + this.textScore = const Value.absent(), + this.recognizedText = const Value.absent(), + this.isVisible = const Value.absent(), + }); + AssetOcrEntityCompanion.insert({ + required String id, + required String assetId, + required double x1, + required double y1, + required double x2, + required double y2, + required double x3, + required double y3, + required double x4, + required double y4, + required double boxScore, + required double textScore, + required String recognizedText, + this.isVisible = const Value.absent(), + }) : id = Value(id), + assetId = Value(assetId), + x1 = Value(x1), + y1 = Value(y1), + x2 = Value(x2), + y2 = Value(y2), + x3 = Value(x3), + y3 = Value(y3), + x4 = Value(x4), + y4 = Value(y4), + boxScore = Value(boxScore), + textScore = Value(textScore), + recognizedText = Value(recognizedText); + static Insertable custom({ + Expression? id, + Expression? assetId, + Expression? x1, + Expression? y1, + Expression? x2, + Expression? y2, + Expression? x3, + Expression? y3, + Expression? x4, + Expression? y4, + Expression? boxScore, + Expression? textScore, + Expression? recognizedText, + Expression? isVisible, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (assetId != null) 'asset_id': assetId, + if (x1 != null) 'x1': x1, + if (y1 != null) 'y1': y1, + if (x2 != null) 'x2': x2, + if (y2 != null) 'y2': y2, + if (x3 != null) 'x3': x3, + if (y3 != null) 'y3': y3, + if (x4 != null) 'x4': x4, + if (y4 != null) 'y4': y4, + if (boxScore != null) 'box_score': boxScore, + if (textScore != null) 'text_score': textScore, + if (recognizedText != null) 'recognized_text': recognizedText, + if (isVisible != null) 'is_visible': isVisible, + }); + } + + AssetOcrEntityCompanion copyWith({ + Value? id, + Value? assetId, + Value? x1, + Value? y1, + Value? x2, + Value? y2, + Value? x3, + Value? y3, + Value? x4, + Value? y4, + Value? boxScore, + Value? textScore, + Value? recognizedText, + Value? isVisible, + }) { + return AssetOcrEntityCompanion( + id: id ?? this.id, + assetId: assetId ?? this.assetId, + x1: x1 ?? this.x1, + y1: y1 ?? this.y1, + x2: x2 ?? this.x2, + y2: y2 ?? this.y2, + x3: x3 ?? this.x3, + y3: y3 ?? this.y3, + x4: x4 ?? this.x4, + y4: y4 ?? this.y4, + boxScore: boxScore ?? this.boxScore, + textScore: textScore ?? this.textScore, + recognizedText: recognizedText ?? this.recognizedText, + isVisible: isVisible ?? this.isVisible, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (assetId.present) { + map['asset_id'] = Variable(assetId.value); + } + if (x1.present) { + map['x1'] = Variable(x1.value); + } + if (y1.present) { + map['y1'] = Variable(y1.value); + } + if (x2.present) { + map['x2'] = Variable(x2.value); + } + if (y2.present) { + map['y2'] = Variable(y2.value); + } + if (x3.present) { + map['x3'] = Variable(x3.value); + } + if (y3.present) { + map['y3'] = Variable(y3.value); + } + if (x4.present) { + map['x4'] = Variable(x4.value); + } + if (y4.present) { + map['y4'] = Variable(y4.value); + } + if (boxScore.present) { + map['box_score'] = Variable(boxScore.value); + } + if (textScore.present) { + map['text_score'] = Variable(textScore.value); + } + if (recognizedText.present) { + map['recognized_text'] = Variable(recognizedText.value); + } + if (isVisible.present) { + map['is_visible'] = Variable(isVisible.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('AssetOcrEntityCompanion(') + ..write('id: $id, ') + ..write('assetId: $assetId, ') + ..write('x1: $x1, ') + ..write('y1: $y1, ') + ..write('x2: $x2, ') + ..write('y2: $y2, ') + ..write('x3: $x3, ') + ..write('y3: $y3, ') + ..write('x4: $x4, ') + ..write('y4: $y4, ') + ..write('boxScore: $boxScore, ') + ..write('textScore: $textScore, ') + ..write('recognizedText: $recognizedText, ') + ..write('isVisible: $isVisible') + ..write(')')) + .toString(); + } +} + +class Session extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + Session(this.attachedDatabase, [this._alias]); + late final GeneratedColumn key = GeneratedColumn( + 'key', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn value = GeneratedColumn( + 'value', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NULL', + ); + late final GeneratedColumn updatedAt = GeneratedColumn( + 'updated_at', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', + defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), + ); + @override + List get $columns => [key, value, updatedAt]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'session'; + @override + Set get $primaryKey => {key}; + @override + SessionData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return SessionData( + key: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}key'], + )!, + value: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}value'], + ), + updatedAt: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}updated_at'], + )!, + ); + } + + @override + Session createAlias(String alias) { + return Session(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + bool get isStrict => true; + @override + List get customConstraints => const ['PRIMARY KEY("key")']; + @override + bool get dontWriteConstraints => true; +} + +class SessionData extends DataClass implements Insertable { + final String key; + final String? value; + final String updatedAt; + const SessionData({required this.key, this.value, required this.updatedAt}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['key'] = Variable(key); + if (!nullToAbsent || value != null) { + map['value'] = Variable(value); + } + map['updated_at'] = Variable(updatedAt); + return map; + } + + factory SessionData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return SessionData( + key: serializer.fromJson(json['key']), + value: serializer.fromJson(json['value']), + updatedAt: serializer.fromJson(json['updatedAt']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'key': serializer.toJson(key), + 'value': serializer.toJson(value), + 'updatedAt': serializer.toJson(updatedAt), + }; + } + + SessionData copyWith({ + String? key, + Value value = const Value.absent(), + String? updatedAt, + }) => SessionData( + key: key ?? this.key, + value: value.present ? value.value : this.value, + updatedAt: updatedAt ?? this.updatedAt, + ); + SessionData copyWithCompanion(SessionCompanion data) { + return SessionData( + key: data.key.present ? data.key.value : this.key, + value: data.value.present ? data.value.value : this.value, + updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, + ); + } + + @override + String toString() { + return (StringBuffer('SessionData(') + ..write('key: $key, ') + ..write('value: $value, ') + ..write('updatedAt: $updatedAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(key, value, updatedAt); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is SessionData && + other.key == this.key && + other.value == this.value && + other.updatedAt == this.updatedAt); +} + +class SessionCompanion extends UpdateCompanion { + final Value key; + final Value value; + final Value updatedAt; + const SessionCompanion({ + this.key = const Value.absent(), + this.value = const Value.absent(), + this.updatedAt = const Value.absent(), + }); + SessionCompanion.insert({ + required String key, + this.value = const Value.absent(), + this.updatedAt = const Value.absent(), + }) : key = Value(key); + static Insertable custom({ + Expression? key, + Expression? value, + Expression? updatedAt, + }) { + return RawValuesInsertable({ + if (key != null) 'key': key, + if (value != null) 'value': value, + if (updatedAt != null) 'updated_at': updatedAt, + }); + } + + SessionCompanion copyWith({ + Value? key, + Value? value, + Value? updatedAt, + }) { + return SessionCompanion( + key: key ?? this.key, + value: value ?? this.value, + updatedAt: updatedAt ?? this.updatedAt, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (key.present) { + map['key'] = Variable(key.value); + } + if (value.present) { + map['value'] = Variable(value.value); + } + if (updatedAt.present) { + map['updated_at'] = Variable(updatedAt.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('SessionCompanion(') + ..write('key: $key, ') + ..write('value: $value, ') + ..write('updatedAt: $updatedAt') + ..write(')')) + .toString(); + } +} + +class DatabaseAtV32 extends GeneratedDatabase { + DatabaseAtV32(QueryExecutor e) : super(e); + late final UserEntity userEntity = UserEntity(this); + late final RemoteAssetEntity remoteAssetEntity = RemoteAssetEntity(this); + late final StackEntity stackEntity = StackEntity(this); + late final LocalAssetEntity localAssetEntity = LocalAssetEntity(this); + late final RemoteAlbumEntity remoteAlbumEntity = RemoteAlbumEntity(this); + late final LocalAlbumEntity localAlbumEntity = LocalAlbumEntity(this); + late final LocalAlbumAssetEntity localAlbumAssetEntity = + LocalAlbumAssetEntity(this); + late final Index idxLocalAlbumAssetAlbumAsset = Index( + 'idx_local_album_asset_album_asset', + 'CREATE INDEX IF NOT EXISTS idx_local_album_asset_album_asset ON local_album_asset_entity (album_id, asset_id)', + ); + late final Index idxLocalAssetChecksum = Index( + 'idx_local_asset_checksum', + 'CREATE INDEX IF NOT EXISTS idx_local_asset_checksum ON local_asset_entity (checksum)', + ); + late final Index idxLocalAssetCloudId = Index( + 'idx_local_asset_cloud_id', + 'CREATE INDEX IF NOT EXISTS idx_local_asset_cloud_id ON local_asset_entity (i_cloud_id)', + ); + late final Index idxLocalAssetCreatedAt = Index( + 'idx_local_asset_created_at', + 'CREATE INDEX IF NOT EXISTS idx_local_asset_created_at ON local_asset_entity (created_at)', + ); + late final Index idxStackPrimaryAssetId = Index( + 'idx_stack_primary_asset_id', + 'CREATE INDEX IF NOT EXISTS idx_stack_primary_asset_id ON stack_entity (primary_asset_id)', + ); + late final Index uQRemoteAssetsOwnerChecksum = Index( + 'UQ_remote_assets_owner_checksum', + 'CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_checksum ON remote_asset_entity (owner_id, checksum) WHERE(library_id IS NULL)', + ); + late final Index uQRemoteAssetsOwnerLibraryChecksum = Index( + 'UQ_remote_assets_owner_library_checksum', + 'CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_library_checksum ON remote_asset_entity (owner_id, library_id, checksum) WHERE(library_id IS NOT NULL)', + ); + late final Index idxRemoteAssetChecksum = Index( + 'idx_remote_asset_checksum', + 'CREATE INDEX IF NOT EXISTS idx_remote_asset_checksum ON remote_asset_entity (checksum)', + ); + late final Index idxRemoteAssetStackId = Index( + 'idx_remote_asset_stack_id', + 'CREATE INDEX IF NOT EXISTS idx_remote_asset_stack_id ON remote_asset_entity (stack_id)', + ); + late final Index idxRemoteAssetOwnerVisibilityDeletedCreated = Index( + 'idx_remote_asset_owner_visibility_deleted_created', + 'CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_visibility_deleted_created ON remote_asset_entity (owner_id, visibility, deleted_at, created_at DESC)', + ); + late final Index idxRemoteAssetUploaded = Index( + 'idx_remote_asset_uploaded', + 'CREATE INDEX IF NOT EXISTS idx_remote_asset_uploaded ON remote_asset_entity (uploaded_at)', + ); + late final AuthUserEntity authUserEntity = AuthUserEntity(this); + late final UserMetadataEntity userMetadataEntity = UserMetadataEntity(this); + late final PartnerEntity partnerEntity = PartnerEntity(this); + late final RemoteExifEntity remoteExifEntity = RemoteExifEntity(this); + late final RemoteAlbumAssetEntity remoteAlbumAssetEntity = + RemoteAlbumAssetEntity(this); + late final RemoteAlbumUserEntity remoteAlbumUserEntity = + RemoteAlbumUserEntity(this); + late final RemoteAssetCloudIdEntity remoteAssetCloudIdEntity = + RemoteAssetCloudIdEntity(this); + late final MemoryEntity memoryEntity = MemoryEntity(this); + late final MemoryAssetEntity memoryAssetEntity = MemoryAssetEntity(this); + late final PersonEntity personEntity = PersonEntity(this); + late final AssetFaceEntity assetFaceEntity = AssetFaceEntity(this); + late final StoreEntity storeEntity = StoreEntity(this); + late final TrashedLocalAssetEntity trashedLocalAssetEntity = + TrashedLocalAssetEntity(this); + late final AssetEditEntity assetEditEntity = AssetEditEntity(this); + late final Settings settings = Settings(this); + late final AssetOcrEntity assetOcrEntity = AssetOcrEntity(this); + late final Session session = Session(this); + late final Index idxPartnerSharedWithId = Index( + 'idx_partner_shared_with_id', + 'CREATE INDEX IF NOT EXISTS idx_partner_shared_with_id ON partner_entity (shared_with_id)', + ); + late final Index idxLatLng = Index( + 'idx_lat_lng', + 'CREATE INDEX IF NOT EXISTS idx_lat_lng ON remote_exif_entity (latitude, longitude)', + ); + late final Index idxRemoteExifCity = Index( + 'idx_remote_exif_city', + 'CREATE INDEX IF NOT EXISTS idx_remote_exif_city ON remote_exif_entity (city) WHERE city IS NOT NULL', + ); + late final Index idxRemoteAlbumAssetAlbumAsset = Index( + 'idx_remote_album_asset_album_asset', + 'CREATE INDEX IF NOT EXISTS idx_remote_album_asset_album_asset ON remote_album_asset_entity (album_id, asset_id)', + ); + late final Index idxRemoteAssetCloudId = Index( + 'idx_remote_asset_cloud_id', + 'CREATE INDEX IF NOT EXISTS idx_remote_asset_cloud_id ON remote_asset_cloud_id_entity (cloud_id)', + ); + late final Index idxPersonOwnerId = Index( + 'idx_person_owner_id', + 'CREATE INDEX IF NOT EXISTS idx_person_owner_id ON person_entity (owner_id)', + ); + late final Index idxAssetFacePersonId = Index( + 'idx_asset_face_person_id', + 'CREATE INDEX IF NOT EXISTS idx_asset_face_person_id ON asset_face_entity (person_id)', + ); + late final Index idxAssetFaceAssetId = Index( + 'idx_asset_face_asset_id', + 'CREATE INDEX IF NOT EXISTS idx_asset_face_asset_id ON asset_face_entity (asset_id)', + ); + late final Index idxAssetFaceVisiblePerson = Index( + 'idx_asset_face_visible_person', + 'CREATE INDEX IF NOT EXISTS idx_asset_face_visible_person ON asset_face_entity (person_id, asset_id) WHERE is_visible = 1 AND deleted_at IS NULL', + ); + late final Index idxTrashedLocalAssetChecksum = Index( + 'idx_trashed_local_asset_checksum', + 'CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_checksum ON trashed_local_asset_entity (checksum)', + ); + late final Index idxTrashedLocalAssetAlbum = Index( + 'idx_trashed_local_asset_album', + 'CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_album ON trashed_local_asset_entity (album_id)', + ); + late final Index idxAssetEditAssetId = Index( + 'idx_asset_edit_asset_id', + 'CREATE INDEX IF NOT EXISTS idx_asset_edit_asset_id ON asset_edit_entity (asset_id)', + ); + late final Index idxAssetOcrAssetId = Index( + 'idx_asset_ocr_asset_id', + 'CREATE INDEX IF NOT EXISTS idx_asset_ocr_asset_id ON asset_ocr_entity (asset_id)', + ); + @override + Iterable> get allTables => + allSchemaEntities.whereType>(); + @override + List get allSchemaEntities => [ + userEntity, + remoteAssetEntity, + stackEntity, + localAssetEntity, + remoteAlbumEntity, + localAlbumEntity, + localAlbumAssetEntity, + idxLocalAlbumAssetAlbumAsset, + idxLocalAssetChecksum, + idxLocalAssetCloudId, + idxLocalAssetCreatedAt, + idxStackPrimaryAssetId, + uQRemoteAssetsOwnerChecksum, + uQRemoteAssetsOwnerLibraryChecksum, + idxRemoteAssetChecksum, + idxRemoteAssetStackId, + idxRemoteAssetOwnerVisibilityDeletedCreated, + idxRemoteAssetUploaded, + authUserEntity, + userMetadataEntity, + partnerEntity, + remoteExifEntity, + remoteAlbumAssetEntity, + remoteAlbumUserEntity, + remoteAssetCloudIdEntity, + memoryEntity, + memoryAssetEntity, + personEntity, + assetFaceEntity, + storeEntity, + trashedLocalAssetEntity, + assetEditEntity, + settings, + assetOcrEntity, + session, + idxPartnerSharedWithId, + idxLatLng, + idxRemoteExifCity, + idxRemoteAlbumAssetAlbumAsset, + idxRemoteAssetCloudId, + idxPersonOwnerId, + idxAssetFacePersonId, + idxAssetFaceAssetId, + idxAssetFaceVisiblePerson, + idxTrashedLocalAssetChecksum, + idxTrashedLocalAssetAlbum, + idxAssetEditAssetId, + idxAssetOcrAssetId, + ]; + @override + StreamQueryUpdateRules get streamUpdateRules => const StreamQueryUpdateRules([ + WritePropagation( + on: TableUpdateQuery.onTableName( + 'user_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('remote_asset_entity', kind: UpdateKind.delete)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'user_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('stack_entity', kind: UpdateKind.delete)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'remote_asset_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('remote_album_entity', kind: UpdateKind.update)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'remote_album_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('local_album_entity', kind: UpdateKind.update)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'local_asset_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [ + TableUpdate('local_album_asset_entity', kind: UpdateKind.delete), + ], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'local_album_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [ + TableUpdate('local_album_asset_entity', kind: UpdateKind.delete), + ], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'user_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('user_metadata_entity', kind: UpdateKind.delete)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'user_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('partner_entity', kind: UpdateKind.delete)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'user_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('partner_entity', kind: UpdateKind.delete)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'remote_asset_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('remote_exif_entity', kind: UpdateKind.delete)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'remote_asset_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [ + TableUpdate('remote_album_asset_entity', kind: UpdateKind.delete), + ], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'remote_album_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [ + TableUpdate('remote_album_asset_entity', kind: UpdateKind.delete), + ], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'remote_album_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [ + TableUpdate('remote_album_user_entity', kind: UpdateKind.delete), + ], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'user_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [ + TableUpdate('remote_album_user_entity', kind: UpdateKind.delete), + ], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'remote_asset_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [ + TableUpdate('remote_asset_cloud_id_entity', kind: UpdateKind.delete), + ], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'user_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('memory_entity', kind: UpdateKind.delete)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'remote_asset_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('memory_asset_entity', kind: UpdateKind.delete)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'memory_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('memory_asset_entity', kind: UpdateKind.delete)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'user_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('person_entity', kind: UpdateKind.delete)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'remote_asset_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('asset_face_entity', kind: UpdateKind.delete)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'person_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('asset_face_entity', kind: UpdateKind.update)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'remote_asset_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('asset_edit_entity', kind: UpdateKind.delete)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'remote_asset_entity', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('asset_ocr_entity', kind: UpdateKind.delete)], + ), + ]); + @override + int get schemaVersion => 32; + @override + DriftDatabaseOptions get options => + const DriftDatabaseOptions(storeDateTimeAsText: true); +} diff --git a/mobile/test/presentation/widgets/timeline/timeline_args_test.dart b/mobile/test/presentation/widgets/timeline/timeline_args_test.dart index 4eb49bd3d6..be83ad8fac 100644 --- a/mobile/test/presentation/widgets/timeline/timeline_args_test.dart +++ b/mobile/test/presentation/widgets/timeline/timeline_args_test.dart @@ -25,6 +25,8 @@ class _FrozenBucketService implements TimelineService { } class _EmptyBucketService implements TimelineService { + const _EmptyBucketService(); + @override Stream> Function() get watchBuckets => () => Stream.value(const []); diff --git a/mobile/test/services/foreground_upload.service_test.dart b/mobile/test/services/foreground_upload.service_test.dart index ed48270b87..2953daf7ee 100644 --- a/mobile/test/services/foreground_upload.service_test.dart +++ b/mobile/test/services/foreground_upload.service_test.dart @@ -8,6 +8,7 @@ import 'package:immich_mobile/domain/models/store.model.dart'; import 'package:immich_mobile/domain/services/store.service.dart'; import 'package:immich_mobile/entities/store.entity.dart'; import 'package:immich_mobile/infrastructure/repositories/db.repository.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/settings.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/store.repository.dart'; import 'package:immich_mobile/repositories/upload.repository.dart'; @@ -38,8 +39,8 @@ void main() { db = Drift(DatabaseConnection(NativeDatabase.memory(), closeStreamsSynchronously: true)); await StoreService.init(storeRepository: DriftStoreRepository(db)); await SettingsRepository.ensureInitialized(db); - - await Store.put(StoreKey.serverEndpoint, 'http://demo.immich.app'); + await SessionRepository.ensureInitialized(db); + await SessionRepository.instance.write(.serverEndpoint, 'http://demo.immich.app'); await Store.put(StoreKey.deviceId, 'device-id'); registerFallbackValue(File('file')); diff --git a/mobile/test/unit/presentation/presentation_context.dart b/mobile/test/unit/presentation/presentation_context.dart index 585cb3707e..5098d52607 100644 --- a/mobile/test/unit/presentation/presentation_context.dart +++ b/mobile/test/unit/presentation/presentation_context.dart @@ -5,11 +5,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:immich_mobile/constants/locales.dart'; -import 'package:immich_mobile/domain/models/store.model.dart'; import 'package:immich_mobile/domain/models/user.model.dart'; import 'package:immich_mobile/domain/services/store.service.dart'; import 'package:immich_mobile/generated/codegen_loader.g.dart'; import 'package:immich_mobile/infrastructure/repositories/db.repository.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/store.repository.dart'; import 'package:immich_mobile/presentation/actions/action.dart'; import 'package:immich_mobile/presentation/actions/action.widget.dart'; @@ -50,7 +50,8 @@ class PresentationContext { if (_db == null) { final db = Drift(DatabaseConnection(NativeDatabase.memory(), closeStreamsSynchronously: true)); await StoreService.init(storeRepository: DriftStoreRepository(db), listenUpdates: false); - await StoreService.I.put(StoreKey.serverEndpoint, serverEndpoint); + await SessionRepository.ensureInitialized(db); + await SessionRepository.instance.write(.serverEndpoint, serverEndpoint); _db = db; } return PresentationContext._(user: UserFactory.createDto()); From d71ca6281b8250da3b8726202da825a503250106 Mon Sep 17 00:00:00 2001 From: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Date: Thu, 6 Aug 2026 01:50:50 +0530 Subject: [PATCH 8/8] rebase over main --- .../background_sync_teardown_test.dart | 1 - mobile/lib/domain/models/session.model.dart | 43 +- .../entities/session.entity.drift.dart | 427 - .../repositories/db.repository.dart | 1 - .../lib/pages/common/splash_screen.page.dart | 9 +- .../actions/open_in_browser.action.dart | 4 +- .../asset_viewer/video_viewer.widget.dart | 3 + .../people/partner_user_avatar.widget.dart | 2 +- .../lib/repositories/upload.repository.dart | 1 + mobile/lib/utils/bootstrap.dart | 1 - .../widgets/common/user_circle_avatar.dart | 6 +- .../test/drift/main/generated/schema_v32.dart | 10246 ---------------- .../presentation/presentation_context.dart | 2 + mobile/test/utils/image_url_builder_test.dart | 8 +- 14 files changed, 30 insertions(+), 10724 deletions(-) delete mode 100644 mobile/lib/infrastructure/entities/session.entity.drift.dart delete mode 100644 mobile/test/drift/main/generated/schema_v32.dart diff --git a/mobile/integration_test/background_sync_teardown_test.dart b/mobile/integration_test/background_sync_teardown_test.dart index 225ed371c4..6231a36d97 100644 --- a/mobile/integration_test/background_sync_teardown_test.dart +++ b/mobile/integration_test/background_sync_teardown_test.dart @@ -40,7 +40,6 @@ void main() { tearDown(() async { await workerManagerPatch.dispose(); await server.close(); - await Store.delete(StoreKey.legacyServerEndpoint); await Store.delete(StoreKey.syncMigrationStatus); }); diff --git a/mobile/lib/domain/models/session.model.dart b/mobile/lib/domain/models/session.model.dart index 81e9b3efd3..83d34400b5 100644 --- a/mobile/lib/domain/models/session.model.dart +++ b/mobile/lib/domain/models/session.model.dart @@ -1,5 +1,7 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:immich_mobile/domain/models/value_codec.dart'; -import 'package:immich_mobile/utils/option.dart'; + +part 'session.model.freezed.dart'; enum SessionKey { serverUrl(), @@ -15,32 +17,14 @@ enum SessionKey { const defaultSession = Session(); -class Session { - final String? serverUrl; - final String? accessToken; - final String? serverEndpoint; +@freezed +abstract class Session with _$Session { + const Session._(); - const Session({this.serverUrl, this.accessToken, this.serverEndpoint}); + const factory Session({String? serverUrl, String? accessToken, String? serverEndpoint}) = _Session; - Session copyWith({Option? serverUrl, Option? accessToken, Option? serverEndpoint}) => .new( - serverUrl: serverUrl.patch(this.serverUrl), - accessToken: accessToken.patch(this.accessToken), - serverEndpoint: serverEndpoint.patch(this.serverEndpoint), - ); - - @override - bool operator ==(Object other) => - identical(this, other) || - (other is Session && - other.serverUrl == serverUrl && - other.accessToken == accessToken && - other.serverEndpoint == serverEndpoint); - - @override - int get hashCode => Object.hash(serverUrl, accessToken, serverEndpoint); - - @override - String toString() => 'Session(serverUrl: $serverUrl, accessToken: $accessToken, serverEndpoint: $serverEndpoint)'; + factory Session.fromEntries(Map overrides) => + overrides.entries.fold(const Session(), (session, entry) => session.write(entry.key, entry.value)); T read(SessionKey key) => (switch (key) { @@ -50,14 +34,11 @@ class Session { }) as T; - factory Session.fromEntries(Map overrides) => - overrides.entries.fold(const Session(), (session, entry) => session.write(entry.key, entry.value)); - Session write(SessionKey key, U value) { return switch (key) { - .serverUrl => copyWith(serverUrl: .fromNullable(value as String?)), - .accessToken => copyWith(accessToken: .fromNullable(value as String?)), - .serverEndpoint => copyWith(serverEndpoint: .fromNullable(value as String?)), + .serverUrl => copyWith(serverUrl: value as String?), + .accessToken => copyWith(accessToken: value as String?), + .serverEndpoint => copyWith(serverEndpoint: value as String?), }; } } diff --git a/mobile/lib/infrastructure/entities/session.entity.drift.dart b/mobile/lib/infrastructure/entities/session.entity.drift.dart deleted file mode 100644 index 0f18ca516b..0000000000 --- a/mobile/lib/infrastructure/entities/session.entity.drift.dart +++ /dev/null @@ -1,427 +0,0 @@ -// dart format width=80 -// ignore_for_file: type=lint -import 'package:drift/drift.dart' as i0; -import 'package:immich_mobile/infrastructure/entities/session.entity.drift.dart' - as i1; -import 'package:immich_mobile/infrastructure/entities/session.entity.dart' - as i2; -import 'package:drift/src/runtime/query_builder/query_builder.dart' as i3; - -typedef $$SessionEntityTableCreateCompanionBuilder = - i1.SessionEntityCompanion Function({ - required String key, - i0.Value value, - i0.Value updatedAt, - }); -typedef $$SessionEntityTableUpdateCompanionBuilder = - i1.SessionEntityCompanion Function({ - i0.Value key, - i0.Value value, - i0.Value updatedAt, - }); - -class $$SessionEntityTableFilterComposer - extends i0.Composer { - $$SessionEntityTableFilterComposer({ - required super.$db, - required super.$table, - super.joinBuilder, - super.$addJoinBuilderToRootComposer, - super.$removeJoinBuilderFromRootComposer, - }); - i0.ColumnFilters get key => $composableBuilder( - column: $table.key, - builder: (column) => i0.ColumnFilters(column), - ); - - i0.ColumnFilters get value => $composableBuilder( - column: $table.value, - builder: (column) => i0.ColumnFilters(column), - ); - - i0.ColumnFilters get updatedAt => $composableBuilder( - column: $table.updatedAt, - builder: (column) => i0.ColumnFilters(column), - ); -} - -class $$SessionEntityTableOrderingComposer - extends i0.Composer { - $$SessionEntityTableOrderingComposer({ - required super.$db, - required super.$table, - super.joinBuilder, - super.$addJoinBuilderToRootComposer, - super.$removeJoinBuilderFromRootComposer, - }); - i0.ColumnOrderings get key => $composableBuilder( - column: $table.key, - builder: (column) => i0.ColumnOrderings(column), - ); - - i0.ColumnOrderings get value => $composableBuilder( - column: $table.value, - builder: (column) => i0.ColumnOrderings(column), - ); - - i0.ColumnOrderings get updatedAt => $composableBuilder( - column: $table.updatedAt, - builder: (column) => i0.ColumnOrderings(column), - ); -} - -class $$SessionEntityTableAnnotationComposer - extends i0.Composer { - $$SessionEntityTableAnnotationComposer({ - required super.$db, - required super.$table, - super.joinBuilder, - super.$addJoinBuilderToRootComposer, - super.$removeJoinBuilderFromRootComposer, - }); - i0.GeneratedColumn get key => - $composableBuilder(column: $table.key, builder: (column) => column); - - i0.GeneratedColumn get value => - $composableBuilder(column: $table.value, builder: (column) => column); - - i0.GeneratedColumn get updatedAt => - $composableBuilder(column: $table.updatedAt, builder: (column) => column); -} - -class $$SessionEntityTableTableManager - extends - i0.RootTableManager< - i0.GeneratedDatabase, - i1.$SessionEntityTable, - i1.SessionEntityData, - i1.$$SessionEntityTableFilterComposer, - i1.$$SessionEntityTableOrderingComposer, - i1.$$SessionEntityTableAnnotationComposer, - $$SessionEntityTableCreateCompanionBuilder, - $$SessionEntityTableUpdateCompanionBuilder, - ( - i1.SessionEntityData, - i0.BaseReferences< - i0.GeneratedDatabase, - i1.$SessionEntityTable, - i1.SessionEntityData - >, - ), - i1.SessionEntityData, - i0.PrefetchHooks Function() - > { - $$SessionEntityTableTableManager( - i0.GeneratedDatabase db, - i1.$SessionEntityTable table, - ) : super( - i0.TableManagerState( - db: db, - table: table, - createFilteringComposer: () => - i1.$$SessionEntityTableFilterComposer($db: db, $table: table), - createOrderingComposer: () => - i1.$$SessionEntityTableOrderingComposer($db: db, $table: table), - createComputedFieldComposer: () => - i1.$$SessionEntityTableAnnotationComposer($db: db, $table: table), - updateCompanionCallback: - ({ - i0.Value key = const i0.Value.absent(), - i0.Value value = const i0.Value.absent(), - i0.Value updatedAt = const i0.Value.absent(), - }) => i1.SessionEntityCompanion( - key: key, - value: value, - updatedAt: updatedAt, - ), - createCompanionCallback: - ({ - required String key, - i0.Value value = const i0.Value.absent(), - i0.Value updatedAt = const i0.Value.absent(), - }) => i1.SessionEntityCompanion.insert( - key: key, - value: value, - updatedAt: updatedAt, - ), - withReferenceMapper: (p0) => p0 - .map((e) => (e.readTable(table), i0.BaseReferences(db, table, e))) - .toList(), - prefetchHooksCallback: null, - ), - ); -} - -typedef $$SessionEntityTableProcessedTableManager = - i0.ProcessedTableManager< - i0.GeneratedDatabase, - i1.$SessionEntityTable, - i1.SessionEntityData, - i1.$$SessionEntityTableFilterComposer, - i1.$$SessionEntityTableOrderingComposer, - i1.$$SessionEntityTableAnnotationComposer, - $$SessionEntityTableCreateCompanionBuilder, - $$SessionEntityTableUpdateCompanionBuilder, - ( - i1.SessionEntityData, - i0.BaseReferences< - i0.GeneratedDatabase, - i1.$SessionEntityTable, - i1.SessionEntityData - >, - ), - i1.SessionEntityData, - i0.PrefetchHooks Function() - >; - -class $SessionEntityTable extends i2.SessionEntity - with i0.TableInfo<$SessionEntityTable, i1.SessionEntityData> { - @override - final i0.GeneratedDatabase attachedDatabase; - final String? _alias; - $SessionEntityTable(this.attachedDatabase, [this._alias]); - static const i0.VerificationMeta _keyMeta = const i0.VerificationMeta('key'); - @override - late final i0.GeneratedColumn key = i0.GeneratedColumn( - 'key', - aliasedName, - false, - type: i0.DriftSqlType.string, - requiredDuringInsert: true, - ); - static const i0.VerificationMeta _valueMeta = const i0.VerificationMeta( - 'value', - ); - @override - late final i0.GeneratedColumn value = i0.GeneratedColumn( - 'value', - aliasedName, - true, - type: i0.DriftSqlType.string, - requiredDuringInsert: false, - ); - 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: i3.currentDateAndTime, - ); - @override - List get $columns => [key, value, updatedAt]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'session'; - @override - i0.VerificationContext validateIntegrity( - i0.Insertable instance, { - bool isInserting = false, - }) { - final context = i0.VerificationContext(); - final data = instance.toColumns(true); - if (data.containsKey('key')) { - context.handle( - _keyMeta, - key.isAcceptableOrUnknown(data['key']!, _keyMeta), - ); - } else if (isInserting) { - context.missing(_keyMeta); - } - if (data.containsKey('value')) { - context.handle( - _valueMeta, - value.isAcceptableOrUnknown(data['value']!, _valueMeta), - ); - } - if (data.containsKey('updated_at')) { - context.handle( - _updatedAtMeta, - updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta), - ); - } - return context; - } - - @override - Set get $primaryKey => {key}; - @override - i1.SessionEntityData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return i1.SessionEntityData( - key: attachedDatabase.typeMapping.read( - i0.DriftSqlType.string, - data['${effectivePrefix}key'], - )!, - value: attachedDatabase.typeMapping.read( - i0.DriftSqlType.string, - data['${effectivePrefix}value'], - ), - updatedAt: attachedDatabase.typeMapping.read( - i0.DriftSqlType.dateTime, - data['${effectivePrefix}updated_at'], - )!, - ); - } - - @override - $SessionEntityTable createAlias(String alias) { - return $SessionEntityTable(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; -} - -class SessionEntityData extends i0.DataClass - implements i0.Insertable { - final String key; - final String? value; - final DateTime updatedAt; - const SessionEntityData({ - required this.key, - this.value, - required this.updatedAt, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['key'] = i0.Variable(key); - if (!nullToAbsent || value != null) { - map['value'] = i0.Variable(value); - } - map['updated_at'] = i0.Variable(updatedAt); - return map; - } - - factory SessionEntityData.fromJson( - Map json, { - i0.ValueSerializer? serializer, - }) { - serializer ??= i0.driftRuntimeOptions.defaultSerializer; - return SessionEntityData( - key: serializer.fromJson(json['key']), - value: serializer.fromJson(json['value']), - updatedAt: serializer.fromJson(json['updatedAt']), - ); - } - @override - Map toJson({i0.ValueSerializer? serializer}) { - serializer ??= i0.driftRuntimeOptions.defaultSerializer; - return { - 'key': serializer.toJson(key), - 'value': serializer.toJson(value), - 'updatedAt': serializer.toJson(updatedAt), - }; - } - - i1.SessionEntityData copyWith({ - String? key, - i0.Value value = const i0.Value.absent(), - DateTime? updatedAt, - }) => i1.SessionEntityData( - key: key ?? this.key, - value: value.present ? value.value : this.value, - updatedAt: updatedAt ?? this.updatedAt, - ); - SessionEntityData copyWithCompanion(i1.SessionEntityCompanion data) { - return SessionEntityData( - key: data.key.present ? data.key.value : this.key, - value: data.value.present ? data.value.value : this.value, - updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, - ); - } - - @override - String toString() { - return (StringBuffer('SessionEntityData(') - ..write('key: $key, ') - ..write('value: $value, ') - ..write('updatedAt: $updatedAt') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash(key, value, updatedAt); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is i1.SessionEntityData && - other.key == this.key && - other.value == this.value && - other.updatedAt == this.updatedAt); -} - -class SessionEntityCompanion extends i0.UpdateCompanion { - final i0.Value key; - final i0.Value value; - final i0.Value updatedAt; - const SessionEntityCompanion({ - this.key = const i0.Value.absent(), - this.value = const i0.Value.absent(), - this.updatedAt = const i0.Value.absent(), - }); - SessionEntityCompanion.insert({ - required String key, - this.value = const i0.Value.absent(), - this.updatedAt = const i0.Value.absent(), - }) : key = i0.Value(key); - static i0.Insertable custom({ - i0.Expression? key, - i0.Expression? value, - i0.Expression? updatedAt, - }) { - return i0.RawValuesInsertable({ - if (key != null) 'key': key, - if (value != null) 'value': value, - if (updatedAt != null) 'updated_at': updatedAt, - }); - } - - i1.SessionEntityCompanion copyWith({ - i0.Value? key, - i0.Value? value, - i0.Value? updatedAt, - }) { - return i1.SessionEntityCompanion( - key: key ?? this.key, - value: value ?? this.value, - updatedAt: updatedAt ?? this.updatedAt, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (key.present) { - map['key'] = i0.Variable(key.value); - } - if (value.present) { - map['value'] = i0.Variable(value.value); - } - if (updatedAt.present) { - map['updated_at'] = i0.Variable(updatedAt.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('SessionEntityCompanion(') - ..write('key: $key, ') - ..write('value: $value, ') - ..write('updatedAt: $updatedAt') - ..write(')')) - .toString(); - } -} diff --git a/mobile/lib/infrastructure/repositories/db.repository.dart b/mobile/lib/infrastructure/repositories/db.repository.dart index a2ccc88d22..d2873ed49e 100644 --- a/mobile/lib/infrastructure/repositories/db.repository.dart +++ b/mobile/lib/infrastructure/repositories/db.repository.dart @@ -319,7 +319,6 @@ class Drift extends $Drift { }, from30To31: (m, v31) async { await m.createIndex(v31.idxRemoteAssetUploaded); - // await m.createTable(v31.session); }, from31To32: (m, v32) async { await m.createTable(v32.session); diff --git a/mobile/lib/pages/common/splash_screen.page.dart b/mobile/lib/pages/common/splash_screen.page.dart index cdc1c523f1..761905c293 100644 --- a/mobile/lib/pages/common/splash_screen.page.dart +++ b/mobile/lib/pages/common/splash_screen.page.dart @@ -7,6 +7,7 @@ import 'package:flutter/services.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:immich_mobile/constants/locales.dart'; import 'package:immich_mobile/domain/models/config/app_config.dart'; +import 'package:immich_mobile/domain/models/session.model.dart'; import 'package:immich_mobile/domain/models/store.model.dart'; import 'package:immich_mobile/entities/store.entity.dart'; import 'package:immich_mobile/generated/codegen_loader.g.dart'; @@ -302,12 +303,8 @@ class SplashScreenPageState extends ConsumerState { log.info("Resuming session at $endpoint"); } - void resumeSession() async { - final session = ref.read(sessionProvider); - final serverUrl = session.serverUrl; - final endpoint = session.serverEndpoint; - final accessToken = session.accessToken; - + Future resumeSession() async { + final Session(:serverUrl, serverEndpoint: endpoint, :accessToken) = ref.read(sessionProvider); if (accessToken != null && serverUrl != null && endpoint != null) { final infoProvider = ref.read(serverInfoProvider.notifier); final wsProvider = ref.read(websocketProvider.notifier); diff --git a/mobile/lib/presentation/actions/open_in_browser.action.dart b/mobile/lib/presentation/actions/open_in_browser.action.dart index 6b05762977..5dd616453d 100644 --- a/mobile/lib/presentation/actions/open_in_browser.action.dart +++ b/mobile/lib/presentation/actions/open_in_browser.action.dart @@ -3,7 +3,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:immich_mobile/domain/services/timeline.service.dart'; import 'package:immich_mobile/generated/translations.g.dart'; import 'package:immich_mobile/presentation/actions/action.dart'; -import 'package:immich_mobile/providers/infrastructure/store.provider.dart'; +import 'package:immich_mobile/providers/infrastructure/session.provider.dart'; import 'package:url_launcher/url_launcher.dart'; class OpenInBrowserAction extends ActionBuilder { @@ -17,7 +17,7 @@ class OpenInBrowserAction extends ActionBuilder { .new(icon: Icons.open_in_browser, label: context.t.open_in_browser, onAction: () => _open(ref)); Future _open(WidgetRef ref) async { - final serverEndpoint = ref.read(storeServiceProvider).get(.serverEndpoint).replaceFirst('/api', ''); + final serverEndpoint = ref.read(sessionProvider).serverEndpoint!.replaceFirst('/api', ''); final url = Uri.parse('$serverEndpoint${webPathFor(origin)}/photos/$remoteId'); if (await canLaunchUrl(url)) { diff --git a/mobile/lib/presentation/widgets/asset_viewer/video_viewer.widget.dart b/mobile/lib/presentation/widgets/asset_viewer/video_viewer.widget.dart index d32ab8a64f..e4451db480 100644 --- a/mobile/lib/presentation/widgets/asset_viewer/video_viewer.widget.dart +++ b/mobile/lib/presentation/widgets/asset_viewer/video_viewer.widget.dart @@ -147,6 +147,9 @@ class _NativeVideoViewerState extends ConsumerState with Widg } final remoteAsset = videoAsset as RemoteAsset; + if (!mounted) { + return null; + } final serverEndpoint = ref.read(sessionProvider).serverEndpoint!; final isOriginalVideo = ref.read(appConfigProvider).viewer.loadOriginalVideo; diff --git a/mobile/lib/presentation/widgets/people/partner_user_avatar.widget.dart b/mobile/lib/presentation/widgets/people/partner_user_avatar.widget.dart index a07585a4b1..2ce86ffea5 100644 --- a/mobile/lib/presentation/widgets/people/partner_user_avatar.widget.dart +++ b/mobile/lib/presentation/widgets/people/partner_user_avatar.widget.dart @@ -12,7 +12,7 @@ class PartnerUserAvatar extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final url = "${ref.read(sessionProvider).serverEndpoint}/users/$userId/profile-image"; + final url = "${ref.watch(sessionProvider.select((s) => s.serverEndpoint))!}/users/$userId/profile-image"; final nameFirstLetter = name.isNotEmpty ? name[0] : ""; return CircleAvatar( radius: 16, diff --git a/mobile/lib/repositories/upload.repository.dart b/mobile/lib/repositories/upload.repository.dart index b8feb6f912..69af76469e 100644 --- a/mobile/lib/repositories/upload.repository.dart +++ b/mobile/lib/repositories/upload.repository.dart @@ -7,6 +7,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:http/http.dart'; import 'package:immich_mobile/constants/constants.dart'; import 'package:immich_mobile/infrastructure/repositories/network.repository.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; import 'package:immich_mobile/utils/debug_print.dart'; import 'package:logging/logging.dart'; diff --git a/mobile/lib/utils/bootstrap.dart b/mobile/lib/utils/bootstrap.dart index 2365ab6575..4c40fac7cf 100644 --- a/mobile/lib/utils/bootstrap.dart +++ b/mobile/lib/utils/bootstrap.dart @@ -53,7 +53,6 @@ abstract final class Bootstrap { final DriftStoreRepository storeRepo = DriftStoreRepository(drift); await StoreService.init(storeRepository: storeRepo, listenUpdates: listenStoreUpdates); - await SessionRepository.ensureInitialized(drift); final settingsRepo = await SettingsRepository.ensureInitialized(drift); diff --git a/mobile/lib/widgets/common/user_circle_avatar.dart b/mobile/lib/widgets/common/user_circle_avatar.dart index efa2a2b806..1c3799d371 100644 --- a/mobile/lib/widgets/common/user_circle_avatar.dart +++ b/mobile/lib/widgets/common/user_circle_avatar.dart @@ -4,7 +4,7 @@ import 'package:immich_mobile/domain/models/user.model.dart'; import 'package:immich_mobile/presentation/widgets/images/remote_image_provider.dart'; import 'package:immich_mobile/providers/infrastructure/session.provider.dart'; -class UserCircleAvatar extends StatelessWidget { +class UserCircleAvatar extends ConsumerWidget { final UserDto user; final double size; final bool hasBorder; @@ -13,10 +13,10 @@ class UserCircleAvatar extends StatelessWidget { const UserCircleAvatar({super.key, this.size = 44, this.hasBorder = false, this.opacity = 1, required this.user}); @override - Widget build(BuildContext context) { + Widget build(BuildContext context, WidgetRef ref) { final userAvatarColor = user.avatarColor.toColor().withValues(alpha: opacity); final profileImageUrl = - '${ref.read(sessionProvider).serverEndpoint}/users/${user.id}/profile-image?d=${user.profileChangedAt.millisecondsSinceEpoch}'; + '${ref.watch(sessionProvider.select((s) => s.serverEndpoint))!}/users/${user.id}/profile-image?d=${user.profileChangedAt.millisecondsSinceEpoch}'; final textColor = (user.avatarColor.toColor().computeLuminance() > 0.5 ? Colors.black : Colors.white).withValues( alpha: opacity, diff --git a/mobile/test/drift/main/generated/schema_v32.dart b/mobile/test/drift/main/generated/schema_v32.dart deleted file mode 100644 index 25018a2a2c..0000000000 --- a/mobile/test/drift/main/generated/schema_v32.dart +++ /dev/null @@ -1,10246 +0,0 @@ -// dart format width=80 -import 'dart:typed_data' as i2; -// GENERATED BY drift_dev, DO NOT MODIFY. -// ignore_for_file: type=lint,unused_import -// -import 'package:drift/drift.dart'; - -class UserEntity extends Table with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - UserEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn id = GeneratedColumn( - 'id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn name = GeneratedColumn( - 'name', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn email = GeneratedColumn( - 'email', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn hasProfileImage = GeneratedColumn( - 'has_profile_image', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: - 'NOT NULL DEFAULT 0 CHECK (has_profile_image IN (0, 1))', - defaultValue: const CustomExpression('0'), - ); - late final GeneratedColumn profileChangedAt = GeneratedColumn( - 'profile_changed_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', - defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), - ); - late final GeneratedColumn avatarColor = GeneratedColumn( - 'avatar_color', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT 0', - defaultValue: const CustomExpression('0'), - ); - @override - List get $columns => [ - id, - name, - email, - hasProfileImage, - profileChangedAt, - avatarColor, - ]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'user_entity'; - @override - Set get $primaryKey => {id}; - @override - UserEntityData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return UserEntityData( - id: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}id'], - )!, - name: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}name'], - )!, - email: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}email'], - )!, - hasProfileImage: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}has_profile_image'], - )!, - profileChangedAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}profile_changed_at'], - )!, - avatarColor: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}avatar_color'], - )!, - ); - } - - @override - UserEntity createAlias(String alias) { - return UserEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const ['PRIMARY KEY(id)']; - @override - bool get dontWriteConstraints => true; -} - -class UserEntityData extends DataClass implements Insertable { - final String id; - final String name; - final String email; - final int hasProfileImage; - final String profileChangedAt; - final int avatarColor; - const UserEntityData({ - required this.id, - required this.name, - required this.email, - required this.hasProfileImage, - required this.profileChangedAt, - required this.avatarColor, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['id'] = Variable(id); - map['name'] = Variable(name); - map['email'] = Variable(email); - map['has_profile_image'] = Variable(hasProfileImage); - map['profile_changed_at'] = Variable(profileChangedAt); - map['avatar_color'] = Variable(avatarColor); - return map; - } - - factory UserEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return UserEntityData( - id: serializer.fromJson(json['id']), - name: serializer.fromJson(json['name']), - email: serializer.fromJson(json['email']), - hasProfileImage: serializer.fromJson(json['hasProfileImage']), - profileChangedAt: serializer.fromJson(json['profileChangedAt']), - avatarColor: serializer.fromJson(json['avatarColor']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'id': serializer.toJson(id), - 'name': serializer.toJson(name), - 'email': serializer.toJson(email), - 'hasProfileImage': serializer.toJson(hasProfileImage), - 'profileChangedAt': serializer.toJson(profileChangedAt), - 'avatarColor': serializer.toJson(avatarColor), - }; - } - - UserEntityData copyWith({ - String? id, - String? name, - String? email, - int? hasProfileImage, - String? profileChangedAt, - int? avatarColor, - }) => UserEntityData( - id: id ?? this.id, - name: name ?? this.name, - email: email ?? this.email, - hasProfileImage: hasProfileImage ?? this.hasProfileImage, - profileChangedAt: profileChangedAt ?? this.profileChangedAt, - avatarColor: avatarColor ?? this.avatarColor, - ); - UserEntityData copyWithCompanion(UserEntityCompanion data) { - return UserEntityData( - id: data.id.present ? data.id.value : this.id, - name: data.name.present ? data.name.value : this.name, - email: data.email.present ? data.email.value : this.email, - hasProfileImage: data.hasProfileImage.present - ? data.hasProfileImage.value - : this.hasProfileImage, - profileChangedAt: data.profileChangedAt.present - ? data.profileChangedAt.value - : this.profileChangedAt, - avatarColor: data.avatarColor.present - ? data.avatarColor.value - : this.avatarColor, - ); - } - - @override - String toString() { - return (StringBuffer('UserEntityData(') - ..write('id: $id, ') - ..write('name: $name, ') - ..write('email: $email, ') - ..write('hasProfileImage: $hasProfileImage, ') - ..write('profileChangedAt: $profileChangedAt, ') - ..write('avatarColor: $avatarColor') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash( - id, - name, - email, - hasProfileImage, - profileChangedAt, - avatarColor, - ); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is UserEntityData && - other.id == this.id && - other.name == this.name && - other.email == this.email && - other.hasProfileImage == this.hasProfileImage && - other.profileChangedAt == this.profileChangedAt && - other.avatarColor == this.avatarColor); -} - -class UserEntityCompanion extends UpdateCompanion { - final Value id; - final Value name; - final Value email; - final Value hasProfileImage; - final Value profileChangedAt; - final Value avatarColor; - const UserEntityCompanion({ - this.id = const Value.absent(), - this.name = const Value.absent(), - this.email = const Value.absent(), - this.hasProfileImage = const Value.absent(), - this.profileChangedAt = const Value.absent(), - this.avatarColor = const Value.absent(), - }); - UserEntityCompanion.insert({ - required String id, - required String name, - required String email, - this.hasProfileImage = const Value.absent(), - this.profileChangedAt = const Value.absent(), - this.avatarColor = const Value.absent(), - }) : id = Value(id), - name = Value(name), - email = Value(email); - static Insertable custom({ - Expression? id, - Expression? name, - Expression? email, - Expression? hasProfileImage, - Expression? profileChangedAt, - Expression? avatarColor, - }) { - return RawValuesInsertable({ - if (id != null) 'id': id, - if (name != null) 'name': name, - if (email != null) 'email': email, - if (hasProfileImage != null) 'has_profile_image': hasProfileImage, - if (profileChangedAt != null) 'profile_changed_at': profileChangedAt, - if (avatarColor != null) 'avatar_color': avatarColor, - }); - } - - UserEntityCompanion copyWith({ - Value? id, - Value? name, - Value? email, - Value? hasProfileImage, - Value? profileChangedAt, - Value? avatarColor, - }) { - return UserEntityCompanion( - id: id ?? this.id, - name: name ?? this.name, - email: email ?? this.email, - hasProfileImage: hasProfileImage ?? this.hasProfileImage, - profileChangedAt: profileChangedAt ?? this.profileChangedAt, - avatarColor: avatarColor ?? this.avatarColor, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (id.present) { - map['id'] = Variable(id.value); - } - if (name.present) { - map['name'] = Variable(name.value); - } - if (email.present) { - map['email'] = Variable(email.value); - } - if (hasProfileImage.present) { - map['has_profile_image'] = Variable(hasProfileImage.value); - } - if (profileChangedAt.present) { - map['profile_changed_at'] = Variable(profileChangedAt.value); - } - if (avatarColor.present) { - map['avatar_color'] = Variable(avatarColor.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('UserEntityCompanion(') - ..write('id: $id, ') - ..write('name: $name, ') - ..write('email: $email, ') - ..write('hasProfileImage: $hasProfileImage, ') - ..write('profileChangedAt: $profileChangedAt, ') - ..write('avatarColor: $avatarColor') - ..write(')')) - .toString(); - } -} - -class RemoteAssetEntity extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - RemoteAssetEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn name = GeneratedColumn( - 'name', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn type = GeneratedColumn( - 'type', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn createdAt = GeneratedColumn( - 'created_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', - defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), - ); - late final GeneratedColumn updatedAt = GeneratedColumn( - 'updated_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', - defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), - ); - late final GeneratedColumn width = GeneratedColumn( - 'width', - aliasedName, - true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn height = GeneratedColumn( - 'height', - aliasedName, - true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn durationMs = GeneratedColumn( - 'duration_ms', - aliasedName, - true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn id = GeneratedColumn( - 'id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn checksum = GeneratedColumn( - 'checksum', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn isFavorite = GeneratedColumn( - 'is_favorite', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT 0 CHECK (is_favorite IN (0, 1))', - defaultValue: const CustomExpression('0'), - ); - late final GeneratedColumn ownerId = GeneratedColumn( - 'owner_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL REFERENCES user_entity(id)ON DELETE CASCADE', - ); - late final GeneratedColumn localDateTime = GeneratedColumn( - 'local_date_time', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn thumbHash = GeneratedColumn( - 'thumb_hash', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn deletedAt = GeneratedColumn( - 'deleted_at', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn uploadedAt = GeneratedColumn( - 'uploaded_at', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn livePhotoVideoId = GeneratedColumn( - 'live_photo_video_id', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn visibility = GeneratedColumn( - 'visibility', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn stackId = GeneratedColumn( - 'stack_id', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn libraryId = GeneratedColumn( - 'library_id', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn isEdited = GeneratedColumn( - 'is_edited', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT 0 CHECK (is_edited IN (0, 1))', - defaultValue: const CustomExpression('0'), - ); - @override - List get $columns => [ - name, - type, - createdAt, - updatedAt, - width, - height, - durationMs, - id, - checksum, - isFavorite, - ownerId, - localDateTime, - thumbHash, - deletedAt, - uploadedAt, - livePhotoVideoId, - visibility, - stackId, - libraryId, - isEdited, - ]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'remote_asset_entity'; - @override - Set get $primaryKey => {id}; - @override - RemoteAssetEntityData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return RemoteAssetEntityData( - name: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}name'], - )!, - type: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}type'], - )!, - createdAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}created_at'], - )!, - updatedAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}updated_at'], - )!, - width: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}width'], - ), - height: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}height'], - ), - durationMs: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}duration_ms'], - ), - id: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}id'], - )!, - checksum: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}checksum'], - )!, - isFavorite: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}is_favorite'], - )!, - ownerId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}owner_id'], - )!, - localDateTime: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}local_date_time'], - ), - thumbHash: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}thumb_hash'], - ), - deletedAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}deleted_at'], - ), - uploadedAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}uploaded_at'], - ), - livePhotoVideoId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}live_photo_video_id'], - ), - visibility: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}visibility'], - )!, - stackId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}stack_id'], - ), - libraryId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}library_id'], - ), - isEdited: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}is_edited'], - )!, - ); - } - - @override - RemoteAssetEntity createAlias(String alias) { - return RemoteAssetEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const ['PRIMARY KEY(id)']; - @override - bool get dontWriteConstraints => true; -} - -class RemoteAssetEntityData extends DataClass - implements Insertable { - final String name; - final int type; - final String createdAt; - final String updatedAt; - final int? width; - final int? height; - final int? durationMs; - final String id; - final String checksum; - final int isFavorite; - final String ownerId; - final String? localDateTime; - final String? thumbHash; - final String? deletedAt; - final String? uploadedAt; - final String? livePhotoVideoId; - final int visibility; - final String? stackId; - final String? libraryId; - final int isEdited; - const RemoteAssetEntityData({ - required this.name, - required this.type, - required this.createdAt, - required this.updatedAt, - this.width, - this.height, - this.durationMs, - required this.id, - required this.checksum, - required this.isFavorite, - required this.ownerId, - this.localDateTime, - this.thumbHash, - this.deletedAt, - this.uploadedAt, - this.livePhotoVideoId, - required this.visibility, - this.stackId, - this.libraryId, - required this.isEdited, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['name'] = Variable(name); - map['type'] = Variable(type); - map['created_at'] = Variable(createdAt); - map['updated_at'] = Variable(updatedAt); - if (!nullToAbsent || width != null) { - map['width'] = Variable(width); - } - if (!nullToAbsent || height != null) { - map['height'] = Variable(height); - } - if (!nullToAbsent || durationMs != null) { - map['duration_ms'] = Variable(durationMs); - } - map['id'] = Variable(id); - map['checksum'] = Variable(checksum); - map['is_favorite'] = Variable(isFavorite); - map['owner_id'] = Variable(ownerId); - if (!nullToAbsent || localDateTime != null) { - map['local_date_time'] = Variable(localDateTime); - } - if (!nullToAbsent || thumbHash != null) { - map['thumb_hash'] = Variable(thumbHash); - } - if (!nullToAbsent || deletedAt != null) { - map['deleted_at'] = Variable(deletedAt); - } - if (!nullToAbsent || uploadedAt != null) { - map['uploaded_at'] = Variable(uploadedAt); - } - if (!nullToAbsent || livePhotoVideoId != null) { - map['live_photo_video_id'] = Variable(livePhotoVideoId); - } - map['visibility'] = Variable(visibility); - if (!nullToAbsent || stackId != null) { - map['stack_id'] = Variable(stackId); - } - if (!nullToAbsent || libraryId != null) { - map['library_id'] = Variable(libraryId); - } - map['is_edited'] = Variable(isEdited); - return map; - } - - factory RemoteAssetEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return RemoteAssetEntityData( - name: serializer.fromJson(json['name']), - type: serializer.fromJson(json['type']), - createdAt: serializer.fromJson(json['createdAt']), - updatedAt: serializer.fromJson(json['updatedAt']), - width: serializer.fromJson(json['width']), - height: serializer.fromJson(json['height']), - durationMs: serializer.fromJson(json['durationMs']), - id: serializer.fromJson(json['id']), - 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']), - uploadedAt: serializer.fromJson(json['uploadedAt']), - livePhotoVideoId: serializer.fromJson(json['livePhotoVideoId']), - visibility: serializer.fromJson(json['visibility']), - stackId: serializer.fromJson(json['stackId']), - libraryId: serializer.fromJson(json['libraryId']), - isEdited: serializer.fromJson(json['isEdited']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'name': serializer.toJson(name), - 'type': serializer.toJson(type), - 'createdAt': serializer.toJson(createdAt), - 'updatedAt': serializer.toJson(updatedAt), - 'width': serializer.toJson(width), - 'height': serializer.toJson(height), - 'durationMs': serializer.toJson(durationMs), - 'id': serializer.toJson(id), - 'checksum': serializer.toJson(checksum), - 'isFavorite': serializer.toJson(isFavorite), - 'ownerId': serializer.toJson(ownerId), - 'localDateTime': serializer.toJson(localDateTime), - 'thumbHash': serializer.toJson(thumbHash), - 'deletedAt': serializer.toJson(deletedAt), - 'uploadedAt': serializer.toJson(uploadedAt), - 'livePhotoVideoId': serializer.toJson(livePhotoVideoId), - 'visibility': serializer.toJson(visibility), - 'stackId': serializer.toJson(stackId), - 'libraryId': serializer.toJson(libraryId), - 'isEdited': serializer.toJson(isEdited), - }; - } - - RemoteAssetEntityData copyWith({ - String? name, - int? type, - String? createdAt, - String? updatedAt, - Value width = const Value.absent(), - Value height = const Value.absent(), - Value durationMs = const Value.absent(), - String? id, - String? checksum, - int? isFavorite, - String? ownerId, - Value localDateTime = const Value.absent(), - Value thumbHash = const Value.absent(), - Value deletedAt = const Value.absent(), - Value uploadedAt = const Value.absent(), - Value livePhotoVideoId = const Value.absent(), - int? visibility, - Value stackId = const Value.absent(), - Value libraryId = const Value.absent(), - int? isEdited, - }) => RemoteAssetEntityData( - 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, - durationMs: durationMs.present ? durationMs.value : this.durationMs, - id: id ?? this.id, - 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, - uploadedAt: uploadedAt.present ? uploadedAt.value : this.uploadedAt, - livePhotoVideoId: livePhotoVideoId.present - ? livePhotoVideoId.value - : this.livePhotoVideoId, - visibility: visibility ?? this.visibility, - stackId: stackId.present ? stackId.value : this.stackId, - libraryId: libraryId.present ? libraryId.value : this.libraryId, - isEdited: isEdited ?? this.isEdited, - ); - RemoteAssetEntityData copyWithCompanion(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, - width: data.width.present ? data.width.value : this.width, - height: data.height.present ? data.height.value : this.height, - durationMs: data.durationMs.present - ? data.durationMs.value - : this.durationMs, - id: data.id.present ? data.id.value : this.id, - 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, - uploadedAt: data.uploadedAt.present - ? data.uploadedAt.value - : this.uploadedAt, - livePhotoVideoId: data.livePhotoVideoId.present - ? data.livePhotoVideoId.value - : this.livePhotoVideoId, - visibility: data.visibility.present - ? data.visibility.value - : this.visibility, - stackId: data.stackId.present ? data.stackId.value : this.stackId, - libraryId: data.libraryId.present ? data.libraryId.value : this.libraryId, - isEdited: data.isEdited.present ? data.isEdited.value : this.isEdited, - ); - } - - @override - String toString() { - return (StringBuffer('RemoteAssetEntityData(') - ..write('name: $name, ') - ..write('type: $type, ') - ..write('createdAt: $createdAt, ') - ..write('updatedAt: $updatedAt, ') - ..write('width: $width, ') - ..write('height: $height, ') - ..write('durationMs: $durationMs, ') - ..write('id: $id, ') - ..write('checksum: $checksum, ') - ..write('isFavorite: $isFavorite, ') - ..write('ownerId: $ownerId, ') - ..write('localDateTime: $localDateTime, ') - ..write('thumbHash: $thumbHash, ') - ..write('deletedAt: $deletedAt, ') - ..write('uploadedAt: $uploadedAt, ') - ..write('livePhotoVideoId: $livePhotoVideoId, ') - ..write('visibility: $visibility, ') - ..write('stackId: $stackId, ') - ..write('libraryId: $libraryId, ') - ..write('isEdited: $isEdited') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash( - name, - type, - createdAt, - updatedAt, - width, - height, - durationMs, - id, - checksum, - isFavorite, - ownerId, - localDateTime, - thumbHash, - deletedAt, - uploadedAt, - livePhotoVideoId, - visibility, - stackId, - libraryId, - isEdited, - ); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is RemoteAssetEntityData && - other.name == this.name && - other.type == this.type && - other.createdAt == this.createdAt && - other.updatedAt == this.updatedAt && - other.width == this.width && - other.height == this.height && - other.durationMs == this.durationMs && - other.id == this.id && - other.checksum == this.checksum && - other.isFavorite == this.isFavorite && - other.ownerId == this.ownerId && - other.localDateTime == this.localDateTime && - other.thumbHash == this.thumbHash && - other.deletedAt == this.deletedAt && - other.uploadedAt == this.uploadedAt && - other.livePhotoVideoId == this.livePhotoVideoId && - other.visibility == this.visibility && - other.stackId == this.stackId && - other.libraryId == this.libraryId && - other.isEdited == this.isEdited); -} - -class RemoteAssetEntityCompanion - extends UpdateCompanion { - final Value name; - final Value type; - final Value createdAt; - final Value updatedAt; - final Value width; - final Value height; - final Value durationMs; - final Value id; - final Value checksum; - final Value isFavorite; - final Value ownerId; - final Value localDateTime; - final Value thumbHash; - final Value deletedAt; - final Value uploadedAt; - final Value livePhotoVideoId; - final Value visibility; - final Value stackId; - final Value libraryId; - final Value isEdited; - const RemoteAssetEntityCompanion({ - this.name = const Value.absent(), - this.type = const Value.absent(), - this.createdAt = const Value.absent(), - this.updatedAt = const Value.absent(), - this.width = const Value.absent(), - this.height = const Value.absent(), - this.durationMs = const Value.absent(), - this.id = const Value.absent(), - this.checksum = const Value.absent(), - this.isFavorite = const Value.absent(), - this.ownerId = const Value.absent(), - this.localDateTime = const Value.absent(), - this.thumbHash = const Value.absent(), - this.deletedAt = const Value.absent(), - this.uploadedAt = const Value.absent(), - this.livePhotoVideoId = const Value.absent(), - this.visibility = const Value.absent(), - this.stackId = const Value.absent(), - this.libraryId = const Value.absent(), - this.isEdited = const Value.absent(), - }); - RemoteAssetEntityCompanion.insert({ - required String name, - required int type, - this.createdAt = const Value.absent(), - this.updatedAt = const Value.absent(), - this.width = const Value.absent(), - this.height = const Value.absent(), - this.durationMs = const Value.absent(), - required String id, - required String checksum, - this.isFavorite = const Value.absent(), - required String ownerId, - this.localDateTime = const Value.absent(), - this.thumbHash = const Value.absent(), - this.deletedAt = const Value.absent(), - this.uploadedAt = const Value.absent(), - this.livePhotoVideoId = const Value.absent(), - required int visibility, - this.stackId = const Value.absent(), - this.libraryId = const Value.absent(), - this.isEdited = const Value.absent(), - }) : name = Value(name), - type = Value(type), - id = Value(id), - checksum = Value(checksum), - ownerId = Value(ownerId), - visibility = Value(visibility); - static Insertable custom({ - Expression? name, - Expression? type, - Expression? createdAt, - Expression? updatedAt, - Expression? width, - Expression? height, - Expression? durationMs, - Expression? id, - Expression? checksum, - Expression? isFavorite, - Expression? ownerId, - Expression? localDateTime, - Expression? thumbHash, - Expression? deletedAt, - Expression? uploadedAt, - Expression? livePhotoVideoId, - Expression? visibility, - Expression? stackId, - Expression? libraryId, - Expression? isEdited, - }) { - return 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 (durationMs != null) 'duration_ms': durationMs, - if (id != null) 'id': id, - 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) 'thumb_hash': thumbHash, - if (deletedAt != null) 'deleted_at': deletedAt, - if (uploadedAt != null) 'uploaded_at': uploadedAt, - if (livePhotoVideoId != null) 'live_photo_video_id': livePhotoVideoId, - if (visibility != null) 'visibility': visibility, - if (stackId != null) 'stack_id': stackId, - if (libraryId != null) 'library_id': libraryId, - if (isEdited != null) 'is_edited': isEdited, - }); - } - - RemoteAssetEntityCompanion copyWith({ - Value? name, - Value? type, - Value? createdAt, - Value? updatedAt, - Value? width, - Value? height, - Value? durationMs, - Value? id, - Value? checksum, - Value? isFavorite, - Value? ownerId, - Value? localDateTime, - Value? thumbHash, - Value? deletedAt, - Value? uploadedAt, - Value? livePhotoVideoId, - Value? visibility, - Value? stackId, - Value? libraryId, - Value? isEdited, - }) { - return RemoteAssetEntityCompanion( - name: name ?? this.name, - type: type ?? this.type, - createdAt: createdAt ?? this.createdAt, - updatedAt: updatedAt ?? this.updatedAt, - width: width ?? this.width, - height: height ?? this.height, - durationMs: durationMs ?? this.durationMs, - id: id ?? this.id, - checksum: checksum ?? this.checksum, - isFavorite: isFavorite ?? this.isFavorite, - ownerId: ownerId ?? this.ownerId, - localDateTime: localDateTime ?? this.localDateTime, - thumbHash: thumbHash ?? this.thumbHash, - deletedAt: deletedAt ?? this.deletedAt, - uploadedAt: uploadedAt ?? this.uploadedAt, - livePhotoVideoId: livePhotoVideoId ?? this.livePhotoVideoId, - visibility: visibility ?? this.visibility, - stackId: stackId ?? this.stackId, - libraryId: libraryId ?? this.libraryId, - isEdited: isEdited ?? this.isEdited, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (name.present) { - map['name'] = Variable(name.value); - } - if (type.present) { - map['type'] = Variable(type.value); - } - if (createdAt.present) { - map['created_at'] = Variable(createdAt.value); - } - if (updatedAt.present) { - map['updated_at'] = Variable(updatedAt.value); - } - if (width.present) { - map['width'] = Variable(width.value); - } - if (height.present) { - map['height'] = Variable(height.value); - } - if (durationMs.present) { - map['duration_ms'] = Variable(durationMs.value); - } - if (id.present) { - map['id'] = Variable(id.value); - } - if (checksum.present) { - map['checksum'] = Variable(checksum.value); - } - if (isFavorite.present) { - map['is_favorite'] = Variable(isFavorite.value); - } - if (ownerId.present) { - map['owner_id'] = Variable(ownerId.value); - } - if (localDateTime.present) { - map['local_date_time'] = Variable(localDateTime.value); - } - if (thumbHash.present) { - map['thumb_hash'] = Variable(thumbHash.value); - } - if (deletedAt.present) { - map['deleted_at'] = Variable(deletedAt.value); - } - if (uploadedAt.present) { - map['uploaded_at'] = Variable(uploadedAt.value); - } - if (livePhotoVideoId.present) { - map['live_photo_video_id'] = Variable(livePhotoVideoId.value); - } - if (visibility.present) { - map['visibility'] = Variable(visibility.value); - } - if (stackId.present) { - map['stack_id'] = Variable(stackId.value); - } - if (libraryId.present) { - map['library_id'] = Variable(libraryId.value); - } - if (isEdited.present) { - map['is_edited'] = Variable(isEdited.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('RemoteAssetEntityCompanion(') - ..write('name: $name, ') - ..write('type: $type, ') - ..write('createdAt: $createdAt, ') - ..write('updatedAt: $updatedAt, ') - ..write('width: $width, ') - ..write('height: $height, ') - ..write('durationMs: $durationMs, ') - ..write('id: $id, ') - ..write('checksum: $checksum, ') - ..write('isFavorite: $isFavorite, ') - ..write('ownerId: $ownerId, ') - ..write('localDateTime: $localDateTime, ') - ..write('thumbHash: $thumbHash, ') - ..write('deletedAt: $deletedAt, ') - ..write('uploadedAt: $uploadedAt, ') - ..write('livePhotoVideoId: $livePhotoVideoId, ') - ..write('visibility: $visibility, ') - ..write('stackId: $stackId, ') - ..write('libraryId: $libraryId, ') - ..write('isEdited: $isEdited') - ..write(')')) - .toString(); - } -} - -class StackEntity extends Table with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - StackEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn id = GeneratedColumn( - 'id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn createdAt = GeneratedColumn( - 'created_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', - defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), - ); - late final GeneratedColumn updatedAt = GeneratedColumn( - 'updated_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', - defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), - ); - late final GeneratedColumn ownerId = GeneratedColumn( - 'owner_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL REFERENCES user_entity(id)ON DELETE CASCADE', - ); - late final GeneratedColumn primaryAssetId = GeneratedColumn( - 'primary_asset_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - @override - List get $columns => [ - id, - createdAt, - updatedAt, - ownerId, - primaryAssetId, - ]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'stack_entity'; - @override - Set get $primaryKey => {id}; - @override - StackEntityData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return StackEntityData( - id: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}id'], - )!, - createdAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}created_at'], - )!, - updatedAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}updated_at'], - )!, - ownerId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}owner_id'], - )!, - primaryAssetId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}primary_asset_id'], - )!, - ); - } - - @override - StackEntity createAlias(String alias) { - return StackEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const ['PRIMARY KEY(id)']; - @override - bool get dontWriteConstraints => true; -} - -class StackEntityData extends DataClass implements Insertable { - final String id; - final String createdAt; - final String updatedAt; - final String ownerId; - final String primaryAssetId; - const StackEntityData({ - required this.id, - required this.createdAt, - required this.updatedAt, - required this.ownerId, - required this.primaryAssetId, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['id'] = Variable(id); - map['created_at'] = Variable(createdAt); - map['updated_at'] = Variable(updatedAt); - map['owner_id'] = Variable(ownerId); - map['primary_asset_id'] = Variable(primaryAssetId); - return map; - } - - factory StackEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return StackEntityData( - id: serializer.fromJson(json['id']), - createdAt: serializer.fromJson(json['createdAt']), - updatedAt: serializer.fromJson(json['updatedAt']), - ownerId: serializer.fromJson(json['ownerId']), - primaryAssetId: serializer.fromJson(json['primaryAssetId']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'id': serializer.toJson(id), - 'createdAt': serializer.toJson(createdAt), - 'updatedAt': serializer.toJson(updatedAt), - 'ownerId': serializer.toJson(ownerId), - 'primaryAssetId': serializer.toJson(primaryAssetId), - }; - } - - StackEntityData copyWith({ - String? id, - String? createdAt, - String? updatedAt, - String? ownerId, - String? primaryAssetId, - }) => StackEntityData( - id: id ?? this.id, - createdAt: createdAt ?? this.createdAt, - updatedAt: updatedAt ?? this.updatedAt, - ownerId: ownerId ?? this.ownerId, - primaryAssetId: primaryAssetId ?? this.primaryAssetId, - ); - StackEntityData copyWithCompanion(StackEntityCompanion data) { - return StackEntityData( - id: data.id.present ? data.id.value : this.id, - createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, - updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, - ownerId: data.ownerId.present ? data.ownerId.value : this.ownerId, - primaryAssetId: data.primaryAssetId.present - ? data.primaryAssetId.value - : this.primaryAssetId, - ); - } - - @override - String toString() { - return (StringBuffer('StackEntityData(') - ..write('id: $id, ') - ..write('createdAt: $createdAt, ') - ..write('updatedAt: $updatedAt, ') - ..write('ownerId: $ownerId, ') - ..write('primaryAssetId: $primaryAssetId') - ..write(')')) - .toString(); - } - - @override - int get hashCode => - Object.hash(id, createdAt, updatedAt, ownerId, primaryAssetId); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is StackEntityData && - other.id == this.id && - other.createdAt == this.createdAt && - other.updatedAt == this.updatedAt && - other.ownerId == this.ownerId && - other.primaryAssetId == this.primaryAssetId); -} - -class StackEntityCompanion extends UpdateCompanion { - final Value id; - final Value createdAt; - final Value updatedAt; - final Value ownerId; - final Value primaryAssetId; - const StackEntityCompanion({ - this.id = const Value.absent(), - this.createdAt = const Value.absent(), - this.updatedAt = const Value.absent(), - this.ownerId = const Value.absent(), - this.primaryAssetId = const Value.absent(), - }); - StackEntityCompanion.insert({ - required String id, - this.createdAt = const Value.absent(), - this.updatedAt = const Value.absent(), - required String ownerId, - required String primaryAssetId, - }) : id = Value(id), - ownerId = Value(ownerId), - primaryAssetId = Value(primaryAssetId); - static Insertable custom({ - Expression? id, - Expression? createdAt, - Expression? updatedAt, - Expression? ownerId, - Expression? primaryAssetId, - }) { - return RawValuesInsertable({ - if (id != null) 'id': id, - if (createdAt != null) 'created_at': createdAt, - if (updatedAt != null) 'updated_at': updatedAt, - if (ownerId != null) 'owner_id': ownerId, - if (primaryAssetId != null) 'primary_asset_id': primaryAssetId, - }); - } - - StackEntityCompanion copyWith({ - Value? id, - Value? createdAt, - Value? updatedAt, - Value? ownerId, - Value? primaryAssetId, - }) { - return StackEntityCompanion( - id: id ?? this.id, - createdAt: createdAt ?? this.createdAt, - updatedAt: updatedAt ?? this.updatedAt, - ownerId: ownerId ?? this.ownerId, - primaryAssetId: primaryAssetId ?? this.primaryAssetId, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (id.present) { - map['id'] = Variable(id.value); - } - if (createdAt.present) { - map['created_at'] = Variable(createdAt.value); - } - if (updatedAt.present) { - map['updated_at'] = Variable(updatedAt.value); - } - if (ownerId.present) { - map['owner_id'] = Variable(ownerId.value); - } - if (primaryAssetId.present) { - map['primary_asset_id'] = Variable(primaryAssetId.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('StackEntityCompanion(') - ..write('id: $id, ') - ..write('createdAt: $createdAt, ') - ..write('updatedAt: $updatedAt, ') - ..write('ownerId: $ownerId, ') - ..write('primaryAssetId: $primaryAssetId') - ..write(')')) - .toString(); - } -} - -class LocalAssetEntity extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - LocalAssetEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn name = GeneratedColumn( - 'name', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn type = GeneratedColumn( - 'type', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn createdAt = GeneratedColumn( - 'created_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', - defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), - ); - late final GeneratedColumn updatedAt = GeneratedColumn( - 'updated_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', - defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), - ); - late final GeneratedColumn width = GeneratedColumn( - 'width', - aliasedName, - true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn height = GeneratedColumn( - 'height', - aliasedName, - true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn durationMs = GeneratedColumn( - 'duration_ms', - aliasedName, - true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn id = GeneratedColumn( - 'id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn checksum = GeneratedColumn( - 'checksum', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn isFavorite = GeneratedColumn( - 'is_favorite', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT 0 CHECK (is_favorite IN (0, 1))', - defaultValue: const CustomExpression('0'), - ); - late final GeneratedColumn orientation = GeneratedColumn( - 'orientation', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT 0', - defaultValue: const CustomExpression('0'), - ); - late final GeneratedColumn iCloudId = GeneratedColumn( - 'i_cloud_id', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn adjustmentTime = GeneratedColumn( - 'adjustment_time', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn latitude = GeneratedColumn( - 'latitude', - aliasedName, - true, - type: DriftSqlType.double, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn longitude = GeneratedColumn( - 'longitude', - aliasedName, - true, - type: DriftSqlType.double, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn playbackStyle = GeneratedColumn( - 'playback_style', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT 0', - defaultValue: const CustomExpression('0'), - ); - @override - List get $columns => [ - name, - type, - createdAt, - updatedAt, - width, - height, - durationMs, - id, - checksum, - isFavorite, - orientation, - iCloudId, - adjustmentTime, - latitude, - longitude, - playbackStyle, - ]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'local_asset_entity'; - @override - Set get $primaryKey => {id}; - @override - LocalAssetEntityData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return LocalAssetEntityData( - name: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}name'], - )!, - type: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}type'], - )!, - createdAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}created_at'], - )!, - updatedAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}updated_at'], - )!, - width: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}width'], - ), - height: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}height'], - ), - durationMs: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}duration_ms'], - ), - id: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}id'], - )!, - checksum: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}checksum'], - ), - isFavorite: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}is_favorite'], - )!, - orientation: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}orientation'], - )!, - iCloudId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}i_cloud_id'], - ), - adjustmentTime: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}adjustment_time'], - ), - latitude: attachedDatabase.typeMapping.read( - DriftSqlType.double, - data['${effectivePrefix}latitude'], - ), - longitude: attachedDatabase.typeMapping.read( - DriftSqlType.double, - data['${effectivePrefix}longitude'], - ), - playbackStyle: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}playback_style'], - )!, - ); - } - - @override - LocalAssetEntity createAlias(String alias) { - return LocalAssetEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const ['PRIMARY KEY(id)']; - @override - bool get dontWriteConstraints => true; -} - -class LocalAssetEntityData extends DataClass - implements Insertable { - final String name; - final int type; - final String createdAt; - final String updatedAt; - final int? width; - final int? height; - final int? durationMs; - final String id; - final String? checksum; - final int isFavorite; - final int orientation; - final String? iCloudId; - final String? adjustmentTime; - final double? latitude; - final double? longitude; - final int playbackStyle; - const LocalAssetEntityData({ - required this.name, - required this.type, - required this.createdAt, - required this.updatedAt, - this.width, - this.height, - this.durationMs, - required this.id, - this.checksum, - required this.isFavorite, - required this.orientation, - this.iCloudId, - this.adjustmentTime, - this.latitude, - this.longitude, - required this.playbackStyle, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['name'] = Variable(name); - map['type'] = Variable(type); - map['created_at'] = Variable(createdAt); - map['updated_at'] = Variable(updatedAt); - if (!nullToAbsent || width != null) { - map['width'] = Variable(width); - } - if (!nullToAbsent || height != null) { - map['height'] = Variable(height); - } - if (!nullToAbsent || durationMs != null) { - map['duration_ms'] = Variable(durationMs); - } - map['id'] = Variable(id); - if (!nullToAbsent || checksum != null) { - map['checksum'] = Variable(checksum); - } - map['is_favorite'] = Variable(isFavorite); - map['orientation'] = Variable(orientation); - if (!nullToAbsent || iCloudId != null) { - map['i_cloud_id'] = Variable(iCloudId); - } - if (!nullToAbsent || adjustmentTime != null) { - map['adjustment_time'] = Variable(adjustmentTime); - } - if (!nullToAbsent || latitude != null) { - map['latitude'] = Variable(latitude); - } - if (!nullToAbsent || longitude != null) { - map['longitude'] = Variable(longitude); - } - map['playback_style'] = Variable(playbackStyle); - return map; - } - - factory LocalAssetEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return LocalAssetEntityData( - name: serializer.fromJson(json['name']), - type: serializer.fromJson(json['type']), - createdAt: serializer.fromJson(json['createdAt']), - updatedAt: serializer.fromJson(json['updatedAt']), - width: serializer.fromJson(json['width']), - height: serializer.fromJson(json['height']), - durationMs: serializer.fromJson(json['durationMs']), - id: serializer.fromJson(json['id']), - checksum: serializer.fromJson(json['checksum']), - isFavorite: serializer.fromJson(json['isFavorite']), - orientation: serializer.fromJson(json['orientation']), - iCloudId: serializer.fromJson(json['iCloudId']), - adjustmentTime: serializer.fromJson(json['adjustmentTime']), - latitude: serializer.fromJson(json['latitude']), - longitude: serializer.fromJson(json['longitude']), - playbackStyle: serializer.fromJson(json['playbackStyle']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'name': serializer.toJson(name), - 'type': serializer.toJson(type), - 'createdAt': serializer.toJson(createdAt), - 'updatedAt': serializer.toJson(updatedAt), - 'width': serializer.toJson(width), - 'height': serializer.toJson(height), - 'durationMs': serializer.toJson(durationMs), - 'id': serializer.toJson(id), - 'checksum': serializer.toJson(checksum), - 'isFavorite': serializer.toJson(isFavorite), - 'orientation': serializer.toJson(orientation), - 'iCloudId': serializer.toJson(iCloudId), - 'adjustmentTime': serializer.toJson(adjustmentTime), - 'latitude': serializer.toJson(latitude), - 'longitude': serializer.toJson(longitude), - 'playbackStyle': serializer.toJson(playbackStyle), - }; - } - - LocalAssetEntityData copyWith({ - String? name, - int? type, - String? createdAt, - String? updatedAt, - Value width = const Value.absent(), - Value height = const Value.absent(), - Value durationMs = const Value.absent(), - String? id, - Value checksum = const Value.absent(), - int? isFavorite, - int? orientation, - Value iCloudId = const Value.absent(), - Value adjustmentTime = const Value.absent(), - Value latitude = const Value.absent(), - Value longitude = const Value.absent(), - int? playbackStyle, - }) => 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, - durationMs: durationMs.present ? durationMs.value : this.durationMs, - id: id ?? this.id, - checksum: checksum.present ? checksum.value : this.checksum, - isFavorite: isFavorite ?? this.isFavorite, - orientation: orientation ?? this.orientation, - iCloudId: iCloudId.present ? iCloudId.value : this.iCloudId, - adjustmentTime: adjustmentTime.present - ? adjustmentTime.value - : this.adjustmentTime, - latitude: latitude.present ? latitude.value : this.latitude, - longitude: longitude.present ? longitude.value : this.longitude, - playbackStyle: playbackStyle ?? this.playbackStyle, - ); - LocalAssetEntityData copyWithCompanion(LocalAssetEntityCompanion data) { - return LocalAssetEntityData( - 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, - width: data.width.present ? data.width.value : this.width, - height: data.height.present ? data.height.value : this.height, - durationMs: data.durationMs.present - ? data.durationMs.value - : this.durationMs, - id: data.id.present ? data.id.value : this.id, - checksum: data.checksum.present ? data.checksum.value : this.checksum, - isFavorite: data.isFavorite.present - ? data.isFavorite.value - : this.isFavorite, - orientation: data.orientation.present - ? data.orientation.value - : this.orientation, - iCloudId: data.iCloudId.present ? data.iCloudId.value : this.iCloudId, - adjustmentTime: data.adjustmentTime.present - ? data.adjustmentTime.value - : this.adjustmentTime, - latitude: data.latitude.present ? data.latitude.value : this.latitude, - longitude: data.longitude.present ? data.longitude.value : this.longitude, - playbackStyle: data.playbackStyle.present - ? data.playbackStyle.value - : this.playbackStyle, - ); - } - - @override - String toString() { - return (StringBuffer('LocalAssetEntityData(') - ..write('name: $name, ') - ..write('type: $type, ') - ..write('createdAt: $createdAt, ') - ..write('updatedAt: $updatedAt, ') - ..write('width: $width, ') - ..write('height: $height, ') - ..write('durationMs: $durationMs, ') - ..write('id: $id, ') - ..write('checksum: $checksum, ') - ..write('isFavorite: $isFavorite, ') - ..write('orientation: $orientation, ') - ..write('iCloudId: $iCloudId, ') - ..write('adjustmentTime: $adjustmentTime, ') - ..write('latitude: $latitude, ') - ..write('longitude: $longitude, ') - ..write('playbackStyle: $playbackStyle') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash( - name, - type, - createdAt, - updatedAt, - width, - height, - durationMs, - id, - checksum, - isFavorite, - orientation, - iCloudId, - adjustmentTime, - latitude, - longitude, - playbackStyle, - ); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is LocalAssetEntityData && - other.name == this.name && - other.type == this.type && - other.createdAt == this.createdAt && - other.updatedAt == this.updatedAt && - other.width == this.width && - other.height == this.height && - other.durationMs == this.durationMs && - other.id == this.id && - other.checksum == this.checksum && - other.isFavorite == this.isFavorite && - other.orientation == this.orientation && - other.iCloudId == this.iCloudId && - other.adjustmentTime == this.adjustmentTime && - other.latitude == this.latitude && - other.longitude == this.longitude && - other.playbackStyle == this.playbackStyle); -} - -class LocalAssetEntityCompanion extends UpdateCompanion { - final Value name; - final Value type; - final Value createdAt; - final Value updatedAt; - final Value width; - final Value height; - final Value durationMs; - final Value id; - final Value checksum; - final Value isFavorite; - final Value orientation; - final Value iCloudId; - final Value adjustmentTime; - final Value latitude; - final Value longitude; - final Value playbackStyle; - const LocalAssetEntityCompanion({ - this.name = const Value.absent(), - this.type = const Value.absent(), - this.createdAt = const Value.absent(), - this.updatedAt = const Value.absent(), - this.width = const Value.absent(), - this.height = const Value.absent(), - this.durationMs = const Value.absent(), - this.id = const Value.absent(), - this.checksum = const Value.absent(), - this.isFavorite = const Value.absent(), - this.orientation = const Value.absent(), - this.iCloudId = const Value.absent(), - this.adjustmentTime = const Value.absent(), - this.latitude = const Value.absent(), - this.longitude = const Value.absent(), - this.playbackStyle = const Value.absent(), - }); - LocalAssetEntityCompanion.insert({ - required String name, - required int type, - this.createdAt = const Value.absent(), - this.updatedAt = const Value.absent(), - this.width = const Value.absent(), - this.height = const Value.absent(), - this.durationMs = const Value.absent(), - required String id, - this.checksum = const Value.absent(), - this.isFavorite = const Value.absent(), - this.orientation = const Value.absent(), - this.iCloudId = const Value.absent(), - this.adjustmentTime = const Value.absent(), - this.latitude = const Value.absent(), - this.longitude = const Value.absent(), - this.playbackStyle = const Value.absent(), - }) : name = Value(name), - type = Value(type), - id = Value(id); - static Insertable custom({ - Expression? name, - Expression? type, - Expression? createdAt, - Expression? updatedAt, - Expression? width, - Expression? height, - Expression? durationMs, - Expression? id, - Expression? checksum, - Expression? isFavorite, - Expression? orientation, - Expression? iCloudId, - Expression? adjustmentTime, - Expression? latitude, - Expression? longitude, - Expression? playbackStyle, - }) { - return 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 (durationMs != null) 'duration_ms': durationMs, - if (id != null) 'id': id, - if (checksum != null) 'checksum': checksum, - if (isFavorite != null) 'is_favorite': isFavorite, - if (orientation != null) 'orientation': orientation, - if (iCloudId != null) 'i_cloud_id': iCloudId, - if (adjustmentTime != null) 'adjustment_time': adjustmentTime, - if (latitude != null) 'latitude': latitude, - if (longitude != null) 'longitude': longitude, - if (playbackStyle != null) 'playback_style': playbackStyle, - }); - } - - LocalAssetEntityCompanion copyWith({ - Value? name, - Value? type, - Value? createdAt, - Value? updatedAt, - Value? width, - Value? height, - Value? durationMs, - Value? id, - Value? checksum, - Value? isFavorite, - Value? orientation, - Value? iCloudId, - Value? adjustmentTime, - Value? latitude, - Value? longitude, - Value? playbackStyle, - }) { - return 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, - durationMs: durationMs ?? this.durationMs, - id: id ?? this.id, - checksum: checksum ?? this.checksum, - isFavorite: isFavorite ?? this.isFavorite, - orientation: orientation ?? this.orientation, - iCloudId: iCloudId ?? this.iCloudId, - adjustmentTime: adjustmentTime ?? this.adjustmentTime, - latitude: latitude ?? this.latitude, - longitude: longitude ?? this.longitude, - playbackStyle: playbackStyle ?? this.playbackStyle, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (name.present) { - map['name'] = Variable(name.value); - } - if (type.present) { - map['type'] = Variable(type.value); - } - if (createdAt.present) { - map['created_at'] = Variable(createdAt.value); - } - if (updatedAt.present) { - map['updated_at'] = Variable(updatedAt.value); - } - if (width.present) { - map['width'] = Variable(width.value); - } - if (height.present) { - map['height'] = Variable(height.value); - } - if (durationMs.present) { - map['duration_ms'] = Variable(durationMs.value); - } - if (id.present) { - map['id'] = Variable(id.value); - } - if (checksum.present) { - map['checksum'] = Variable(checksum.value); - } - if (isFavorite.present) { - map['is_favorite'] = Variable(isFavorite.value); - } - if (orientation.present) { - map['orientation'] = Variable(orientation.value); - } - if (iCloudId.present) { - map['i_cloud_id'] = Variable(iCloudId.value); - } - if (adjustmentTime.present) { - map['adjustment_time'] = Variable(adjustmentTime.value); - } - if (latitude.present) { - map['latitude'] = Variable(latitude.value); - } - if (longitude.present) { - map['longitude'] = Variable(longitude.value); - } - if (playbackStyle.present) { - map['playback_style'] = Variable(playbackStyle.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('LocalAssetEntityCompanion(') - ..write('name: $name, ') - ..write('type: $type, ') - ..write('createdAt: $createdAt, ') - ..write('updatedAt: $updatedAt, ') - ..write('width: $width, ') - ..write('height: $height, ') - ..write('durationMs: $durationMs, ') - ..write('id: $id, ') - ..write('checksum: $checksum, ') - ..write('isFavorite: $isFavorite, ') - ..write('orientation: $orientation, ') - ..write('iCloudId: $iCloudId, ') - ..write('adjustmentTime: $adjustmentTime, ') - ..write('latitude: $latitude, ') - ..write('longitude: $longitude, ') - ..write('playbackStyle: $playbackStyle') - ..write(')')) - .toString(); - } -} - -class RemoteAlbumEntity extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - RemoteAlbumEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn id = GeneratedColumn( - 'id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn name = GeneratedColumn( - 'name', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn description = GeneratedColumn( - 'description', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT \'\'', - defaultValue: const CustomExpression('\'\''), - ); - late final GeneratedColumn createdAt = GeneratedColumn( - 'created_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', - defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), - ); - late final GeneratedColumn updatedAt = GeneratedColumn( - 'updated_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', - defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), - ); - late final GeneratedColumn thumbnailAssetId = GeneratedColumn( - 'thumbnail_asset_id', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: - 'NULL REFERENCES remote_asset_entity(id)ON DELETE SET NULL', - ); - late final GeneratedColumn isActivityEnabled = GeneratedColumn( - 'is_activity_enabled', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: - 'NOT NULL DEFAULT 1 CHECK (is_activity_enabled IN (0, 1))', - defaultValue: const CustomExpression('1'), - ); - late final GeneratedColumn order = GeneratedColumn( - 'order', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - @override - List get $columns => [ - id, - name, - description, - createdAt, - updatedAt, - thumbnailAssetId, - isActivityEnabled, - order, - ]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'remote_album_entity'; - @override - Set get $primaryKey => {id}; - @override - RemoteAlbumEntityData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return RemoteAlbumEntityData( - id: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}id'], - )!, - name: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}name'], - )!, - description: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}description'], - )!, - createdAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}created_at'], - )!, - updatedAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}updated_at'], - )!, - thumbnailAssetId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}thumbnail_asset_id'], - ), - isActivityEnabled: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}is_activity_enabled'], - )!, - order: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}order'], - )!, - ); - } - - @override - RemoteAlbumEntity createAlias(String alias) { - return RemoteAlbumEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const ['PRIMARY KEY(id)']; - @override - bool get dontWriteConstraints => true; -} - -class RemoteAlbumEntityData extends DataClass - implements Insertable { - final String id; - final String name; - final String description; - final String createdAt; - final String updatedAt; - final String? thumbnailAssetId; - final int isActivityEnabled; - final int order; - const RemoteAlbumEntityData({ - required this.id, - required this.name, - required this.description, - required this.createdAt, - required this.updatedAt, - this.thumbnailAssetId, - required this.isActivityEnabled, - required this.order, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['id'] = Variable(id); - map['name'] = Variable(name); - map['description'] = Variable(description); - map['created_at'] = Variable(createdAt); - map['updated_at'] = Variable(updatedAt); - if (!nullToAbsent || thumbnailAssetId != null) { - map['thumbnail_asset_id'] = Variable(thumbnailAssetId); - } - map['is_activity_enabled'] = Variable(isActivityEnabled); - map['order'] = Variable(order); - return map; - } - - factory RemoteAlbumEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return RemoteAlbumEntityData( - id: serializer.fromJson(json['id']), - name: serializer.fromJson(json['name']), - description: serializer.fromJson(json['description']), - createdAt: serializer.fromJson(json['createdAt']), - updatedAt: serializer.fromJson(json['updatedAt']), - thumbnailAssetId: serializer.fromJson(json['thumbnailAssetId']), - isActivityEnabled: serializer.fromJson(json['isActivityEnabled']), - order: serializer.fromJson(json['order']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'id': serializer.toJson(id), - 'name': serializer.toJson(name), - 'description': serializer.toJson(description), - 'createdAt': serializer.toJson(createdAt), - 'updatedAt': serializer.toJson(updatedAt), - 'thumbnailAssetId': serializer.toJson(thumbnailAssetId), - 'isActivityEnabled': serializer.toJson(isActivityEnabled), - 'order': serializer.toJson(order), - }; - } - - RemoteAlbumEntityData copyWith({ - String? id, - String? name, - String? description, - String? createdAt, - String? updatedAt, - Value thumbnailAssetId = const Value.absent(), - int? isActivityEnabled, - int? order, - }) => RemoteAlbumEntityData( - id: id ?? this.id, - name: name ?? this.name, - description: description ?? this.description, - createdAt: createdAt ?? this.createdAt, - updatedAt: updatedAt ?? this.updatedAt, - thumbnailAssetId: thumbnailAssetId.present - ? thumbnailAssetId.value - : this.thumbnailAssetId, - isActivityEnabled: isActivityEnabled ?? this.isActivityEnabled, - order: order ?? this.order, - ); - RemoteAlbumEntityData copyWithCompanion(RemoteAlbumEntityCompanion data) { - return RemoteAlbumEntityData( - id: data.id.present ? data.id.value : this.id, - name: data.name.present ? data.name.value : this.name, - description: data.description.present - ? data.description.value - : this.description, - createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, - updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, - thumbnailAssetId: data.thumbnailAssetId.present - ? data.thumbnailAssetId.value - : this.thumbnailAssetId, - isActivityEnabled: data.isActivityEnabled.present - ? data.isActivityEnabled.value - : this.isActivityEnabled, - order: data.order.present ? data.order.value : this.order, - ); - } - - @override - String toString() { - return (StringBuffer('RemoteAlbumEntityData(') - ..write('id: $id, ') - ..write('name: $name, ') - ..write('description: $description, ') - ..write('createdAt: $createdAt, ') - ..write('updatedAt: $updatedAt, ') - ..write('thumbnailAssetId: $thumbnailAssetId, ') - ..write('isActivityEnabled: $isActivityEnabled, ') - ..write('order: $order') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash( - id, - name, - description, - createdAt, - updatedAt, - thumbnailAssetId, - isActivityEnabled, - order, - ); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is RemoteAlbumEntityData && - other.id == this.id && - other.name == this.name && - other.description == this.description && - other.createdAt == this.createdAt && - other.updatedAt == this.updatedAt && - other.thumbnailAssetId == this.thumbnailAssetId && - other.isActivityEnabled == this.isActivityEnabled && - other.order == this.order); -} - -class RemoteAlbumEntityCompanion - extends UpdateCompanion { - final Value id; - final Value name; - final Value description; - final Value createdAt; - final Value updatedAt; - final Value thumbnailAssetId; - final Value isActivityEnabled; - final Value order; - const RemoteAlbumEntityCompanion({ - this.id = const Value.absent(), - this.name = const Value.absent(), - this.description = const Value.absent(), - this.createdAt = const Value.absent(), - this.updatedAt = const Value.absent(), - this.thumbnailAssetId = const Value.absent(), - this.isActivityEnabled = const Value.absent(), - this.order = const Value.absent(), - }); - RemoteAlbumEntityCompanion.insert({ - required String id, - required String name, - this.description = const Value.absent(), - this.createdAt = const Value.absent(), - this.updatedAt = const Value.absent(), - this.thumbnailAssetId = const Value.absent(), - this.isActivityEnabled = const Value.absent(), - required int order, - }) : id = Value(id), - name = Value(name), - order = Value(order); - static Insertable custom({ - Expression? id, - Expression? name, - Expression? description, - Expression? createdAt, - Expression? updatedAt, - Expression? thumbnailAssetId, - Expression? isActivityEnabled, - Expression? order, - }) { - return RawValuesInsertable({ - if (id != null) 'id': id, - if (name != null) 'name': name, - if (description != null) 'description': description, - if (createdAt != null) 'created_at': createdAt, - if (updatedAt != null) 'updated_at': updatedAt, - if (thumbnailAssetId != null) 'thumbnail_asset_id': thumbnailAssetId, - if (isActivityEnabled != null) 'is_activity_enabled': isActivityEnabled, - if (order != null) 'order': order, - }); - } - - RemoteAlbumEntityCompanion copyWith({ - Value? id, - Value? name, - Value? description, - Value? createdAt, - Value? updatedAt, - Value? thumbnailAssetId, - Value? isActivityEnabled, - Value? order, - }) { - return RemoteAlbumEntityCompanion( - id: id ?? this.id, - name: name ?? this.name, - description: description ?? this.description, - createdAt: createdAt ?? this.createdAt, - updatedAt: updatedAt ?? this.updatedAt, - thumbnailAssetId: thumbnailAssetId ?? this.thumbnailAssetId, - isActivityEnabled: isActivityEnabled ?? this.isActivityEnabled, - order: order ?? this.order, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (id.present) { - map['id'] = Variable(id.value); - } - if (name.present) { - map['name'] = Variable(name.value); - } - if (description.present) { - map['description'] = Variable(description.value); - } - if (createdAt.present) { - map['created_at'] = Variable(createdAt.value); - } - if (updatedAt.present) { - map['updated_at'] = Variable(updatedAt.value); - } - if (thumbnailAssetId.present) { - map['thumbnail_asset_id'] = Variable(thumbnailAssetId.value); - } - if (isActivityEnabled.present) { - map['is_activity_enabled'] = Variable(isActivityEnabled.value); - } - if (order.present) { - map['order'] = Variable(order.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('RemoteAlbumEntityCompanion(') - ..write('id: $id, ') - ..write('name: $name, ') - ..write('description: $description, ') - ..write('createdAt: $createdAt, ') - ..write('updatedAt: $updatedAt, ') - ..write('thumbnailAssetId: $thumbnailAssetId, ') - ..write('isActivityEnabled: $isActivityEnabled, ') - ..write('order: $order') - ..write(')')) - .toString(); - } -} - -class LocalAlbumEntity extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - LocalAlbumEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn id = GeneratedColumn( - 'id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn name = GeneratedColumn( - 'name', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn updatedAt = GeneratedColumn( - 'updated_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', - defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), - ); - late final GeneratedColumn backupSelection = GeneratedColumn( - 'backup_selection', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn isIosSharedAlbum = GeneratedColumn( - 'is_ios_shared_album', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: - 'NOT NULL DEFAULT 0 CHECK (is_ios_shared_album IN (0, 1))', - defaultValue: const CustomExpression('0'), - ); - late final GeneratedColumn linkedRemoteAlbumId = - GeneratedColumn( - 'linked_remote_album_id', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: - 'NULL REFERENCES remote_album_entity(id)ON DELETE SET NULL', - ); - late final GeneratedColumn marker = GeneratedColumn( - 'marker', - aliasedName, - true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NULL CHECK (marker IN (0, 1))', - ); - @override - List get $columns => [ - id, - name, - updatedAt, - backupSelection, - isIosSharedAlbum, - linkedRemoteAlbumId, - marker, - ]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'local_album_entity'; - @override - Set get $primaryKey => {id}; - @override - LocalAlbumEntityData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return LocalAlbumEntityData( - id: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}id'], - )!, - name: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}name'], - )!, - updatedAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}updated_at'], - )!, - backupSelection: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}backup_selection'], - )!, - isIosSharedAlbum: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}is_ios_shared_album'], - )!, - linkedRemoteAlbumId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}linked_remote_album_id'], - ), - marker: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}marker'], - ), - ); - } - - @override - LocalAlbumEntity createAlias(String alias) { - return LocalAlbumEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const ['PRIMARY KEY(id)']; - @override - bool get dontWriteConstraints => true; -} - -class LocalAlbumEntityData extends DataClass - implements Insertable { - final String id; - final String name; - final String updatedAt; - final int backupSelection; - final int isIosSharedAlbum; - final String? linkedRemoteAlbumId; - final int? marker; - const LocalAlbumEntityData({ - required this.id, - required this.name, - required this.updatedAt, - required this.backupSelection, - required this.isIosSharedAlbum, - this.linkedRemoteAlbumId, - this.marker, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['id'] = Variable(id); - map['name'] = Variable(name); - map['updated_at'] = Variable(updatedAt); - map['backup_selection'] = Variable(backupSelection); - map['is_ios_shared_album'] = Variable(isIosSharedAlbum); - if (!nullToAbsent || linkedRemoteAlbumId != null) { - map['linked_remote_album_id'] = Variable(linkedRemoteAlbumId); - } - if (!nullToAbsent || marker != null) { - map['marker'] = Variable(marker); - } - return map; - } - - factory LocalAlbumEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return LocalAlbumEntityData( - id: serializer.fromJson(json['id']), - name: serializer.fromJson(json['name']), - updatedAt: serializer.fromJson(json['updatedAt']), - backupSelection: serializer.fromJson(json['backupSelection']), - isIosSharedAlbum: serializer.fromJson(json['isIosSharedAlbum']), - linkedRemoteAlbumId: serializer.fromJson( - json['linkedRemoteAlbumId'], - ), - marker: serializer.fromJson(json['marker']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'id': serializer.toJson(id), - 'name': serializer.toJson(name), - 'updatedAt': serializer.toJson(updatedAt), - 'backupSelection': serializer.toJson(backupSelection), - 'isIosSharedAlbum': serializer.toJson(isIosSharedAlbum), - 'linkedRemoteAlbumId': serializer.toJson(linkedRemoteAlbumId), - 'marker': serializer.toJson(marker), - }; - } - - LocalAlbumEntityData copyWith({ - String? id, - String? name, - String? updatedAt, - int? backupSelection, - int? isIosSharedAlbum, - Value linkedRemoteAlbumId = const Value.absent(), - Value marker = const Value.absent(), - }) => LocalAlbumEntityData( - id: id ?? this.id, - name: name ?? this.name, - updatedAt: updatedAt ?? this.updatedAt, - backupSelection: backupSelection ?? this.backupSelection, - isIosSharedAlbum: isIosSharedAlbum ?? this.isIosSharedAlbum, - linkedRemoteAlbumId: linkedRemoteAlbumId.present - ? linkedRemoteAlbumId.value - : this.linkedRemoteAlbumId, - marker: marker.present ? marker.value : this.marker, - ); - LocalAlbumEntityData copyWithCompanion(LocalAlbumEntityCompanion data) { - return LocalAlbumEntityData( - id: data.id.present ? data.id.value : this.id, - name: data.name.present ? data.name.value : this.name, - updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, - backupSelection: data.backupSelection.present - ? data.backupSelection.value - : this.backupSelection, - isIosSharedAlbum: data.isIosSharedAlbum.present - ? data.isIosSharedAlbum.value - : this.isIosSharedAlbum, - linkedRemoteAlbumId: data.linkedRemoteAlbumId.present - ? data.linkedRemoteAlbumId.value - : this.linkedRemoteAlbumId, - marker: data.marker.present ? data.marker.value : this.marker, - ); - } - - @override - String toString() { - return (StringBuffer('LocalAlbumEntityData(') - ..write('id: $id, ') - ..write('name: $name, ') - ..write('updatedAt: $updatedAt, ') - ..write('backupSelection: $backupSelection, ') - ..write('isIosSharedAlbum: $isIosSharedAlbum, ') - ..write('linkedRemoteAlbumId: $linkedRemoteAlbumId, ') - ..write('marker: $marker') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash( - id, - name, - updatedAt, - backupSelection, - isIosSharedAlbum, - linkedRemoteAlbumId, - marker, - ); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is LocalAlbumEntityData && - other.id == this.id && - other.name == this.name && - other.updatedAt == this.updatedAt && - other.backupSelection == this.backupSelection && - other.isIosSharedAlbum == this.isIosSharedAlbum && - other.linkedRemoteAlbumId == this.linkedRemoteAlbumId && - other.marker == this.marker); -} - -class LocalAlbumEntityCompanion extends UpdateCompanion { - final Value id; - final Value name; - final Value updatedAt; - final Value backupSelection; - final Value isIosSharedAlbum; - final Value linkedRemoteAlbumId; - final Value marker; - const LocalAlbumEntityCompanion({ - this.id = const Value.absent(), - this.name = const Value.absent(), - this.updatedAt = const Value.absent(), - this.backupSelection = const Value.absent(), - this.isIosSharedAlbum = const Value.absent(), - this.linkedRemoteAlbumId = const Value.absent(), - this.marker = const Value.absent(), - }); - LocalAlbumEntityCompanion.insert({ - required String id, - required String name, - this.updatedAt = const Value.absent(), - required int backupSelection, - this.isIosSharedAlbum = const Value.absent(), - this.linkedRemoteAlbumId = const Value.absent(), - this.marker = const Value.absent(), - }) : id = Value(id), - name = Value(name), - backupSelection = Value(backupSelection); - static Insertable custom({ - Expression? id, - Expression? name, - Expression? updatedAt, - Expression? backupSelection, - Expression? isIosSharedAlbum, - Expression? linkedRemoteAlbumId, - Expression? marker, - }) { - return RawValuesInsertable({ - if (id != null) 'id': id, - if (name != null) 'name': name, - if (updatedAt != null) 'updated_at': updatedAt, - if (backupSelection != null) 'backup_selection': backupSelection, - if (isIosSharedAlbum != null) 'is_ios_shared_album': isIosSharedAlbum, - if (linkedRemoteAlbumId != null) - 'linked_remote_album_id': linkedRemoteAlbumId, - if (marker != null) 'marker': marker, - }); - } - - LocalAlbumEntityCompanion copyWith({ - Value? id, - Value? name, - Value? updatedAt, - Value? backupSelection, - Value? isIosSharedAlbum, - Value? linkedRemoteAlbumId, - Value? marker, - }) { - return LocalAlbumEntityCompanion( - id: id ?? this.id, - name: name ?? this.name, - updatedAt: updatedAt ?? this.updatedAt, - backupSelection: backupSelection ?? this.backupSelection, - isIosSharedAlbum: isIosSharedAlbum ?? this.isIosSharedAlbum, - linkedRemoteAlbumId: linkedRemoteAlbumId ?? this.linkedRemoteAlbumId, - marker: marker ?? this.marker, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (id.present) { - map['id'] = Variable(id.value); - } - if (name.present) { - map['name'] = Variable(name.value); - } - if (updatedAt.present) { - map['updated_at'] = Variable(updatedAt.value); - } - if (backupSelection.present) { - map['backup_selection'] = Variable(backupSelection.value); - } - if (isIosSharedAlbum.present) { - map['is_ios_shared_album'] = Variable(isIosSharedAlbum.value); - } - if (linkedRemoteAlbumId.present) { - map['linked_remote_album_id'] = Variable( - linkedRemoteAlbumId.value, - ); - } - if (marker.present) { - map['marker'] = Variable(marker.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('LocalAlbumEntityCompanion(') - ..write('id: $id, ') - ..write('name: $name, ') - ..write('updatedAt: $updatedAt, ') - ..write('backupSelection: $backupSelection, ') - ..write('isIosSharedAlbum: $isIosSharedAlbum, ') - ..write('linkedRemoteAlbumId: $linkedRemoteAlbumId, ') - ..write('marker: $marker') - ..write(')')) - .toString(); - } -} - -class LocalAlbumAssetEntity extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - LocalAlbumAssetEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn assetId = GeneratedColumn( - 'asset_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: - 'NOT NULL REFERENCES local_asset_entity(id)ON DELETE CASCADE', - ); - late final GeneratedColumn albumId = GeneratedColumn( - 'album_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: - 'NOT NULL REFERENCES local_album_entity(id)ON DELETE CASCADE', - ); - late final GeneratedColumn marker = GeneratedColumn( - 'marker', - aliasedName, - true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NULL CHECK (marker IN (0, 1))', - ); - @override - List get $columns => [assetId, albumId, marker]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'local_album_asset_entity'; - @override - Set get $primaryKey => {assetId, albumId}; - @override - LocalAlbumAssetEntityData map( - Map data, { - String? tablePrefix, - }) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return LocalAlbumAssetEntityData( - assetId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}asset_id'], - )!, - albumId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}album_id'], - )!, - marker: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}marker'], - ), - ); - } - - @override - LocalAlbumAssetEntity createAlias(String alias) { - return LocalAlbumAssetEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const [ - 'PRIMARY KEY(asset_id, album_id)', - ]; - @override - bool get dontWriteConstraints => true; -} - -class LocalAlbumAssetEntityData extends DataClass - implements Insertable { - final String assetId; - final String albumId; - final int? marker; - const LocalAlbumAssetEntityData({ - required this.assetId, - required this.albumId, - this.marker, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['asset_id'] = Variable(assetId); - map['album_id'] = Variable(albumId); - if (!nullToAbsent || marker != null) { - map['marker'] = Variable(marker); - } - return map; - } - - factory LocalAlbumAssetEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return LocalAlbumAssetEntityData( - assetId: serializer.fromJson(json['assetId']), - albumId: serializer.fromJson(json['albumId']), - marker: serializer.fromJson(json['marker']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'assetId': serializer.toJson(assetId), - 'albumId': serializer.toJson(albumId), - 'marker': serializer.toJson(marker), - }; - } - - LocalAlbumAssetEntityData copyWith({ - String? assetId, - String? albumId, - Value marker = const Value.absent(), - }) => LocalAlbumAssetEntityData( - assetId: assetId ?? this.assetId, - albumId: albumId ?? this.albumId, - marker: marker.present ? marker.value : this.marker, - ); - LocalAlbumAssetEntityData copyWithCompanion( - LocalAlbumAssetEntityCompanion data, - ) { - return LocalAlbumAssetEntityData( - assetId: data.assetId.present ? data.assetId.value : this.assetId, - albumId: data.albumId.present ? data.albumId.value : this.albumId, - marker: data.marker.present ? data.marker.value : this.marker, - ); - } - - @override - String toString() { - return (StringBuffer('LocalAlbumAssetEntityData(') - ..write('assetId: $assetId, ') - ..write('albumId: $albumId, ') - ..write('marker: $marker') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash(assetId, albumId, marker); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is LocalAlbumAssetEntityData && - other.assetId == this.assetId && - other.albumId == this.albumId && - other.marker == this.marker); -} - -class LocalAlbumAssetEntityCompanion - extends UpdateCompanion { - final Value assetId; - final Value albumId; - final Value marker; - const LocalAlbumAssetEntityCompanion({ - this.assetId = const Value.absent(), - this.albumId = const Value.absent(), - this.marker = const Value.absent(), - }); - LocalAlbumAssetEntityCompanion.insert({ - required String assetId, - required String albumId, - this.marker = const Value.absent(), - }) : assetId = Value(assetId), - albumId = Value(albumId); - static Insertable custom({ - Expression? assetId, - Expression? albumId, - Expression? marker, - }) { - return RawValuesInsertable({ - if (assetId != null) 'asset_id': assetId, - if (albumId != null) 'album_id': albumId, - if (marker != null) 'marker': marker, - }); - } - - LocalAlbumAssetEntityCompanion copyWith({ - Value? assetId, - Value? albumId, - Value? marker, - }) { - return LocalAlbumAssetEntityCompanion( - assetId: assetId ?? this.assetId, - albumId: albumId ?? this.albumId, - marker: marker ?? this.marker, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (assetId.present) { - map['asset_id'] = Variable(assetId.value); - } - if (albumId.present) { - map['album_id'] = Variable(albumId.value); - } - if (marker.present) { - map['marker'] = Variable(marker.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('LocalAlbumAssetEntityCompanion(') - ..write('assetId: $assetId, ') - ..write('albumId: $albumId, ') - ..write('marker: $marker') - ..write(')')) - .toString(); - } -} - -class AuthUserEntity extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - AuthUserEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn id = GeneratedColumn( - 'id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn name = GeneratedColumn( - 'name', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn email = GeneratedColumn( - 'email', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn isAdmin = GeneratedColumn( - 'is_admin', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT 0 CHECK (is_admin IN (0, 1))', - defaultValue: const CustomExpression('0'), - ); - late final GeneratedColumn hasProfileImage = GeneratedColumn( - 'has_profile_image', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: - 'NOT NULL DEFAULT 0 CHECK (has_profile_image IN (0, 1))', - defaultValue: const CustomExpression('0'), - ); - late final GeneratedColumn profileChangedAt = GeneratedColumn( - 'profile_changed_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', - defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), - ); - late final GeneratedColumn avatarColor = GeneratedColumn( - 'avatar_color', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn quotaSizeInBytes = GeneratedColumn( - 'quota_size_in_bytes', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT 0', - defaultValue: const CustomExpression('0'), - ); - late final GeneratedColumn quotaUsageInBytes = GeneratedColumn( - 'quota_usage_in_bytes', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT 0', - defaultValue: const CustomExpression('0'), - ); - late final GeneratedColumn pinCode = GeneratedColumn( - 'pin_code', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - @override - List get $columns => [ - id, - name, - email, - isAdmin, - hasProfileImage, - profileChangedAt, - avatarColor, - quotaSizeInBytes, - quotaUsageInBytes, - pinCode, - ]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'auth_user_entity'; - @override - Set get $primaryKey => {id}; - @override - AuthUserEntityData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return AuthUserEntityData( - id: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}id'], - )!, - name: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}name'], - )!, - email: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}email'], - )!, - isAdmin: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}is_admin'], - )!, - hasProfileImage: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}has_profile_image'], - )!, - profileChangedAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}profile_changed_at'], - )!, - avatarColor: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}avatar_color'], - )!, - quotaSizeInBytes: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}quota_size_in_bytes'], - )!, - quotaUsageInBytes: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}quota_usage_in_bytes'], - )!, - pinCode: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}pin_code'], - ), - ); - } - - @override - AuthUserEntity createAlias(String alias) { - return AuthUserEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const ['PRIMARY KEY(id)']; - @override - bool get dontWriteConstraints => true; -} - -class AuthUserEntityData extends DataClass - implements Insertable { - final String id; - final String name; - final String email; - final int isAdmin; - final int hasProfileImage; - final String profileChangedAt; - final int avatarColor; - final int quotaSizeInBytes; - final int quotaUsageInBytes; - final String? pinCode; - const AuthUserEntityData({ - required this.id, - required this.name, - required this.email, - required this.isAdmin, - required this.hasProfileImage, - required this.profileChangedAt, - required this.avatarColor, - required this.quotaSizeInBytes, - required this.quotaUsageInBytes, - this.pinCode, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['id'] = Variable(id); - map['name'] = Variable(name); - map['email'] = Variable(email); - map['is_admin'] = Variable(isAdmin); - map['has_profile_image'] = Variable(hasProfileImage); - map['profile_changed_at'] = Variable(profileChangedAt); - map['avatar_color'] = Variable(avatarColor); - map['quota_size_in_bytes'] = Variable(quotaSizeInBytes); - map['quota_usage_in_bytes'] = Variable(quotaUsageInBytes); - if (!nullToAbsent || pinCode != null) { - map['pin_code'] = Variable(pinCode); - } - return map; - } - - factory AuthUserEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return AuthUserEntityData( - id: serializer.fromJson(json['id']), - name: serializer.fromJson(json['name']), - email: serializer.fromJson(json['email']), - isAdmin: serializer.fromJson(json['isAdmin']), - hasProfileImage: serializer.fromJson(json['hasProfileImage']), - profileChangedAt: serializer.fromJson(json['profileChangedAt']), - avatarColor: serializer.fromJson(json['avatarColor']), - quotaSizeInBytes: serializer.fromJson(json['quotaSizeInBytes']), - quotaUsageInBytes: serializer.fromJson(json['quotaUsageInBytes']), - pinCode: serializer.fromJson(json['pinCode']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'id': serializer.toJson(id), - 'name': serializer.toJson(name), - 'email': serializer.toJson(email), - 'isAdmin': serializer.toJson(isAdmin), - 'hasProfileImage': serializer.toJson(hasProfileImage), - 'profileChangedAt': serializer.toJson(profileChangedAt), - 'avatarColor': serializer.toJson(avatarColor), - 'quotaSizeInBytes': serializer.toJson(quotaSizeInBytes), - 'quotaUsageInBytes': serializer.toJson(quotaUsageInBytes), - 'pinCode': serializer.toJson(pinCode), - }; - } - - AuthUserEntityData copyWith({ - String? id, - String? name, - String? email, - int? isAdmin, - int? hasProfileImage, - String? profileChangedAt, - int? avatarColor, - int? quotaSizeInBytes, - int? quotaUsageInBytes, - Value pinCode = const Value.absent(), - }) => AuthUserEntityData( - id: id ?? this.id, - name: name ?? this.name, - email: email ?? this.email, - isAdmin: isAdmin ?? this.isAdmin, - hasProfileImage: hasProfileImage ?? this.hasProfileImage, - profileChangedAt: profileChangedAt ?? this.profileChangedAt, - avatarColor: avatarColor ?? this.avatarColor, - quotaSizeInBytes: quotaSizeInBytes ?? this.quotaSizeInBytes, - quotaUsageInBytes: quotaUsageInBytes ?? this.quotaUsageInBytes, - pinCode: pinCode.present ? pinCode.value : this.pinCode, - ); - AuthUserEntityData copyWithCompanion(AuthUserEntityCompanion data) { - return AuthUserEntityData( - id: data.id.present ? data.id.value : this.id, - name: data.name.present ? data.name.value : this.name, - email: data.email.present ? data.email.value : this.email, - isAdmin: data.isAdmin.present ? data.isAdmin.value : this.isAdmin, - hasProfileImage: data.hasProfileImage.present - ? data.hasProfileImage.value - : this.hasProfileImage, - profileChangedAt: data.profileChangedAt.present - ? data.profileChangedAt.value - : this.profileChangedAt, - avatarColor: data.avatarColor.present - ? data.avatarColor.value - : this.avatarColor, - quotaSizeInBytes: data.quotaSizeInBytes.present - ? data.quotaSizeInBytes.value - : this.quotaSizeInBytes, - quotaUsageInBytes: data.quotaUsageInBytes.present - ? data.quotaUsageInBytes.value - : this.quotaUsageInBytes, - pinCode: data.pinCode.present ? data.pinCode.value : this.pinCode, - ); - } - - @override - String toString() { - return (StringBuffer('AuthUserEntityData(') - ..write('id: $id, ') - ..write('name: $name, ') - ..write('email: $email, ') - ..write('isAdmin: $isAdmin, ') - ..write('hasProfileImage: $hasProfileImage, ') - ..write('profileChangedAt: $profileChangedAt, ') - ..write('avatarColor: $avatarColor, ') - ..write('quotaSizeInBytes: $quotaSizeInBytes, ') - ..write('quotaUsageInBytes: $quotaUsageInBytes, ') - ..write('pinCode: $pinCode') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash( - id, - name, - email, - isAdmin, - hasProfileImage, - profileChangedAt, - avatarColor, - quotaSizeInBytes, - quotaUsageInBytes, - pinCode, - ); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is AuthUserEntityData && - other.id == this.id && - other.name == this.name && - other.email == this.email && - other.isAdmin == this.isAdmin && - other.hasProfileImage == this.hasProfileImage && - other.profileChangedAt == this.profileChangedAt && - other.avatarColor == this.avatarColor && - other.quotaSizeInBytes == this.quotaSizeInBytes && - other.quotaUsageInBytes == this.quotaUsageInBytes && - other.pinCode == this.pinCode); -} - -class AuthUserEntityCompanion extends UpdateCompanion { - final Value id; - final Value name; - final Value email; - final Value isAdmin; - final Value hasProfileImage; - final Value profileChangedAt; - final Value avatarColor; - final Value quotaSizeInBytes; - final Value quotaUsageInBytes; - final Value pinCode; - const AuthUserEntityCompanion({ - this.id = const Value.absent(), - this.name = const Value.absent(), - this.email = const Value.absent(), - this.isAdmin = const Value.absent(), - this.hasProfileImage = const Value.absent(), - this.profileChangedAt = const Value.absent(), - this.avatarColor = const Value.absent(), - this.quotaSizeInBytes = const Value.absent(), - this.quotaUsageInBytes = const Value.absent(), - this.pinCode = const Value.absent(), - }); - AuthUserEntityCompanion.insert({ - required String id, - required String name, - required String email, - this.isAdmin = const Value.absent(), - this.hasProfileImage = const Value.absent(), - this.profileChangedAt = const Value.absent(), - required int avatarColor, - this.quotaSizeInBytes = const Value.absent(), - this.quotaUsageInBytes = const Value.absent(), - this.pinCode = const Value.absent(), - }) : id = Value(id), - name = Value(name), - email = Value(email), - avatarColor = Value(avatarColor); - static Insertable custom({ - Expression? id, - Expression? name, - Expression? email, - Expression? isAdmin, - Expression? hasProfileImage, - Expression? profileChangedAt, - Expression? avatarColor, - Expression? quotaSizeInBytes, - Expression? quotaUsageInBytes, - Expression? pinCode, - }) { - return RawValuesInsertable({ - if (id != null) 'id': id, - if (name != null) 'name': name, - if (email != null) 'email': email, - if (isAdmin != null) 'is_admin': isAdmin, - if (hasProfileImage != null) 'has_profile_image': hasProfileImage, - if (profileChangedAt != null) 'profile_changed_at': profileChangedAt, - if (avatarColor != null) 'avatar_color': avatarColor, - if (quotaSizeInBytes != null) 'quota_size_in_bytes': quotaSizeInBytes, - if (quotaUsageInBytes != null) 'quota_usage_in_bytes': quotaUsageInBytes, - if (pinCode != null) 'pin_code': pinCode, - }); - } - - AuthUserEntityCompanion copyWith({ - Value? id, - Value? name, - Value? email, - Value? isAdmin, - Value? hasProfileImage, - Value? profileChangedAt, - Value? avatarColor, - Value? quotaSizeInBytes, - Value? quotaUsageInBytes, - Value? pinCode, - }) { - return AuthUserEntityCompanion( - id: id ?? this.id, - name: name ?? this.name, - email: email ?? this.email, - isAdmin: isAdmin ?? this.isAdmin, - hasProfileImage: hasProfileImage ?? this.hasProfileImage, - profileChangedAt: profileChangedAt ?? this.profileChangedAt, - avatarColor: avatarColor ?? this.avatarColor, - quotaSizeInBytes: quotaSizeInBytes ?? this.quotaSizeInBytes, - quotaUsageInBytes: quotaUsageInBytes ?? this.quotaUsageInBytes, - pinCode: pinCode ?? this.pinCode, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (id.present) { - map['id'] = Variable(id.value); - } - if (name.present) { - map['name'] = Variable(name.value); - } - if (email.present) { - map['email'] = Variable(email.value); - } - if (isAdmin.present) { - map['is_admin'] = Variable(isAdmin.value); - } - if (hasProfileImage.present) { - map['has_profile_image'] = Variable(hasProfileImage.value); - } - if (profileChangedAt.present) { - map['profile_changed_at'] = Variable(profileChangedAt.value); - } - if (avatarColor.present) { - map['avatar_color'] = Variable(avatarColor.value); - } - if (quotaSizeInBytes.present) { - map['quota_size_in_bytes'] = Variable(quotaSizeInBytes.value); - } - if (quotaUsageInBytes.present) { - map['quota_usage_in_bytes'] = Variable(quotaUsageInBytes.value); - } - if (pinCode.present) { - map['pin_code'] = Variable(pinCode.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('AuthUserEntityCompanion(') - ..write('id: $id, ') - ..write('name: $name, ') - ..write('email: $email, ') - ..write('isAdmin: $isAdmin, ') - ..write('hasProfileImage: $hasProfileImage, ') - ..write('profileChangedAt: $profileChangedAt, ') - ..write('avatarColor: $avatarColor, ') - ..write('quotaSizeInBytes: $quotaSizeInBytes, ') - ..write('quotaUsageInBytes: $quotaUsageInBytes, ') - ..write('pinCode: $pinCode') - ..write(')')) - .toString(); - } -} - -class UserMetadataEntity extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - UserMetadataEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn userId = GeneratedColumn( - 'user_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL REFERENCES user_entity(id)ON DELETE CASCADE', - ); - late final GeneratedColumn key = GeneratedColumn( - 'key', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn value = - GeneratedColumn( - 'value', - aliasedName, - false, - type: DriftSqlType.blob, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - @override - List get $columns => [userId, key, value]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'user_metadata_entity'; - @override - Set get $primaryKey => {userId, key}; - @override - UserMetadataEntityData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return UserMetadataEntityData( - userId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}user_id'], - )!, - key: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}key'], - )!, - value: attachedDatabase.typeMapping.read( - DriftSqlType.blob, - data['${effectivePrefix}value'], - )!, - ); - } - - @override - UserMetadataEntity createAlias(String alias) { - return UserMetadataEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const ['PRIMARY KEY(user_id, "key")']; - @override - bool get dontWriteConstraints => true; -} - -class UserMetadataEntityData extends DataClass - implements Insertable { - final String userId; - final int key; - final i2.Uint8List value; - const UserMetadataEntityData({ - required this.userId, - required this.key, - required this.value, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['user_id'] = Variable(userId); - map['key'] = Variable(key); - map['value'] = Variable(value); - return map; - } - - factory UserMetadataEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return UserMetadataEntityData( - userId: serializer.fromJson(json['userId']), - key: serializer.fromJson(json['key']), - value: serializer.fromJson(json['value']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'userId': serializer.toJson(userId), - 'key': serializer.toJson(key), - 'value': serializer.toJson(value), - }; - } - - UserMetadataEntityData copyWith({ - String? userId, - int? key, - i2.Uint8List? value, - }) => UserMetadataEntityData( - userId: userId ?? this.userId, - key: key ?? this.key, - value: value ?? this.value, - ); - UserMetadataEntityData copyWithCompanion(UserMetadataEntityCompanion data) { - return UserMetadataEntityData( - userId: data.userId.present ? data.userId.value : this.userId, - key: data.key.present ? data.key.value : this.key, - value: data.value.present ? data.value.value : this.value, - ); - } - - @override - String toString() { - return (StringBuffer('UserMetadataEntityData(') - ..write('userId: $userId, ') - ..write('key: $key, ') - ..write('value: $value') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash(userId, key, $driftBlobEquality.hash(value)); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is UserMetadataEntityData && - other.userId == this.userId && - other.key == this.key && - $driftBlobEquality.equals(other.value, this.value)); -} - -class UserMetadataEntityCompanion - extends UpdateCompanion { - final Value userId; - final Value key; - final Value value; - const UserMetadataEntityCompanion({ - this.userId = const Value.absent(), - this.key = const Value.absent(), - this.value = const Value.absent(), - }); - UserMetadataEntityCompanion.insert({ - required String userId, - required int key, - required i2.Uint8List value, - }) : userId = Value(userId), - key = Value(key), - value = Value(value); - static Insertable custom({ - Expression? userId, - Expression? key, - Expression? value, - }) { - return RawValuesInsertable({ - if (userId != null) 'user_id': userId, - if (key != null) 'key': key, - if (value != null) 'value': value, - }); - } - - UserMetadataEntityCompanion copyWith({ - Value? userId, - Value? key, - Value? value, - }) { - return UserMetadataEntityCompanion( - userId: userId ?? this.userId, - key: key ?? this.key, - value: value ?? this.value, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (userId.present) { - map['user_id'] = Variable(userId.value); - } - if (key.present) { - map['key'] = Variable(key.value); - } - if (value.present) { - map['value'] = Variable(value.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('UserMetadataEntityCompanion(') - ..write('userId: $userId, ') - ..write('key: $key, ') - ..write('value: $value') - ..write(')')) - .toString(); - } -} - -class PartnerEntity extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - PartnerEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn sharedById = GeneratedColumn( - 'shared_by_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL REFERENCES user_entity(id)ON DELETE CASCADE', - ); - late final GeneratedColumn sharedWithId = GeneratedColumn( - 'shared_with_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL REFERENCES user_entity(id)ON DELETE CASCADE', - ); - late final GeneratedColumn inTimeline = GeneratedColumn( - 'in_timeline', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT 0 CHECK (in_timeline IN (0, 1))', - defaultValue: const CustomExpression('0'), - ); - @override - List get $columns => [sharedById, sharedWithId, inTimeline]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'partner_entity'; - @override - Set get $primaryKey => {sharedById, sharedWithId}; - @override - PartnerEntityData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return PartnerEntityData( - sharedById: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}shared_by_id'], - )!, - sharedWithId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}shared_with_id'], - )!, - inTimeline: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}in_timeline'], - )!, - ); - } - - @override - PartnerEntity createAlias(String alias) { - return PartnerEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const [ - 'PRIMARY KEY(shared_by_id, shared_with_id)', - ]; - @override - bool get dontWriteConstraints => true; -} - -class PartnerEntityData extends DataClass - implements Insertable { - final String sharedById; - final String sharedWithId; - final int inTimeline; - const PartnerEntityData({ - required this.sharedById, - required this.sharedWithId, - required this.inTimeline, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['shared_by_id'] = Variable(sharedById); - map['shared_with_id'] = Variable(sharedWithId); - map['in_timeline'] = Variable(inTimeline); - return map; - } - - factory PartnerEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return PartnerEntityData( - sharedById: serializer.fromJson(json['sharedById']), - sharedWithId: serializer.fromJson(json['sharedWithId']), - inTimeline: serializer.fromJson(json['inTimeline']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'sharedById': serializer.toJson(sharedById), - 'sharedWithId': serializer.toJson(sharedWithId), - 'inTimeline': serializer.toJson(inTimeline), - }; - } - - PartnerEntityData copyWith({ - String? sharedById, - String? sharedWithId, - int? inTimeline, - }) => PartnerEntityData( - sharedById: sharedById ?? this.sharedById, - sharedWithId: sharedWithId ?? this.sharedWithId, - inTimeline: inTimeline ?? this.inTimeline, - ); - PartnerEntityData copyWithCompanion(PartnerEntityCompanion data) { - return PartnerEntityData( - sharedById: data.sharedById.present - ? data.sharedById.value - : this.sharedById, - sharedWithId: data.sharedWithId.present - ? data.sharedWithId.value - : this.sharedWithId, - inTimeline: data.inTimeline.present - ? data.inTimeline.value - : this.inTimeline, - ); - } - - @override - String toString() { - return (StringBuffer('PartnerEntityData(') - ..write('sharedById: $sharedById, ') - ..write('sharedWithId: $sharedWithId, ') - ..write('inTimeline: $inTimeline') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash(sharedById, sharedWithId, inTimeline); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is PartnerEntityData && - other.sharedById == this.sharedById && - other.sharedWithId == this.sharedWithId && - other.inTimeline == this.inTimeline); -} - -class PartnerEntityCompanion extends UpdateCompanion { - final Value sharedById; - final Value sharedWithId; - final Value inTimeline; - const PartnerEntityCompanion({ - this.sharedById = const Value.absent(), - this.sharedWithId = const Value.absent(), - this.inTimeline = const Value.absent(), - }); - PartnerEntityCompanion.insert({ - required String sharedById, - required String sharedWithId, - this.inTimeline = const Value.absent(), - }) : sharedById = Value(sharedById), - sharedWithId = Value(sharedWithId); - static Insertable custom({ - Expression? sharedById, - Expression? sharedWithId, - Expression? inTimeline, - }) { - return RawValuesInsertable({ - if (sharedById != null) 'shared_by_id': sharedById, - if (sharedWithId != null) 'shared_with_id': sharedWithId, - if (inTimeline != null) 'in_timeline': inTimeline, - }); - } - - PartnerEntityCompanion copyWith({ - Value? sharedById, - Value? sharedWithId, - Value? inTimeline, - }) { - return PartnerEntityCompanion( - sharedById: sharedById ?? this.sharedById, - sharedWithId: sharedWithId ?? this.sharedWithId, - inTimeline: inTimeline ?? this.inTimeline, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (sharedById.present) { - map['shared_by_id'] = Variable(sharedById.value); - } - if (sharedWithId.present) { - map['shared_with_id'] = Variable(sharedWithId.value); - } - if (inTimeline.present) { - map['in_timeline'] = Variable(inTimeline.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('PartnerEntityCompanion(') - ..write('sharedById: $sharedById, ') - ..write('sharedWithId: $sharedWithId, ') - ..write('inTimeline: $inTimeline') - ..write(')')) - .toString(); - } -} - -class RemoteExifEntity extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - RemoteExifEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn assetId = GeneratedColumn( - 'asset_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: - 'NOT NULL REFERENCES remote_asset_entity(id)ON DELETE CASCADE', - ); - late final GeneratedColumn city = GeneratedColumn( - 'city', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn state = GeneratedColumn( - 'state', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn country = GeneratedColumn( - 'country', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn dateTimeOriginal = GeneratedColumn( - 'date_time_original', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn description = GeneratedColumn( - 'description', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn height = GeneratedColumn( - 'height', - aliasedName, - true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn width = GeneratedColumn( - 'width', - aliasedName, - true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn exposureTime = GeneratedColumn( - 'exposure_time', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn fNumber = GeneratedColumn( - 'f_number', - aliasedName, - true, - type: DriftSqlType.double, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn fileSize = GeneratedColumn( - 'file_size', - aliasedName, - true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn focalLength = GeneratedColumn( - 'focal_length', - aliasedName, - true, - type: DriftSqlType.double, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn latitude = GeneratedColumn( - 'latitude', - aliasedName, - true, - type: DriftSqlType.double, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn longitude = GeneratedColumn( - 'longitude', - aliasedName, - true, - type: DriftSqlType.double, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn iso = GeneratedColumn( - 'iso', - aliasedName, - true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn make = GeneratedColumn( - 'make', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn model = GeneratedColumn( - 'model', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn lens = GeneratedColumn( - 'lens', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn orientation = GeneratedColumn( - 'orientation', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn timeZone = GeneratedColumn( - 'time_zone', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn rating = GeneratedColumn( - 'rating', - aliasedName, - true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn projectionType = GeneratedColumn( - 'projection_type', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - @override - List get $columns => [ - assetId, - city, - state, - country, - dateTimeOriginal, - description, - height, - width, - exposureTime, - fNumber, - fileSize, - focalLength, - latitude, - longitude, - iso, - make, - model, - lens, - orientation, - timeZone, - rating, - projectionType, - ]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'remote_exif_entity'; - @override - Set get $primaryKey => {assetId}; - @override - RemoteExifEntityData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return RemoteExifEntityData( - assetId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}asset_id'], - )!, - city: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}city'], - ), - state: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}state'], - ), - country: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}country'], - ), - dateTimeOriginal: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}date_time_original'], - ), - description: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}description'], - ), - height: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}height'], - ), - width: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}width'], - ), - exposureTime: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}exposure_time'], - ), - fNumber: attachedDatabase.typeMapping.read( - DriftSqlType.double, - data['${effectivePrefix}f_number'], - ), - fileSize: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}file_size'], - ), - focalLength: attachedDatabase.typeMapping.read( - DriftSqlType.double, - data['${effectivePrefix}focal_length'], - ), - latitude: attachedDatabase.typeMapping.read( - DriftSqlType.double, - data['${effectivePrefix}latitude'], - ), - longitude: attachedDatabase.typeMapping.read( - DriftSqlType.double, - data['${effectivePrefix}longitude'], - ), - iso: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}iso'], - ), - make: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}make'], - ), - model: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}model'], - ), - lens: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}lens'], - ), - orientation: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}orientation'], - ), - timeZone: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}time_zone'], - ), - rating: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}rating'], - ), - projectionType: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}projection_type'], - ), - ); - } - - @override - RemoteExifEntity createAlias(String alias) { - return RemoteExifEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const ['PRIMARY KEY(asset_id)']; - @override - bool get dontWriteConstraints => true; -} - -class RemoteExifEntityData extends DataClass - implements Insertable { - final String assetId; - final String? city; - final String? state; - final String? country; - final String? dateTimeOriginal; - final String? description; - final int? height; - final int? width; - final String? exposureTime; - final double? fNumber; - final int? fileSize; - final double? focalLength; - final double? latitude; - final double? longitude; - final int? iso; - final String? make; - final String? model; - final String? lens; - final String? orientation; - final String? timeZone; - final int? rating; - final String? projectionType; - const RemoteExifEntityData({ - 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.lens, - this.orientation, - this.timeZone, - this.rating, - this.projectionType, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['asset_id'] = Variable(assetId); - if (!nullToAbsent || city != null) { - map['city'] = Variable(city); - } - if (!nullToAbsent || state != null) { - map['state'] = Variable(state); - } - if (!nullToAbsent || country != null) { - map['country'] = Variable(country); - } - if (!nullToAbsent || dateTimeOriginal != null) { - map['date_time_original'] = Variable(dateTimeOriginal); - } - if (!nullToAbsent || description != null) { - map['description'] = Variable(description); - } - if (!nullToAbsent || height != null) { - map['height'] = Variable(height); - } - if (!nullToAbsent || width != null) { - map['width'] = Variable(width); - } - if (!nullToAbsent || exposureTime != null) { - map['exposure_time'] = Variable(exposureTime); - } - if (!nullToAbsent || fNumber != null) { - map['f_number'] = Variable(fNumber); - } - if (!nullToAbsent || fileSize != null) { - map['file_size'] = Variable(fileSize); - } - if (!nullToAbsent || focalLength != null) { - map['focal_length'] = Variable(focalLength); - } - if (!nullToAbsent || latitude != null) { - map['latitude'] = Variable(latitude); - } - if (!nullToAbsent || longitude != null) { - map['longitude'] = Variable(longitude); - } - if (!nullToAbsent || iso != null) { - map['iso'] = Variable(iso); - } - if (!nullToAbsent || make != null) { - map['make'] = Variable(make); - } - if (!nullToAbsent || model != null) { - map['model'] = Variable(model); - } - if (!nullToAbsent || lens != null) { - map['lens'] = Variable(lens); - } - if (!nullToAbsent || orientation != null) { - map['orientation'] = Variable(orientation); - } - if (!nullToAbsent || timeZone != null) { - map['time_zone'] = Variable(timeZone); - } - if (!nullToAbsent || rating != null) { - map['rating'] = Variable(rating); - } - if (!nullToAbsent || projectionType != null) { - map['projection_type'] = Variable(projectionType); - } - return map; - } - - factory RemoteExifEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return RemoteExifEntityData( - 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']), - lens: serializer.fromJson(json['lens']), - orientation: serializer.fromJson(json['orientation']), - timeZone: serializer.fromJson(json['timeZone']), - rating: serializer.fromJson(json['rating']), - projectionType: serializer.fromJson(json['projectionType']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= 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), - 'lens': serializer.toJson(lens), - 'orientation': serializer.toJson(orientation), - 'timeZone': serializer.toJson(timeZone), - 'rating': serializer.toJson(rating), - 'projectionType': serializer.toJson(projectionType), - }; - } - - RemoteExifEntityData copyWith({ - String? assetId, - Value city = const Value.absent(), - Value state = const Value.absent(), - Value country = const Value.absent(), - Value dateTimeOriginal = const Value.absent(), - Value description = const Value.absent(), - Value height = const Value.absent(), - Value width = const Value.absent(), - Value exposureTime = const Value.absent(), - Value fNumber = const Value.absent(), - Value fileSize = const Value.absent(), - Value focalLength = const Value.absent(), - Value latitude = const Value.absent(), - Value longitude = const Value.absent(), - Value iso = const Value.absent(), - Value make = const Value.absent(), - Value model = const Value.absent(), - Value lens = const Value.absent(), - Value orientation = const Value.absent(), - Value timeZone = const Value.absent(), - Value rating = const Value.absent(), - Value projectionType = const Value.absent(), - }) => RemoteExifEntityData( - 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, - lens: lens.present ? lens.value : this.lens, - 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, - ); - RemoteExifEntityData copyWithCompanion(RemoteExifEntityCompanion data) { - return RemoteExifEntityData( - 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, - lens: data.lens.present ? data.lens.value : this.lens, - 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('RemoteExifEntityData(') - ..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('lens: $lens, ') - ..write('orientation: $orientation, ') - ..write('timeZone: $timeZone, ') - ..write('rating: $rating, ') - ..write('projectionType: $projectionType') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hashAll([ - assetId, - city, - state, - country, - dateTimeOriginal, - description, - height, - width, - exposureTime, - fNumber, - fileSize, - focalLength, - latitude, - longitude, - iso, - make, - model, - lens, - orientation, - timeZone, - rating, - projectionType, - ]); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is RemoteExifEntityData && - 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.lens == this.lens && - other.orientation == this.orientation && - other.timeZone == this.timeZone && - other.rating == this.rating && - other.projectionType == this.projectionType); -} - -class RemoteExifEntityCompanion extends UpdateCompanion { - final Value assetId; - final Value city; - final Value state; - final Value country; - final Value dateTimeOriginal; - final Value description; - final Value height; - final Value width; - final Value exposureTime; - final Value fNumber; - final Value fileSize; - final Value focalLength; - final Value latitude; - final Value longitude; - final Value iso; - final Value make; - final Value model; - final Value lens; - final Value orientation; - final Value timeZone; - final Value rating; - final Value projectionType; - const RemoteExifEntityCompanion({ - this.assetId = const Value.absent(), - this.city = const Value.absent(), - this.state = const Value.absent(), - this.country = const Value.absent(), - this.dateTimeOriginal = const Value.absent(), - this.description = const Value.absent(), - this.height = const Value.absent(), - this.width = const Value.absent(), - this.exposureTime = const Value.absent(), - this.fNumber = const Value.absent(), - this.fileSize = const Value.absent(), - this.focalLength = const Value.absent(), - this.latitude = const Value.absent(), - this.longitude = const Value.absent(), - this.iso = const Value.absent(), - this.make = const Value.absent(), - this.model = const Value.absent(), - this.lens = const Value.absent(), - this.orientation = const Value.absent(), - this.timeZone = const Value.absent(), - this.rating = const Value.absent(), - this.projectionType = const Value.absent(), - }); - RemoteExifEntityCompanion.insert({ - required String assetId, - this.city = const Value.absent(), - this.state = const Value.absent(), - this.country = const Value.absent(), - this.dateTimeOriginal = const Value.absent(), - this.description = const Value.absent(), - this.height = const Value.absent(), - this.width = const Value.absent(), - this.exposureTime = const Value.absent(), - this.fNumber = const Value.absent(), - this.fileSize = const Value.absent(), - this.focalLength = const Value.absent(), - this.latitude = const Value.absent(), - this.longitude = const Value.absent(), - this.iso = const Value.absent(), - this.make = const Value.absent(), - this.model = const Value.absent(), - this.lens = const Value.absent(), - this.orientation = const Value.absent(), - this.timeZone = const Value.absent(), - this.rating = const Value.absent(), - this.projectionType = const Value.absent(), - }) : assetId = Value(assetId); - static Insertable custom({ - Expression? assetId, - Expression? city, - Expression? state, - Expression? country, - Expression? dateTimeOriginal, - Expression? description, - Expression? height, - Expression? width, - Expression? exposureTime, - Expression? fNumber, - Expression? fileSize, - Expression? focalLength, - Expression? latitude, - Expression? longitude, - Expression? iso, - Expression? make, - Expression? model, - Expression? lens, - Expression? orientation, - Expression? timeZone, - Expression? rating, - Expression? projectionType, - }) { - return 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 (lens != null) 'lens': lens, - if (orientation != null) 'orientation': orientation, - if (timeZone != null) 'time_zone': timeZone, - if (rating != null) 'rating': rating, - if (projectionType != null) 'projection_type': projectionType, - }); - } - - RemoteExifEntityCompanion copyWith({ - Value? assetId, - Value? city, - Value? state, - Value? country, - Value? dateTimeOriginal, - Value? description, - Value? height, - Value? width, - Value? exposureTime, - Value? fNumber, - Value? fileSize, - Value? focalLength, - Value? latitude, - Value? longitude, - Value? iso, - Value? make, - Value? model, - Value? lens, - Value? orientation, - Value? timeZone, - Value? rating, - Value? projectionType, - }) { - return RemoteExifEntityCompanion( - 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, - lens: lens ?? this.lens, - 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'] = Variable(assetId.value); - } - if (city.present) { - map['city'] = Variable(city.value); - } - if (state.present) { - map['state'] = Variable(state.value); - } - if (country.present) { - map['country'] = Variable(country.value); - } - if (dateTimeOriginal.present) { - map['date_time_original'] = Variable(dateTimeOriginal.value); - } - if (description.present) { - map['description'] = Variable(description.value); - } - if (height.present) { - map['height'] = Variable(height.value); - } - if (width.present) { - map['width'] = Variable(width.value); - } - if (exposureTime.present) { - map['exposure_time'] = Variable(exposureTime.value); - } - if (fNumber.present) { - map['f_number'] = Variable(fNumber.value); - } - if (fileSize.present) { - map['file_size'] = Variable(fileSize.value); - } - if (focalLength.present) { - map['focal_length'] = Variable(focalLength.value); - } - if (latitude.present) { - map['latitude'] = Variable(latitude.value); - } - if (longitude.present) { - map['longitude'] = Variable(longitude.value); - } - if (iso.present) { - map['iso'] = Variable(iso.value); - } - if (make.present) { - map['make'] = Variable(make.value); - } - if (model.present) { - map['model'] = Variable(model.value); - } - if (lens.present) { - map['lens'] = Variable(lens.value); - } - if (orientation.present) { - map['orientation'] = Variable(orientation.value); - } - if (timeZone.present) { - map['time_zone'] = Variable(timeZone.value); - } - if (rating.present) { - map['rating'] = Variable(rating.value); - } - if (projectionType.present) { - map['projection_type'] = Variable(projectionType.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('RemoteExifEntityCompanion(') - ..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('lens: $lens, ') - ..write('orientation: $orientation, ') - ..write('timeZone: $timeZone, ') - ..write('rating: $rating, ') - ..write('projectionType: $projectionType') - ..write(')')) - .toString(); - } -} - -class RemoteAlbumAssetEntity extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - RemoteAlbumAssetEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn assetId = GeneratedColumn( - 'asset_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: - 'NOT NULL REFERENCES remote_asset_entity(id)ON DELETE CASCADE', - ); - late final GeneratedColumn albumId = GeneratedColumn( - 'album_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: - 'NOT NULL REFERENCES remote_album_entity(id)ON DELETE CASCADE', - ); - @override - List get $columns => [assetId, albumId]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'remote_album_asset_entity'; - @override - Set get $primaryKey => {assetId, albumId}; - @override - RemoteAlbumAssetEntityData map( - Map data, { - String? tablePrefix, - }) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return RemoteAlbumAssetEntityData( - assetId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}asset_id'], - )!, - albumId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}album_id'], - )!, - ); - } - - @override - RemoteAlbumAssetEntity createAlias(String alias) { - return RemoteAlbumAssetEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const [ - 'PRIMARY KEY(asset_id, album_id)', - ]; - @override - bool get dontWriteConstraints => true; -} - -class RemoteAlbumAssetEntityData extends DataClass - implements Insertable { - final String assetId; - final String albumId; - const RemoteAlbumAssetEntityData({ - required this.assetId, - required this.albumId, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['asset_id'] = Variable(assetId); - map['album_id'] = Variable(albumId); - return map; - } - - factory RemoteAlbumAssetEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return RemoteAlbumAssetEntityData( - assetId: serializer.fromJson(json['assetId']), - albumId: serializer.fromJson(json['albumId']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'assetId': serializer.toJson(assetId), - 'albumId': serializer.toJson(albumId), - }; - } - - RemoteAlbumAssetEntityData copyWith({String? assetId, String? albumId}) => - RemoteAlbumAssetEntityData( - assetId: assetId ?? this.assetId, - albumId: albumId ?? this.albumId, - ); - RemoteAlbumAssetEntityData copyWithCompanion( - RemoteAlbumAssetEntityCompanion data, - ) { - return RemoteAlbumAssetEntityData( - assetId: data.assetId.present ? data.assetId.value : this.assetId, - albumId: data.albumId.present ? data.albumId.value : this.albumId, - ); - } - - @override - String toString() { - return (StringBuffer('RemoteAlbumAssetEntityData(') - ..write('assetId: $assetId, ') - ..write('albumId: $albumId') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash(assetId, albumId); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is RemoteAlbumAssetEntityData && - other.assetId == this.assetId && - other.albumId == this.albumId); -} - -class RemoteAlbumAssetEntityCompanion - extends UpdateCompanion { - final Value assetId; - final Value albumId; - const RemoteAlbumAssetEntityCompanion({ - this.assetId = const Value.absent(), - this.albumId = const Value.absent(), - }); - RemoteAlbumAssetEntityCompanion.insert({ - required String assetId, - required String albumId, - }) : assetId = Value(assetId), - albumId = Value(albumId); - static Insertable custom({ - Expression? assetId, - Expression? albumId, - }) { - return RawValuesInsertable({ - if (assetId != null) 'asset_id': assetId, - if (albumId != null) 'album_id': albumId, - }); - } - - RemoteAlbumAssetEntityCompanion copyWith({ - Value? assetId, - Value? albumId, - }) { - return RemoteAlbumAssetEntityCompanion( - assetId: assetId ?? this.assetId, - albumId: albumId ?? this.albumId, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (assetId.present) { - map['asset_id'] = Variable(assetId.value); - } - if (albumId.present) { - map['album_id'] = Variable(albumId.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('RemoteAlbumAssetEntityCompanion(') - ..write('assetId: $assetId, ') - ..write('albumId: $albumId') - ..write(')')) - .toString(); - } -} - -class RemoteAlbumUserEntity extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - RemoteAlbumUserEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn albumId = GeneratedColumn( - 'album_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: - 'NOT NULL REFERENCES remote_album_entity(id)ON DELETE CASCADE', - ); - late final GeneratedColumn userId = GeneratedColumn( - 'user_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL REFERENCES user_entity(id)ON DELETE CASCADE', - ); - late final GeneratedColumn role = GeneratedColumn( - 'role', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - @override - List get $columns => [albumId, userId, role]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'remote_album_user_entity'; - @override - Set get $primaryKey => {albumId, userId}; - @override - RemoteAlbumUserEntityData map( - Map data, { - String? tablePrefix, - }) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return RemoteAlbumUserEntityData( - albumId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}album_id'], - )!, - userId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}user_id'], - )!, - role: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}role'], - )!, - ); - } - - @override - RemoteAlbumUserEntity createAlias(String alias) { - return RemoteAlbumUserEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const [ - 'PRIMARY KEY(album_id, user_id)', - ]; - @override - bool get dontWriteConstraints => true; -} - -class RemoteAlbumUserEntityData extends DataClass - implements Insertable { - final String albumId; - final String userId; - final int role; - const RemoteAlbumUserEntityData({ - required this.albumId, - required this.userId, - required this.role, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['album_id'] = Variable(albumId); - map['user_id'] = Variable(userId); - map['role'] = Variable(role); - return map; - } - - factory RemoteAlbumUserEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return RemoteAlbumUserEntityData( - albumId: serializer.fromJson(json['albumId']), - userId: serializer.fromJson(json['userId']), - role: serializer.fromJson(json['role']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'albumId': serializer.toJson(albumId), - 'userId': serializer.toJson(userId), - 'role': serializer.toJson(role), - }; - } - - RemoteAlbumUserEntityData copyWith({ - String? albumId, - String? userId, - int? role, - }) => RemoteAlbumUserEntityData( - albumId: albumId ?? this.albumId, - userId: userId ?? this.userId, - role: role ?? this.role, - ); - RemoteAlbumUserEntityData copyWithCompanion( - RemoteAlbumUserEntityCompanion data, - ) { - return RemoteAlbumUserEntityData( - albumId: data.albumId.present ? data.albumId.value : this.albumId, - userId: data.userId.present ? data.userId.value : this.userId, - role: data.role.present ? data.role.value : this.role, - ); - } - - @override - String toString() { - return (StringBuffer('RemoteAlbumUserEntityData(') - ..write('albumId: $albumId, ') - ..write('userId: $userId, ') - ..write('role: $role') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash(albumId, userId, role); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is RemoteAlbumUserEntityData && - other.albumId == this.albumId && - other.userId == this.userId && - other.role == this.role); -} - -class RemoteAlbumUserEntityCompanion - extends UpdateCompanion { - final Value albumId; - final Value userId; - final Value role; - const RemoteAlbumUserEntityCompanion({ - this.albumId = const Value.absent(), - this.userId = const Value.absent(), - this.role = const Value.absent(), - }); - RemoteAlbumUserEntityCompanion.insert({ - required String albumId, - required String userId, - required int role, - }) : albumId = Value(albumId), - userId = Value(userId), - role = Value(role); - static Insertable custom({ - Expression? albumId, - Expression? userId, - Expression? role, - }) { - return RawValuesInsertable({ - if (albumId != null) 'album_id': albumId, - if (userId != null) 'user_id': userId, - if (role != null) 'role': role, - }); - } - - RemoteAlbumUserEntityCompanion copyWith({ - Value? albumId, - Value? userId, - Value? role, - }) { - return RemoteAlbumUserEntityCompanion( - albumId: albumId ?? this.albumId, - userId: userId ?? this.userId, - role: role ?? this.role, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (albumId.present) { - map['album_id'] = Variable(albumId.value); - } - if (userId.present) { - map['user_id'] = Variable(userId.value); - } - if (role.present) { - map['role'] = Variable(role.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('RemoteAlbumUserEntityCompanion(') - ..write('albumId: $albumId, ') - ..write('userId: $userId, ') - ..write('role: $role') - ..write(')')) - .toString(); - } -} - -class RemoteAssetCloudIdEntity extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - RemoteAssetCloudIdEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn assetId = GeneratedColumn( - 'asset_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: - 'NOT NULL REFERENCES remote_asset_entity(id)ON DELETE CASCADE', - ); - late final GeneratedColumn cloudId = GeneratedColumn( - 'cloud_id', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn createdAt = GeneratedColumn( - 'created_at', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn adjustmentTime = GeneratedColumn( - 'adjustment_time', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn latitude = GeneratedColumn( - 'latitude', - aliasedName, - true, - type: DriftSqlType.double, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn longitude = GeneratedColumn( - 'longitude', - aliasedName, - true, - type: DriftSqlType.double, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - @override - List get $columns => [ - assetId, - cloudId, - createdAt, - adjustmentTime, - latitude, - longitude, - ]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'remote_asset_cloud_id_entity'; - @override - Set get $primaryKey => {assetId}; - @override - RemoteAssetCloudIdEntityData map( - Map data, { - String? tablePrefix, - }) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return RemoteAssetCloudIdEntityData( - assetId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}asset_id'], - )!, - cloudId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}cloud_id'], - ), - createdAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}created_at'], - ), - adjustmentTime: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}adjustment_time'], - ), - latitude: attachedDatabase.typeMapping.read( - DriftSqlType.double, - data['${effectivePrefix}latitude'], - ), - longitude: attachedDatabase.typeMapping.read( - DriftSqlType.double, - data['${effectivePrefix}longitude'], - ), - ); - } - - @override - RemoteAssetCloudIdEntity createAlias(String alias) { - return RemoteAssetCloudIdEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const ['PRIMARY KEY(asset_id)']; - @override - bool get dontWriteConstraints => true; -} - -class RemoteAssetCloudIdEntityData extends DataClass - implements Insertable { - final String assetId; - final String? cloudId; - final String? createdAt; - final String? adjustmentTime; - final double? latitude; - final double? longitude; - const RemoteAssetCloudIdEntityData({ - required this.assetId, - this.cloudId, - this.createdAt, - this.adjustmentTime, - this.latitude, - this.longitude, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['asset_id'] = Variable(assetId); - if (!nullToAbsent || cloudId != null) { - map['cloud_id'] = Variable(cloudId); - } - if (!nullToAbsent || createdAt != null) { - map['created_at'] = Variable(createdAt); - } - if (!nullToAbsent || adjustmentTime != null) { - map['adjustment_time'] = Variable(adjustmentTime); - } - if (!nullToAbsent || latitude != null) { - map['latitude'] = Variable(latitude); - } - if (!nullToAbsent || longitude != null) { - map['longitude'] = Variable(longitude); - } - return map; - } - - factory RemoteAssetCloudIdEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return RemoteAssetCloudIdEntityData( - assetId: serializer.fromJson(json['assetId']), - cloudId: serializer.fromJson(json['cloudId']), - createdAt: serializer.fromJson(json['createdAt']), - adjustmentTime: serializer.fromJson(json['adjustmentTime']), - latitude: serializer.fromJson(json['latitude']), - longitude: serializer.fromJson(json['longitude']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'assetId': serializer.toJson(assetId), - 'cloudId': serializer.toJson(cloudId), - 'createdAt': serializer.toJson(createdAt), - 'adjustmentTime': serializer.toJson(adjustmentTime), - 'latitude': serializer.toJson(latitude), - 'longitude': serializer.toJson(longitude), - }; - } - - RemoteAssetCloudIdEntityData copyWith({ - String? assetId, - Value cloudId = const Value.absent(), - Value createdAt = const Value.absent(), - Value adjustmentTime = const Value.absent(), - Value latitude = const Value.absent(), - Value longitude = const Value.absent(), - }) => RemoteAssetCloudIdEntityData( - assetId: assetId ?? this.assetId, - cloudId: cloudId.present ? cloudId.value : this.cloudId, - createdAt: createdAt.present ? createdAt.value : this.createdAt, - adjustmentTime: adjustmentTime.present - ? adjustmentTime.value - : this.adjustmentTime, - latitude: latitude.present ? latitude.value : this.latitude, - longitude: longitude.present ? longitude.value : this.longitude, - ); - RemoteAssetCloudIdEntityData copyWithCompanion( - RemoteAssetCloudIdEntityCompanion data, - ) { - return RemoteAssetCloudIdEntityData( - assetId: data.assetId.present ? data.assetId.value : this.assetId, - cloudId: data.cloudId.present ? data.cloudId.value : this.cloudId, - createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, - adjustmentTime: data.adjustmentTime.present - ? data.adjustmentTime.value - : this.adjustmentTime, - latitude: data.latitude.present ? data.latitude.value : this.latitude, - longitude: data.longitude.present ? data.longitude.value : this.longitude, - ); - } - - @override - String toString() { - return (StringBuffer('RemoteAssetCloudIdEntityData(') - ..write('assetId: $assetId, ') - ..write('cloudId: $cloudId, ') - ..write('createdAt: $createdAt, ') - ..write('adjustmentTime: $adjustmentTime, ') - ..write('latitude: $latitude, ') - ..write('longitude: $longitude') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash( - assetId, - cloudId, - createdAt, - adjustmentTime, - latitude, - longitude, - ); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is RemoteAssetCloudIdEntityData && - other.assetId == this.assetId && - other.cloudId == this.cloudId && - other.createdAt == this.createdAt && - other.adjustmentTime == this.adjustmentTime && - other.latitude == this.latitude && - other.longitude == this.longitude); -} - -class RemoteAssetCloudIdEntityCompanion - extends UpdateCompanion { - final Value assetId; - final Value cloudId; - final Value createdAt; - final Value adjustmentTime; - final Value latitude; - final Value longitude; - const RemoteAssetCloudIdEntityCompanion({ - this.assetId = const Value.absent(), - this.cloudId = const Value.absent(), - this.createdAt = const Value.absent(), - this.adjustmentTime = const Value.absent(), - this.latitude = const Value.absent(), - this.longitude = const Value.absent(), - }); - RemoteAssetCloudIdEntityCompanion.insert({ - required String assetId, - this.cloudId = const Value.absent(), - this.createdAt = const Value.absent(), - this.adjustmentTime = const Value.absent(), - this.latitude = const Value.absent(), - this.longitude = const Value.absent(), - }) : assetId = Value(assetId); - static Insertable custom({ - Expression? assetId, - Expression? cloudId, - Expression? createdAt, - Expression? adjustmentTime, - Expression? latitude, - Expression? longitude, - }) { - return RawValuesInsertable({ - if (assetId != null) 'asset_id': assetId, - if (cloudId != null) 'cloud_id': cloudId, - if (createdAt != null) 'created_at': createdAt, - if (adjustmentTime != null) 'adjustment_time': adjustmentTime, - if (latitude != null) 'latitude': latitude, - if (longitude != null) 'longitude': longitude, - }); - } - - RemoteAssetCloudIdEntityCompanion copyWith({ - Value? assetId, - Value? cloudId, - Value? createdAt, - Value? adjustmentTime, - Value? latitude, - Value? longitude, - }) { - return RemoteAssetCloudIdEntityCompanion( - assetId: assetId ?? this.assetId, - cloudId: cloudId ?? this.cloudId, - createdAt: createdAt ?? this.createdAt, - adjustmentTime: adjustmentTime ?? this.adjustmentTime, - latitude: latitude ?? this.latitude, - longitude: longitude ?? this.longitude, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (assetId.present) { - map['asset_id'] = Variable(assetId.value); - } - if (cloudId.present) { - map['cloud_id'] = Variable(cloudId.value); - } - if (createdAt.present) { - map['created_at'] = Variable(createdAt.value); - } - if (adjustmentTime.present) { - map['adjustment_time'] = Variable(adjustmentTime.value); - } - if (latitude.present) { - map['latitude'] = Variable(latitude.value); - } - if (longitude.present) { - map['longitude'] = Variable(longitude.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('RemoteAssetCloudIdEntityCompanion(') - ..write('assetId: $assetId, ') - ..write('cloudId: $cloudId, ') - ..write('createdAt: $createdAt, ') - ..write('adjustmentTime: $adjustmentTime, ') - ..write('latitude: $latitude, ') - ..write('longitude: $longitude') - ..write(')')) - .toString(); - } -} - -class MemoryEntity extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - MemoryEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn id = GeneratedColumn( - 'id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn createdAt = GeneratedColumn( - 'created_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', - defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), - ); - late final GeneratedColumn updatedAt = GeneratedColumn( - 'updated_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', - defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), - ); - late final GeneratedColumn deletedAt = GeneratedColumn( - 'deleted_at', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn ownerId = GeneratedColumn( - 'owner_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL REFERENCES user_entity(id)ON DELETE CASCADE', - ); - late final GeneratedColumn type = GeneratedColumn( - 'type', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn data = GeneratedColumn( - 'data', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn isSaved = GeneratedColumn( - 'is_saved', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT 0 CHECK (is_saved IN (0, 1))', - defaultValue: const CustomExpression('0'), - ); - late final GeneratedColumn memoryAt = GeneratedColumn( - 'memory_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn seenAt = GeneratedColumn( - 'seen_at', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn showAt = GeneratedColumn( - 'show_at', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn hideAt = GeneratedColumn( - 'hide_at', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - @override - List get $columns => [ - id, - createdAt, - updatedAt, - deletedAt, - ownerId, - type, - data, - isSaved, - memoryAt, - seenAt, - showAt, - hideAt, - ]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'memory_entity'; - @override - Set get $primaryKey => {id}; - @override - MemoryEntityData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return MemoryEntityData( - id: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}id'], - )!, - createdAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}created_at'], - )!, - updatedAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}updated_at'], - )!, - deletedAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}deleted_at'], - ), - ownerId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}owner_id'], - )!, - type: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}type'], - )!, - data: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}data'], - )!, - isSaved: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}is_saved'], - )!, - memoryAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}memory_at'], - )!, - seenAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}seen_at'], - ), - showAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}show_at'], - ), - hideAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}hide_at'], - ), - ); - } - - @override - MemoryEntity createAlias(String alias) { - return MemoryEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const ['PRIMARY KEY(id)']; - @override - bool get dontWriteConstraints => true; -} - -class MemoryEntityData extends DataClass - implements Insertable { - final String id; - final String createdAt; - final String updatedAt; - final String? deletedAt; - final String ownerId; - final int type; - final String data; - final int isSaved; - final String memoryAt; - final String? seenAt; - final String? showAt; - final String? hideAt; - const MemoryEntityData({ - required this.id, - required this.createdAt, - required this.updatedAt, - this.deletedAt, - required this.ownerId, - required this.type, - required this.data, - required this.isSaved, - required this.memoryAt, - this.seenAt, - this.showAt, - this.hideAt, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['id'] = Variable(id); - map['created_at'] = Variable(createdAt); - map['updated_at'] = Variable(updatedAt); - if (!nullToAbsent || deletedAt != null) { - map['deleted_at'] = Variable(deletedAt); - } - map['owner_id'] = Variable(ownerId); - map['type'] = Variable(type); - map['data'] = Variable(data); - map['is_saved'] = Variable(isSaved); - map['memory_at'] = Variable(memoryAt); - if (!nullToAbsent || seenAt != null) { - map['seen_at'] = Variable(seenAt); - } - if (!nullToAbsent || showAt != null) { - map['show_at'] = Variable(showAt); - } - if (!nullToAbsent || hideAt != null) { - map['hide_at'] = Variable(hideAt); - } - return map; - } - - factory MemoryEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return MemoryEntityData( - id: serializer.fromJson(json['id']), - createdAt: serializer.fromJson(json['createdAt']), - updatedAt: serializer.fromJson(json['updatedAt']), - deletedAt: serializer.fromJson(json['deletedAt']), - ownerId: serializer.fromJson(json['ownerId']), - type: serializer.fromJson(json['type']), - data: serializer.fromJson(json['data']), - isSaved: serializer.fromJson(json['isSaved']), - memoryAt: serializer.fromJson(json['memoryAt']), - seenAt: serializer.fromJson(json['seenAt']), - showAt: serializer.fromJson(json['showAt']), - hideAt: serializer.fromJson(json['hideAt']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'id': serializer.toJson(id), - 'createdAt': serializer.toJson(createdAt), - 'updatedAt': serializer.toJson(updatedAt), - 'deletedAt': serializer.toJson(deletedAt), - 'ownerId': serializer.toJson(ownerId), - 'type': serializer.toJson(type), - 'data': serializer.toJson(data), - 'isSaved': serializer.toJson(isSaved), - 'memoryAt': serializer.toJson(memoryAt), - 'seenAt': serializer.toJson(seenAt), - 'showAt': serializer.toJson(showAt), - 'hideAt': serializer.toJson(hideAt), - }; - } - - MemoryEntityData copyWith({ - String? id, - String? createdAt, - String? updatedAt, - Value deletedAt = const Value.absent(), - String? ownerId, - int? type, - String? data, - int? isSaved, - String? memoryAt, - Value seenAt = const Value.absent(), - Value showAt = const Value.absent(), - Value hideAt = const Value.absent(), - }) => MemoryEntityData( - id: id ?? this.id, - createdAt: createdAt ?? this.createdAt, - updatedAt: updatedAt ?? this.updatedAt, - deletedAt: deletedAt.present ? deletedAt.value : this.deletedAt, - ownerId: ownerId ?? this.ownerId, - type: type ?? this.type, - data: data ?? this.data, - isSaved: isSaved ?? this.isSaved, - memoryAt: memoryAt ?? this.memoryAt, - seenAt: seenAt.present ? seenAt.value : this.seenAt, - showAt: showAt.present ? showAt.value : this.showAt, - hideAt: hideAt.present ? hideAt.value : this.hideAt, - ); - MemoryEntityData copyWithCompanion(MemoryEntityCompanion data) { - return MemoryEntityData( - id: data.id.present ? data.id.value : this.id, - createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, - updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, - deletedAt: data.deletedAt.present ? data.deletedAt.value : this.deletedAt, - ownerId: data.ownerId.present ? data.ownerId.value : this.ownerId, - type: data.type.present ? data.type.value : this.type, - data: data.data.present ? data.data.value : this.data, - isSaved: data.isSaved.present ? data.isSaved.value : this.isSaved, - memoryAt: data.memoryAt.present ? data.memoryAt.value : this.memoryAt, - seenAt: data.seenAt.present ? data.seenAt.value : this.seenAt, - showAt: data.showAt.present ? data.showAt.value : this.showAt, - hideAt: data.hideAt.present ? data.hideAt.value : this.hideAt, - ); - } - - @override - String toString() { - return (StringBuffer('MemoryEntityData(') - ..write('id: $id, ') - ..write('createdAt: $createdAt, ') - ..write('updatedAt: $updatedAt, ') - ..write('deletedAt: $deletedAt, ') - ..write('ownerId: $ownerId, ') - ..write('type: $type, ') - ..write('data: $data, ') - ..write('isSaved: $isSaved, ') - ..write('memoryAt: $memoryAt, ') - ..write('seenAt: $seenAt, ') - ..write('showAt: $showAt, ') - ..write('hideAt: $hideAt') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash( - id, - createdAt, - updatedAt, - deletedAt, - ownerId, - type, - data, - isSaved, - memoryAt, - seenAt, - showAt, - hideAt, - ); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is MemoryEntityData && - other.id == this.id && - other.createdAt == this.createdAt && - other.updatedAt == this.updatedAt && - other.deletedAt == this.deletedAt && - other.ownerId == this.ownerId && - other.type == this.type && - other.data == this.data && - other.isSaved == this.isSaved && - other.memoryAt == this.memoryAt && - other.seenAt == this.seenAt && - other.showAt == this.showAt && - other.hideAt == this.hideAt); -} - -class MemoryEntityCompanion extends UpdateCompanion { - final Value id; - final Value createdAt; - final Value updatedAt; - final Value deletedAt; - final Value ownerId; - final Value type; - final Value data; - final Value isSaved; - final Value memoryAt; - final Value seenAt; - final Value showAt; - final Value hideAt; - const MemoryEntityCompanion({ - this.id = const Value.absent(), - this.createdAt = const Value.absent(), - this.updatedAt = const Value.absent(), - this.deletedAt = const Value.absent(), - this.ownerId = const Value.absent(), - this.type = const Value.absent(), - this.data = const Value.absent(), - this.isSaved = const Value.absent(), - this.memoryAt = const Value.absent(), - this.seenAt = const Value.absent(), - this.showAt = const Value.absent(), - this.hideAt = const Value.absent(), - }); - MemoryEntityCompanion.insert({ - required String id, - this.createdAt = const Value.absent(), - this.updatedAt = const Value.absent(), - this.deletedAt = const Value.absent(), - required String ownerId, - required int type, - required String data, - this.isSaved = const Value.absent(), - required String memoryAt, - this.seenAt = const Value.absent(), - this.showAt = const Value.absent(), - this.hideAt = const Value.absent(), - }) : id = Value(id), - ownerId = Value(ownerId), - type = Value(type), - data = Value(data), - memoryAt = Value(memoryAt); - static Insertable custom({ - Expression? id, - Expression? createdAt, - Expression? updatedAt, - Expression? deletedAt, - Expression? ownerId, - Expression? type, - Expression? data, - Expression? isSaved, - Expression? memoryAt, - Expression? seenAt, - Expression? showAt, - Expression? hideAt, - }) { - return RawValuesInsertable({ - if (id != null) 'id': id, - if (createdAt != null) 'created_at': createdAt, - if (updatedAt != null) 'updated_at': updatedAt, - if (deletedAt != null) 'deleted_at': deletedAt, - if (ownerId != null) 'owner_id': ownerId, - if (type != null) 'type': type, - if (data != null) 'data': data, - if (isSaved != null) 'is_saved': isSaved, - if (memoryAt != null) 'memory_at': memoryAt, - if (seenAt != null) 'seen_at': seenAt, - if (showAt != null) 'show_at': showAt, - if (hideAt != null) 'hide_at': hideAt, - }); - } - - MemoryEntityCompanion copyWith({ - Value? id, - Value? createdAt, - Value? updatedAt, - Value? deletedAt, - Value? ownerId, - Value? type, - Value? data, - Value? isSaved, - Value? memoryAt, - Value? seenAt, - Value? showAt, - Value? hideAt, - }) { - return MemoryEntityCompanion( - id: id ?? this.id, - createdAt: createdAt ?? this.createdAt, - updatedAt: updatedAt ?? this.updatedAt, - deletedAt: deletedAt ?? this.deletedAt, - ownerId: ownerId ?? this.ownerId, - type: type ?? this.type, - data: data ?? this.data, - isSaved: isSaved ?? this.isSaved, - memoryAt: memoryAt ?? this.memoryAt, - seenAt: seenAt ?? this.seenAt, - showAt: showAt ?? this.showAt, - hideAt: hideAt ?? this.hideAt, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (id.present) { - map['id'] = Variable(id.value); - } - if (createdAt.present) { - map['created_at'] = Variable(createdAt.value); - } - if (updatedAt.present) { - map['updated_at'] = Variable(updatedAt.value); - } - if (deletedAt.present) { - map['deleted_at'] = Variable(deletedAt.value); - } - if (ownerId.present) { - map['owner_id'] = Variable(ownerId.value); - } - if (type.present) { - map['type'] = Variable(type.value); - } - if (data.present) { - map['data'] = Variable(data.value); - } - if (isSaved.present) { - map['is_saved'] = Variable(isSaved.value); - } - if (memoryAt.present) { - map['memory_at'] = Variable(memoryAt.value); - } - if (seenAt.present) { - map['seen_at'] = Variable(seenAt.value); - } - if (showAt.present) { - map['show_at'] = Variable(showAt.value); - } - if (hideAt.present) { - map['hide_at'] = Variable(hideAt.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('MemoryEntityCompanion(') - ..write('id: $id, ') - ..write('createdAt: $createdAt, ') - ..write('updatedAt: $updatedAt, ') - ..write('deletedAt: $deletedAt, ') - ..write('ownerId: $ownerId, ') - ..write('type: $type, ') - ..write('data: $data, ') - ..write('isSaved: $isSaved, ') - ..write('memoryAt: $memoryAt, ') - ..write('seenAt: $seenAt, ') - ..write('showAt: $showAt, ') - ..write('hideAt: $hideAt') - ..write(')')) - .toString(); - } -} - -class MemoryAssetEntity extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - MemoryAssetEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn assetId = GeneratedColumn( - 'asset_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: - 'NOT NULL REFERENCES remote_asset_entity(id)ON DELETE CASCADE', - ); - late final GeneratedColumn memoryId = GeneratedColumn( - 'memory_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: - 'NOT NULL REFERENCES memory_entity(id)ON DELETE CASCADE', - ); - @override - List get $columns => [assetId, memoryId]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'memory_asset_entity'; - @override - Set get $primaryKey => {assetId, memoryId}; - @override - MemoryAssetEntityData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return MemoryAssetEntityData( - assetId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}asset_id'], - )!, - memoryId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}memory_id'], - )!, - ); - } - - @override - MemoryAssetEntity createAlias(String alias) { - return MemoryAssetEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const [ - 'PRIMARY KEY(asset_id, memory_id)', - ]; - @override - bool get dontWriteConstraints => true; -} - -class MemoryAssetEntityData extends DataClass - implements Insertable { - final String assetId; - final String memoryId; - const MemoryAssetEntityData({required this.assetId, required this.memoryId}); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['asset_id'] = Variable(assetId); - map['memory_id'] = Variable(memoryId); - return map; - } - - factory MemoryAssetEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return MemoryAssetEntityData( - assetId: serializer.fromJson(json['assetId']), - memoryId: serializer.fromJson(json['memoryId']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'assetId': serializer.toJson(assetId), - 'memoryId': serializer.toJson(memoryId), - }; - } - - MemoryAssetEntityData copyWith({String? assetId, String? memoryId}) => - MemoryAssetEntityData( - assetId: assetId ?? this.assetId, - memoryId: memoryId ?? this.memoryId, - ); - MemoryAssetEntityData copyWithCompanion(MemoryAssetEntityCompanion data) { - return MemoryAssetEntityData( - assetId: data.assetId.present ? data.assetId.value : this.assetId, - memoryId: data.memoryId.present ? data.memoryId.value : this.memoryId, - ); - } - - @override - String toString() { - return (StringBuffer('MemoryAssetEntityData(') - ..write('assetId: $assetId, ') - ..write('memoryId: $memoryId') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash(assetId, memoryId); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is MemoryAssetEntityData && - other.assetId == this.assetId && - other.memoryId == this.memoryId); -} - -class MemoryAssetEntityCompanion - extends UpdateCompanion { - final Value assetId; - final Value memoryId; - const MemoryAssetEntityCompanion({ - this.assetId = const Value.absent(), - this.memoryId = const Value.absent(), - }); - MemoryAssetEntityCompanion.insert({ - required String assetId, - required String memoryId, - }) : assetId = Value(assetId), - memoryId = Value(memoryId); - static Insertable custom({ - Expression? assetId, - Expression? memoryId, - }) { - return RawValuesInsertable({ - if (assetId != null) 'asset_id': assetId, - if (memoryId != null) 'memory_id': memoryId, - }); - } - - MemoryAssetEntityCompanion copyWith({ - Value? assetId, - Value? memoryId, - }) { - return MemoryAssetEntityCompanion( - assetId: assetId ?? this.assetId, - memoryId: memoryId ?? this.memoryId, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (assetId.present) { - map['asset_id'] = Variable(assetId.value); - } - if (memoryId.present) { - map['memory_id'] = Variable(memoryId.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('MemoryAssetEntityCompanion(') - ..write('assetId: $assetId, ') - ..write('memoryId: $memoryId') - ..write(')')) - .toString(); - } -} - -class PersonEntity extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - PersonEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn id = GeneratedColumn( - 'id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn createdAt = GeneratedColumn( - 'created_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', - defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), - ); - late final GeneratedColumn updatedAt = GeneratedColumn( - 'updated_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', - defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), - ); - late final GeneratedColumn ownerId = GeneratedColumn( - 'owner_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL REFERENCES user_entity(id)ON DELETE CASCADE', - ); - late final GeneratedColumn name = GeneratedColumn( - 'name', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn faceAssetId = GeneratedColumn( - 'face_asset_id', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn isFavorite = GeneratedColumn( - 'is_favorite', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL CHECK (is_favorite IN (0, 1))', - ); - late final GeneratedColumn isHidden = GeneratedColumn( - 'is_hidden', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL CHECK (is_hidden IN (0, 1))', - ); - late final GeneratedColumn color = GeneratedColumn( - 'color', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn birthDate = GeneratedColumn( - 'birth_date', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - @override - List get $columns => [ - id, - createdAt, - updatedAt, - ownerId, - name, - faceAssetId, - isFavorite, - isHidden, - color, - birthDate, - ]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'person_entity'; - @override - Set get $primaryKey => {id}; - @override - PersonEntityData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return PersonEntityData( - id: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}id'], - )!, - createdAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}created_at'], - )!, - updatedAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}updated_at'], - )!, - ownerId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}owner_id'], - )!, - name: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}name'], - )!, - faceAssetId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}face_asset_id'], - ), - isFavorite: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}is_favorite'], - )!, - isHidden: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}is_hidden'], - )!, - color: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}color'], - ), - birthDate: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}birth_date'], - ), - ); - } - - @override - PersonEntity createAlias(String alias) { - return PersonEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const ['PRIMARY KEY(id)']; - @override - bool get dontWriteConstraints => true; -} - -class PersonEntityData extends DataClass - implements Insertable { - final String id; - final String createdAt; - final String updatedAt; - final String ownerId; - final String name; - final String? faceAssetId; - final int isFavorite; - final int isHidden; - final String? color; - final String? birthDate; - const PersonEntityData({ - required this.id, - required this.createdAt, - required this.updatedAt, - required this.ownerId, - required this.name, - this.faceAssetId, - required this.isFavorite, - required this.isHidden, - this.color, - this.birthDate, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['id'] = Variable(id); - map['created_at'] = Variable(createdAt); - map['updated_at'] = Variable(updatedAt); - map['owner_id'] = Variable(ownerId); - map['name'] = Variable(name); - if (!nullToAbsent || faceAssetId != null) { - map['face_asset_id'] = Variable(faceAssetId); - } - map['is_favorite'] = Variable(isFavorite); - map['is_hidden'] = Variable(isHidden); - if (!nullToAbsent || color != null) { - map['color'] = Variable(color); - } - if (!nullToAbsent || birthDate != null) { - map['birth_date'] = Variable(birthDate); - } - return map; - } - - factory PersonEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return PersonEntityData( - id: serializer.fromJson(json['id']), - createdAt: serializer.fromJson(json['createdAt']), - updatedAt: serializer.fromJson(json['updatedAt']), - ownerId: serializer.fromJson(json['ownerId']), - name: serializer.fromJson(json['name']), - faceAssetId: serializer.fromJson(json['faceAssetId']), - isFavorite: serializer.fromJson(json['isFavorite']), - isHidden: serializer.fromJson(json['isHidden']), - color: serializer.fromJson(json['color']), - birthDate: serializer.fromJson(json['birthDate']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'id': serializer.toJson(id), - 'createdAt': serializer.toJson(createdAt), - 'updatedAt': serializer.toJson(updatedAt), - 'ownerId': serializer.toJson(ownerId), - 'name': serializer.toJson(name), - 'faceAssetId': serializer.toJson(faceAssetId), - 'isFavorite': serializer.toJson(isFavorite), - 'isHidden': serializer.toJson(isHidden), - 'color': serializer.toJson(color), - 'birthDate': serializer.toJson(birthDate), - }; - } - - PersonEntityData copyWith({ - String? id, - String? createdAt, - String? updatedAt, - String? ownerId, - String? name, - Value faceAssetId = const Value.absent(), - int? isFavorite, - int? isHidden, - Value color = const Value.absent(), - Value birthDate = const Value.absent(), - }) => PersonEntityData( - id: id ?? this.id, - createdAt: createdAt ?? this.createdAt, - updatedAt: updatedAt ?? this.updatedAt, - ownerId: ownerId ?? this.ownerId, - name: name ?? this.name, - faceAssetId: faceAssetId.present ? faceAssetId.value : this.faceAssetId, - isFavorite: isFavorite ?? this.isFavorite, - isHidden: isHidden ?? this.isHidden, - color: color.present ? color.value : this.color, - birthDate: birthDate.present ? birthDate.value : this.birthDate, - ); - PersonEntityData copyWithCompanion(PersonEntityCompanion data) { - return PersonEntityData( - id: data.id.present ? data.id.value : this.id, - createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, - updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, - ownerId: data.ownerId.present ? data.ownerId.value : this.ownerId, - name: data.name.present ? data.name.value : this.name, - faceAssetId: data.faceAssetId.present - ? data.faceAssetId.value - : this.faceAssetId, - isFavorite: data.isFavorite.present - ? data.isFavorite.value - : this.isFavorite, - isHidden: data.isHidden.present ? data.isHidden.value : this.isHidden, - color: data.color.present ? data.color.value : this.color, - birthDate: data.birthDate.present ? data.birthDate.value : this.birthDate, - ); - } - - @override - String toString() { - return (StringBuffer('PersonEntityData(') - ..write('id: $id, ') - ..write('createdAt: $createdAt, ') - ..write('updatedAt: $updatedAt, ') - ..write('ownerId: $ownerId, ') - ..write('name: $name, ') - ..write('faceAssetId: $faceAssetId, ') - ..write('isFavorite: $isFavorite, ') - ..write('isHidden: $isHidden, ') - ..write('color: $color, ') - ..write('birthDate: $birthDate') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash( - id, - createdAt, - updatedAt, - ownerId, - name, - faceAssetId, - isFavorite, - isHidden, - color, - birthDate, - ); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is PersonEntityData && - other.id == this.id && - other.createdAt == this.createdAt && - other.updatedAt == this.updatedAt && - other.ownerId == this.ownerId && - other.name == this.name && - other.faceAssetId == this.faceAssetId && - other.isFavorite == this.isFavorite && - other.isHidden == this.isHidden && - other.color == this.color && - other.birthDate == this.birthDate); -} - -class PersonEntityCompanion extends UpdateCompanion { - final Value id; - final Value createdAt; - final Value updatedAt; - final Value ownerId; - final Value name; - final Value faceAssetId; - final Value isFavorite; - final Value isHidden; - final Value color; - final Value birthDate; - const PersonEntityCompanion({ - this.id = const Value.absent(), - this.createdAt = const Value.absent(), - this.updatedAt = const Value.absent(), - this.ownerId = const Value.absent(), - this.name = const Value.absent(), - this.faceAssetId = const Value.absent(), - this.isFavorite = const Value.absent(), - this.isHidden = const Value.absent(), - this.color = const Value.absent(), - this.birthDate = const Value.absent(), - }); - PersonEntityCompanion.insert({ - required String id, - this.createdAt = const Value.absent(), - this.updatedAt = const Value.absent(), - required String ownerId, - required String name, - this.faceAssetId = const Value.absent(), - required int isFavorite, - required int isHidden, - this.color = const Value.absent(), - this.birthDate = const Value.absent(), - }) : id = Value(id), - ownerId = Value(ownerId), - name = Value(name), - isFavorite = Value(isFavorite), - isHidden = Value(isHidden); - static Insertable custom({ - Expression? id, - Expression? createdAt, - Expression? updatedAt, - Expression? ownerId, - Expression? name, - Expression? faceAssetId, - Expression? isFavorite, - Expression? isHidden, - Expression? color, - Expression? birthDate, - }) { - return RawValuesInsertable({ - if (id != null) 'id': id, - if (createdAt != null) 'created_at': createdAt, - if (updatedAt != null) 'updated_at': updatedAt, - if (ownerId != null) 'owner_id': ownerId, - if (name != null) 'name': name, - if (faceAssetId != null) 'face_asset_id': faceAssetId, - if (isFavorite != null) 'is_favorite': isFavorite, - if (isHidden != null) 'is_hidden': isHidden, - if (color != null) 'color': color, - if (birthDate != null) 'birth_date': birthDate, - }); - } - - PersonEntityCompanion copyWith({ - Value? id, - Value? createdAt, - Value? updatedAt, - Value? ownerId, - Value? name, - Value? faceAssetId, - Value? isFavorite, - Value? isHidden, - Value? color, - Value? birthDate, - }) { - return PersonEntityCompanion( - id: id ?? this.id, - createdAt: createdAt ?? this.createdAt, - updatedAt: updatedAt ?? this.updatedAt, - ownerId: ownerId ?? this.ownerId, - name: name ?? this.name, - faceAssetId: faceAssetId ?? this.faceAssetId, - isFavorite: isFavorite ?? this.isFavorite, - isHidden: isHidden ?? this.isHidden, - color: color ?? this.color, - birthDate: birthDate ?? this.birthDate, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (id.present) { - map['id'] = Variable(id.value); - } - if (createdAt.present) { - map['created_at'] = Variable(createdAt.value); - } - if (updatedAt.present) { - map['updated_at'] = Variable(updatedAt.value); - } - if (ownerId.present) { - map['owner_id'] = Variable(ownerId.value); - } - if (name.present) { - map['name'] = Variable(name.value); - } - if (faceAssetId.present) { - map['face_asset_id'] = Variable(faceAssetId.value); - } - if (isFavorite.present) { - map['is_favorite'] = Variable(isFavorite.value); - } - if (isHidden.present) { - map['is_hidden'] = Variable(isHidden.value); - } - if (color.present) { - map['color'] = Variable(color.value); - } - if (birthDate.present) { - map['birth_date'] = Variable(birthDate.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('PersonEntityCompanion(') - ..write('id: $id, ') - ..write('createdAt: $createdAt, ') - ..write('updatedAt: $updatedAt, ') - ..write('ownerId: $ownerId, ') - ..write('name: $name, ') - ..write('faceAssetId: $faceAssetId, ') - ..write('isFavorite: $isFavorite, ') - ..write('isHidden: $isHidden, ') - ..write('color: $color, ') - ..write('birthDate: $birthDate') - ..write(')')) - .toString(); - } -} - -class AssetFaceEntity extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - AssetFaceEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn id = GeneratedColumn( - 'id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn assetId = GeneratedColumn( - 'asset_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: - 'NOT NULL REFERENCES remote_asset_entity(id)ON DELETE CASCADE', - ); - late final GeneratedColumn personId = GeneratedColumn( - 'person_id', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL REFERENCES person_entity(id)ON DELETE SET NULL', - ); - late final GeneratedColumn imageWidth = GeneratedColumn( - 'image_width', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn imageHeight = GeneratedColumn( - 'image_height', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn boundingBoxX1 = GeneratedColumn( - 'bounding_box_x1', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn boundingBoxY1 = GeneratedColumn( - 'bounding_box_y1', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn boundingBoxX2 = GeneratedColumn( - 'bounding_box_x2', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn boundingBoxY2 = GeneratedColumn( - 'bounding_box_y2', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn sourceType = GeneratedColumn( - 'source_type', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn isVisible = GeneratedColumn( - 'is_visible', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT 1 CHECK (is_visible IN (0, 1))', - defaultValue: const CustomExpression('1'), - ); - late final GeneratedColumn deletedAt = GeneratedColumn( - 'deleted_at', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - @override - List get $columns => [ - id, - assetId, - personId, - imageWidth, - imageHeight, - boundingBoxX1, - boundingBoxY1, - boundingBoxX2, - boundingBoxY2, - sourceType, - isVisible, - deletedAt, - ]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'asset_face_entity'; - @override - Set get $primaryKey => {id}; - @override - AssetFaceEntityData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return AssetFaceEntityData( - id: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}id'], - )!, - assetId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}asset_id'], - )!, - personId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}person_id'], - ), - imageWidth: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}image_width'], - )!, - imageHeight: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}image_height'], - )!, - boundingBoxX1: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}bounding_box_x1'], - )!, - boundingBoxY1: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}bounding_box_y1'], - )!, - boundingBoxX2: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}bounding_box_x2'], - )!, - boundingBoxY2: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}bounding_box_y2'], - )!, - sourceType: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}source_type'], - )!, - isVisible: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}is_visible'], - )!, - deletedAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}deleted_at'], - ), - ); - } - - @override - AssetFaceEntity createAlias(String alias) { - return AssetFaceEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const ['PRIMARY KEY(id)']; - @override - bool get dontWriteConstraints => true; -} - -class AssetFaceEntityData extends DataClass - implements Insertable { - final String id; - final String assetId; - final String? personId; - final int imageWidth; - final int imageHeight; - final int boundingBoxX1; - final int boundingBoxY1; - final int boundingBoxX2; - final int boundingBoxY2; - final String sourceType; - final int isVisible; - final String? deletedAt; - const AssetFaceEntityData({ - required this.id, - required this.assetId, - this.personId, - required this.imageWidth, - required this.imageHeight, - required this.boundingBoxX1, - required this.boundingBoxY1, - required this.boundingBoxX2, - required this.boundingBoxY2, - required this.sourceType, - required this.isVisible, - this.deletedAt, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['id'] = Variable(id); - map['asset_id'] = Variable(assetId); - if (!nullToAbsent || personId != null) { - map['person_id'] = Variable(personId); - } - map['image_width'] = Variable(imageWidth); - map['image_height'] = Variable(imageHeight); - map['bounding_box_x1'] = Variable(boundingBoxX1); - map['bounding_box_y1'] = Variable(boundingBoxY1); - map['bounding_box_x2'] = Variable(boundingBoxX2); - map['bounding_box_y2'] = Variable(boundingBoxY2); - map['source_type'] = Variable(sourceType); - map['is_visible'] = Variable(isVisible); - if (!nullToAbsent || deletedAt != null) { - map['deleted_at'] = Variable(deletedAt); - } - return map; - } - - factory AssetFaceEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return AssetFaceEntityData( - id: serializer.fromJson(json['id']), - assetId: serializer.fromJson(json['assetId']), - personId: serializer.fromJson(json['personId']), - imageWidth: serializer.fromJson(json['imageWidth']), - imageHeight: serializer.fromJson(json['imageHeight']), - boundingBoxX1: serializer.fromJson(json['boundingBoxX1']), - boundingBoxY1: serializer.fromJson(json['boundingBoxY1']), - boundingBoxX2: serializer.fromJson(json['boundingBoxX2']), - boundingBoxY2: serializer.fromJson(json['boundingBoxY2']), - sourceType: serializer.fromJson(json['sourceType']), - isVisible: serializer.fromJson(json['isVisible']), - deletedAt: serializer.fromJson(json['deletedAt']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'id': serializer.toJson(id), - 'assetId': serializer.toJson(assetId), - 'personId': serializer.toJson(personId), - 'imageWidth': serializer.toJson(imageWidth), - 'imageHeight': serializer.toJson(imageHeight), - 'boundingBoxX1': serializer.toJson(boundingBoxX1), - 'boundingBoxY1': serializer.toJson(boundingBoxY1), - 'boundingBoxX2': serializer.toJson(boundingBoxX2), - 'boundingBoxY2': serializer.toJson(boundingBoxY2), - 'sourceType': serializer.toJson(sourceType), - 'isVisible': serializer.toJson(isVisible), - 'deletedAt': serializer.toJson(deletedAt), - }; - } - - AssetFaceEntityData copyWith({ - String? id, - String? assetId, - Value personId = const Value.absent(), - int? imageWidth, - int? imageHeight, - int? boundingBoxX1, - int? boundingBoxY1, - int? boundingBoxX2, - int? boundingBoxY2, - String? sourceType, - int? isVisible, - Value deletedAt = const Value.absent(), - }) => AssetFaceEntityData( - id: id ?? this.id, - assetId: assetId ?? this.assetId, - personId: personId.present ? personId.value : this.personId, - imageWidth: imageWidth ?? this.imageWidth, - imageHeight: imageHeight ?? this.imageHeight, - boundingBoxX1: boundingBoxX1 ?? this.boundingBoxX1, - boundingBoxY1: boundingBoxY1 ?? this.boundingBoxY1, - boundingBoxX2: boundingBoxX2 ?? this.boundingBoxX2, - boundingBoxY2: boundingBoxY2 ?? this.boundingBoxY2, - sourceType: sourceType ?? this.sourceType, - isVisible: isVisible ?? this.isVisible, - deletedAt: deletedAt.present ? deletedAt.value : this.deletedAt, - ); - AssetFaceEntityData copyWithCompanion(AssetFaceEntityCompanion data) { - return AssetFaceEntityData( - id: data.id.present ? data.id.value : this.id, - assetId: data.assetId.present ? data.assetId.value : this.assetId, - personId: data.personId.present ? data.personId.value : this.personId, - imageWidth: data.imageWidth.present - ? data.imageWidth.value - : this.imageWidth, - imageHeight: data.imageHeight.present - ? data.imageHeight.value - : this.imageHeight, - boundingBoxX1: data.boundingBoxX1.present - ? data.boundingBoxX1.value - : this.boundingBoxX1, - boundingBoxY1: data.boundingBoxY1.present - ? data.boundingBoxY1.value - : this.boundingBoxY1, - boundingBoxX2: data.boundingBoxX2.present - ? data.boundingBoxX2.value - : this.boundingBoxX2, - boundingBoxY2: data.boundingBoxY2.present - ? data.boundingBoxY2.value - : this.boundingBoxY2, - sourceType: data.sourceType.present - ? data.sourceType.value - : this.sourceType, - isVisible: data.isVisible.present ? data.isVisible.value : this.isVisible, - deletedAt: data.deletedAt.present ? data.deletedAt.value : this.deletedAt, - ); - } - - @override - String toString() { - return (StringBuffer('AssetFaceEntityData(') - ..write('id: $id, ') - ..write('assetId: $assetId, ') - ..write('personId: $personId, ') - ..write('imageWidth: $imageWidth, ') - ..write('imageHeight: $imageHeight, ') - ..write('boundingBoxX1: $boundingBoxX1, ') - ..write('boundingBoxY1: $boundingBoxY1, ') - ..write('boundingBoxX2: $boundingBoxX2, ') - ..write('boundingBoxY2: $boundingBoxY2, ') - ..write('sourceType: $sourceType, ') - ..write('isVisible: $isVisible, ') - ..write('deletedAt: $deletedAt') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash( - id, - assetId, - personId, - imageWidth, - imageHeight, - boundingBoxX1, - boundingBoxY1, - boundingBoxX2, - boundingBoxY2, - sourceType, - isVisible, - deletedAt, - ); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is AssetFaceEntityData && - other.id == this.id && - other.assetId == this.assetId && - other.personId == this.personId && - other.imageWidth == this.imageWidth && - other.imageHeight == this.imageHeight && - other.boundingBoxX1 == this.boundingBoxX1 && - other.boundingBoxY1 == this.boundingBoxY1 && - other.boundingBoxX2 == this.boundingBoxX2 && - other.boundingBoxY2 == this.boundingBoxY2 && - other.sourceType == this.sourceType && - other.isVisible == this.isVisible && - other.deletedAt == this.deletedAt); -} - -class AssetFaceEntityCompanion extends UpdateCompanion { - final Value id; - final Value assetId; - final Value personId; - final Value imageWidth; - final Value imageHeight; - final Value boundingBoxX1; - final Value boundingBoxY1; - final Value boundingBoxX2; - final Value boundingBoxY2; - final Value sourceType; - final Value isVisible; - final Value deletedAt; - const AssetFaceEntityCompanion({ - this.id = const Value.absent(), - this.assetId = const Value.absent(), - this.personId = const Value.absent(), - this.imageWidth = const Value.absent(), - this.imageHeight = const Value.absent(), - this.boundingBoxX1 = const Value.absent(), - this.boundingBoxY1 = const Value.absent(), - this.boundingBoxX2 = const Value.absent(), - this.boundingBoxY2 = const Value.absent(), - this.sourceType = const Value.absent(), - this.isVisible = const Value.absent(), - this.deletedAt = const Value.absent(), - }); - AssetFaceEntityCompanion.insert({ - required String id, - required String assetId, - this.personId = const Value.absent(), - required int imageWidth, - required int imageHeight, - required int boundingBoxX1, - required int boundingBoxY1, - required int boundingBoxX2, - required int boundingBoxY2, - required String sourceType, - this.isVisible = const Value.absent(), - this.deletedAt = const Value.absent(), - }) : id = Value(id), - assetId = Value(assetId), - imageWidth = Value(imageWidth), - imageHeight = Value(imageHeight), - boundingBoxX1 = Value(boundingBoxX1), - boundingBoxY1 = Value(boundingBoxY1), - boundingBoxX2 = Value(boundingBoxX2), - boundingBoxY2 = Value(boundingBoxY2), - sourceType = Value(sourceType); - static Insertable custom({ - Expression? id, - Expression? assetId, - Expression? personId, - Expression? imageWidth, - Expression? imageHeight, - Expression? boundingBoxX1, - Expression? boundingBoxY1, - Expression? boundingBoxX2, - Expression? boundingBoxY2, - Expression? sourceType, - Expression? isVisible, - Expression? deletedAt, - }) { - return RawValuesInsertable({ - if (id != null) 'id': id, - if (assetId != null) 'asset_id': assetId, - if (personId != null) 'person_id': personId, - if (imageWidth != null) 'image_width': imageWidth, - if (imageHeight != null) 'image_height': imageHeight, - if (boundingBoxX1 != null) 'bounding_box_x1': boundingBoxX1, - if (boundingBoxY1 != null) 'bounding_box_y1': boundingBoxY1, - if (boundingBoxX2 != null) 'bounding_box_x2': boundingBoxX2, - if (boundingBoxY2 != null) 'bounding_box_y2': boundingBoxY2, - if (sourceType != null) 'source_type': sourceType, - if (isVisible != null) 'is_visible': isVisible, - if (deletedAt != null) 'deleted_at': deletedAt, - }); - } - - AssetFaceEntityCompanion copyWith({ - Value? id, - Value? assetId, - Value? personId, - Value? imageWidth, - Value? imageHeight, - Value? boundingBoxX1, - Value? boundingBoxY1, - Value? boundingBoxX2, - Value? boundingBoxY2, - Value? sourceType, - Value? isVisible, - Value? deletedAt, - }) { - return AssetFaceEntityCompanion( - id: id ?? this.id, - assetId: assetId ?? this.assetId, - personId: personId ?? this.personId, - imageWidth: imageWidth ?? this.imageWidth, - imageHeight: imageHeight ?? this.imageHeight, - boundingBoxX1: boundingBoxX1 ?? this.boundingBoxX1, - boundingBoxY1: boundingBoxY1 ?? this.boundingBoxY1, - boundingBoxX2: boundingBoxX2 ?? this.boundingBoxX2, - boundingBoxY2: boundingBoxY2 ?? this.boundingBoxY2, - sourceType: sourceType ?? this.sourceType, - isVisible: isVisible ?? this.isVisible, - deletedAt: deletedAt ?? this.deletedAt, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (id.present) { - map['id'] = Variable(id.value); - } - if (assetId.present) { - map['asset_id'] = Variable(assetId.value); - } - if (personId.present) { - map['person_id'] = Variable(personId.value); - } - if (imageWidth.present) { - map['image_width'] = Variable(imageWidth.value); - } - if (imageHeight.present) { - map['image_height'] = Variable(imageHeight.value); - } - if (boundingBoxX1.present) { - map['bounding_box_x1'] = Variable(boundingBoxX1.value); - } - if (boundingBoxY1.present) { - map['bounding_box_y1'] = Variable(boundingBoxY1.value); - } - if (boundingBoxX2.present) { - map['bounding_box_x2'] = Variable(boundingBoxX2.value); - } - if (boundingBoxY2.present) { - map['bounding_box_y2'] = Variable(boundingBoxY2.value); - } - if (sourceType.present) { - map['source_type'] = Variable(sourceType.value); - } - if (isVisible.present) { - map['is_visible'] = Variable(isVisible.value); - } - if (deletedAt.present) { - map['deleted_at'] = Variable(deletedAt.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('AssetFaceEntityCompanion(') - ..write('id: $id, ') - ..write('assetId: $assetId, ') - ..write('personId: $personId, ') - ..write('imageWidth: $imageWidth, ') - ..write('imageHeight: $imageHeight, ') - ..write('boundingBoxX1: $boundingBoxX1, ') - ..write('boundingBoxY1: $boundingBoxY1, ') - ..write('boundingBoxX2: $boundingBoxX2, ') - ..write('boundingBoxY2: $boundingBoxY2, ') - ..write('sourceType: $sourceType, ') - ..write('isVisible: $isVisible, ') - ..write('deletedAt: $deletedAt') - ..write(')')) - .toString(); - } -} - -class StoreEntity extends Table with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - StoreEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn id = GeneratedColumn( - 'id', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn stringValue = GeneratedColumn( - 'string_value', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn intValue = GeneratedColumn( - 'int_value', - aliasedName, - true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - @override - List get $columns => [id, stringValue, intValue]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'store_entity'; - @override - Set get $primaryKey => {id}; - @override - StoreEntityData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return StoreEntityData( - id: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}id'], - )!, - stringValue: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}string_value'], - ), - intValue: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}int_value'], - ), - ); - } - - @override - StoreEntity createAlias(String alias) { - return StoreEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const ['PRIMARY KEY(id)']; - @override - bool get dontWriteConstraints => true; -} - -class StoreEntityData extends DataClass implements Insertable { - final int id; - final String? stringValue; - final int? intValue; - const StoreEntityData({required this.id, this.stringValue, this.intValue}); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['id'] = Variable(id); - if (!nullToAbsent || stringValue != null) { - map['string_value'] = Variable(stringValue); - } - if (!nullToAbsent || intValue != null) { - map['int_value'] = Variable(intValue); - } - return map; - } - - factory StoreEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return StoreEntityData( - id: serializer.fromJson(json['id']), - stringValue: serializer.fromJson(json['stringValue']), - intValue: serializer.fromJson(json['intValue']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'id': serializer.toJson(id), - 'stringValue': serializer.toJson(stringValue), - 'intValue': serializer.toJson(intValue), - }; - } - - StoreEntityData copyWith({ - int? id, - Value stringValue = const Value.absent(), - Value intValue = const Value.absent(), - }) => StoreEntityData( - id: id ?? this.id, - stringValue: stringValue.present ? stringValue.value : this.stringValue, - intValue: intValue.present ? intValue.value : this.intValue, - ); - StoreEntityData copyWithCompanion(StoreEntityCompanion data) { - return StoreEntityData( - id: data.id.present ? data.id.value : this.id, - stringValue: data.stringValue.present - ? data.stringValue.value - : this.stringValue, - intValue: data.intValue.present ? data.intValue.value : this.intValue, - ); - } - - @override - String toString() { - return (StringBuffer('StoreEntityData(') - ..write('id: $id, ') - ..write('stringValue: $stringValue, ') - ..write('intValue: $intValue') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash(id, stringValue, intValue); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is StoreEntityData && - other.id == this.id && - other.stringValue == this.stringValue && - other.intValue == this.intValue); -} - -class StoreEntityCompanion extends UpdateCompanion { - final Value id; - final Value stringValue; - final Value intValue; - const StoreEntityCompanion({ - this.id = const Value.absent(), - this.stringValue = const Value.absent(), - this.intValue = const Value.absent(), - }); - StoreEntityCompanion.insert({ - required int id, - this.stringValue = const Value.absent(), - this.intValue = const Value.absent(), - }) : id = Value(id); - static Insertable custom({ - Expression? id, - Expression? stringValue, - Expression? intValue, - }) { - return RawValuesInsertable({ - if (id != null) 'id': id, - if (stringValue != null) 'string_value': stringValue, - if (intValue != null) 'int_value': intValue, - }); - } - - StoreEntityCompanion copyWith({ - Value? id, - Value? stringValue, - Value? intValue, - }) { - return StoreEntityCompanion( - id: id ?? this.id, - stringValue: stringValue ?? this.stringValue, - intValue: intValue ?? this.intValue, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (id.present) { - map['id'] = Variable(id.value); - } - if (stringValue.present) { - map['string_value'] = Variable(stringValue.value); - } - if (intValue.present) { - map['int_value'] = Variable(intValue.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('StoreEntityCompanion(') - ..write('id: $id, ') - ..write('stringValue: $stringValue, ') - ..write('intValue: $intValue') - ..write(')')) - .toString(); - } -} - -class TrashedLocalAssetEntity extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - TrashedLocalAssetEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn name = GeneratedColumn( - 'name', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn type = GeneratedColumn( - 'type', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn createdAt = GeneratedColumn( - 'created_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', - defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), - ); - late final GeneratedColumn updatedAt = GeneratedColumn( - 'updated_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', - defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), - ); - late final GeneratedColumn width = GeneratedColumn( - 'width', - aliasedName, - true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn height = GeneratedColumn( - 'height', - aliasedName, - true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn durationMs = GeneratedColumn( - 'duration_ms', - aliasedName, - true, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn id = GeneratedColumn( - 'id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn albumId = GeneratedColumn( - 'album_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn checksum = GeneratedColumn( - 'checksum', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn isFavorite = GeneratedColumn( - 'is_favorite', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT 0 CHECK (is_favorite IN (0, 1))', - defaultValue: const CustomExpression('0'), - ); - late final GeneratedColumn orientation = GeneratedColumn( - 'orientation', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT 0', - defaultValue: const CustomExpression('0'), - ); - late final GeneratedColumn source = GeneratedColumn( - 'source', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn playbackStyle = GeneratedColumn( - 'playback_style', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT 0', - defaultValue: const CustomExpression('0'), - ); - @override - List get $columns => [ - name, - type, - createdAt, - updatedAt, - width, - height, - durationMs, - id, - albumId, - checksum, - isFavorite, - orientation, - source, - playbackStyle, - ]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'trashed_local_asset_entity'; - @override - Set get $primaryKey => {id, albumId}; - @override - TrashedLocalAssetEntityData map( - Map data, { - String? tablePrefix, - }) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return TrashedLocalAssetEntityData( - name: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}name'], - )!, - type: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}type'], - )!, - createdAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}created_at'], - )!, - updatedAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}updated_at'], - )!, - width: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}width'], - ), - height: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}height'], - ), - durationMs: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}duration_ms'], - ), - id: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}id'], - )!, - albumId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}album_id'], - )!, - checksum: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}checksum'], - ), - isFavorite: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}is_favorite'], - )!, - orientation: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}orientation'], - )!, - source: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}source'], - )!, - playbackStyle: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}playback_style'], - )!, - ); - } - - @override - TrashedLocalAssetEntity createAlias(String alias) { - return TrashedLocalAssetEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const ['PRIMARY KEY(id, album_id)']; - @override - bool get dontWriteConstraints => true; -} - -class TrashedLocalAssetEntityData extends DataClass - implements Insertable { - final String name; - final int type; - final String createdAt; - final String updatedAt; - final int? width; - final int? height; - final int? durationMs; - final String id; - final String albumId; - final String? checksum; - final int isFavorite; - final int orientation; - final int source; - final int playbackStyle; - const TrashedLocalAssetEntityData({ - required this.name, - required this.type, - required this.createdAt, - required this.updatedAt, - this.width, - this.height, - this.durationMs, - required this.id, - required this.albumId, - this.checksum, - required this.isFavorite, - required this.orientation, - required this.source, - required this.playbackStyle, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['name'] = Variable(name); - map['type'] = Variable(type); - map['created_at'] = Variable(createdAt); - map['updated_at'] = Variable(updatedAt); - if (!nullToAbsent || width != null) { - map['width'] = Variable(width); - } - if (!nullToAbsent || height != null) { - map['height'] = Variable(height); - } - if (!nullToAbsent || durationMs != null) { - map['duration_ms'] = Variable(durationMs); - } - map['id'] = Variable(id); - map['album_id'] = Variable(albumId); - if (!nullToAbsent || checksum != null) { - map['checksum'] = Variable(checksum); - } - map['is_favorite'] = Variable(isFavorite); - map['orientation'] = Variable(orientation); - map['source'] = Variable(source); - map['playback_style'] = Variable(playbackStyle); - return map; - } - - factory TrashedLocalAssetEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return TrashedLocalAssetEntityData( - name: serializer.fromJson(json['name']), - type: serializer.fromJson(json['type']), - createdAt: serializer.fromJson(json['createdAt']), - updatedAt: serializer.fromJson(json['updatedAt']), - width: serializer.fromJson(json['width']), - height: serializer.fromJson(json['height']), - durationMs: serializer.fromJson(json['durationMs']), - id: serializer.fromJson(json['id']), - albumId: serializer.fromJson(json['albumId']), - checksum: serializer.fromJson(json['checksum']), - isFavorite: serializer.fromJson(json['isFavorite']), - orientation: serializer.fromJson(json['orientation']), - source: serializer.fromJson(json['source']), - playbackStyle: serializer.fromJson(json['playbackStyle']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'name': serializer.toJson(name), - 'type': serializer.toJson(type), - 'createdAt': serializer.toJson(createdAt), - 'updatedAt': serializer.toJson(updatedAt), - 'width': serializer.toJson(width), - 'height': serializer.toJson(height), - 'durationMs': serializer.toJson(durationMs), - 'id': serializer.toJson(id), - 'albumId': serializer.toJson(albumId), - 'checksum': serializer.toJson(checksum), - 'isFavorite': serializer.toJson(isFavorite), - 'orientation': serializer.toJson(orientation), - 'source': serializer.toJson(source), - 'playbackStyle': serializer.toJson(playbackStyle), - }; - } - - TrashedLocalAssetEntityData copyWith({ - String? name, - int? type, - String? createdAt, - String? updatedAt, - Value width = const Value.absent(), - Value height = const Value.absent(), - Value durationMs = const Value.absent(), - String? id, - String? albumId, - Value checksum = const Value.absent(), - int? isFavorite, - int? orientation, - int? source, - int? playbackStyle, - }) => TrashedLocalAssetEntityData( - 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, - durationMs: durationMs.present ? durationMs.value : this.durationMs, - id: id ?? this.id, - albumId: albumId ?? this.albumId, - checksum: checksum.present ? checksum.value : this.checksum, - isFavorite: isFavorite ?? this.isFavorite, - orientation: orientation ?? this.orientation, - source: source ?? this.source, - playbackStyle: playbackStyle ?? this.playbackStyle, - ); - TrashedLocalAssetEntityData copyWithCompanion( - TrashedLocalAssetEntityCompanion data, - ) { - return TrashedLocalAssetEntityData( - 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, - width: data.width.present ? data.width.value : this.width, - height: data.height.present ? data.height.value : this.height, - durationMs: data.durationMs.present - ? data.durationMs.value - : this.durationMs, - id: data.id.present ? data.id.value : this.id, - albumId: data.albumId.present ? data.albumId.value : this.albumId, - checksum: data.checksum.present ? data.checksum.value : this.checksum, - isFavorite: data.isFavorite.present - ? data.isFavorite.value - : this.isFavorite, - orientation: data.orientation.present - ? data.orientation.value - : this.orientation, - source: data.source.present ? data.source.value : this.source, - playbackStyle: data.playbackStyle.present - ? data.playbackStyle.value - : this.playbackStyle, - ); - } - - @override - String toString() { - return (StringBuffer('TrashedLocalAssetEntityData(') - ..write('name: $name, ') - ..write('type: $type, ') - ..write('createdAt: $createdAt, ') - ..write('updatedAt: $updatedAt, ') - ..write('width: $width, ') - ..write('height: $height, ') - ..write('durationMs: $durationMs, ') - ..write('id: $id, ') - ..write('albumId: $albumId, ') - ..write('checksum: $checksum, ') - ..write('isFavorite: $isFavorite, ') - ..write('orientation: $orientation, ') - ..write('source: $source, ') - ..write('playbackStyle: $playbackStyle') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash( - name, - type, - createdAt, - updatedAt, - width, - height, - durationMs, - id, - albumId, - checksum, - isFavorite, - orientation, - source, - playbackStyle, - ); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is TrashedLocalAssetEntityData && - other.name == this.name && - other.type == this.type && - other.createdAt == this.createdAt && - other.updatedAt == this.updatedAt && - other.width == this.width && - other.height == this.height && - other.durationMs == this.durationMs && - other.id == this.id && - other.albumId == this.albumId && - other.checksum == this.checksum && - other.isFavorite == this.isFavorite && - other.orientation == this.orientation && - other.source == this.source && - other.playbackStyle == this.playbackStyle); -} - -class TrashedLocalAssetEntityCompanion - extends UpdateCompanion { - final Value name; - final Value type; - final Value createdAt; - final Value updatedAt; - final Value width; - final Value height; - final Value durationMs; - final Value id; - final Value albumId; - final Value checksum; - final Value isFavorite; - final Value orientation; - final Value source; - final Value playbackStyle; - const TrashedLocalAssetEntityCompanion({ - this.name = const Value.absent(), - this.type = const Value.absent(), - this.createdAt = const Value.absent(), - this.updatedAt = const Value.absent(), - this.width = const Value.absent(), - this.height = const Value.absent(), - this.durationMs = const Value.absent(), - this.id = const Value.absent(), - this.albumId = const Value.absent(), - this.checksum = const Value.absent(), - this.isFavorite = const Value.absent(), - this.orientation = const Value.absent(), - this.source = const Value.absent(), - this.playbackStyle = const Value.absent(), - }); - TrashedLocalAssetEntityCompanion.insert({ - required String name, - required int type, - this.createdAt = const Value.absent(), - this.updatedAt = const Value.absent(), - this.width = const Value.absent(), - this.height = const Value.absent(), - this.durationMs = const Value.absent(), - required String id, - required String albumId, - this.checksum = const Value.absent(), - this.isFavorite = const Value.absent(), - this.orientation = const Value.absent(), - required int source, - this.playbackStyle = const Value.absent(), - }) : name = Value(name), - type = Value(type), - id = Value(id), - albumId = Value(albumId), - source = Value(source); - static Insertable custom({ - Expression? name, - Expression? type, - Expression? createdAt, - Expression? updatedAt, - Expression? width, - Expression? height, - Expression? durationMs, - Expression? id, - Expression? albumId, - Expression? checksum, - Expression? isFavorite, - Expression? orientation, - Expression? source, - Expression? playbackStyle, - }) { - return 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 (durationMs != null) 'duration_ms': durationMs, - if (id != null) 'id': id, - if (albumId != null) 'album_id': albumId, - if (checksum != null) 'checksum': checksum, - if (isFavorite != null) 'is_favorite': isFavorite, - if (orientation != null) 'orientation': orientation, - if (source != null) 'source': source, - if (playbackStyle != null) 'playback_style': playbackStyle, - }); - } - - TrashedLocalAssetEntityCompanion copyWith({ - Value? name, - Value? type, - Value? createdAt, - Value? updatedAt, - Value? width, - Value? height, - Value? durationMs, - Value? id, - Value? albumId, - Value? checksum, - Value? isFavorite, - Value? orientation, - Value? source, - Value? playbackStyle, - }) { - return TrashedLocalAssetEntityCompanion( - name: name ?? this.name, - type: type ?? this.type, - createdAt: createdAt ?? this.createdAt, - updatedAt: updatedAt ?? this.updatedAt, - width: width ?? this.width, - height: height ?? this.height, - durationMs: durationMs ?? this.durationMs, - id: id ?? this.id, - albumId: albumId ?? this.albumId, - checksum: checksum ?? this.checksum, - isFavorite: isFavorite ?? this.isFavorite, - orientation: orientation ?? this.orientation, - source: source ?? this.source, - playbackStyle: playbackStyle ?? this.playbackStyle, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (name.present) { - map['name'] = Variable(name.value); - } - if (type.present) { - map['type'] = Variable(type.value); - } - if (createdAt.present) { - map['created_at'] = Variable(createdAt.value); - } - if (updatedAt.present) { - map['updated_at'] = Variable(updatedAt.value); - } - if (width.present) { - map['width'] = Variable(width.value); - } - if (height.present) { - map['height'] = Variable(height.value); - } - if (durationMs.present) { - map['duration_ms'] = Variable(durationMs.value); - } - if (id.present) { - map['id'] = Variable(id.value); - } - if (albumId.present) { - map['album_id'] = Variable(albumId.value); - } - if (checksum.present) { - map['checksum'] = Variable(checksum.value); - } - if (isFavorite.present) { - map['is_favorite'] = Variable(isFavorite.value); - } - if (orientation.present) { - map['orientation'] = Variable(orientation.value); - } - if (source.present) { - map['source'] = Variable(source.value); - } - if (playbackStyle.present) { - map['playback_style'] = Variable(playbackStyle.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('TrashedLocalAssetEntityCompanion(') - ..write('name: $name, ') - ..write('type: $type, ') - ..write('createdAt: $createdAt, ') - ..write('updatedAt: $updatedAt, ') - ..write('width: $width, ') - ..write('height: $height, ') - ..write('durationMs: $durationMs, ') - ..write('id: $id, ') - ..write('albumId: $albumId, ') - ..write('checksum: $checksum, ') - ..write('isFavorite: $isFavorite, ') - ..write('orientation: $orientation, ') - ..write('source: $source, ') - ..write('playbackStyle: $playbackStyle') - ..write(')')) - .toString(); - } -} - -class AssetEditEntity extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - AssetEditEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn id = GeneratedColumn( - 'id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn assetId = GeneratedColumn( - 'asset_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: - 'NOT NULL REFERENCES remote_asset_entity(id)ON DELETE CASCADE', - ); - late final GeneratedColumn action = GeneratedColumn( - 'action', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn parameters = - GeneratedColumn( - 'parameters', - aliasedName, - false, - type: DriftSqlType.blob, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn sequence = GeneratedColumn( - 'sequence', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - @override - List get $columns => [ - id, - assetId, - action, - parameters, - sequence, - ]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'asset_edit_entity'; - @override - Set get $primaryKey => {id}; - @override - AssetEditEntityData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return AssetEditEntityData( - id: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}id'], - )!, - assetId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}asset_id'], - )!, - action: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}action'], - )!, - parameters: attachedDatabase.typeMapping.read( - DriftSqlType.blob, - data['${effectivePrefix}parameters'], - )!, - sequence: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}sequence'], - )!, - ); - } - - @override - AssetEditEntity createAlias(String alias) { - return AssetEditEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const ['PRIMARY KEY(id)']; - @override - bool get dontWriteConstraints => true; -} - -class AssetEditEntityData extends DataClass - implements Insertable { - final String id; - final String assetId; - final int action; - final i2.Uint8List parameters; - final int sequence; - const AssetEditEntityData({ - required this.id, - required this.assetId, - required this.action, - required this.parameters, - required this.sequence, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['id'] = Variable(id); - map['asset_id'] = Variable(assetId); - map['action'] = Variable(action); - map['parameters'] = Variable(parameters); - map['sequence'] = Variable(sequence); - return map; - } - - factory AssetEditEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return AssetEditEntityData( - id: serializer.fromJson(json['id']), - assetId: serializer.fromJson(json['assetId']), - action: serializer.fromJson(json['action']), - parameters: serializer.fromJson(json['parameters']), - sequence: serializer.fromJson(json['sequence']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'id': serializer.toJson(id), - 'assetId': serializer.toJson(assetId), - 'action': serializer.toJson(action), - 'parameters': serializer.toJson(parameters), - 'sequence': serializer.toJson(sequence), - }; - } - - AssetEditEntityData copyWith({ - String? id, - String? assetId, - int? action, - i2.Uint8List? parameters, - int? sequence, - }) => AssetEditEntityData( - id: id ?? this.id, - assetId: assetId ?? this.assetId, - action: action ?? this.action, - parameters: parameters ?? this.parameters, - sequence: sequence ?? this.sequence, - ); - AssetEditEntityData copyWithCompanion(AssetEditEntityCompanion data) { - return AssetEditEntityData( - id: data.id.present ? data.id.value : this.id, - assetId: data.assetId.present ? data.assetId.value : this.assetId, - action: data.action.present ? data.action.value : this.action, - parameters: data.parameters.present - ? data.parameters.value - : this.parameters, - sequence: data.sequence.present ? data.sequence.value : this.sequence, - ); - } - - @override - String toString() { - return (StringBuffer('AssetEditEntityData(') - ..write('id: $id, ') - ..write('assetId: $assetId, ') - ..write('action: $action, ') - ..write('parameters: $parameters, ') - ..write('sequence: $sequence') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash( - id, - assetId, - action, - $driftBlobEquality.hash(parameters), - sequence, - ); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is AssetEditEntityData && - other.id == this.id && - other.assetId == this.assetId && - other.action == this.action && - $driftBlobEquality.equals(other.parameters, this.parameters) && - other.sequence == this.sequence); -} - -class AssetEditEntityCompanion extends UpdateCompanion { - final Value id; - final Value assetId; - final Value action; - final Value parameters; - final Value sequence; - const AssetEditEntityCompanion({ - this.id = const Value.absent(), - this.assetId = const Value.absent(), - this.action = const Value.absent(), - this.parameters = const Value.absent(), - this.sequence = const Value.absent(), - }); - AssetEditEntityCompanion.insert({ - required String id, - required String assetId, - required int action, - required i2.Uint8List parameters, - required int sequence, - }) : id = Value(id), - assetId = Value(assetId), - action = Value(action), - parameters = Value(parameters), - sequence = Value(sequence); - static Insertable custom({ - Expression? id, - Expression? assetId, - Expression? action, - Expression? parameters, - Expression? sequence, - }) { - return RawValuesInsertable({ - if (id != null) 'id': id, - if (assetId != null) 'asset_id': assetId, - if (action != null) 'action': action, - if (parameters != null) 'parameters': parameters, - if (sequence != null) 'sequence': sequence, - }); - } - - AssetEditEntityCompanion copyWith({ - Value? id, - Value? assetId, - Value? action, - Value? parameters, - Value? sequence, - }) { - return AssetEditEntityCompanion( - id: id ?? this.id, - assetId: assetId ?? this.assetId, - action: action ?? this.action, - parameters: parameters ?? this.parameters, - sequence: sequence ?? this.sequence, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (id.present) { - map['id'] = Variable(id.value); - } - if (assetId.present) { - map['asset_id'] = Variable(assetId.value); - } - if (action.present) { - map['action'] = Variable(action.value); - } - if (parameters.present) { - map['parameters'] = Variable(parameters.value); - } - if (sequence.present) { - map['sequence'] = Variable(sequence.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('AssetEditEntityCompanion(') - ..write('id: $id, ') - ..write('assetId: $assetId, ') - ..write('action: $action, ') - ..write('parameters: $parameters, ') - ..write('sequence: $sequence') - ..write(')')) - .toString(); - } -} - -class Settings extends Table with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - Settings(this.attachedDatabase, [this._alias]); - late final GeneratedColumn key = GeneratedColumn( - 'key', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn value = GeneratedColumn( - 'value', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn updatedAt = GeneratedColumn( - 'updated_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', - defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), - ); - @override - List get $columns => [key, value, updatedAt]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'settings'; - @override - Set get $primaryKey => {key}; - @override - SettingsData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return SettingsData( - key: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}key'], - )!, - value: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}value'], - ), - updatedAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}updated_at'], - )!, - ); - } - - @override - Settings createAlias(String alias) { - return Settings(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const ['PRIMARY KEY("key")']; - @override - bool get dontWriteConstraints => true; -} - -class SettingsData extends DataClass implements Insertable { - final String key; - final String? value; - final String updatedAt; - const SettingsData({required this.key, this.value, required this.updatedAt}); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['key'] = Variable(key); - if (!nullToAbsent || value != null) { - map['value'] = Variable(value); - } - map['updated_at'] = Variable(updatedAt); - return map; - } - - factory SettingsData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return SettingsData( - key: serializer.fromJson(json['key']), - value: serializer.fromJson(json['value']), - updatedAt: serializer.fromJson(json['updatedAt']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'key': serializer.toJson(key), - 'value': serializer.toJson(value), - 'updatedAt': serializer.toJson(updatedAt), - }; - } - - SettingsData copyWith({ - String? key, - Value value = const Value.absent(), - String? updatedAt, - }) => SettingsData( - key: key ?? this.key, - value: value.present ? value.value : this.value, - updatedAt: updatedAt ?? this.updatedAt, - ); - SettingsData copyWithCompanion(SettingsCompanion data) { - return SettingsData( - key: data.key.present ? data.key.value : this.key, - value: data.value.present ? data.value.value : this.value, - updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, - ); - } - - @override - String toString() { - return (StringBuffer('SettingsData(') - ..write('key: $key, ') - ..write('value: $value, ') - ..write('updatedAt: $updatedAt') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash(key, value, updatedAt); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is SettingsData && - other.key == this.key && - other.value == this.value && - other.updatedAt == this.updatedAt); -} - -class SettingsCompanion extends UpdateCompanion { - final Value key; - final Value value; - final Value updatedAt; - const SettingsCompanion({ - this.key = const Value.absent(), - this.value = const Value.absent(), - this.updatedAt = const Value.absent(), - }); - SettingsCompanion.insert({ - required String key, - this.value = const Value.absent(), - this.updatedAt = const Value.absent(), - }) : key = Value(key); - static Insertable custom({ - Expression? key, - Expression? value, - Expression? updatedAt, - }) { - return RawValuesInsertable({ - if (key != null) 'key': key, - if (value != null) 'value': value, - if (updatedAt != null) 'updated_at': updatedAt, - }); - } - - SettingsCompanion copyWith({ - Value? key, - Value? value, - Value? updatedAt, - }) { - return SettingsCompanion( - key: key ?? this.key, - value: value ?? this.value, - updatedAt: updatedAt ?? this.updatedAt, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (key.present) { - map['key'] = Variable(key.value); - } - if (value.present) { - map['value'] = Variable(value.value); - } - if (updatedAt.present) { - map['updated_at'] = Variable(updatedAt.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('SettingsCompanion(') - ..write('key: $key, ') - ..write('value: $value, ') - ..write('updatedAt: $updatedAt') - ..write(')')) - .toString(); - } -} - -class AssetOcrEntity extends Table - with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - AssetOcrEntity(this.attachedDatabase, [this._alias]); - late final GeneratedColumn id = GeneratedColumn( - 'id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn assetId = GeneratedColumn( - 'asset_id', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: - 'NOT NULL REFERENCES remote_asset_entity(id)ON DELETE CASCADE', - ); - late final GeneratedColumn x1 = GeneratedColumn( - 'x1', - aliasedName, - false, - type: DriftSqlType.double, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn y1 = GeneratedColumn( - 'y1', - aliasedName, - false, - type: DriftSqlType.double, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn x2 = GeneratedColumn( - 'x2', - aliasedName, - false, - type: DriftSqlType.double, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn y2 = GeneratedColumn( - 'y2', - aliasedName, - false, - type: DriftSqlType.double, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn x3 = GeneratedColumn( - 'x3', - aliasedName, - false, - type: DriftSqlType.double, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn y3 = GeneratedColumn( - 'y3', - aliasedName, - false, - type: DriftSqlType.double, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn x4 = GeneratedColumn( - 'x4', - aliasedName, - false, - type: DriftSqlType.double, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn y4 = GeneratedColumn( - 'y4', - aliasedName, - false, - type: DriftSqlType.double, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn boxScore = GeneratedColumn( - 'box_score', - aliasedName, - false, - type: DriftSqlType.double, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn textScore = GeneratedColumn( - 'text_score', - aliasedName, - false, - type: DriftSqlType.double, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn recognizedText = GeneratedColumn( - 'recognized_text', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn isVisible = GeneratedColumn( - 'is_visible', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT 1 CHECK (is_visible IN (0, 1))', - defaultValue: const CustomExpression('1'), - ); - @override - List get $columns => [ - id, - assetId, - x1, - y1, - x2, - y2, - x3, - y3, - x4, - y4, - boxScore, - textScore, - recognizedText, - isVisible, - ]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'asset_ocr_entity'; - @override - Set get $primaryKey => {id}; - @override - AssetOcrEntityData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return AssetOcrEntityData( - id: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}id'], - )!, - assetId: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}asset_id'], - )!, - x1: attachedDatabase.typeMapping.read( - DriftSqlType.double, - data['${effectivePrefix}x1'], - )!, - y1: attachedDatabase.typeMapping.read( - DriftSqlType.double, - data['${effectivePrefix}y1'], - )!, - x2: attachedDatabase.typeMapping.read( - DriftSqlType.double, - data['${effectivePrefix}x2'], - )!, - y2: attachedDatabase.typeMapping.read( - DriftSqlType.double, - data['${effectivePrefix}y2'], - )!, - x3: attachedDatabase.typeMapping.read( - DriftSqlType.double, - data['${effectivePrefix}x3'], - )!, - y3: attachedDatabase.typeMapping.read( - DriftSqlType.double, - data['${effectivePrefix}y3'], - )!, - x4: attachedDatabase.typeMapping.read( - DriftSqlType.double, - data['${effectivePrefix}x4'], - )!, - y4: attachedDatabase.typeMapping.read( - DriftSqlType.double, - data['${effectivePrefix}y4'], - )!, - boxScore: attachedDatabase.typeMapping.read( - DriftSqlType.double, - data['${effectivePrefix}box_score'], - )!, - textScore: attachedDatabase.typeMapping.read( - DriftSqlType.double, - data['${effectivePrefix}text_score'], - )!, - recognizedText: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}recognized_text'], - )!, - isVisible: attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}is_visible'], - )!, - ); - } - - @override - AssetOcrEntity createAlias(String alias) { - return AssetOcrEntity(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const ['PRIMARY KEY(id)']; - @override - bool get dontWriteConstraints => true; -} - -class AssetOcrEntityData extends DataClass - implements Insertable { - final String id; - final String assetId; - final double x1; - final double y1; - final double x2; - final double y2; - final double x3; - final double y3; - final double x4; - final double y4; - final double boxScore; - final double textScore; - final String recognizedText; - final int isVisible; - const AssetOcrEntityData({ - required this.id, - required this.assetId, - required this.x1, - required this.y1, - required this.x2, - required this.y2, - required this.x3, - required this.y3, - required this.x4, - required this.y4, - required this.boxScore, - required this.textScore, - required this.recognizedText, - required this.isVisible, - }); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['id'] = Variable(id); - map['asset_id'] = Variable(assetId); - map['x1'] = Variable(x1); - map['y1'] = Variable(y1); - map['x2'] = Variable(x2); - map['y2'] = Variable(y2); - map['x3'] = Variable(x3); - map['y3'] = Variable(y3); - map['x4'] = Variable(x4); - map['y4'] = Variable(y4); - map['box_score'] = Variable(boxScore); - map['text_score'] = Variable(textScore); - map['recognized_text'] = Variable(recognizedText); - map['is_visible'] = Variable(isVisible); - return map; - } - - factory AssetOcrEntityData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return AssetOcrEntityData( - id: serializer.fromJson(json['id']), - assetId: serializer.fromJson(json['assetId']), - x1: serializer.fromJson(json['x1']), - y1: serializer.fromJson(json['y1']), - x2: serializer.fromJson(json['x2']), - y2: serializer.fromJson(json['y2']), - x3: serializer.fromJson(json['x3']), - y3: serializer.fromJson(json['y3']), - x4: serializer.fromJson(json['x4']), - y4: serializer.fromJson(json['y4']), - boxScore: serializer.fromJson(json['boxScore']), - textScore: serializer.fromJson(json['textScore']), - recognizedText: serializer.fromJson(json['recognizedText']), - isVisible: serializer.fromJson(json['isVisible']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'id': serializer.toJson(id), - 'assetId': serializer.toJson(assetId), - 'x1': serializer.toJson(x1), - 'y1': serializer.toJson(y1), - 'x2': serializer.toJson(x2), - 'y2': serializer.toJson(y2), - 'x3': serializer.toJson(x3), - 'y3': serializer.toJson(y3), - 'x4': serializer.toJson(x4), - 'y4': serializer.toJson(y4), - 'boxScore': serializer.toJson(boxScore), - 'textScore': serializer.toJson(textScore), - 'recognizedText': serializer.toJson(recognizedText), - 'isVisible': serializer.toJson(isVisible), - }; - } - - AssetOcrEntityData copyWith({ - String? id, - String? assetId, - double? x1, - double? y1, - double? x2, - double? y2, - double? x3, - double? y3, - double? x4, - double? y4, - double? boxScore, - double? textScore, - String? recognizedText, - int? isVisible, - }) => AssetOcrEntityData( - id: id ?? this.id, - assetId: assetId ?? this.assetId, - x1: x1 ?? this.x1, - y1: y1 ?? this.y1, - x2: x2 ?? this.x2, - y2: y2 ?? this.y2, - x3: x3 ?? this.x3, - y3: y3 ?? this.y3, - x4: x4 ?? this.x4, - y4: y4 ?? this.y4, - boxScore: boxScore ?? this.boxScore, - textScore: textScore ?? this.textScore, - recognizedText: recognizedText ?? this.recognizedText, - isVisible: isVisible ?? this.isVisible, - ); - AssetOcrEntityData copyWithCompanion(AssetOcrEntityCompanion data) { - return AssetOcrEntityData( - id: data.id.present ? data.id.value : this.id, - assetId: data.assetId.present ? data.assetId.value : this.assetId, - x1: data.x1.present ? data.x1.value : this.x1, - y1: data.y1.present ? data.y1.value : this.y1, - x2: data.x2.present ? data.x2.value : this.x2, - y2: data.y2.present ? data.y2.value : this.y2, - x3: data.x3.present ? data.x3.value : this.x3, - y3: data.y3.present ? data.y3.value : this.y3, - x4: data.x4.present ? data.x4.value : this.x4, - y4: data.y4.present ? data.y4.value : this.y4, - boxScore: data.boxScore.present ? data.boxScore.value : this.boxScore, - textScore: data.textScore.present ? data.textScore.value : this.textScore, - recognizedText: data.recognizedText.present - ? data.recognizedText.value - : this.recognizedText, - isVisible: data.isVisible.present ? data.isVisible.value : this.isVisible, - ); - } - - @override - String toString() { - return (StringBuffer('AssetOcrEntityData(') - ..write('id: $id, ') - ..write('assetId: $assetId, ') - ..write('x1: $x1, ') - ..write('y1: $y1, ') - ..write('x2: $x2, ') - ..write('y2: $y2, ') - ..write('x3: $x3, ') - ..write('y3: $y3, ') - ..write('x4: $x4, ') - ..write('y4: $y4, ') - ..write('boxScore: $boxScore, ') - ..write('textScore: $textScore, ') - ..write('recognizedText: $recognizedText, ') - ..write('isVisible: $isVisible') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash( - id, - assetId, - x1, - y1, - x2, - y2, - x3, - y3, - x4, - y4, - boxScore, - textScore, - recognizedText, - isVisible, - ); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is AssetOcrEntityData && - other.id == this.id && - other.assetId == this.assetId && - other.x1 == this.x1 && - other.y1 == this.y1 && - other.x2 == this.x2 && - other.y2 == this.y2 && - other.x3 == this.x3 && - other.y3 == this.y3 && - other.x4 == this.x4 && - other.y4 == this.y4 && - other.boxScore == this.boxScore && - other.textScore == this.textScore && - other.recognizedText == this.recognizedText && - other.isVisible == this.isVisible); -} - -class AssetOcrEntityCompanion extends UpdateCompanion { - final Value id; - final Value assetId; - final Value x1; - final Value y1; - final Value x2; - final Value y2; - final Value x3; - final Value y3; - final Value x4; - final Value y4; - final Value boxScore; - final Value textScore; - final Value recognizedText; - final Value isVisible; - const AssetOcrEntityCompanion({ - this.id = const Value.absent(), - this.assetId = const Value.absent(), - this.x1 = const Value.absent(), - this.y1 = const Value.absent(), - this.x2 = const Value.absent(), - this.y2 = const Value.absent(), - this.x3 = const Value.absent(), - this.y3 = const Value.absent(), - this.x4 = const Value.absent(), - this.y4 = const Value.absent(), - this.boxScore = const Value.absent(), - this.textScore = const Value.absent(), - this.recognizedText = const Value.absent(), - this.isVisible = const Value.absent(), - }); - AssetOcrEntityCompanion.insert({ - required String id, - required String assetId, - required double x1, - required double y1, - required double x2, - required double y2, - required double x3, - required double y3, - required double x4, - required double y4, - required double boxScore, - required double textScore, - required String recognizedText, - this.isVisible = const Value.absent(), - }) : id = Value(id), - assetId = Value(assetId), - x1 = Value(x1), - y1 = Value(y1), - x2 = Value(x2), - y2 = Value(y2), - x3 = Value(x3), - y3 = Value(y3), - x4 = Value(x4), - y4 = Value(y4), - boxScore = Value(boxScore), - textScore = Value(textScore), - recognizedText = Value(recognizedText); - static Insertable custom({ - Expression? id, - Expression? assetId, - Expression? x1, - Expression? y1, - Expression? x2, - Expression? y2, - Expression? x3, - Expression? y3, - Expression? x4, - Expression? y4, - Expression? boxScore, - Expression? textScore, - Expression? recognizedText, - Expression? isVisible, - }) { - return RawValuesInsertable({ - if (id != null) 'id': id, - if (assetId != null) 'asset_id': assetId, - if (x1 != null) 'x1': x1, - if (y1 != null) 'y1': y1, - if (x2 != null) 'x2': x2, - if (y2 != null) 'y2': y2, - if (x3 != null) 'x3': x3, - if (y3 != null) 'y3': y3, - if (x4 != null) 'x4': x4, - if (y4 != null) 'y4': y4, - if (boxScore != null) 'box_score': boxScore, - if (textScore != null) 'text_score': textScore, - if (recognizedText != null) 'recognized_text': recognizedText, - if (isVisible != null) 'is_visible': isVisible, - }); - } - - AssetOcrEntityCompanion copyWith({ - Value? id, - Value? assetId, - Value? x1, - Value? y1, - Value? x2, - Value? y2, - Value? x3, - Value? y3, - Value? x4, - Value? y4, - Value? boxScore, - Value? textScore, - Value? recognizedText, - Value? isVisible, - }) { - return AssetOcrEntityCompanion( - id: id ?? this.id, - assetId: assetId ?? this.assetId, - x1: x1 ?? this.x1, - y1: y1 ?? this.y1, - x2: x2 ?? this.x2, - y2: y2 ?? this.y2, - x3: x3 ?? this.x3, - y3: y3 ?? this.y3, - x4: x4 ?? this.x4, - y4: y4 ?? this.y4, - boxScore: boxScore ?? this.boxScore, - textScore: textScore ?? this.textScore, - recognizedText: recognizedText ?? this.recognizedText, - isVisible: isVisible ?? this.isVisible, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (id.present) { - map['id'] = Variable(id.value); - } - if (assetId.present) { - map['asset_id'] = Variable(assetId.value); - } - if (x1.present) { - map['x1'] = Variable(x1.value); - } - if (y1.present) { - map['y1'] = Variable(y1.value); - } - if (x2.present) { - map['x2'] = Variable(x2.value); - } - if (y2.present) { - map['y2'] = Variable(y2.value); - } - if (x3.present) { - map['x3'] = Variable(x3.value); - } - if (y3.present) { - map['y3'] = Variable(y3.value); - } - if (x4.present) { - map['x4'] = Variable(x4.value); - } - if (y4.present) { - map['y4'] = Variable(y4.value); - } - if (boxScore.present) { - map['box_score'] = Variable(boxScore.value); - } - if (textScore.present) { - map['text_score'] = Variable(textScore.value); - } - if (recognizedText.present) { - map['recognized_text'] = Variable(recognizedText.value); - } - if (isVisible.present) { - map['is_visible'] = Variable(isVisible.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('AssetOcrEntityCompanion(') - ..write('id: $id, ') - ..write('assetId: $assetId, ') - ..write('x1: $x1, ') - ..write('y1: $y1, ') - ..write('x2: $x2, ') - ..write('y2: $y2, ') - ..write('x3: $x3, ') - ..write('y3: $y3, ') - ..write('x4: $x4, ') - ..write('y4: $y4, ') - ..write('boxScore: $boxScore, ') - ..write('textScore: $textScore, ') - ..write('recognizedText: $recognizedText, ') - ..write('isVisible: $isVisible') - ..write(')')) - .toString(); - } -} - -class Session extends Table with TableInfo { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - Session(this.attachedDatabase, [this._alias]); - late final GeneratedColumn key = GeneratedColumn( - 'key', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: true, - $customConstraints: 'NOT NULL', - ); - late final GeneratedColumn value = GeneratedColumn( - 'value', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NULL', - ); - late final GeneratedColumn updatedAt = GeneratedColumn( - 'updated_at', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: 'NOT NULL DEFAULT CURRENT_TIMESTAMP', - defaultValue: const CustomExpression('CURRENT_TIMESTAMP'), - ); - @override - List get $columns => [key, value, updatedAt]; - @override - String get aliasedName => _alias ?? actualTableName; - @override - String get actualTableName => $name; - static const String $name = 'session'; - @override - Set get $primaryKey => {key}; - @override - SessionData map(Map data, {String? tablePrefix}) { - final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; - return SessionData( - key: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}key'], - )!, - value: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}value'], - ), - updatedAt: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}updated_at'], - )!, - ); - } - - @override - Session createAlias(String alias) { - return Session(attachedDatabase, alias); - } - - @override - bool get withoutRowId => true; - @override - bool get isStrict => true; - @override - List get customConstraints => const ['PRIMARY KEY("key")']; - @override - bool get dontWriteConstraints => true; -} - -class SessionData extends DataClass implements Insertable { - final String key; - final String? value; - final String updatedAt; - const SessionData({required this.key, this.value, required this.updatedAt}); - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - map['key'] = Variable(key); - if (!nullToAbsent || value != null) { - map['value'] = Variable(value); - } - map['updated_at'] = Variable(updatedAt); - return map; - } - - factory SessionData.fromJson( - Map json, { - ValueSerializer? serializer, - }) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return SessionData( - key: serializer.fromJson(json['key']), - value: serializer.fromJson(json['value']), - updatedAt: serializer.fromJson(json['updatedAt']), - ); - } - @override - Map toJson({ValueSerializer? serializer}) { - serializer ??= driftRuntimeOptions.defaultSerializer; - return { - 'key': serializer.toJson(key), - 'value': serializer.toJson(value), - 'updatedAt': serializer.toJson(updatedAt), - }; - } - - SessionData copyWith({ - String? key, - Value value = const Value.absent(), - String? updatedAt, - }) => SessionData( - key: key ?? this.key, - value: value.present ? value.value : this.value, - updatedAt: updatedAt ?? this.updatedAt, - ); - SessionData copyWithCompanion(SessionCompanion data) { - return SessionData( - key: data.key.present ? data.key.value : this.key, - value: data.value.present ? data.value.value : this.value, - updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, - ); - } - - @override - String toString() { - return (StringBuffer('SessionData(') - ..write('key: $key, ') - ..write('value: $value, ') - ..write('updatedAt: $updatedAt') - ..write(')')) - .toString(); - } - - @override - int get hashCode => Object.hash(key, value, updatedAt); - @override - bool operator ==(Object other) => - identical(this, other) || - (other is SessionData && - other.key == this.key && - other.value == this.value && - other.updatedAt == this.updatedAt); -} - -class SessionCompanion extends UpdateCompanion { - final Value key; - final Value value; - final Value updatedAt; - const SessionCompanion({ - this.key = const Value.absent(), - this.value = const Value.absent(), - this.updatedAt = const Value.absent(), - }); - SessionCompanion.insert({ - required String key, - this.value = const Value.absent(), - this.updatedAt = const Value.absent(), - }) : key = Value(key); - static Insertable custom({ - Expression? key, - Expression? value, - Expression? updatedAt, - }) { - return RawValuesInsertable({ - if (key != null) 'key': key, - if (value != null) 'value': value, - if (updatedAt != null) 'updated_at': updatedAt, - }); - } - - SessionCompanion copyWith({ - Value? key, - Value? value, - Value? updatedAt, - }) { - return SessionCompanion( - key: key ?? this.key, - value: value ?? this.value, - updatedAt: updatedAt ?? this.updatedAt, - ); - } - - @override - Map toColumns(bool nullToAbsent) { - final map = {}; - if (key.present) { - map['key'] = Variable(key.value); - } - if (value.present) { - map['value'] = Variable(value.value); - } - if (updatedAt.present) { - map['updated_at'] = Variable(updatedAt.value); - } - return map; - } - - @override - String toString() { - return (StringBuffer('SessionCompanion(') - ..write('key: $key, ') - ..write('value: $value, ') - ..write('updatedAt: $updatedAt') - ..write(')')) - .toString(); - } -} - -class DatabaseAtV32 extends GeneratedDatabase { - DatabaseAtV32(QueryExecutor e) : super(e); - late final UserEntity userEntity = UserEntity(this); - late final RemoteAssetEntity remoteAssetEntity = RemoteAssetEntity(this); - late final StackEntity stackEntity = StackEntity(this); - late final LocalAssetEntity localAssetEntity = LocalAssetEntity(this); - late final RemoteAlbumEntity remoteAlbumEntity = RemoteAlbumEntity(this); - late final LocalAlbumEntity localAlbumEntity = LocalAlbumEntity(this); - late final LocalAlbumAssetEntity localAlbumAssetEntity = - LocalAlbumAssetEntity(this); - late final Index idxLocalAlbumAssetAlbumAsset = Index( - 'idx_local_album_asset_album_asset', - 'CREATE INDEX IF NOT EXISTS idx_local_album_asset_album_asset ON local_album_asset_entity (album_id, asset_id)', - ); - late final Index idxLocalAssetChecksum = Index( - 'idx_local_asset_checksum', - 'CREATE INDEX IF NOT EXISTS idx_local_asset_checksum ON local_asset_entity (checksum)', - ); - late final Index idxLocalAssetCloudId = Index( - 'idx_local_asset_cloud_id', - 'CREATE INDEX IF NOT EXISTS idx_local_asset_cloud_id ON local_asset_entity (i_cloud_id)', - ); - late final Index idxLocalAssetCreatedAt = Index( - 'idx_local_asset_created_at', - 'CREATE INDEX IF NOT EXISTS idx_local_asset_created_at ON local_asset_entity (created_at)', - ); - late final Index idxStackPrimaryAssetId = Index( - 'idx_stack_primary_asset_id', - 'CREATE INDEX IF NOT EXISTS idx_stack_primary_asset_id ON stack_entity (primary_asset_id)', - ); - late final Index uQRemoteAssetsOwnerChecksum = Index( - 'UQ_remote_assets_owner_checksum', - 'CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_checksum ON remote_asset_entity (owner_id, checksum) WHERE(library_id IS NULL)', - ); - late final Index uQRemoteAssetsOwnerLibraryChecksum = Index( - 'UQ_remote_assets_owner_library_checksum', - 'CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_library_checksum ON remote_asset_entity (owner_id, library_id, checksum) WHERE(library_id IS NOT NULL)', - ); - late final Index idxRemoteAssetChecksum = Index( - 'idx_remote_asset_checksum', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_checksum ON remote_asset_entity (checksum)', - ); - late final Index idxRemoteAssetStackId = Index( - 'idx_remote_asset_stack_id', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_stack_id ON remote_asset_entity (stack_id)', - ); - late final Index idxRemoteAssetOwnerVisibilityDeletedCreated = Index( - 'idx_remote_asset_owner_visibility_deleted_created', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_visibility_deleted_created ON remote_asset_entity (owner_id, visibility, deleted_at, created_at DESC)', - ); - late final Index idxRemoteAssetUploaded = Index( - 'idx_remote_asset_uploaded', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_uploaded ON remote_asset_entity (uploaded_at)', - ); - late final AuthUserEntity authUserEntity = AuthUserEntity(this); - late final UserMetadataEntity userMetadataEntity = UserMetadataEntity(this); - late final PartnerEntity partnerEntity = PartnerEntity(this); - late final RemoteExifEntity remoteExifEntity = RemoteExifEntity(this); - late final RemoteAlbumAssetEntity remoteAlbumAssetEntity = - RemoteAlbumAssetEntity(this); - late final RemoteAlbumUserEntity remoteAlbumUserEntity = - RemoteAlbumUserEntity(this); - late final RemoteAssetCloudIdEntity remoteAssetCloudIdEntity = - RemoteAssetCloudIdEntity(this); - late final MemoryEntity memoryEntity = MemoryEntity(this); - late final MemoryAssetEntity memoryAssetEntity = MemoryAssetEntity(this); - late final PersonEntity personEntity = PersonEntity(this); - late final AssetFaceEntity assetFaceEntity = AssetFaceEntity(this); - late final StoreEntity storeEntity = StoreEntity(this); - late final TrashedLocalAssetEntity trashedLocalAssetEntity = - TrashedLocalAssetEntity(this); - late final AssetEditEntity assetEditEntity = AssetEditEntity(this); - late final Settings settings = Settings(this); - late final AssetOcrEntity assetOcrEntity = AssetOcrEntity(this); - late final Session session = Session(this); - late final Index idxPartnerSharedWithId = Index( - 'idx_partner_shared_with_id', - 'CREATE INDEX IF NOT EXISTS idx_partner_shared_with_id ON partner_entity (shared_with_id)', - ); - late final Index idxLatLng = Index( - 'idx_lat_lng', - 'CREATE INDEX IF NOT EXISTS idx_lat_lng ON remote_exif_entity (latitude, longitude)', - ); - late final Index idxRemoteExifCity = Index( - 'idx_remote_exif_city', - 'CREATE INDEX IF NOT EXISTS idx_remote_exif_city ON remote_exif_entity (city) WHERE city IS NOT NULL', - ); - late final Index idxRemoteAlbumAssetAlbumAsset = Index( - 'idx_remote_album_asset_album_asset', - 'CREATE INDEX IF NOT EXISTS idx_remote_album_asset_album_asset ON remote_album_asset_entity (album_id, asset_id)', - ); - late final Index idxRemoteAssetCloudId = Index( - 'idx_remote_asset_cloud_id', - 'CREATE INDEX IF NOT EXISTS idx_remote_asset_cloud_id ON remote_asset_cloud_id_entity (cloud_id)', - ); - late final Index idxPersonOwnerId = Index( - 'idx_person_owner_id', - 'CREATE INDEX IF NOT EXISTS idx_person_owner_id ON person_entity (owner_id)', - ); - late final Index idxAssetFacePersonId = Index( - 'idx_asset_face_person_id', - 'CREATE INDEX IF NOT EXISTS idx_asset_face_person_id ON asset_face_entity (person_id)', - ); - late final Index idxAssetFaceAssetId = Index( - 'idx_asset_face_asset_id', - 'CREATE INDEX IF NOT EXISTS idx_asset_face_asset_id ON asset_face_entity (asset_id)', - ); - late final Index idxAssetFaceVisiblePerson = Index( - 'idx_asset_face_visible_person', - 'CREATE INDEX IF NOT EXISTS idx_asset_face_visible_person ON asset_face_entity (person_id, asset_id) WHERE is_visible = 1 AND deleted_at IS NULL', - ); - late final Index idxTrashedLocalAssetChecksum = Index( - 'idx_trashed_local_asset_checksum', - 'CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_checksum ON trashed_local_asset_entity (checksum)', - ); - late final Index idxTrashedLocalAssetAlbum = Index( - 'idx_trashed_local_asset_album', - 'CREATE INDEX IF NOT EXISTS idx_trashed_local_asset_album ON trashed_local_asset_entity (album_id)', - ); - late final Index idxAssetEditAssetId = Index( - 'idx_asset_edit_asset_id', - 'CREATE INDEX IF NOT EXISTS idx_asset_edit_asset_id ON asset_edit_entity (asset_id)', - ); - late final Index idxAssetOcrAssetId = Index( - 'idx_asset_ocr_asset_id', - 'CREATE INDEX IF NOT EXISTS idx_asset_ocr_asset_id ON asset_ocr_entity (asset_id)', - ); - @override - Iterable> get allTables => - allSchemaEntities.whereType>(); - @override - List get allSchemaEntities => [ - userEntity, - remoteAssetEntity, - stackEntity, - localAssetEntity, - remoteAlbumEntity, - localAlbumEntity, - localAlbumAssetEntity, - idxLocalAlbumAssetAlbumAsset, - idxLocalAssetChecksum, - idxLocalAssetCloudId, - idxLocalAssetCreatedAt, - idxStackPrimaryAssetId, - uQRemoteAssetsOwnerChecksum, - uQRemoteAssetsOwnerLibraryChecksum, - idxRemoteAssetChecksum, - idxRemoteAssetStackId, - idxRemoteAssetOwnerVisibilityDeletedCreated, - idxRemoteAssetUploaded, - authUserEntity, - userMetadataEntity, - partnerEntity, - remoteExifEntity, - remoteAlbumAssetEntity, - remoteAlbumUserEntity, - remoteAssetCloudIdEntity, - memoryEntity, - memoryAssetEntity, - personEntity, - assetFaceEntity, - storeEntity, - trashedLocalAssetEntity, - assetEditEntity, - settings, - assetOcrEntity, - session, - idxPartnerSharedWithId, - idxLatLng, - idxRemoteExifCity, - idxRemoteAlbumAssetAlbumAsset, - idxRemoteAssetCloudId, - idxPersonOwnerId, - idxAssetFacePersonId, - idxAssetFaceAssetId, - idxAssetFaceVisiblePerson, - idxTrashedLocalAssetChecksum, - idxTrashedLocalAssetAlbum, - idxAssetEditAssetId, - idxAssetOcrAssetId, - ]; - @override - StreamQueryUpdateRules get streamUpdateRules => const StreamQueryUpdateRules([ - WritePropagation( - on: TableUpdateQuery.onTableName( - 'user_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [TableUpdate('remote_asset_entity', kind: UpdateKind.delete)], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'user_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [TableUpdate('stack_entity', kind: UpdateKind.delete)], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'remote_asset_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [TableUpdate('remote_album_entity', kind: UpdateKind.update)], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'remote_album_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [TableUpdate('local_album_entity', kind: UpdateKind.update)], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'local_asset_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [ - TableUpdate('local_album_asset_entity', kind: UpdateKind.delete), - ], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'local_album_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [ - TableUpdate('local_album_asset_entity', kind: UpdateKind.delete), - ], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'user_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [TableUpdate('user_metadata_entity', kind: UpdateKind.delete)], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'user_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [TableUpdate('partner_entity', kind: UpdateKind.delete)], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'user_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [TableUpdate('partner_entity', kind: UpdateKind.delete)], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'remote_asset_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [TableUpdate('remote_exif_entity', kind: UpdateKind.delete)], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'remote_asset_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [ - TableUpdate('remote_album_asset_entity', kind: UpdateKind.delete), - ], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'remote_album_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [ - TableUpdate('remote_album_asset_entity', kind: UpdateKind.delete), - ], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'remote_album_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [ - TableUpdate('remote_album_user_entity', kind: UpdateKind.delete), - ], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'user_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [ - TableUpdate('remote_album_user_entity', kind: UpdateKind.delete), - ], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'remote_asset_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [ - TableUpdate('remote_asset_cloud_id_entity', kind: UpdateKind.delete), - ], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'user_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [TableUpdate('memory_entity', kind: UpdateKind.delete)], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'remote_asset_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [TableUpdate('memory_asset_entity', kind: UpdateKind.delete)], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'memory_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [TableUpdate('memory_asset_entity', kind: UpdateKind.delete)], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'user_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [TableUpdate('person_entity', kind: UpdateKind.delete)], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'remote_asset_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [TableUpdate('asset_face_entity', kind: UpdateKind.delete)], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'person_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [TableUpdate('asset_face_entity', kind: UpdateKind.update)], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'remote_asset_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [TableUpdate('asset_edit_entity', kind: UpdateKind.delete)], - ), - WritePropagation( - on: TableUpdateQuery.onTableName( - 'remote_asset_entity', - limitUpdateKind: UpdateKind.delete, - ), - result: [TableUpdate('asset_ocr_entity', kind: UpdateKind.delete)], - ), - ]); - @override - int get schemaVersion => 32; - @override - DriftDatabaseOptions get options => - const DriftDatabaseOptions(storeDateTimeAsText: true); -} diff --git a/mobile/test/unit/presentation/presentation_context.dart b/mobile/test/unit/presentation/presentation_context.dart index 8671371070..95aa6c9dfe 100644 --- a/mobile/test/unit/presentation/presentation_context.dart +++ b/mobile/test/unit/presentation/presentation_context.dart @@ -5,11 +5,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:immich_mobile/constants/locales.dart'; +import 'package:immich_mobile/domain/models/asset/base_asset.model.dart'; import 'package:immich_mobile/domain/models/user.model.dart'; import 'package:immich_mobile/domain/services/store.service.dart'; import 'package:immich_mobile/generated/codegen_loader.g.dart'; import 'package:immich_mobile/infrastructure/repositories/db.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; +import 'package:immich_mobile/infrastructure/repositories/settings.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/store.repository.dart'; import 'package:immich_mobile/presentation/actions/action.dart'; import 'package:immich_mobile/presentation/actions/action.widget.dart'; diff --git a/mobile/test/utils/image_url_builder_test.dart b/mobile/test/utils/image_url_builder_test.dart index 1845d38eeb..3235ee9b89 100644 --- a/mobile/test/utils/image_url_builder_test.dart +++ b/mobile/test/utils/image_url_builder_test.dart @@ -1,10 +1,8 @@ import 'package:drift/drift.dart'; import 'package:drift/native.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:immich_mobile/domain/models/store.model.dart'; -import 'package:immich_mobile/domain/services/store.service.dart'; import 'package:immich_mobile/infrastructure/repositories/db.repository.dart'; -import 'package:immich_mobile/infrastructure/repositories/store.repository.dart'; +import 'package:immich_mobile/infrastructure/repositories/session.repository.dart'; import 'package:immich_mobile/utils/image_url_builder.dart'; void main() { @@ -12,8 +10,8 @@ void main() { setUpAll(() async { final db = Drift(DatabaseConnection(NativeDatabase.memory(), closeStreamsSynchronously: true)); - await StoreService.init(storeRepository: DriftStoreRepository(db), listenUpdates: false); - await StoreService.I.put(StoreKey.serverEndpoint, endpoint); + await SessionRepository.ensureInitialized(db); + await SessionRepository.instance.write(.serverEndpoint, endpoint); }); group('getFaceThumbnailUrl', () {