mirror of
https://github.com/immich-app/immich.git
synced 2025-12-09 14:45:21 -05:00
merge main
# Conflicts: # mobile/drift_schemas/main/drift_schema_v10.json # mobile/lib/infrastructure/repositories/db.repository.dart # mobile/lib/infrastructure/repositories/db.repository.drift.dart # mobile/lib/infrastructure/repositories/db.repository.steps.dart # mobile/test/drift/main/generated/schema_v10.dart
This commit is contained in:
commit
53fc603d91
96
.github/workflows/merge-translations.yml
vendored
Normal file
96
.github/workflows/merge-translations.yml
vendored
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
name: Merge translations
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions: {}
|
||||||
|
|
||||||
|
env:
|
||||||
|
WEBLATE_HOST: 'https://hosted.weblate.org'
|
||||||
|
WEBLATE_COMPONENT: 'immich/immich'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
merge:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
steps:
|
||||||
|
- name: Find translation PR
|
||||||
|
id: find_pr
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
gh pr list --repo $GITHUB_REPOSITORY --author weblate --json number,mergeable | read PR
|
||||||
|
echo "$PR"
|
||||||
|
|
||||||
|
echo "$PR" | jq '
|
||||||
|
if length == 1 then
|
||||||
|
.[0].number
|
||||||
|
else
|
||||||
|
error("Expected exactly 1 entry, got \(length)")
|
||||||
|
end
|
||||||
|
' 2>&1 | read PR_NUMBER || exit 1
|
||||||
|
|
||||||
|
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
|
||||||
|
echo "Selected PR $PR_NUMBER"
|
||||||
|
|
||||||
|
echo "$PR" | jq -e '.[0].mergeable == "MERGEABLE"' || { echo "PR is not mergeable" ; exit 1 }
|
||||||
|
|
||||||
|
- name: Generate a token
|
||||||
|
id: generate_token
|
||||||
|
uses: actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2.1.1
|
||||||
|
with:
|
||||||
|
app-id: ${{ secrets.PUSH_O_MATIC_APP_ID }}
|
||||||
|
private-key: ${{ secrets.PUSH_O_MATIC_APP_KEY }}
|
||||||
|
|
||||||
|
- name: Lock weblate
|
||||||
|
env:
|
||||||
|
WEBLATE_TOKEN: ${{ secrets.WEBLATE_TOKEN }}
|
||||||
|
run: |
|
||||||
|
curl -X POST -H "Authorization: Token $WEBLATE_TOKEN" "$WEBLATE_HOST/api/components/$WEBLATE_COMPONENT/lock/" -d lock=true
|
||||||
|
|
||||||
|
- name: Commit translations
|
||||||
|
env:
|
||||||
|
WEBLATE_TOKEN: ${{ secrets.WEBLATE_TOKEN }}
|
||||||
|
run: |
|
||||||
|
curl -X POST -H "Authorization: Token $WEBLATE_TOKEN" "$WEBLATE_HOST/api/components/$WEBLATE_COMPONENT/repository/" -d operation=commit
|
||||||
|
curl -X POST -H "Authorization: Token $WEBLATE_TOKEN" "$WEBLATE_HOST/api/components/$WEBLATE_COMPONENT/repository/" -d operation=push
|
||||||
|
|
||||||
|
- name: Merge PR
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||||
|
PR_NUMBER: ${{ steps.find_pr.outputs.PR_NUMBER }}
|
||||||
|
run: |
|
||||||
|
gh api -X POST "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/reviews" --field event='APPROVE' --field body='Automatically merging translations PR' \
|
||||||
|
| jq '.id' | read REVIEW_ID
|
||||||
|
echo "REVIEW_ID=$REVIEW_ID" >> $GITHUB_OUTPUT
|
||||||
|
gh pr merge "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --auto --squash
|
||||||
|
|
||||||
|
- name: Wait for PR to merge
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||||
|
PR_NUMBER: ${{ steps.find_pr.outputs.PR_NUMBER }}
|
||||||
|
REVIEW_ID: ${{ steps.merge_pr.outputs.REVIEW_ID }}
|
||||||
|
run: |
|
||||||
|
for i in {1..10}; do
|
||||||
|
if gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --json merged | jq -e '.merged == true'; then
|
||||||
|
echo "PR merged"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "PR not merged yet, waiting..."
|
||||||
|
sleep 6
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "PR did not merge in time"
|
||||||
|
gh api -X PUT "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/reviews/$REVIEW_ID/dismissals" --field message='Merge attempt timed out' --field event='DISMISS'
|
||||||
|
gh pr merge "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --disable-auto
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
- name: Unlock weblate
|
||||||
|
env:
|
||||||
|
WEBLATE_TOKEN: ${{ secrets.WEBLATE_TOKEN }}
|
||||||
|
run: |
|
||||||
|
curl -X POST -H "Authorization: Token $WEBLATE_TOKEN" "$WEBLATE_HOST/api/components/$WEBLATE_COMPONENT/lock/" -d lock=false
|
||||||
9
.github/workflows/prepare-release.yml
vendored
9
.github/workflows/prepare-release.yml
vendored
@ -24,6 +24,15 @@ concurrency:
|
|||||||
permissions: {}
|
permissions: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
merge_translations:
|
||||||
|
uses: ./.github/workflows/merge-translations.yml
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
secrets:
|
||||||
|
PUSH_O_MATIC_APP_ID: ${{ secrets.PUSH_O_MATIC_APP_ID }}
|
||||||
|
PUSH_O_MATIC_APP_KEY: ${{ secrets.PUSH_O_MATIC_APP_KEY }}
|
||||||
|
WEBLATE_TOKEN: ${{ secrets.WEBLATE_TOKEN }}
|
||||||
|
|
||||||
bump_version:
|
bump_version:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
|
|||||||
23
.github/workflows/weblate-lock.yml
vendored
23
.github/workflows/weblate-lock.yml
vendored
@ -1,6 +1,7 @@
|
|||||||
name: Weblate checks
|
name: Weblate checks
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
pull_request_review:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
@ -12,7 +13,7 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
outputs:
|
outputs:
|
||||||
should_run: ${{ steps.found_paths.outputs.i18n == 'true' && github.head_ref != 'chore/translations'}}
|
should_run: ${{ steps.found_paths.outputs.i18n == 'true' }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
@ -32,19 +33,15 @@ jobs:
|
|||||||
permissions: {}
|
permissions: {}
|
||||||
if: ${{ needs.pre-job.outputs.should_run == 'true' }}
|
if: ${{ needs.pre-job.outputs.should_run == 'true' }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check weblate lock
|
- name: Bot review status
|
||||||
|
env:
|
||||||
|
PR_NUMBER: ${{ github.event.pull_request.number || github.event.pull_request_review.pull_request.number }}
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
run: |
|
run: |
|
||||||
if [[ "false" = $(curl https://hosted.weblate.org/api/components/immich/immich/lock/ | jq .locked) ]]; then
|
# Then check for APPROVED by the bot, if absent fail
|
||||||
exit 1
|
gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --json reviews | jq -e '.reviews | map(select(.author.login == "github-actions[bot]" and .state == "APPROVED")) | length > 0' \
|
||||||
fi
|
|| (echo "The push-o-matic bot has not approved this PR yet" && exit 1)
|
||||||
- name: Find Pull Request
|
|
||||||
uses: juliangruber/find-pull-request-action@952b3bb1ddb2dcc0aa3479e98bb1c2d1a922f096 # v1.10.0
|
|
||||||
id: find-pr
|
|
||||||
with:
|
|
||||||
branch: chore/translations
|
|
||||||
- name: Fail if existing weblate PR
|
|
||||||
if: ${{ steps.find-pr.outputs.number }}
|
|
||||||
run: exit 1
|
|
||||||
success-check-lock:
|
success-check-lock:
|
||||||
name: Weblate Lock Check Success
|
name: Weblate Lock Check Success
|
||||||
needs: [enforce-lock]
|
needs: [enforce-lock]
|
||||||
|
|||||||
@ -23,8 +23,8 @@ describe('/partners', () => {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
createPartner({ id: user2.userId }, { headers: asBearerAuth(user1.accessToken) }),
|
createPartner({ partnerCreateDto: { sharedWithId: user2.userId } }, { headers: asBearerAuth(user1.accessToken) }),
|
||||||
createPartner({ id: user1.userId }, { headers: asBearerAuth(user2.accessToken) }),
|
createPartner({ partnerCreateDto: { sharedWithId: user1.userId } }, { headers: asBearerAuth(user2.accessToken) }),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -462,7 +462,8 @@ export const utils = {
|
|||||||
updateLibrary: (accessToken: string, id: string, dto: UpdateLibraryDto) =>
|
updateLibrary: (accessToken: string, id: string, dto: UpdateLibraryDto) =>
|
||||||
updateLibrary({ id, updateLibraryDto: dto }, { headers: asBearerAuth(accessToken) }),
|
updateLibrary({ id, updateLibraryDto: dto }, { headers: asBearerAuth(accessToken) }),
|
||||||
|
|
||||||
createPartner: (accessToken: string, id: string) => createPartner({ id }, { headers: asBearerAuth(accessToken) }),
|
createPartner: (accessToken: string, id: string) =>
|
||||||
|
createPartner({ partnerCreateDto: { sharedWithId: id } }, { headers: asBearerAuth(accessToken) }),
|
||||||
|
|
||||||
updateMyPreferences: (accessToken: string, userPreferencesUpdateDto: UserPreferencesUpdateDto) =>
|
updateMyPreferences: (accessToken: string, userPreferencesUpdateDto: UserPreferencesUpdateDto) =>
|
||||||
updateMyPreferences({ userPreferencesUpdateDto }, { headers: asBearerAuth(accessToken) }),
|
updateMyPreferences({ userPreferencesUpdateDto }, { headers: asBearerAuth(accessToken) }),
|
||||||
|
|||||||
2
mobile/drift_schemas/main/drift_schema_v10.json
generated
2
mobile/drift_schemas/main/drift_schema_v10.json
generated
File diff suppressed because one or more lines are too long
@ -1,7 +1,36 @@
|
|||||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:immich_mobile/domain/models/user_metadata.model.dart';
|
enum AvatarColor {
|
||||||
|
// do not change this order or reuse indices for other purposes, adding is OK
|
||||||
|
primary("primary"),
|
||||||
|
pink("pink"),
|
||||||
|
red("red"),
|
||||||
|
yellow("yellow"),
|
||||||
|
blue("blue"),
|
||||||
|
green("green"),
|
||||||
|
purple("purple"),
|
||||||
|
orange("orange"),
|
||||||
|
gray("gray"),
|
||||||
|
amber("amber");
|
||||||
|
|
||||||
|
final String value;
|
||||||
|
const AvatarColor(this.value);
|
||||||
|
|
||||||
|
Color toColor({bool isDarkTheme = false}) => switch (this) {
|
||||||
|
AvatarColor.primary => isDarkTheme ? const Color(0xFFABCBFA) : const Color(0xFF4250AF),
|
||||||
|
AvatarColor.pink => const Color.fromARGB(255, 244, 114, 182),
|
||||||
|
AvatarColor.red => const Color.fromARGB(255, 239, 68, 68),
|
||||||
|
AvatarColor.yellow => const Color.fromARGB(255, 234, 179, 8),
|
||||||
|
AvatarColor.blue => const Color.fromARGB(255, 59, 130, 246),
|
||||||
|
AvatarColor.green => const Color.fromARGB(255, 22, 163, 74),
|
||||||
|
AvatarColor.purple => const Color.fromARGB(255, 147, 51, 234),
|
||||||
|
AvatarColor.orange => const Color.fromARGB(255, 234, 88, 12),
|
||||||
|
AvatarColor.gray => const Color.fromARGB(255, 75, 85, 99),
|
||||||
|
AvatarColor.amber => const Color.fromARGB(255, 217, 119, 6),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Rename to User once Isar is removed
|
// TODO: Rename to User once Isar is removed
|
||||||
class UserDto {
|
class UserDto {
|
||||||
@ -9,7 +38,7 @@ class UserDto {
|
|||||||
final String email;
|
final String email;
|
||||||
final String name;
|
final String name;
|
||||||
final bool isAdmin;
|
final bool isAdmin;
|
||||||
final DateTime updatedAt;
|
final DateTime? updatedAt;
|
||||||
|
|
||||||
final AvatarColor avatarColor;
|
final AvatarColor avatarColor;
|
||||||
|
|
||||||
@ -31,8 +60,8 @@ class UserDto {
|
|||||||
required this.id,
|
required this.id,
|
||||||
required this.email,
|
required this.email,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.isAdmin,
|
this.isAdmin = false,
|
||||||
required this.updatedAt,
|
this.updatedAt,
|
||||||
required this.profileChangedAt,
|
required this.profileChangedAt,
|
||||||
this.avatarColor = AvatarColor.primary,
|
this.avatarColor = AvatarColor.primary,
|
||||||
this.memoryEnabled = true,
|
this.memoryEnabled = true,
|
||||||
@ -99,7 +128,8 @@ profileChangedAt: $profileChangedAt
|
|||||||
if (identical(this, other)) return true;
|
if (identical(this, other)) return true;
|
||||||
|
|
||||||
return other.id == id &&
|
return other.id == id &&
|
||||||
other.updatedAt.isAtSameMomentAs(updatedAt) &&
|
((updatedAt == null && other.updatedAt == null) ||
|
||||||
|
(updatedAt != null && other.updatedAt != null && other.updatedAt!.isAtSameMomentAs(updatedAt!))) &&
|
||||||
other.avatarColor == avatarColor &&
|
other.avatarColor == avatarColor &&
|
||||||
other.email == email &&
|
other.email == email &&
|
||||||
other.name == name &&
|
other.name == name &&
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import 'dart:ui';
|
import 'package:immich_mobile/domain/models/user.model.dart';
|
||||||
|
|
||||||
enum UserMetadataKey {
|
enum UserMetadataKey {
|
||||||
// do not change this order!
|
// do not change this order!
|
||||||
@ -7,36 +7,6 @@ enum UserMetadataKey {
|
|||||||
license,
|
license,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum AvatarColor {
|
|
||||||
// do not change this order or reuse indices for other purposes, adding is OK
|
|
||||||
primary("primary"),
|
|
||||||
pink("pink"),
|
|
||||||
red("red"),
|
|
||||||
yellow("yellow"),
|
|
||||||
blue("blue"),
|
|
||||||
green("green"),
|
|
||||||
purple("purple"),
|
|
||||||
orange("orange"),
|
|
||||||
gray("gray"),
|
|
||||||
amber("amber");
|
|
||||||
|
|
||||||
final String value;
|
|
||||||
const AvatarColor(this.value);
|
|
||||||
|
|
||||||
Color toColor({bool isDarkTheme = false}) => switch (this) {
|
|
||||||
AvatarColor.primary => isDarkTheme ? const Color(0xFFABCBFA) : const Color(0xFF4250AF),
|
|
||||||
AvatarColor.pink => const Color.fromARGB(255, 244, 114, 182),
|
|
||||||
AvatarColor.red => const Color.fromARGB(255, 239, 68, 68),
|
|
||||||
AvatarColor.yellow => const Color.fromARGB(255, 234, 179, 8),
|
|
||||||
AvatarColor.blue => const Color.fromARGB(255, 59, 130, 246),
|
|
||||||
AvatarColor.green => const Color.fromARGB(255, 22, 163, 74),
|
|
||||||
AvatarColor.purple => const Color.fromARGB(255, 147, 51, 234),
|
|
||||||
AvatarColor.orange => const Color.fromARGB(255, 234, 88, 12),
|
|
||||||
AvatarColor.gray => const Color.fromARGB(255, 75, 85, 99),
|
|
||||||
AvatarColor.amber => const Color.fromARGB(255, 217, 119, 6),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
class Onboarding {
|
class Onboarding {
|
||||||
final bool isOnboarded;
|
final bool isOnboarded;
|
||||||
|
|
||||||
|
|||||||
@ -169,15 +169,20 @@ class BackgroundWorkerBgService extends BackgroundWorkerFlutterApi {
|
|||||||
try {
|
try {
|
||||||
_isCleanedUp = true;
|
_isCleanedUp = true;
|
||||||
_logger.info("Cleaning up background worker");
|
_logger.info("Cleaning up background worker");
|
||||||
await _ref.read(backgroundSyncProvider).cancel();
|
final cleanupFutures = [
|
||||||
await _ref.read(backgroundSyncProvider).cancelLocal();
|
_drift.close(),
|
||||||
|
_driftLogger.close(),
|
||||||
|
_ref.read(backgroundSyncProvider).cancel(),
|
||||||
|
_ref.read(backgroundSyncProvider).cancelLocal(),
|
||||||
|
];
|
||||||
|
|
||||||
if (_isar.isOpen) {
|
if (_isar.isOpen) {
|
||||||
await _isar.close();
|
cleanupFutures.add(_isar.close());
|
||||||
}
|
}
|
||||||
await _drift.close();
|
|
||||||
await _driftLogger.close();
|
|
||||||
_ref.dispose();
|
_ref.dispose();
|
||||||
_lockManager.releaseLock();
|
_lockManager.releaseLock();
|
||||||
|
|
||||||
|
await Future.wait(cleanupFutures);
|
||||||
_logger.info("Background worker resources cleaned up");
|
_logger.info("Background worker resources cleaned up");
|
||||||
} catch (error, stack) {
|
} catch (error, stack) {
|
||||||
debugPrint('Failed to cleanup background worker: $error with stack: $stack');
|
debugPrint('Failed to cleanup background worker: $error with stack: $stack');
|
||||||
|
|||||||
@ -23,54 +23,17 @@ class SyncStreamService {
|
|||||||
|
|
||||||
bool get isCancelled => _cancelChecker?.call() ?? false;
|
bool get isCancelled => _cancelChecker?.call() ?? false;
|
||||||
|
|
||||||
Future<void> sync() {
|
Future<void> sync() async {
|
||||||
_logger.info("Remote sync request for user");
|
_logger.info("Remote sync request for user");
|
||||||
// Start the sync stream and handle events
|
// Start the sync stream and handle events
|
||||||
return _syncApiRepository.streamChanges(_handleEvents);
|
bool shouldReset = false;
|
||||||
}
|
await _syncApiRepository.streamChanges(_handleEvents, onReset: () => shouldReset = true);
|
||||||
|
if (shouldReset) {
|
||||||
Future<void> handleWsAssetUploadReadyV1Batch(List<dynamic> batchData) async {
|
await _syncApiRepository.streamChanges(_handleEvents);
|
||||||
if (batchData.isEmpty) return;
|
|
||||||
|
|
||||||
_logger.info('Processing batch of ${batchData.length} AssetUploadReadyV1 events');
|
|
||||||
|
|
||||||
final List<SyncAssetV1> assets = [];
|
|
||||||
final List<SyncAssetExifV1> exifs = [];
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (final data in batchData) {
|
|
||||||
if (data is! Map<String, dynamic>) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final payload = data;
|
|
||||||
final assetData = payload['asset'];
|
|
||||||
final exifData = payload['exif'];
|
|
||||||
|
|
||||||
if (assetData == null || exifData == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final asset = SyncAssetV1.fromJson(assetData);
|
|
||||||
final exif = SyncAssetExifV1.fromJson(exifData);
|
|
||||||
|
|
||||||
if (asset != null && exif != null) {
|
|
||||||
assets.add(asset);
|
|
||||||
exifs.add(exif);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assets.isNotEmpty && exifs.isNotEmpty) {
|
Future<void> _handleEvents(List<SyncEvent> events, Function() abort, Function() reset) async {
|
||||||
await _syncStreamRepository.updateAssetsV1(assets, debugLabel: 'websocket-batch');
|
|
||||||
await _syncStreamRepository.updateAssetsExifV1(exifs, debugLabel: 'websocket-batch');
|
|
||||||
_logger.info('Successfully processed ${assets.length} assets in batch');
|
|
||||||
}
|
|
||||||
} catch (error, stackTrace) {
|
|
||||||
_logger.severe("Error processing AssetUploadReadyV1 websocket batch events", error, stackTrace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _handleEvents(List<SyncEvent> events, Function() abort) async {
|
|
||||||
List<SyncEvent> items = [];
|
List<SyncEvent> items = [];
|
||||||
for (final event in events) {
|
for (final event in events) {
|
||||||
if (isCancelled) {
|
if (isCancelled) {
|
||||||
@ -83,6 +46,10 @@ class SyncStreamService {
|
|||||||
await _processBatch(items);
|
await _processBatch(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.type == SyncEntityType.syncResetV1) {
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
items.add(event);
|
items.add(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,6 +70,8 @@ class SyncStreamService {
|
|||||||
Future<void> _handleSyncData(SyncEntityType type, Iterable<Object> data) async {
|
Future<void> _handleSyncData(SyncEntityType type, Iterable<Object> data) async {
|
||||||
_logger.fine("Processing sync data for $type of length ${data.length}");
|
_logger.fine("Processing sync data for $type of length ${data.length}");
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
case SyncEntityType.authUserV1:
|
||||||
|
return _syncStreamRepository.updateAuthUsersV1(data.cast());
|
||||||
case SyncEntityType.userV1:
|
case SyncEntityType.userV1:
|
||||||
return _syncStreamRepository.updateUsersV1(data.cast());
|
return _syncStreamRepository.updateUsersV1(data.cast());
|
||||||
case SyncEntityType.userDeleteV1:
|
case SyncEntityType.userDeleteV1:
|
||||||
@ -163,6 +132,12 @@ class SyncStreamService {
|
|||||||
// to acknowledge that the client has processed all the backfill events
|
// to acknowledge that the client has processed all the backfill events
|
||||||
case SyncEntityType.syncAckV1:
|
case SyncEntityType.syncAckV1:
|
||||||
return;
|
return;
|
||||||
|
// No-op. SyncCompleteV1 is used to signal the completion of the sync process
|
||||||
|
case SyncEntityType.syncCompleteV1:
|
||||||
|
return;
|
||||||
|
// Request to reset the client state. Clear everything related to remote entities
|
||||||
|
case SyncEntityType.syncResetV1:
|
||||||
|
return _syncStreamRepository.reset();
|
||||||
case SyncEntityType.memoryV1:
|
case SyncEntityType.memoryV1:
|
||||||
return _syncStreamRepository.updateMemoriesV1(data.cast());
|
return _syncStreamRepository.updateMemoriesV1(data.cast());
|
||||||
case SyncEntityType.memoryDeleteV1:
|
case SyncEntityType.memoryDeleteV1:
|
||||||
@ -197,4 +172,45 @@ class SyncStreamService {
|
|||||||
_logger.warning("Unknown sync data type: $type");
|
_logger.warning("Unknown sync data type: $type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> handleWsAssetUploadReadyV1Batch(List<dynamic> batchData) async {
|
||||||
|
if (batchData.isEmpty) return;
|
||||||
|
|
||||||
|
_logger.info('Processing batch of ${batchData.length} AssetUploadReadyV1 events');
|
||||||
|
|
||||||
|
final List<SyncAssetV1> assets = [];
|
||||||
|
final List<SyncAssetExifV1> exifs = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (final data in batchData) {
|
||||||
|
if (data is! Map<String, dynamic>) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
final payload = data;
|
||||||
|
final assetData = payload['asset'];
|
||||||
|
final exifData = payload['exif'];
|
||||||
|
|
||||||
|
if (assetData == null || exifData == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
final asset = SyncAssetV1.fromJson(assetData);
|
||||||
|
final exif = SyncAssetExifV1.fromJson(exifData);
|
||||||
|
|
||||||
|
if (asset != null && exif != null) {
|
||||||
|
assets.add(asset);
|
||||||
|
exifs.add(exif);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (assets.isNotEmpty && exifs.isNotEmpty) {
|
||||||
|
await _syncStreamRepository.updateAssetsV1(assets, debugLabel: 'websocket-batch');
|
||||||
|
await _syncStreamRepository.updateAssetsExifV1(exifs, debugLabel: 'websocket-batch');
|
||||||
|
_logger.info('Successfully processed ${assets.length} assets in batch');
|
||||||
|
}
|
||||||
|
} catch (error, stackTrace) {
|
||||||
|
_logger.severe("Error processing AssetUploadReadyV1 websocket batch events", error, stackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
27
mobile/lib/infrastructure/entities/auth_user.entity.dart
Normal file
27
mobile/lib/infrastructure/entities/auth_user.entity.dart
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import 'package:drift/drift.dart';
|
||||||
|
import 'package:immich_mobile/domain/models/user.model.dart';
|
||||||
|
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
|
||||||
|
|
||||||
|
class AuthUserEntity extends Table with DriftDefaultsMixin {
|
||||||
|
const AuthUserEntity();
|
||||||
|
|
||||||
|
TextColumn get id => text()();
|
||||||
|
TextColumn get name => text()();
|
||||||
|
TextColumn get email => text()();
|
||||||
|
BoolColumn get isAdmin => boolean().withDefault(const Constant(false))();
|
||||||
|
|
||||||
|
// Profile image
|
||||||
|
BoolColumn get hasProfileImage => boolean().withDefault(const Constant(false))();
|
||||||
|
DateTimeColumn get profileChangedAt => dateTime().withDefault(currentDateAndTime)();
|
||||||
|
IntColumn get avatarColor => intEnum<AvatarColor>()();
|
||||||
|
|
||||||
|
// Quota
|
||||||
|
IntColumn get quotaSizeInBytes => integer().withDefault(const Constant(0))();
|
||||||
|
IntColumn get quotaUsageInBytes => integer().withDefault(const Constant(0))();
|
||||||
|
|
||||||
|
// Locked Folder
|
||||||
|
TextColumn get pinCode => text().nullable()();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Set<Column> get primaryKey => {id};
|
||||||
|
}
|
||||||
933
mobile/lib/infrastructure/entities/auth_user.entity.drift.dart
generated
Normal file
933
mobile/lib/infrastructure/entities/auth_user.entity.drift.dart
generated
Normal file
@ -0,0 +1,933 @@
|
|||||||
|
// dart format width=80
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
import 'package:drift/drift.dart' as i0;
|
||||||
|
import 'package:immich_mobile/infrastructure/entities/auth_user.entity.drift.dart'
|
||||||
|
as i1;
|
||||||
|
import 'package:immich_mobile/domain/models/user.model.dart' as i2;
|
||||||
|
import 'package:immich_mobile/infrastructure/entities/auth_user.entity.dart'
|
||||||
|
as i3;
|
||||||
|
import 'package:drift/src/runtime/query_builder/query_builder.dart' as i4;
|
||||||
|
|
||||||
|
typedef $$AuthUserEntityTableCreateCompanionBuilder =
|
||||||
|
i1.AuthUserEntityCompanion Function({
|
||||||
|
required String id,
|
||||||
|
required String name,
|
||||||
|
required String email,
|
||||||
|
i0.Value<bool> isAdmin,
|
||||||
|
i0.Value<bool> hasProfileImage,
|
||||||
|
i0.Value<DateTime> profileChangedAt,
|
||||||
|
required i2.AvatarColor avatarColor,
|
||||||
|
i0.Value<int> quotaSizeInBytes,
|
||||||
|
i0.Value<int> quotaUsageInBytes,
|
||||||
|
i0.Value<String?> pinCode,
|
||||||
|
});
|
||||||
|
typedef $$AuthUserEntityTableUpdateCompanionBuilder =
|
||||||
|
i1.AuthUserEntityCompanion Function({
|
||||||
|
i0.Value<String> id,
|
||||||
|
i0.Value<String> name,
|
||||||
|
i0.Value<String> email,
|
||||||
|
i0.Value<bool> isAdmin,
|
||||||
|
i0.Value<bool> hasProfileImage,
|
||||||
|
i0.Value<DateTime> profileChangedAt,
|
||||||
|
i0.Value<i2.AvatarColor> avatarColor,
|
||||||
|
i0.Value<int> quotaSizeInBytes,
|
||||||
|
i0.Value<int> quotaUsageInBytes,
|
||||||
|
i0.Value<String?> pinCode,
|
||||||
|
});
|
||||||
|
|
||||||
|
class $$AuthUserEntityTableFilterComposer
|
||||||
|
extends i0.Composer<i0.GeneratedDatabase, i1.$AuthUserEntityTable> {
|
||||||
|
$$AuthUserEntityTableFilterComposer({
|
||||||
|
required super.$db,
|
||||||
|
required super.$table,
|
||||||
|
super.joinBuilder,
|
||||||
|
super.$addJoinBuilderToRootComposer,
|
||||||
|
super.$removeJoinBuilderFromRootComposer,
|
||||||
|
});
|
||||||
|
i0.ColumnFilters<String> get id => $composableBuilder(
|
||||||
|
column: $table.id,
|
||||||
|
builder: (column) => i0.ColumnFilters(column),
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.ColumnFilters<String> get name => $composableBuilder(
|
||||||
|
column: $table.name,
|
||||||
|
builder: (column) => i0.ColumnFilters(column),
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.ColumnFilters<String> get email => $composableBuilder(
|
||||||
|
column: $table.email,
|
||||||
|
builder: (column) => i0.ColumnFilters(column),
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.ColumnFilters<bool> get isAdmin => $composableBuilder(
|
||||||
|
column: $table.isAdmin,
|
||||||
|
builder: (column) => i0.ColumnFilters(column),
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.ColumnFilters<bool> get hasProfileImage => $composableBuilder(
|
||||||
|
column: $table.hasProfileImage,
|
||||||
|
builder: (column) => i0.ColumnFilters(column),
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.ColumnFilters<DateTime> get profileChangedAt => $composableBuilder(
|
||||||
|
column: $table.profileChangedAt,
|
||||||
|
builder: (column) => i0.ColumnFilters(column),
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.ColumnWithTypeConverterFilters<i2.AvatarColor, i2.AvatarColor, int>
|
||||||
|
get avatarColor => $composableBuilder(
|
||||||
|
column: $table.avatarColor,
|
||||||
|
builder: (column) => i0.ColumnWithTypeConverterFilters(column),
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.ColumnFilters<int> get quotaSizeInBytes => $composableBuilder(
|
||||||
|
column: $table.quotaSizeInBytes,
|
||||||
|
builder: (column) => i0.ColumnFilters(column),
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.ColumnFilters<int> get quotaUsageInBytes => $composableBuilder(
|
||||||
|
column: $table.quotaUsageInBytes,
|
||||||
|
builder: (column) => i0.ColumnFilters(column),
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.ColumnFilters<String> get pinCode => $composableBuilder(
|
||||||
|
column: $table.pinCode,
|
||||||
|
builder: (column) => i0.ColumnFilters(column),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
class $$AuthUserEntityTableOrderingComposer
|
||||||
|
extends i0.Composer<i0.GeneratedDatabase, i1.$AuthUserEntityTable> {
|
||||||
|
$$AuthUserEntityTableOrderingComposer({
|
||||||
|
required super.$db,
|
||||||
|
required super.$table,
|
||||||
|
super.joinBuilder,
|
||||||
|
super.$addJoinBuilderToRootComposer,
|
||||||
|
super.$removeJoinBuilderFromRootComposer,
|
||||||
|
});
|
||||||
|
i0.ColumnOrderings<String> get id => $composableBuilder(
|
||||||
|
column: $table.id,
|
||||||
|
builder: (column) => i0.ColumnOrderings(column),
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.ColumnOrderings<String> get name => $composableBuilder(
|
||||||
|
column: $table.name,
|
||||||
|
builder: (column) => i0.ColumnOrderings(column),
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.ColumnOrderings<String> get email => $composableBuilder(
|
||||||
|
column: $table.email,
|
||||||
|
builder: (column) => i0.ColumnOrderings(column),
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.ColumnOrderings<bool> get isAdmin => $composableBuilder(
|
||||||
|
column: $table.isAdmin,
|
||||||
|
builder: (column) => i0.ColumnOrderings(column),
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.ColumnOrderings<bool> get hasProfileImage => $composableBuilder(
|
||||||
|
column: $table.hasProfileImage,
|
||||||
|
builder: (column) => i0.ColumnOrderings(column),
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.ColumnOrderings<DateTime> get profileChangedAt => $composableBuilder(
|
||||||
|
column: $table.profileChangedAt,
|
||||||
|
builder: (column) => i0.ColumnOrderings(column),
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.ColumnOrderings<int> get avatarColor => $composableBuilder(
|
||||||
|
column: $table.avatarColor,
|
||||||
|
builder: (column) => i0.ColumnOrderings(column),
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.ColumnOrderings<int> get quotaSizeInBytes => $composableBuilder(
|
||||||
|
column: $table.quotaSizeInBytes,
|
||||||
|
builder: (column) => i0.ColumnOrderings(column),
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.ColumnOrderings<int> get quotaUsageInBytes => $composableBuilder(
|
||||||
|
column: $table.quotaUsageInBytes,
|
||||||
|
builder: (column) => i0.ColumnOrderings(column),
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.ColumnOrderings<String> get pinCode => $composableBuilder(
|
||||||
|
column: $table.pinCode,
|
||||||
|
builder: (column) => i0.ColumnOrderings(column),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
class $$AuthUserEntityTableAnnotationComposer
|
||||||
|
extends i0.Composer<i0.GeneratedDatabase, i1.$AuthUserEntityTable> {
|
||||||
|
$$AuthUserEntityTableAnnotationComposer({
|
||||||
|
required super.$db,
|
||||||
|
required super.$table,
|
||||||
|
super.joinBuilder,
|
||||||
|
super.$addJoinBuilderToRootComposer,
|
||||||
|
super.$removeJoinBuilderFromRootComposer,
|
||||||
|
});
|
||||||
|
i0.GeneratedColumn<String> get id =>
|
||||||
|
$composableBuilder(column: $table.id, builder: (column) => column);
|
||||||
|
|
||||||
|
i0.GeneratedColumn<String> get name =>
|
||||||
|
$composableBuilder(column: $table.name, builder: (column) => column);
|
||||||
|
|
||||||
|
i0.GeneratedColumn<String> get email =>
|
||||||
|
$composableBuilder(column: $table.email, builder: (column) => column);
|
||||||
|
|
||||||
|
i0.GeneratedColumn<bool> get isAdmin =>
|
||||||
|
$composableBuilder(column: $table.isAdmin, builder: (column) => column);
|
||||||
|
|
||||||
|
i0.GeneratedColumn<bool> get hasProfileImage => $composableBuilder(
|
||||||
|
column: $table.hasProfileImage,
|
||||||
|
builder: (column) => column,
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.GeneratedColumn<DateTime> get profileChangedAt => $composableBuilder(
|
||||||
|
column: $table.profileChangedAt,
|
||||||
|
builder: (column) => column,
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.GeneratedColumnWithTypeConverter<i2.AvatarColor, int> get avatarColor =>
|
||||||
|
$composableBuilder(
|
||||||
|
column: $table.avatarColor,
|
||||||
|
builder: (column) => column,
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.GeneratedColumn<int> get quotaSizeInBytes => $composableBuilder(
|
||||||
|
column: $table.quotaSizeInBytes,
|
||||||
|
builder: (column) => column,
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.GeneratedColumn<int> get quotaUsageInBytes => $composableBuilder(
|
||||||
|
column: $table.quotaUsageInBytes,
|
||||||
|
builder: (column) => column,
|
||||||
|
);
|
||||||
|
|
||||||
|
i0.GeneratedColumn<String> get pinCode =>
|
||||||
|
$composableBuilder(column: $table.pinCode, builder: (column) => column);
|
||||||
|
}
|
||||||
|
|
||||||
|
class $$AuthUserEntityTableTableManager
|
||||||
|
extends
|
||||||
|
i0.RootTableManager<
|
||||||
|
i0.GeneratedDatabase,
|
||||||
|
i1.$AuthUserEntityTable,
|
||||||
|
i1.AuthUserEntityData,
|
||||||
|
i1.$$AuthUserEntityTableFilterComposer,
|
||||||
|
i1.$$AuthUserEntityTableOrderingComposer,
|
||||||
|
i1.$$AuthUserEntityTableAnnotationComposer,
|
||||||
|
$$AuthUserEntityTableCreateCompanionBuilder,
|
||||||
|
$$AuthUserEntityTableUpdateCompanionBuilder,
|
||||||
|
(
|
||||||
|
i1.AuthUserEntityData,
|
||||||
|
i0.BaseReferences<
|
||||||
|
i0.GeneratedDatabase,
|
||||||
|
i1.$AuthUserEntityTable,
|
||||||
|
i1.AuthUserEntityData
|
||||||
|
>,
|
||||||
|
),
|
||||||
|
i1.AuthUserEntityData,
|
||||||
|
i0.PrefetchHooks Function()
|
||||||
|
> {
|
||||||
|
$$AuthUserEntityTableTableManager(
|
||||||
|
i0.GeneratedDatabase db,
|
||||||
|
i1.$AuthUserEntityTable table,
|
||||||
|
) : super(
|
||||||
|
i0.TableManagerState(
|
||||||
|
db: db,
|
||||||
|
table: table,
|
||||||
|
createFilteringComposer: () =>
|
||||||
|
i1.$$AuthUserEntityTableFilterComposer($db: db, $table: table),
|
||||||
|
createOrderingComposer: () =>
|
||||||
|
i1.$$AuthUserEntityTableOrderingComposer($db: db, $table: table),
|
||||||
|
createComputedFieldComposer: () => i1
|
||||||
|
.$$AuthUserEntityTableAnnotationComposer($db: db, $table: table),
|
||||||
|
updateCompanionCallback:
|
||||||
|
({
|
||||||
|
i0.Value<String> id = const i0.Value.absent(),
|
||||||
|
i0.Value<String> name = const i0.Value.absent(),
|
||||||
|
i0.Value<String> email = const i0.Value.absent(),
|
||||||
|
i0.Value<bool> isAdmin = const i0.Value.absent(),
|
||||||
|
i0.Value<bool> hasProfileImage = const i0.Value.absent(),
|
||||||
|
i0.Value<DateTime> profileChangedAt = const i0.Value.absent(),
|
||||||
|
i0.Value<i2.AvatarColor> avatarColor = const i0.Value.absent(),
|
||||||
|
i0.Value<int> quotaSizeInBytes = const i0.Value.absent(),
|
||||||
|
i0.Value<int> quotaUsageInBytes = const i0.Value.absent(),
|
||||||
|
i0.Value<String?> pinCode = const i0.Value.absent(),
|
||||||
|
}) => i1.AuthUserEntityCompanion(
|
||||||
|
id: id,
|
||||||
|
name: name,
|
||||||
|
email: email,
|
||||||
|
isAdmin: isAdmin,
|
||||||
|
hasProfileImage: hasProfileImage,
|
||||||
|
profileChangedAt: profileChangedAt,
|
||||||
|
avatarColor: avatarColor,
|
||||||
|
quotaSizeInBytes: quotaSizeInBytes,
|
||||||
|
quotaUsageInBytes: quotaUsageInBytes,
|
||||||
|
pinCode: pinCode,
|
||||||
|
),
|
||||||
|
createCompanionCallback:
|
||||||
|
({
|
||||||
|
required String id,
|
||||||
|
required String name,
|
||||||
|
required String email,
|
||||||
|
i0.Value<bool> isAdmin = const i0.Value.absent(),
|
||||||
|
i0.Value<bool> hasProfileImage = const i0.Value.absent(),
|
||||||
|
i0.Value<DateTime> profileChangedAt = const i0.Value.absent(),
|
||||||
|
required i2.AvatarColor avatarColor,
|
||||||
|
i0.Value<int> quotaSizeInBytes = const i0.Value.absent(),
|
||||||
|
i0.Value<int> quotaUsageInBytes = const i0.Value.absent(),
|
||||||
|
i0.Value<String?> pinCode = const i0.Value.absent(),
|
||||||
|
}) => i1.AuthUserEntityCompanion.insert(
|
||||||
|
id: id,
|
||||||
|
name: name,
|
||||||
|
email: email,
|
||||||
|
isAdmin: isAdmin,
|
||||||
|
hasProfileImage: hasProfileImage,
|
||||||
|
profileChangedAt: profileChangedAt,
|
||||||
|
avatarColor: avatarColor,
|
||||||
|
quotaSizeInBytes: quotaSizeInBytes,
|
||||||
|
quotaUsageInBytes: quotaUsageInBytes,
|
||||||
|
pinCode: pinCode,
|
||||||
|
),
|
||||||
|
withReferenceMapper: (p0) => p0
|
||||||
|
.map((e) => (e.readTable(table), i0.BaseReferences(db, table, e)))
|
||||||
|
.toList(),
|
||||||
|
prefetchHooksCallback: null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef $$AuthUserEntityTableProcessedTableManager =
|
||||||
|
i0.ProcessedTableManager<
|
||||||
|
i0.GeneratedDatabase,
|
||||||
|
i1.$AuthUserEntityTable,
|
||||||
|
i1.AuthUserEntityData,
|
||||||
|
i1.$$AuthUserEntityTableFilterComposer,
|
||||||
|
i1.$$AuthUserEntityTableOrderingComposer,
|
||||||
|
i1.$$AuthUserEntityTableAnnotationComposer,
|
||||||
|
$$AuthUserEntityTableCreateCompanionBuilder,
|
||||||
|
$$AuthUserEntityTableUpdateCompanionBuilder,
|
||||||
|
(
|
||||||
|
i1.AuthUserEntityData,
|
||||||
|
i0.BaseReferences<
|
||||||
|
i0.GeneratedDatabase,
|
||||||
|
i1.$AuthUserEntityTable,
|
||||||
|
i1.AuthUserEntityData
|
||||||
|
>,
|
||||||
|
),
|
||||||
|
i1.AuthUserEntityData,
|
||||||
|
i0.PrefetchHooks Function()
|
||||||
|
>;
|
||||||
|
|
||||||
|
class $AuthUserEntityTable extends i3.AuthUserEntity
|
||||||
|
with i0.TableInfo<$AuthUserEntityTable, i1.AuthUserEntityData> {
|
||||||
|
@override
|
||||||
|
final i0.GeneratedDatabase attachedDatabase;
|
||||||
|
final String? _alias;
|
||||||
|
$AuthUserEntityTable(this.attachedDatabase, [this._alias]);
|
||||||
|
static const i0.VerificationMeta _idMeta = const i0.VerificationMeta('id');
|
||||||
|
@override
|
||||||
|
late final i0.GeneratedColumn<String> id = i0.GeneratedColumn<String>(
|
||||||
|
'id',
|
||||||
|
aliasedName,
|
||||||
|
false,
|
||||||
|
type: i0.DriftSqlType.string,
|
||||||
|
requiredDuringInsert: true,
|
||||||
|
);
|
||||||
|
static const i0.VerificationMeta _nameMeta = const i0.VerificationMeta(
|
||||||
|
'name',
|
||||||
|
);
|
||||||
|
@override
|
||||||
|
late final i0.GeneratedColumn<String> name = i0.GeneratedColumn<String>(
|
||||||
|
'name',
|
||||||
|
aliasedName,
|
||||||
|
false,
|
||||||
|
type: i0.DriftSqlType.string,
|
||||||
|
requiredDuringInsert: true,
|
||||||
|
);
|
||||||
|
static const i0.VerificationMeta _emailMeta = const i0.VerificationMeta(
|
||||||
|
'email',
|
||||||
|
);
|
||||||
|
@override
|
||||||
|
late final i0.GeneratedColumn<String> email = i0.GeneratedColumn<String>(
|
||||||
|
'email',
|
||||||
|
aliasedName,
|
||||||
|
false,
|
||||||
|
type: i0.DriftSqlType.string,
|
||||||
|
requiredDuringInsert: true,
|
||||||
|
);
|
||||||
|
static const i0.VerificationMeta _isAdminMeta = const i0.VerificationMeta(
|
||||||
|
'isAdmin',
|
||||||
|
);
|
||||||
|
@override
|
||||||
|
late final i0.GeneratedColumn<bool> isAdmin = i0.GeneratedColumn<bool>(
|
||||||
|
'is_admin',
|
||||||
|
aliasedName,
|
||||||
|
false,
|
||||||
|
type: i0.DriftSqlType.bool,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
defaultConstraints: i0.GeneratedColumn.constraintIsAlways(
|
||||||
|
'CHECK ("is_admin" IN (0, 1))',
|
||||||
|
),
|
||||||
|
defaultValue: const i4.Constant(false),
|
||||||
|
);
|
||||||
|
static const i0.VerificationMeta _hasProfileImageMeta =
|
||||||
|
const i0.VerificationMeta('hasProfileImage');
|
||||||
|
@override
|
||||||
|
late final i0.GeneratedColumn<bool> hasProfileImage =
|
||||||
|
i0.GeneratedColumn<bool>(
|
||||||
|
'has_profile_image',
|
||||||
|
aliasedName,
|
||||||
|
false,
|
||||||
|
type: i0.DriftSqlType.bool,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
defaultConstraints: i0.GeneratedColumn.constraintIsAlways(
|
||||||
|
'CHECK ("has_profile_image" IN (0, 1))',
|
||||||
|
),
|
||||||
|
defaultValue: const i4.Constant(false),
|
||||||
|
);
|
||||||
|
static const i0.VerificationMeta _profileChangedAtMeta =
|
||||||
|
const i0.VerificationMeta('profileChangedAt');
|
||||||
|
@override
|
||||||
|
late final i0.GeneratedColumn<DateTime> profileChangedAt =
|
||||||
|
i0.GeneratedColumn<DateTime>(
|
||||||
|
'profile_changed_at',
|
||||||
|
aliasedName,
|
||||||
|
false,
|
||||||
|
type: i0.DriftSqlType.dateTime,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
defaultValue: i4.currentDateAndTime,
|
||||||
|
);
|
||||||
|
@override
|
||||||
|
late final i0.GeneratedColumnWithTypeConverter<i2.AvatarColor, int>
|
||||||
|
avatarColor =
|
||||||
|
i0.GeneratedColumn<int>(
|
||||||
|
'avatar_color',
|
||||||
|
aliasedName,
|
||||||
|
false,
|
||||||
|
type: i0.DriftSqlType.int,
|
||||||
|
requiredDuringInsert: true,
|
||||||
|
).withConverter<i2.AvatarColor>(
|
||||||
|
i1.$AuthUserEntityTable.$converteravatarColor,
|
||||||
|
);
|
||||||
|
static const i0.VerificationMeta _quotaSizeInBytesMeta =
|
||||||
|
const i0.VerificationMeta('quotaSizeInBytes');
|
||||||
|
@override
|
||||||
|
late final i0.GeneratedColumn<int> quotaSizeInBytes = i0.GeneratedColumn<int>(
|
||||||
|
'quota_size_in_bytes',
|
||||||
|
aliasedName,
|
||||||
|
false,
|
||||||
|
type: i0.DriftSqlType.int,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
defaultValue: const i4.Constant(0),
|
||||||
|
);
|
||||||
|
static const i0.VerificationMeta _quotaUsageInBytesMeta =
|
||||||
|
const i0.VerificationMeta('quotaUsageInBytes');
|
||||||
|
@override
|
||||||
|
late final i0.GeneratedColumn<int> quotaUsageInBytes =
|
||||||
|
i0.GeneratedColumn<int>(
|
||||||
|
'quota_usage_in_bytes',
|
||||||
|
aliasedName,
|
||||||
|
false,
|
||||||
|
type: i0.DriftSqlType.int,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
defaultValue: const i4.Constant(0),
|
||||||
|
);
|
||||||
|
static const i0.VerificationMeta _pinCodeMeta = const i0.VerificationMeta(
|
||||||
|
'pinCode',
|
||||||
|
);
|
||||||
|
@override
|
||||||
|
late final i0.GeneratedColumn<String> pinCode = i0.GeneratedColumn<String>(
|
||||||
|
'pin_code',
|
||||||
|
aliasedName,
|
||||||
|
true,
|
||||||
|
type: i0.DriftSqlType.string,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
);
|
||||||
|
@override
|
||||||
|
List<i0.GeneratedColumn> 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
|
||||||
|
i0.VerificationContext validateIntegrity(
|
||||||
|
i0.Insertable<i1.AuthUserEntityData> instance, {
|
||||||
|
bool isInserting = false,
|
||||||
|
}) {
|
||||||
|
final context = i0.VerificationContext();
|
||||||
|
final data = instance.toColumns(true);
|
||||||
|
if (data.containsKey('id')) {
|
||||||
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
||||||
|
} else if (isInserting) {
|
||||||
|
context.missing(_idMeta);
|
||||||
|
}
|
||||||
|
if (data.containsKey('name')) {
|
||||||
|
context.handle(
|
||||||
|
_nameMeta,
|
||||||
|
name.isAcceptableOrUnknown(data['name']!, _nameMeta),
|
||||||
|
);
|
||||||
|
} else if (isInserting) {
|
||||||
|
context.missing(_nameMeta);
|
||||||
|
}
|
||||||
|
if (data.containsKey('email')) {
|
||||||
|
context.handle(
|
||||||
|
_emailMeta,
|
||||||
|
email.isAcceptableOrUnknown(data['email']!, _emailMeta),
|
||||||
|
);
|
||||||
|
} else if (isInserting) {
|
||||||
|
context.missing(_emailMeta);
|
||||||
|
}
|
||||||
|
if (data.containsKey('is_admin')) {
|
||||||
|
context.handle(
|
||||||
|
_isAdminMeta,
|
||||||
|
isAdmin.isAcceptableOrUnknown(data['is_admin']!, _isAdminMeta),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (data.containsKey('has_profile_image')) {
|
||||||
|
context.handle(
|
||||||
|
_hasProfileImageMeta,
|
||||||
|
hasProfileImage.isAcceptableOrUnknown(
|
||||||
|
data['has_profile_image']!,
|
||||||
|
_hasProfileImageMeta,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (data.containsKey('profile_changed_at')) {
|
||||||
|
context.handle(
|
||||||
|
_profileChangedAtMeta,
|
||||||
|
profileChangedAt.isAcceptableOrUnknown(
|
||||||
|
data['profile_changed_at']!,
|
||||||
|
_profileChangedAtMeta,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (data.containsKey('quota_size_in_bytes')) {
|
||||||
|
context.handle(
|
||||||
|
_quotaSizeInBytesMeta,
|
||||||
|
quotaSizeInBytes.isAcceptableOrUnknown(
|
||||||
|
data['quota_size_in_bytes']!,
|
||||||
|
_quotaSizeInBytesMeta,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (data.containsKey('quota_usage_in_bytes')) {
|
||||||
|
context.handle(
|
||||||
|
_quotaUsageInBytesMeta,
|
||||||
|
quotaUsageInBytes.isAcceptableOrUnknown(
|
||||||
|
data['quota_usage_in_bytes']!,
|
||||||
|
_quotaUsageInBytesMeta,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (data.containsKey('pin_code')) {
|
||||||
|
context.handle(
|
||||||
|
_pinCodeMeta,
|
||||||
|
pinCode.isAcceptableOrUnknown(data['pin_code']!, _pinCodeMeta),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Set<i0.GeneratedColumn> get $primaryKey => {id};
|
||||||
|
@override
|
||||||
|
i1.AuthUserEntityData map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||||
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||||
|
return i1.AuthUserEntityData(
|
||||||
|
id: attachedDatabase.typeMapping.read(
|
||||||
|
i0.DriftSqlType.string,
|
||||||
|
data['${effectivePrefix}id'],
|
||||||
|
)!,
|
||||||
|
name: attachedDatabase.typeMapping.read(
|
||||||
|
i0.DriftSqlType.string,
|
||||||
|
data['${effectivePrefix}name'],
|
||||||
|
)!,
|
||||||
|
email: attachedDatabase.typeMapping.read(
|
||||||
|
i0.DriftSqlType.string,
|
||||||
|
data['${effectivePrefix}email'],
|
||||||
|
)!,
|
||||||
|
isAdmin: attachedDatabase.typeMapping.read(
|
||||||
|
i0.DriftSqlType.bool,
|
||||||
|
data['${effectivePrefix}is_admin'],
|
||||||
|
)!,
|
||||||
|
hasProfileImage: attachedDatabase.typeMapping.read(
|
||||||
|
i0.DriftSqlType.bool,
|
||||||
|
data['${effectivePrefix}has_profile_image'],
|
||||||
|
)!,
|
||||||
|
profileChangedAt: attachedDatabase.typeMapping.read(
|
||||||
|
i0.DriftSqlType.dateTime,
|
||||||
|
data['${effectivePrefix}profile_changed_at'],
|
||||||
|
)!,
|
||||||
|
avatarColor: i1.$AuthUserEntityTable.$converteravatarColor.fromSql(
|
||||||
|
attachedDatabase.typeMapping.read(
|
||||||
|
i0.DriftSqlType.int,
|
||||||
|
data['${effectivePrefix}avatar_color'],
|
||||||
|
)!,
|
||||||
|
),
|
||||||
|
quotaSizeInBytes: attachedDatabase.typeMapping.read(
|
||||||
|
i0.DriftSqlType.int,
|
||||||
|
data['${effectivePrefix}quota_size_in_bytes'],
|
||||||
|
)!,
|
||||||
|
quotaUsageInBytes: attachedDatabase.typeMapping.read(
|
||||||
|
i0.DriftSqlType.int,
|
||||||
|
data['${effectivePrefix}quota_usage_in_bytes'],
|
||||||
|
)!,
|
||||||
|
pinCode: attachedDatabase.typeMapping.read(
|
||||||
|
i0.DriftSqlType.string,
|
||||||
|
data['${effectivePrefix}pin_code'],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
$AuthUserEntityTable createAlias(String alias) {
|
||||||
|
return $AuthUserEntityTable(attachedDatabase, alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
static i0.JsonTypeConverter2<i2.AvatarColor, int, int> $converteravatarColor =
|
||||||
|
const i0.EnumIndexConverter<i2.AvatarColor>(i2.AvatarColor.values);
|
||||||
|
@override
|
||||||
|
bool get withoutRowId => true;
|
||||||
|
@override
|
||||||
|
bool get isStrict => true;
|
||||||
|
}
|
||||||
|
|
||||||
|
class AuthUserEntityData extends i0.DataClass
|
||||||
|
implements i0.Insertable<i1.AuthUserEntityData> {
|
||||||
|
final String id;
|
||||||
|
final String name;
|
||||||
|
final String email;
|
||||||
|
final bool isAdmin;
|
||||||
|
final bool hasProfileImage;
|
||||||
|
final DateTime profileChangedAt;
|
||||||
|
final i2.AvatarColor 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<String, i0.Expression> toColumns(bool nullToAbsent) {
|
||||||
|
final map = <String, i0.Expression>{};
|
||||||
|
map['id'] = i0.Variable<String>(id);
|
||||||
|
map['name'] = i0.Variable<String>(name);
|
||||||
|
map['email'] = i0.Variable<String>(email);
|
||||||
|
map['is_admin'] = i0.Variable<bool>(isAdmin);
|
||||||
|
map['has_profile_image'] = i0.Variable<bool>(hasProfileImage);
|
||||||
|
map['profile_changed_at'] = i0.Variable<DateTime>(profileChangedAt);
|
||||||
|
{
|
||||||
|
map['avatar_color'] = i0.Variable<int>(
|
||||||
|
i1.$AuthUserEntityTable.$converteravatarColor.toSql(avatarColor),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
map['quota_size_in_bytes'] = i0.Variable<int>(quotaSizeInBytes);
|
||||||
|
map['quota_usage_in_bytes'] = i0.Variable<int>(quotaUsageInBytes);
|
||||||
|
if (!nullToAbsent || pinCode != null) {
|
||||||
|
map['pin_code'] = i0.Variable<String>(pinCode);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
factory AuthUserEntityData.fromJson(
|
||||||
|
Map<String, dynamic> json, {
|
||||||
|
i0.ValueSerializer? serializer,
|
||||||
|
}) {
|
||||||
|
serializer ??= i0.driftRuntimeOptions.defaultSerializer;
|
||||||
|
return AuthUserEntityData(
|
||||||
|
id: serializer.fromJson<String>(json['id']),
|
||||||
|
name: serializer.fromJson<String>(json['name']),
|
||||||
|
email: serializer.fromJson<String>(json['email']),
|
||||||
|
isAdmin: serializer.fromJson<bool>(json['isAdmin']),
|
||||||
|
hasProfileImage: serializer.fromJson<bool>(json['hasProfileImage']),
|
||||||
|
profileChangedAt: serializer.fromJson<DateTime>(json['profileChangedAt']),
|
||||||
|
avatarColor: i1.$AuthUserEntityTable.$converteravatarColor.fromJson(
|
||||||
|
serializer.fromJson<int>(json['avatarColor']),
|
||||||
|
),
|
||||||
|
quotaSizeInBytes: serializer.fromJson<int>(json['quotaSizeInBytes']),
|
||||||
|
quotaUsageInBytes: serializer.fromJson<int>(json['quotaUsageInBytes']),
|
||||||
|
pinCode: serializer.fromJson<String?>(json['pinCode']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson({i0.ValueSerializer? serializer}) {
|
||||||
|
serializer ??= i0.driftRuntimeOptions.defaultSerializer;
|
||||||
|
return <String, dynamic>{
|
||||||
|
'id': serializer.toJson<String>(id),
|
||||||
|
'name': serializer.toJson<String>(name),
|
||||||
|
'email': serializer.toJson<String>(email),
|
||||||
|
'isAdmin': serializer.toJson<bool>(isAdmin),
|
||||||
|
'hasProfileImage': serializer.toJson<bool>(hasProfileImage),
|
||||||
|
'profileChangedAt': serializer.toJson<DateTime>(profileChangedAt),
|
||||||
|
'avatarColor': serializer.toJson<int>(
|
||||||
|
i1.$AuthUserEntityTable.$converteravatarColor.toJson(avatarColor),
|
||||||
|
),
|
||||||
|
'quotaSizeInBytes': serializer.toJson<int>(quotaSizeInBytes),
|
||||||
|
'quotaUsageInBytes': serializer.toJson<int>(quotaUsageInBytes),
|
||||||
|
'pinCode': serializer.toJson<String?>(pinCode),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
i1.AuthUserEntityData copyWith({
|
||||||
|
String? id,
|
||||||
|
String? name,
|
||||||
|
String? email,
|
||||||
|
bool? isAdmin,
|
||||||
|
bool? hasProfileImage,
|
||||||
|
DateTime? profileChangedAt,
|
||||||
|
i2.AvatarColor? avatarColor,
|
||||||
|
int? quotaSizeInBytes,
|
||||||
|
int? quotaUsageInBytes,
|
||||||
|
i0.Value<String?> pinCode = const i0.Value.absent(),
|
||||||
|
}) => i1.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(i1.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 i1.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 i0.UpdateCompanion<i1.AuthUserEntityData> {
|
||||||
|
final i0.Value<String> id;
|
||||||
|
final i0.Value<String> name;
|
||||||
|
final i0.Value<String> email;
|
||||||
|
final i0.Value<bool> isAdmin;
|
||||||
|
final i0.Value<bool> hasProfileImage;
|
||||||
|
final i0.Value<DateTime> profileChangedAt;
|
||||||
|
final i0.Value<i2.AvatarColor> avatarColor;
|
||||||
|
final i0.Value<int> quotaSizeInBytes;
|
||||||
|
final i0.Value<int> quotaUsageInBytes;
|
||||||
|
final i0.Value<String?> pinCode;
|
||||||
|
const AuthUserEntityCompanion({
|
||||||
|
this.id = const i0.Value.absent(),
|
||||||
|
this.name = const i0.Value.absent(),
|
||||||
|
this.email = const i0.Value.absent(),
|
||||||
|
this.isAdmin = const i0.Value.absent(),
|
||||||
|
this.hasProfileImage = const i0.Value.absent(),
|
||||||
|
this.profileChangedAt = const i0.Value.absent(),
|
||||||
|
this.avatarColor = const i0.Value.absent(),
|
||||||
|
this.quotaSizeInBytes = const i0.Value.absent(),
|
||||||
|
this.quotaUsageInBytes = const i0.Value.absent(),
|
||||||
|
this.pinCode = const i0.Value.absent(),
|
||||||
|
});
|
||||||
|
AuthUserEntityCompanion.insert({
|
||||||
|
required String id,
|
||||||
|
required String name,
|
||||||
|
required String email,
|
||||||
|
this.isAdmin = const i0.Value.absent(),
|
||||||
|
this.hasProfileImage = const i0.Value.absent(),
|
||||||
|
this.profileChangedAt = const i0.Value.absent(),
|
||||||
|
required i2.AvatarColor avatarColor,
|
||||||
|
this.quotaSizeInBytes = const i0.Value.absent(),
|
||||||
|
this.quotaUsageInBytes = const i0.Value.absent(),
|
||||||
|
this.pinCode = const i0.Value.absent(),
|
||||||
|
}) : id = i0.Value(id),
|
||||||
|
name = i0.Value(name),
|
||||||
|
email = i0.Value(email),
|
||||||
|
avatarColor = i0.Value(avatarColor);
|
||||||
|
static i0.Insertable<i1.AuthUserEntityData> custom({
|
||||||
|
i0.Expression<String>? id,
|
||||||
|
i0.Expression<String>? name,
|
||||||
|
i0.Expression<String>? email,
|
||||||
|
i0.Expression<bool>? isAdmin,
|
||||||
|
i0.Expression<bool>? hasProfileImage,
|
||||||
|
i0.Expression<DateTime>? profileChangedAt,
|
||||||
|
i0.Expression<int>? avatarColor,
|
||||||
|
i0.Expression<int>? quotaSizeInBytes,
|
||||||
|
i0.Expression<int>? quotaUsageInBytes,
|
||||||
|
i0.Expression<String>? pinCode,
|
||||||
|
}) {
|
||||||
|
return i0.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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
i1.AuthUserEntityCompanion copyWith({
|
||||||
|
i0.Value<String>? id,
|
||||||
|
i0.Value<String>? name,
|
||||||
|
i0.Value<String>? email,
|
||||||
|
i0.Value<bool>? isAdmin,
|
||||||
|
i0.Value<bool>? hasProfileImage,
|
||||||
|
i0.Value<DateTime>? profileChangedAt,
|
||||||
|
i0.Value<i2.AvatarColor>? avatarColor,
|
||||||
|
i0.Value<int>? quotaSizeInBytes,
|
||||||
|
i0.Value<int>? quotaUsageInBytes,
|
||||||
|
i0.Value<String?>? pinCode,
|
||||||
|
}) {
|
||||||
|
return i1.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<String, i0.Expression> toColumns(bool nullToAbsent) {
|
||||||
|
final map = <String, i0.Expression>{};
|
||||||
|
if (id.present) {
|
||||||
|
map['id'] = i0.Variable<String>(id.value);
|
||||||
|
}
|
||||||
|
if (name.present) {
|
||||||
|
map['name'] = i0.Variable<String>(name.value);
|
||||||
|
}
|
||||||
|
if (email.present) {
|
||||||
|
map['email'] = i0.Variable<String>(email.value);
|
||||||
|
}
|
||||||
|
if (isAdmin.present) {
|
||||||
|
map['is_admin'] = i0.Variable<bool>(isAdmin.value);
|
||||||
|
}
|
||||||
|
if (hasProfileImage.present) {
|
||||||
|
map['has_profile_image'] = i0.Variable<bool>(hasProfileImage.value);
|
||||||
|
}
|
||||||
|
if (profileChangedAt.present) {
|
||||||
|
map['profile_changed_at'] = i0.Variable<DateTime>(profileChangedAt.value);
|
||||||
|
}
|
||||||
|
if (avatarColor.present) {
|
||||||
|
map['avatar_color'] = i0.Variable<int>(
|
||||||
|
i1.$AuthUserEntityTable.$converteravatarColor.toSql(avatarColor.value),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (quotaSizeInBytes.present) {
|
||||||
|
map['quota_size_in_bytes'] = i0.Variable<int>(quotaSizeInBytes.value);
|
||||||
|
}
|
||||||
|
if (quotaUsageInBytes.present) {
|
||||||
|
map['quota_usage_in_bytes'] = i0.Variable<int>(quotaUsageInBytes.value);
|
||||||
|
}
|
||||||
|
if (pinCode.present) {
|
||||||
|
map['pin_code'] = i0.Variable<String>(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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,5 @@
|
|||||||
import 'package:drift/drift.dart' hide Index;
|
import 'package:drift/drift.dart' hide Index;
|
||||||
import 'package:immich_mobile/domain/models/user.model.dart';
|
import 'package:immich_mobile/domain/models/user.model.dart';
|
||||||
import 'package:immich_mobile/domain/models/user_metadata.model.dart';
|
|
||||||
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
|
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
|
||||||
import 'package:immich_mobile/utils/hash.dart';
|
import 'package:immich_mobile/utils/hash.dart';
|
||||||
import 'package:isar/isar.dart';
|
import 'package:isar/isar.dart';
|
||||||
@ -44,7 +43,7 @@ class User {
|
|||||||
|
|
||||||
static User fromDto(UserDto dto) => User(
|
static User fromDto(UserDto dto) => User(
|
||||||
id: dto.id,
|
id: dto.id,
|
||||||
updatedAt: dto.updatedAt,
|
updatedAt: dto.updatedAt ?? DateTime(2025),
|
||||||
email: dto.email,
|
email: dto.email,
|
||||||
name: dto.name,
|
name: dto.name,
|
||||||
isAdmin: dto.isAdmin,
|
isAdmin: dto.isAdmin,
|
||||||
@ -81,13 +80,12 @@ class UserEntity extends Table with DriftDefaultsMixin {
|
|||||||
|
|
||||||
TextColumn get id => text()();
|
TextColumn get id => text()();
|
||||||
TextColumn get name => text()();
|
TextColumn get name => text()();
|
||||||
BoolColumn get isAdmin => boolean().withDefault(const Constant(false))();
|
|
||||||
TextColumn get email => text()();
|
TextColumn get email => text()();
|
||||||
|
|
||||||
|
// Profile image
|
||||||
BoolColumn get hasProfileImage => boolean().withDefault(const Constant(false))();
|
BoolColumn get hasProfileImage => boolean().withDefault(const Constant(false))();
|
||||||
DateTimeColumn get profileChangedAt => dateTime().withDefault(currentDateAndTime)();
|
DateTimeColumn get profileChangedAt => dateTime().withDefault(currentDateAndTime)();
|
||||||
|
IntColumn get avatarColor => intEnum<AvatarColor>().withDefault(const Constant(0))();
|
||||||
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Set<Column> get primaryKey => {id};
|
Set<Column> get primaryKey => {id};
|
||||||
|
|||||||
@ -3,28 +3,27 @@
|
|||||||
import 'package:drift/drift.dart' as i0;
|
import 'package:drift/drift.dart' as i0;
|
||||||
import 'package:immich_mobile/infrastructure/entities/user.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/user.entity.drift.dart'
|
||||||
as i1;
|
as i1;
|
||||||
import 'package:immich_mobile/infrastructure/entities/user.entity.dart' as i2;
|
import 'package:immich_mobile/domain/models/user.model.dart' as i2;
|
||||||
import 'package:drift/src/runtime/query_builder/query_builder.dart' as i3;
|
import 'package:immich_mobile/infrastructure/entities/user.entity.dart' as i3;
|
||||||
|
import 'package:drift/src/runtime/query_builder/query_builder.dart' as i4;
|
||||||
|
|
||||||
typedef $$UserEntityTableCreateCompanionBuilder =
|
typedef $$UserEntityTableCreateCompanionBuilder =
|
||||||
i1.UserEntityCompanion Function({
|
i1.UserEntityCompanion Function({
|
||||||
required String id,
|
required String id,
|
||||||
required String name,
|
required String name,
|
||||||
i0.Value<bool> isAdmin,
|
|
||||||
required String email,
|
required String email,
|
||||||
i0.Value<bool> hasProfileImage,
|
i0.Value<bool> hasProfileImage,
|
||||||
i0.Value<DateTime> profileChangedAt,
|
i0.Value<DateTime> profileChangedAt,
|
||||||
i0.Value<DateTime> updatedAt,
|
i0.Value<i2.AvatarColor> avatarColor,
|
||||||
});
|
});
|
||||||
typedef $$UserEntityTableUpdateCompanionBuilder =
|
typedef $$UserEntityTableUpdateCompanionBuilder =
|
||||||
i1.UserEntityCompanion Function({
|
i1.UserEntityCompanion Function({
|
||||||
i0.Value<String> id,
|
i0.Value<String> id,
|
||||||
i0.Value<String> name,
|
i0.Value<String> name,
|
||||||
i0.Value<bool> isAdmin,
|
|
||||||
i0.Value<String> email,
|
i0.Value<String> email,
|
||||||
i0.Value<bool> hasProfileImage,
|
i0.Value<bool> hasProfileImage,
|
||||||
i0.Value<DateTime> profileChangedAt,
|
i0.Value<DateTime> profileChangedAt,
|
||||||
i0.Value<DateTime> updatedAt,
|
i0.Value<i2.AvatarColor> avatarColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
class $$UserEntityTableFilterComposer
|
class $$UserEntityTableFilterComposer
|
||||||
@ -46,11 +45,6 @@ class $$UserEntityTableFilterComposer
|
|||||||
builder: (column) => i0.ColumnFilters(column),
|
builder: (column) => i0.ColumnFilters(column),
|
||||||
);
|
);
|
||||||
|
|
||||||
i0.ColumnFilters<bool> get isAdmin => $composableBuilder(
|
|
||||||
column: $table.isAdmin,
|
|
||||||
builder: (column) => i0.ColumnFilters(column),
|
|
||||||
);
|
|
||||||
|
|
||||||
i0.ColumnFilters<String> get email => $composableBuilder(
|
i0.ColumnFilters<String> get email => $composableBuilder(
|
||||||
column: $table.email,
|
column: $table.email,
|
||||||
builder: (column) => i0.ColumnFilters(column),
|
builder: (column) => i0.ColumnFilters(column),
|
||||||
@ -66,9 +60,10 @@ class $$UserEntityTableFilterComposer
|
|||||||
builder: (column) => i0.ColumnFilters(column),
|
builder: (column) => i0.ColumnFilters(column),
|
||||||
);
|
);
|
||||||
|
|
||||||
i0.ColumnFilters<DateTime> get updatedAt => $composableBuilder(
|
i0.ColumnWithTypeConverterFilters<i2.AvatarColor, i2.AvatarColor, int>
|
||||||
column: $table.updatedAt,
|
get avatarColor => $composableBuilder(
|
||||||
builder: (column) => i0.ColumnFilters(column),
|
column: $table.avatarColor,
|
||||||
|
builder: (column) => i0.ColumnWithTypeConverterFilters(column),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,11 +86,6 @@ class $$UserEntityTableOrderingComposer
|
|||||||
builder: (column) => i0.ColumnOrderings(column),
|
builder: (column) => i0.ColumnOrderings(column),
|
||||||
);
|
);
|
||||||
|
|
||||||
i0.ColumnOrderings<bool> get isAdmin => $composableBuilder(
|
|
||||||
column: $table.isAdmin,
|
|
||||||
builder: (column) => i0.ColumnOrderings(column),
|
|
||||||
);
|
|
||||||
|
|
||||||
i0.ColumnOrderings<String> get email => $composableBuilder(
|
i0.ColumnOrderings<String> get email => $composableBuilder(
|
||||||
column: $table.email,
|
column: $table.email,
|
||||||
builder: (column) => i0.ColumnOrderings(column),
|
builder: (column) => i0.ColumnOrderings(column),
|
||||||
@ -111,8 +101,8 @@ class $$UserEntityTableOrderingComposer
|
|||||||
builder: (column) => i0.ColumnOrderings(column),
|
builder: (column) => i0.ColumnOrderings(column),
|
||||||
);
|
);
|
||||||
|
|
||||||
i0.ColumnOrderings<DateTime> get updatedAt => $composableBuilder(
|
i0.ColumnOrderings<int> get avatarColor => $composableBuilder(
|
||||||
column: $table.updatedAt,
|
column: $table.avatarColor,
|
||||||
builder: (column) => i0.ColumnOrderings(column),
|
builder: (column) => i0.ColumnOrderings(column),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -132,9 +122,6 @@ class $$UserEntityTableAnnotationComposer
|
|||||||
i0.GeneratedColumn<String> get name =>
|
i0.GeneratedColumn<String> get name =>
|
||||||
$composableBuilder(column: $table.name, builder: (column) => column);
|
$composableBuilder(column: $table.name, builder: (column) => column);
|
||||||
|
|
||||||
i0.GeneratedColumn<bool> get isAdmin =>
|
|
||||||
$composableBuilder(column: $table.isAdmin, builder: (column) => column);
|
|
||||||
|
|
||||||
i0.GeneratedColumn<String> get email =>
|
i0.GeneratedColumn<String> get email =>
|
||||||
$composableBuilder(column: $table.email, builder: (column) => column);
|
$composableBuilder(column: $table.email, builder: (column) => column);
|
||||||
|
|
||||||
@ -148,8 +135,11 @@ class $$UserEntityTableAnnotationComposer
|
|||||||
builder: (column) => column,
|
builder: (column) => column,
|
||||||
);
|
);
|
||||||
|
|
||||||
i0.GeneratedColumn<DateTime> get updatedAt =>
|
i0.GeneratedColumnWithTypeConverter<i2.AvatarColor, int> get avatarColor =>
|
||||||
$composableBuilder(column: $table.updatedAt, builder: (column) => column);
|
$composableBuilder(
|
||||||
|
column: $table.avatarColor,
|
||||||
|
builder: (column) => column,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class $$UserEntityTableTableManager
|
class $$UserEntityTableTableManager
|
||||||
@ -191,37 +181,33 @@ class $$UserEntityTableTableManager
|
|||||||
({
|
({
|
||||||
i0.Value<String> id = const i0.Value.absent(),
|
i0.Value<String> id = const i0.Value.absent(),
|
||||||
i0.Value<String> name = const i0.Value.absent(),
|
i0.Value<String> name = const i0.Value.absent(),
|
||||||
i0.Value<bool> isAdmin = const i0.Value.absent(),
|
|
||||||
i0.Value<String> email = const i0.Value.absent(),
|
i0.Value<String> email = const i0.Value.absent(),
|
||||||
i0.Value<bool> hasProfileImage = const i0.Value.absent(),
|
i0.Value<bool> hasProfileImage = const i0.Value.absent(),
|
||||||
i0.Value<DateTime> profileChangedAt = const i0.Value.absent(),
|
i0.Value<DateTime> profileChangedAt = const i0.Value.absent(),
|
||||||
i0.Value<DateTime> updatedAt = const i0.Value.absent(),
|
i0.Value<i2.AvatarColor> avatarColor = const i0.Value.absent(),
|
||||||
}) => i1.UserEntityCompanion(
|
}) => i1.UserEntityCompanion(
|
||||||
id: id,
|
id: id,
|
||||||
name: name,
|
name: name,
|
||||||
isAdmin: isAdmin,
|
|
||||||
email: email,
|
email: email,
|
||||||
hasProfileImage: hasProfileImage,
|
hasProfileImage: hasProfileImage,
|
||||||
profileChangedAt: profileChangedAt,
|
profileChangedAt: profileChangedAt,
|
||||||
updatedAt: updatedAt,
|
avatarColor: avatarColor,
|
||||||
),
|
),
|
||||||
createCompanionCallback:
|
createCompanionCallback:
|
||||||
({
|
({
|
||||||
required String id,
|
required String id,
|
||||||
required String name,
|
required String name,
|
||||||
i0.Value<bool> isAdmin = const i0.Value.absent(),
|
|
||||||
required String email,
|
required String email,
|
||||||
i0.Value<bool> hasProfileImage = const i0.Value.absent(),
|
i0.Value<bool> hasProfileImage = const i0.Value.absent(),
|
||||||
i0.Value<DateTime> profileChangedAt = const i0.Value.absent(),
|
i0.Value<DateTime> profileChangedAt = const i0.Value.absent(),
|
||||||
i0.Value<DateTime> updatedAt = const i0.Value.absent(),
|
i0.Value<i2.AvatarColor> avatarColor = const i0.Value.absent(),
|
||||||
}) => i1.UserEntityCompanion.insert(
|
}) => i1.UserEntityCompanion.insert(
|
||||||
id: id,
|
id: id,
|
||||||
name: name,
|
name: name,
|
||||||
isAdmin: isAdmin,
|
|
||||||
email: email,
|
email: email,
|
||||||
hasProfileImage: hasProfileImage,
|
hasProfileImage: hasProfileImage,
|
||||||
profileChangedAt: profileChangedAt,
|
profileChangedAt: profileChangedAt,
|
||||||
updatedAt: updatedAt,
|
avatarColor: avatarColor,
|
||||||
),
|
),
|
||||||
withReferenceMapper: (p0) => p0
|
withReferenceMapper: (p0) => p0
|
||||||
.map((e) => (e.readTable(table), i0.BaseReferences(db, table, e)))
|
.map((e) => (e.readTable(table), i0.BaseReferences(db, table, e)))
|
||||||
@ -253,7 +239,7 @@ typedef $$UserEntityTableProcessedTableManager =
|
|||||||
i0.PrefetchHooks Function()
|
i0.PrefetchHooks Function()
|
||||||
>;
|
>;
|
||||||
|
|
||||||
class $UserEntityTable extends i2.UserEntity
|
class $UserEntityTable extends i3.UserEntity
|
||||||
with i0.TableInfo<$UserEntityTable, i1.UserEntityData> {
|
with i0.TableInfo<$UserEntityTable, i1.UserEntityData> {
|
||||||
@override
|
@override
|
||||||
final i0.GeneratedDatabase attachedDatabase;
|
final i0.GeneratedDatabase attachedDatabase;
|
||||||
@ -279,21 +265,6 @@ class $UserEntityTable extends i2.UserEntity
|
|||||||
type: i0.DriftSqlType.string,
|
type: i0.DriftSqlType.string,
|
||||||
requiredDuringInsert: true,
|
requiredDuringInsert: true,
|
||||||
);
|
);
|
||||||
static const i0.VerificationMeta _isAdminMeta = const i0.VerificationMeta(
|
|
||||||
'isAdmin',
|
|
||||||
);
|
|
||||||
@override
|
|
||||||
late final i0.GeneratedColumn<bool> isAdmin = i0.GeneratedColumn<bool>(
|
|
||||||
'is_admin',
|
|
||||||
aliasedName,
|
|
||||||
false,
|
|
||||||
type: i0.DriftSqlType.bool,
|
|
||||||
requiredDuringInsert: false,
|
|
||||||
defaultConstraints: i0.GeneratedColumn.constraintIsAlways(
|
|
||||||
'CHECK ("is_admin" IN (0, 1))',
|
|
||||||
),
|
|
||||||
defaultValue: const i3.Constant(false),
|
|
||||||
);
|
|
||||||
static const i0.VerificationMeta _emailMeta = const i0.VerificationMeta(
|
static const i0.VerificationMeta _emailMeta = const i0.VerificationMeta(
|
||||||
'email',
|
'email',
|
||||||
);
|
);
|
||||||
@ -318,7 +289,7 @@ class $UserEntityTable extends i2.UserEntity
|
|||||||
defaultConstraints: i0.GeneratedColumn.constraintIsAlways(
|
defaultConstraints: i0.GeneratedColumn.constraintIsAlways(
|
||||||
'CHECK ("has_profile_image" IN (0, 1))',
|
'CHECK ("has_profile_image" IN (0, 1))',
|
||||||
),
|
),
|
||||||
defaultValue: const i3.Constant(false),
|
defaultValue: const i4.Constant(false),
|
||||||
);
|
);
|
||||||
static const i0.VerificationMeta _profileChangedAtMeta =
|
static const i0.VerificationMeta _profileChangedAtMeta =
|
||||||
const i0.VerificationMeta('profileChangedAt');
|
const i0.VerificationMeta('profileChangedAt');
|
||||||
@ -330,30 +301,26 @@ class $UserEntityTable extends i2.UserEntity
|
|||||||
false,
|
false,
|
||||||
type: i0.DriftSqlType.dateTime,
|
type: i0.DriftSqlType.dateTime,
|
||||||
requiredDuringInsert: false,
|
requiredDuringInsert: false,
|
||||||
defaultValue: i3.currentDateAndTime,
|
defaultValue: i4.currentDateAndTime,
|
||||||
);
|
|
||||||
static const i0.VerificationMeta _updatedAtMeta = const i0.VerificationMeta(
|
|
||||||
'updatedAt',
|
|
||||||
);
|
);
|
||||||
@override
|
@override
|
||||||
late final i0.GeneratedColumn<DateTime> updatedAt =
|
late final i0.GeneratedColumnWithTypeConverter<i2.AvatarColor, int>
|
||||||
i0.GeneratedColumn<DateTime>(
|
avatarColor = i0.GeneratedColumn<int>(
|
||||||
'updated_at',
|
'avatar_color',
|
||||||
aliasedName,
|
aliasedName,
|
||||||
false,
|
false,
|
||||||
type: i0.DriftSqlType.dateTime,
|
type: i0.DriftSqlType.int,
|
||||||
requiredDuringInsert: false,
|
requiredDuringInsert: false,
|
||||||
defaultValue: i3.currentDateAndTime,
|
defaultValue: const i4.Constant(0),
|
||||||
);
|
).withConverter<i2.AvatarColor>(i1.$UserEntityTable.$converteravatarColor);
|
||||||
@override
|
@override
|
||||||
List<i0.GeneratedColumn> get $columns => [
|
List<i0.GeneratedColumn> get $columns => [
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
isAdmin,
|
|
||||||
email,
|
email,
|
||||||
hasProfileImage,
|
hasProfileImage,
|
||||||
profileChangedAt,
|
profileChangedAt,
|
||||||
updatedAt,
|
avatarColor,
|
||||||
];
|
];
|
||||||
@override
|
@override
|
||||||
String get aliasedName => _alias ?? actualTableName;
|
String get aliasedName => _alias ?? actualTableName;
|
||||||
@ -380,12 +347,6 @@ class $UserEntityTable extends i2.UserEntity
|
|||||||
} else if (isInserting) {
|
} else if (isInserting) {
|
||||||
context.missing(_nameMeta);
|
context.missing(_nameMeta);
|
||||||
}
|
}
|
||||||
if (data.containsKey('is_admin')) {
|
|
||||||
context.handle(
|
|
||||||
_isAdminMeta,
|
|
||||||
isAdmin.isAcceptableOrUnknown(data['is_admin']!, _isAdminMeta),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (data.containsKey('email')) {
|
if (data.containsKey('email')) {
|
||||||
context.handle(
|
context.handle(
|
||||||
_emailMeta,
|
_emailMeta,
|
||||||
@ -412,12 +373,6 @@ class $UserEntityTable extends i2.UserEntity
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (data.containsKey('updated_at')) {
|
|
||||||
context.handle(
|
|
||||||
_updatedAtMeta,
|
|
||||||
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,10 +390,6 @@ class $UserEntityTable extends i2.UserEntity
|
|||||||
i0.DriftSqlType.string,
|
i0.DriftSqlType.string,
|
||||||
data['${effectivePrefix}name'],
|
data['${effectivePrefix}name'],
|
||||||
)!,
|
)!,
|
||||||
isAdmin: attachedDatabase.typeMapping.read(
|
|
||||||
i0.DriftSqlType.bool,
|
|
||||||
data['${effectivePrefix}is_admin'],
|
|
||||||
)!,
|
|
||||||
email: attachedDatabase.typeMapping.read(
|
email: attachedDatabase.typeMapping.read(
|
||||||
i0.DriftSqlType.string,
|
i0.DriftSqlType.string,
|
||||||
data['${effectivePrefix}email'],
|
data['${effectivePrefix}email'],
|
||||||
@ -451,10 +402,12 @@ class $UserEntityTable extends i2.UserEntity
|
|||||||
i0.DriftSqlType.dateTime,
|
i0.DriftSqlType.dateTime,
|
||||||
data['${effectivePrefix}profile_changed_at'],
|
data['${effectivePrefix}profile_changed_at'],
|
||||||
)!,
|
)!,
|
||||||
updatedAt: attachedDatabase.typeMapping.read(
|
avatarColor: i1.$UserEntityTable.$converteravatarColor.fromSql(
|
||||||
i0.DriftSqlType.dateTime,
|
attachedDatabase.typeMapping.read(
|
||||||
data['${effectivePrefix}updated_at'],
|
i0.DriftSqlType.int,
|
||||||
|
data['${effectivePrefix}avatar_color'],
|
||||||
)!,
|
)!,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,6 +416,8 @@ class $UserEntityTable extends i2.UserEntity
|
|||||||
return $UserEntityTable(attachedDatabase, alias);
|
return $UserEntityTable(attachedDatabase, alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static i0.JsonTypeConverter2<i2.AvatarColor, int, int> $converteravatarColor =
|
||||||
|
const i0.EnumIndexConverter<i2.AvatarColor>(i2.AvatarColor.values);
|
||||||
@override
|
@override
|
||||||
bool get withoutRowId => true;
|
bool get withoutRowId => true;
|
||||||
@override
|
@override
|
||||||
@ -473,30 +428,31 @@ class UserEntityData extends i0.DataClass
|
|||||||
implements i0.Insertable<i1.UserEntityData> {
|
implements i0.Insertable<i1.UserEntityData> {
|
||||||
final String id;
|
final String id;
|
||||||
final String name;
|
final String name;
|
||||||
final bool isAdmin;
|
|
||||||
final String email;
|
final String email;
|
||||||
final bool hasProfileImage;
|
final bool hasProfileImage;
|
||||||
final DateTime profileChangedAt;
|
final DateTime profileChangedAt;
|
||||||
final DateTime updatedAt;
|
final i2.AvatarColor avatarColor;
|
||||||
const UserEntityData({
|
const UserEntityData({
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.isAdmin,
|
|
||||||
required this.email,
|
required this.email,
|
||||||
required this.hasProfileImage,
|
required this.hasProfileImage,
|
||||||
required this.profileChangedAt,
|
required this.profileChangedAt,
|
||||||
required this.updatedAt,
|
required this.avatarColor,
|
||||||
});
|
});
|
||||||
@override
|
@override
|
||||||
Map<String, i0.Expression> toColumns(bool nullToAbsent) {
|
Map<String, i0.Expression> toColumns(bool nullToAbsent) {
|
||||||
final map = <String, i0.Expression>{};
|
final map = <String, i0.Expression>{};
|
||||||
map['id'] = i0.Variable<String>(id);
|
map['id'] = i0.Variable<String>(id);
|
||||||
map['name'] = i0.Variable<String>(name);
|
map['name'] = i0.Variable<String>(name);
|
||||||
map['is_admin'] = i0.Variable<bool>(isAdmin);
|
|
||||||
map['email'] = i0.Variable<String>(email);
|
map['email'] = i0.Variable<String>(email);
|
||||||
map['has_profile_image'] = i0.Variable<bool>(hasProfileImage);
|
map['has_profile_image'] = i0.Variable<bool>(hasProfileImage);
|
||||||
map['profile_changed_at'] = i0.Variable<DateTime>(profileChangedAt);
|
map['profile_changed_at'] = i0.Variable<DateTime>(profileChangedAt);
|
||||||
map['updated_at'] = i0.Variable<DateTime>(updatedAt);
|
{
|
||||||
|
map['avatar_color'] = i0.Variable<int>(
|
||||||
|
i1.$UserEntityTable.$converteravatarColor.toSql(avatarColor),
|
||||||
|
);
|
||||||
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -508,11 +464,12 @@ class UserEntityData extends i0.DataClass
|
|||||||
return UserEntityData(
|
return UserEntityData(
|
||||||
id: serializer.fromJson<String>(json['id']),
|
id: serializer.fromJson<String>(json['id']),
|
||||||
name: serializer.fromJson<String>(json['name']),
|
name: serializer.fromJson<String>(json['name']),
|
||||||
isAdmin: serializer.fromJson<bool>(json['isAdmin']),
|
|
||||||
email: serializer.fromJson<String>(json['email']),
|
email: serializer.fromJson<String>(json['email']),
|
||||||
hasProfileImage: serializer.fromJson<bool>(json['hasProfileImage']),
|
hasProfileImage: serializer.fromJson<bool>(json['hasProfileImage']),
|
||||||
profileChangedAt: serializer.fromJson<DateTime>(json['profileChangedAt']),
|
profileChangedAt: serializer.fromJson<DateTime>(json['profileChangedAt']),
|
||||||
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
avatarColor: i1.$UserEntityTable.$converteravatarColor.fromJson(
|
||||||
|
serializer.fromJson<int>(json['avatarColor']),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@override
|
@override
|
||||||
@ -521,36 +478,34 @@ class UserEntityData extends i0.DataClass
|
|||||||
return <String, dynamic>{
|
return <String, dynamic>{
|
||||||
'id': serializer.toJson<String>(id),
|
'id': serializer.toJson<String>(id),
|
||||||
'name': serializer.toJson<String>(name),
|
'name': serializer.toJson<String>(name),
|
||||||
'isAdmin': serializer.toJson<bool>(isAdmin),
|
|
||||||
'email': serializer.toJson<String>(email),
|
'email': serializer.toJson<String>(email),
|
||||||
'hasProfileImage': serializer.toJson<bool>(hasProfileImage),
|
'hasProfileImage': serializer.toJson<bool>(hasProfileImage),
|
||||||
'profileChangedAt': serializer.toJson<DateTime>(profileChangedAt),
|
'profileChangedAt': serializer.toJson<DateTime>(profileChangedAt),
|
||||||
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
'avatarColor': serializer.toJson<int>(
|
||||||
|
i1.$UserEntityTable.$converteravatarColor.toJson(avatarColor),
|
||||||
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
i1.UserEntityData copyWith({
|
i1.UserEntityData copyWith({
|
||||||
String? id,
|
String? id,
|
||||||
String? name,
|
String? name,
|
||||||
bool? isAdmin,
|
|
||||||
String? email,
|
String? email,
|
||||||
bool? hasProfileImage,
|
bool? hasProfileImage,
|
||||||
DateTime? profileChangedAt,
|
DateTime? profileChangedAt,
|
||||||
DateTime? updatedAt,
|
i2.AvatarColor? avatarColor,
|
||||||
}) => i1.UserEntityData(
|
}) => i1.UserEntityData(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
name: name ?? this.name,
|
name: name ?? this.name,
|
||||||
isAdmin: isAdmin ?? this.isAdmin,
|
|
||||||
email: email ?? this.email,
|
email: email ?? this.email,
|
||||||
hasProfileImage: hasProfileImage ?? this.hasProfileImage,
|
hasProfileImage: hasProfileImage ?? this.hasProfileImage,
|
||||||
profileChangedAt: profileChangedAt ?? this.profileChangedAt,
|
profileChangedAt: profileChangedAt ?? this.profileChangedAt,
|
||||||
updatedAt: updatedAt ?? this.updatedAt,
|
avatarColor: avatarColor ?? this.avatarColor,
|
||||||
);
|
);
|
||||||
UserEntityData copyWithCompanion(i1.UserEntityCompanion data) {
|
UserEntityData copyWithCompanion(i1.UserEntityCompanion data) {
|
||||||
return UserEntityData(
|
return UserEntityData(
|
||||||
id: data.id.present ? data.id.value : this.id,
|
id: data.id.present ? data.id.value : this.id,
|
||||||
name: data.name.present ? data.name.value : this.name,
|
name: data.name.present ? data.name.value : this.name,
|
||||||
isAdmin: data.isAdmin.present ? data.isAdmin.value : this.isAdmin,
|
|
||||||
email: data.email.present ? data.email.value : this.email,
|
email: data.email.present ? data.email.value : this.email,
|
||||||
hasProfileImage: data.hasProfileImage.present
|
hasProfileImage: data.hasProfileImage.present
|
||||||
? data.hasProfileImage.value
|
? data.hasProfileImage.value
|
||||||
@ -558,7 +513,9 @@ class UserEntityData extends i0.DataClass
|
|||||||
profileChangedAt: data.profileChangedAt.present
|
profileChangedAt: data.profileChangedAt.present
|
||||||
? data.profileChangedAt.value
|
? data.profileChangedAt.value
|
||||||
: this.profileChangedAt,
|
: this.profileChangedAt,
|
||||||
updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt,
|
avatarColor: data.avatarColor.present
|
||||||
|
? data.avatarColor.value
|
||||||
|
: this.avatarColor,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,11 +524,10 @@ class UserEntityData extends i0.DataClass
|
|||||||
return (StringBuffer('UserEntityData(')
|
return (StringBuffer('UserEntityData(')
|
||||||
..write('id: $id, ')
|
..write('id: $id, ')
|
||||||
..write('name: $name, ')
|
..write('name: $name, ')
|
||||||
..write('isAdmin: $isAdmin, ')
|
|
||||||
..write('email: $email, ')
|
..write('email: $email, ')
|
||||||
..write('hasProfileImage: $hasProfileImage, ')
|
..write('hasProfileImage: $hasProfileImage, ')
|
||||||
..write('profileChangedAt: $profileChangedAt, ')
|
..write('profileChangedAt: $profileChangedAt, ')
|
||||||
..write('updatedAt: $updatedAt')
|
..write('avatarColor: $avatarColor')
|
||||||
..write(')'))
|
..write(')'))
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
@ -580,11 +536,10 @@ class UserEntityData extends i0.DataClass
|
|||||||
int get hashCode => Object.hash(
|
int get hashCode => Object.hash(
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
isAdmin,
|
|
||||||
email,
|
email,
|
||||||
hasProfileImage,
|
hasProfileImage,
|
||||||
profileChangedAt,
|
profileChangedAt,
|
||||||
updatedAt,
|
avatarColor,
|
||||||
);
|
);
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) =>
|
bool operator ==(Object other) =>
|
||||||
@ -592,78 +547,70 @@ class UserEntityData extends i0.DataClass
|
|||||||
(other is i1.UserEntityData &&
|
(other is i1.UserEntityData &&
|
||||||
other.id == this.id &&
|
other.id == this.id &&
|
||||||
other.name == this.name &&
|
other.name == this.name &&
|
||||||
other.isAdmin == this.isAdmin &&
|
|
||||||
other.email == this.email &&
|
other.email == this.email &&
|
||||||
other.hasProfileImage == this.hasProfileImage &&
|
other.hasProfileImage == this.hasProfileImage &&
|
||||||
other.profileChangedAt == this.profileChangedAt &&
|
other.profileChangedAt == this.profileChangedAt &&
|
||||||
other.updatedAt == this.updatedAt);
|
other.avatarColor == this.avatarColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
class UserEntityCompanion extends i0.UpdateCompanion<i1.UserEntityData> {
|
class UserEntityCompanion extends i0.UpdateCompanion<i1.UserEntityData> {
|
||||||
final i0.Value<String> id;
|
final i0.Value<String> id;
|
||||||
final i0.Value<String> name;
|
final i0.Value<String> name;
|
||||||
final i0.Value<bool> isAdmin;
|
|
||||||
final i0.Value<String> email;
|
final i0.Value<String> email;
|
||||||
final i0.Value<bool> hasProfileImage;
|
final i0.Value<bool> hasProfileImage;
|
||||||
final i0.Value<DateTime> profileChangedAt;
|
final i0.Value<DateTime> profileChangedAt;
|
||||||
final i0.Value<DateTime> updatedAt;
|
final i0.Value<i2.AvatarColor> avatarColor;
|
||||||
const UserEntityCompanion({
|
const UserEntityCompanion({
|
||||||
this.id = const i0.Value.absent(),
|
this.id = const i0.Value.absent(),
|
||||||
this.name = const i0.Value.absent(),
|
this.name = const i0.Value.absent(),
|
||||||
this.isAdmin = const i0.Value.absent(),
|
|
||||||
this.email = const i0.Value.absent(),
|
this.email = const i0.Value.absent(),
|
||||||
this.hasProfileImage = const i0.Value.absent(),
|
this.hasProfileImage = const i0.Value.absent(),
|
||||||
this.profileChangedAt = const i0.Value.absent(),
|
this.profileChangedAt = const i0.Value.absent(),
|
||||||
this.updatedAt = const i0.Value.absent(),
|
this.avatarColor = const i0.Value.absent(),
|
||||||
});
|
});
|
||||||
UserEntityCompanion.insert({
|
UserEntityCompanion.insert({
|
||||||
required String id,
|
required String id,
|
||||||
required String name,
|
required String name,
|
||||||
this.isAdmin = const i0.Value.absent(),
|
|
||||||
required String email,
|
required String email,
|
||||||
this.hasProfileImage = const i0.Value.absent(),
|
this.hasProfileImage = const i0.Value.absent(),
|
||||||
this.profileChangedAt = const i0.Value.absent(),
|
this.profileChangedAt = const i0.Value.absent(),
|
||||||
this.updatedAt = const i0.Value.absent(),
|
this.avatarColor = const i0.Value.absent(),
|
||||||
}) : id = i0.Value(id),
|
}) : id = i0.Value(id),
|
||||||
name = i0.Value(name),
|
name = i0.Value(name),
|
||||||
email = i0.Value(email);
|
email = i0.Value(email);
|
||||||
static i0.Insertable<i1.UserEntityData> custom({
|
static i0.Insertable<i1.UserEntityData> custom({
|
||||||
i0.Expression<String>? id,
|
i0.Expression<String>? id,
|
||||||
i0.Expression<String>? name,
|
i0.Expression<String>? name,
|
||||||
i0.Expression<bool>? isAdmin,
|
|
||||||
i0.Expression<String>? email,
|
i0.Expression<String>? email,
|
||||||
i0.Expression<bool>? hasProfileImage,
|
i0.Expression<bool>? hasProfileImage,
|
||||||
i0.Expression<DateTime>? profileChangedAt,
|
i0.Expression<DateTime>? profileChangedAt,
|
||||||
i0.Expression<DateTime>? updatedAt,
|
i0.Expression<int>? avatarColor,
|
||||||
}) {
|
}) {
|
||||||
return i0.RawValuesInsertable({
|
return i0.RawValuesInsertable({
|
||||||
if (id != null) 'id': id,
|
if (id != null) 'id': id,
|
||||||
if (name != null) 'name': name,
|
if (name != null) 'name': name,
|
||||||
if (isAdmin != null) 'is_admin': isAdmin,
|
|
||||||
if (email != null) 'email': email,
|
if (email != null) 'email': email,
|
||||||
if (hasProfileImage != null) 'has_profile_image': hasProfileImage,
|
if (hasProfileImage != null) 'has_profile_image': hasProfileImage,
|
||||||
if (profileChangedAt != null) 'profile_changed_at': profileChangedAt,
|
if (profileChangedAt != null) 'profile_changed_at': profileChangedAt,
|
||||||
if (updatedAt != null) 'updated_at': updatedAt,
|
if (avatarColor != null) 'avatar_color': avatarColor,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
i1.UserEntityCompanion copyWith({
|
i1.UserEntityCompanion copyWith({
|
||||||
i0.Value<String>? id,
|
i0.Value<String>? id,
|
||||||
i0.Value<String>? name,
|
i0.Value<String>? name,
|
||||||
i0.Value<bool>? isAdmin,
|
|
||||||
i0.Value<String>? email,
|
i0.Value<String>? email,
|
||||||
i0.Value<bool>? hasProfileImage,
|
i0.Value<bool>? hasProfileImage,
|
||||||
i0.Value<DateTime>? profileChangedAt,
|
i0.Value<DateTime>? profileChangedAt,
|
||||||
i0.Value<DateTime>? updatedAt,
|
i0.Value<i2.AvatarColor>? avatarColor,
|
||||||
}) {
|
}) {
|
||||||
return i1.UserEntityCompanion(
|
return i1.UserEntityCompanion(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
name: name ?? this.name,
|
name: name ?? this.name,
|
||||||
isAdmin: isAdmin ?? this.isAdmin,
|
|
||||||
email: email ?? this.email,
|
email: email ?? this.email,
|
||||||
hasProfileImage: hasProfileImage ?? this.hasProfileImage,
|
hasProfileImage: hasProfileImage ?? this.hasProfileImage,
|
||||||
profileChangedAt: profileChangedAt ?? this.profileChangedAt,
|
profileChangedAt: profileChangedAt ?? this.profileChangedAt,
|
||||||
updatedAt: updatedAt ?? this.updatedAt,
|
avatarColor: avatarColor ?? this.avatarColor,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -676,9 +623,6 @@ class UserEntityCompanion extends i0.UpdateCompanion<i1.UserEntityData> {
|
|||||||
if (name.present) {
|
if (name.present) {
|
||||||
map['name'] = i0.Variable<String>(name.value);
|
map['name'] = i0.Variable<String>(name.value);
|
||||||
}
|
}
|
||||||
if (isAdmin.present) {
|
|
||||||
map['is_admin'] = i0.Variable<bool>(isAdmin.value);
|
|
||||||
}
|
|
||||||
if (email.present) {
|
if (email.present) {
|
||||||
map['email'] = i0.Variable<String>(email.value);
|
map['email'] = i0.Variable<String>(email.value);
|
||||||
}
|
}
|
||||||
@ -688,8 +632,10 @@ class UserEntityCompanion extends i0.UpdateCompanion<i1.UserEntityData> {
|
|||||||
if (profileChangedAt.present) {
|
if (profileChangedAt.present) {
|
||||||
map['profile_changed_at'] = i0.Variable<DateTime>(profileChangedAt.value);
|
map['profile_changed_at'] = i0.Variable<DateTime>(profileChangedAt.value);
|
||||||
}
|
}
|
||||||
if (updatedAt.present) {
|
if (avatarColor.present) {
|
||||||
map['updated_at'] = i0.Variable<DateTime>(updatedAt.value);
|
map['avatar_color'] = i0.Variable<int>(
|
||||||
|
i1.$UserEntityTable.$converteravatarColor.toSql(avatarColor.value),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@ -699,11 +645,10 @@ class UserEntityCompanion extends i0.UpdateCompanion<i1.UserEntityData> {
|
|||||||
return (StringBuffer('UserEntityCompanion(')
|
return (StringBuffer('UserEntityCompanion(')
|
||||||
..write('id: $id, ')
|
..write('id: $id, ')
|
||||||
..write('name: $name, ')
|
..write('name: $name, ')
|
||||||
..write('isAdmin: $isAdmin, ')
|
|
||||||
..write('email: $email, ')
|
..write('email: $email, ')
|
||||||
..write('hasProfileImage: $hasProfileImage, ')
|
..write('hasProfileImage: $hasProfileImage, ')
|
||||||
..write('profileChangedAt: $profileChangedAt, ')
|
..write('profileChangedAt: $profileChangedAt, ')
|
||||||
..write('updatedAt: $updatedAt')
|
..write('avatarColor: $avatarColor')
|
||||||
..write(')'))
|
..write(')'))
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import 'package:drift_flutter/drift_flutter.dart';
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:immich_mobile/domain/interfaces/db.interface.dart';
|
import 'package:immich_mobile/domain/interfaces/db.interface.dart';
|
||||||
import 'package:immich_mobile/infrastructure/entities/asset_face.entity.dart';
|
import 'package:immich_mobile/infrastructure/entities/asset_face.entity.dart';
|
||||||
|
import 'package:immich_mobile/infrastructure/entities/auth_user.entity.dart';
|
||||||
import 'package:immich_mobile/infrastructure/entities/exif.entity.dart';
|
import 'package:immich_mobile/infrastructure/entities/exif.entity.dart';
|
||||||
import 'package:immich_mobile/infrastructure/entities/local_album.entity.dart';
|
import 'package:immich_mobile/infrastructure/entities/local_album.entity.dart';
|
||||||
import 'package:immich_mobile/infrastructure/entities/local_album_asset.entity.dart';
|
import 'package:immich_mobile/infrastructure/entities/local_album_asset.entity.dart';
|
||||||
@ -44,6 +45,7 @@ class IsarDatabaseRepository implements IDatabaseRepository {
|
|||||||
|
|
||||||
@DriftDatabase(
|
@DriftDatabase(
|
||||||
tables: [
|
tables: [
|
||||||
|
AuthUserEntity,
|
||||||
UserEntity,
|
UserEntity,
|
||||||
UserMetadataEntity,
|
UserMetadataEntity,
|
||||||
PartnerEntity,
|
PartnerEntity,
|
||||||
@ -129,10 +131,9 @@ class Drift extends $Drift implements IDatabaseRepository {
|
|||||||
await m.addColumn(v9.localAlbumEntity, v9.localAlbumEntity.linkedRemoteAlbumId);
|
await m.addColumn(v9.localAlbumEntity, v9.localAlbumEntity.linkedRemoteAlbumId);
|
||||||
},
|
},
|
||||||
from9To10: (m, v10) async {
|
from9To10: (m, v10) async {
|
||||||
// Add cloud_id to local and remote asset tables
|
await m.createTable(v10.authUserEntity);
|
||||||
await m.addColumn(v10.localAssetEntity, v10.localAssetEntity.cloudId);
|
await m.addColumn(v10.userEntity, v10.userEntity.avatarColor);
|
||||||
await m.createIndex(v10.idxLocalAssetCloudId);
|
await m.alterTable(TableMigration(v10.userEntity));
|
||||||
await m.createTable(v10.remoteAssetCloudIdEntity);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -149,7 +150,7 @@ class Drift extends $Drift implements IDatabaseRepository {
|
|||||||
await customStatement('PRAGMA foreign_keys = ON');
|
await customStatement('PRAGMA foreign_keys = ON');
|
||||||
await customStatement('PRAGMA synchronous = NORMAL');
|
await customStatement('PRAGMA synchronous = NORMAL');
|
||||||
await customStatement('PRAGMA journal_mode = WAL');
|
await customStatement('PRAGMA journal_mode = WAL');
|
||||||
await customStatement('PRAGMA busy_timeout = 500');
|
await customStatement('PRAGMA busy_timeout = 30000');
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,17 +15,17 @@ import 'package:immich_mobile/infrastructure/entities/local_album.entity.drift.d
|
|||||||
as i6;
|
as i6;
|
||||||
import 'package:immich_mobile/infrastructure/entities/local_album_asset.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/local_album_asset.entity.drift.dart'
|
||||||
as i7;
|
as i7;
|
||||||
import 'package:immich_mobile/infrastructure/entities/user_metadata.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/auth_user.entity.drift.dart'
|
||||||
as i8;
|
as i8;
|
||||||
import 'package:immich_mobile/infrastructure/entities/partner.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/user_metadata.entity.drift.dart'
|
||||||
as i9;
|
as i9;
|
||||||
import 'package:immich_mobile/infrastructure/entities/exif.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/partner.entity.drift.dart'
|
||||||
as i10;
|
as i10;
|
||||||
import 'package:immich_mobile/infrastructure/entities/remote_album_asset.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/exif.entity.drift.dart'
|
||||||
as i11;
|
as i11;
|
||||||
import 'package:immich_mobile/infrastructure/entities/remote_album_user.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/remote_album_asset.entity.drift.dart'
|
||||||
as i12;
|
as i12;
|
||||||
import 'package:immich_mobile/infrastructure/entities/remote_asset_cloud_id.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/remote_album_user.entity.drift.dart'
|
||||||
as i13;
|
as i13;
|
||||||
import 'package:immich_mobile/infrastructure/entities/memory.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/memory.entity.drift.dart'
|
||||||
as i14;
|
as i14;
|
||||||
@ -56,19 +56,20 @@ abstract class $Drift extends i0.GeneratedDatabase {
|
|||||||
.$LocalAlbumEntityTable(this);
|
.$LocalAlbumEntityTable(this);
|
||||||
late final i7.$LocalAlbumAssetEntityTable localAlbumAssetEntity = i7
|
late final i7.$LocalAlbumAssetEntityTable localAlbumAssetEntity = i7
|
||||||
.$LocalAlbumAssetEntityTable(this);
|
.$LocalAlbumAssetEntityTable(this);
|
||||||
late final i8.$UserMetadataEntityTable userMetadataEntity = i8
|
late final i8.$AuthUserEntityTable authUserEntity = i8.$AuthUserEntityTable(
|
||||||
.$UserMetadataEntityTable(this);
|
|
||||||
late final i9.$PartnerEntityTable partnerEntity = i9.$PartnerEntityTable(
|
|
||||||
this,
|
this,
|
||||||
);
|
);
|
||||||
late final i10.$RemoteExifEntityTable remoteExifEntity = i10
|
late final i9.$UserMetadataEntityTable userMetadataEntity = i9
|
||||||
|
.$UserMetadataEntityTable(this);
|
||||||
|
late final i10.$PartnerEntityTable partnerEntity = i10.$PartnerEntityTable(
|
||||||
|
this,
|
||||||
|
);
|
||||||
|
late final i11.$RemoteExifEntityTable remoteExifEntity = i11
|
||||||
.$RemoteExifEntityTable(this);
|
.$RemoteExifEntityTable(this);
|
||||||
late final i11.$RemoteAlbumAssetEntityTable remoteAlbumAssetEntity = i11
|
late final i12.$RemoteAlbumAssetEntityTable remoteAlbumAssetEntity = i12
|
||||||
.$RemoteAlbumAssetEntityTable(this);
|
.$RemoteAlbumAssetEntityTable(this);
|
||||||
late final i12.$RemoteAlbumUserEntityTable remoteAlbumUserEntity = i12
|
late final i13.$RemoteAlbumUserEntityTable remoteAlbumUserEntity = i13
|
||||||
.$RemoteAlbumUserEntityTable(this);
|
.$RemoteAlbumUserEntityTable(this);
|
||||||
late final i13.$RemoteAssetCloudIdEntityTable remoteAssetCloudIdEntity = i13
|
|
||||||
.$RemoteAssetCloudIdEntityTable(this);
|
|
||||||
late final i14.$MemoryEntityTable memoryEntity = i14.$MemoryEntityTable(this);
|
late final i14.$MemoryEntityTable memoryEntity = i14.$MemoryEntityTable(this);
|
||||||
late final i15.$MemoryAssetEntityTable memoryAssetEntity = i15
|
late final i15.$MemoryAssetEntityTable memoryAssetEntity = i15
|
||||||
.$MemoryAssetEntityTable(this);
|
.$MemoryAssetEntityTable(this);
|
||||||
@ -92,23 +93,22 @@ abstract class $Drift extends i0.GeneratedDatabase {
|
|||||||
localAlbumEntity,
|
localAlbumEntity,
|
||||||
localAlbumAssetEntity,
|
localAlbumAssetEntity,
|
||||||
i4.idxLocalAssetChecksum,
|
i4.idxLocalAssetChecksum,
|
||||||
i4.idxLocalAssetCloudId,
|
|
||||||
i2.idxRemoteAssetOwnerChecksum,
|
i2.idxRemoteAssetOwnerChecksum,
|
||||||
i2.uQRemoteAssetsOwnerChecksum,
|
i2.uQRemoteAssetsOwnerChecksum,
|
||||||
i2.uQRemoteAssetsOwnerLibraryChecksum,
|
i2.uQRemoteAssetsOwnerLibraryChecksum,
|
||||||
i2.idxRemoteAssetChecksum,
|
i2.idxRemoteAssetChecksum,
|
||||||
|
authUserEntity,
|
||||||
userMetadataEntity,
|
userMetadataEntity,
|
||||||
partnerEntity,
|
partnerEntity,
|
||||||
remoteExifEntity,
|
remoteExifEntity,
|
||||||
remoteAlbumAssetEntity,
|
remoteAlbumAssetEntity,
|
||||||
remoteAlbumUserEntity,
|
remoteAlbumUserEntity,
|
||||||
remoteAssetCloudIdEntity,
|
|
||||||
memoryEntity,
|
memoryEntity,
|
||||||
memoryAssetEntity,
|
memoryAssetEntity,
|
||||||
personEntity,
|
personEntity,
|
||||||
assetFaceEntity,
|
assetFaceEntity,
|
||||||
storeEntity,
|
storeEntity,
|
||||||
i10.idxLatLng,
|
i11.idxLatLng,
|
||||||
];
|
];
|
||||||
@override
|
@override
|
||||||
i0.StreamQueryUpdateRules
|
i0.StreamQueryUpdateRules
|
||||||
@ -242,18 +242,6 @@ abstract class $Drift extends i0.GeneratedDatabase {
|
|||||||
i0.TableUpdate('remote_album_user_entity', kind: i0.UpdateKind.delete),
|
i0.TableUpdate('remote_album_user_entity', kind: i0.UpdateKind.delete),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
i0.WritePropagation(
|
|
||||||
on: i0.TableUpdateQuery.onTableName(
|
|
||||||
'remote_asset_entity',
|
|
||||||
limitUpdateKind: i0.UpdateKind.delete,
|
|
||||||
),
|
|
||||||
result: [
|
|
||||||
i0.TableUpdate(
|
|
||||||
'remote_asset_cloud_id_entity',
|
|
||||||
kind: i0.UpdateKind.delete,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
i0.WritePropagation(
|
i0.WritePropagation(
|
||||||
on: i0.TableUpdateQuery.onTableName(
|
on: i0.TableUpdateQuery.onTableName(
|
||||||
'user_entity',
|
'user_entity',
|
||||||
@ -323,25 +311,21 @@ class $DriftManager {
|
|||||||
i6.$$LocalAlbumEntityTableTableManager(_db, _db.localAlbumEntity);
|
i6.$$LocalAlbumEntityTableTableManager(_db, _db.localAlbumEntity);
|
||||||
i7.$$LocalAlbumAssetEntityTableTableManager get localAlbumAssetEntity => i7
|
i7.$$LocalAlbumAssetEntityTableTableManager get localAlbumAssetEntity => i7
|
||||||
.$$LocalAlbumAssetEntityTableTableManager(_db, _db.localAlbumAssetEntity);
|
.$$LocalAlbumAssetEntityTableTableManager(_db, _db.localAlbumAssetEntity);
|
||||||
i8.$$UserMetadataEntityTableTableManager get userMetadataEntity =>
|
i8.$$AuthUserEntityTableTableManager get authUserEntity =>
|
||||||
i8.$$UserMetadataEntityTableTableManager(_db, _db.userMetadataEntity);
|
i8.$$AuthUserEntityTableTableManager(_db, _db.authUserEntity);
|
||||||
i9.$$PartnerEntityTableTableManager get partnerEntity =>
|
i9.$$UserMetadataEntityTableTableManager get userMetadataEntity =>
|
||||||
i9.$$PartnerEntityTableTableManager(_db, _db.partnerEntity);
|
i9.$$UserMetadataEntityTableTableManager(_db, _db.userMetadataEntity);
|
||||||
i10.$$RemoteExifEntityTableTableManager get remoteExifEntity =>
|
i10.$$PartnerEntityTableTableManager get partnerEntity =>
|
||||||
i10.$$RemoteExifEntityTableTableManager(_db, _db.remoteExifEntity);
|
i10.$$PartnerEntityTableTableManager(_db, _db.partnerEntity);
|
||||||
i11.$$RemoteAlbumAssetEntityTableTableManager get remoteAlbumAssetEntity =>
|
i11.$$RemoteExifEntityTableTableManager get remoteExifEntity =>
|
||||||
i11.$$RemoteAlbumAssetEntityTableTableManager(
|
i11.$$RemoteExifEntityTableTableManager(_db, _db.remoteExifEntity);
|
||||||
|
i12.$$RemoteAlbumAssetEntityTableTableManager get remoteAlbumAssetEntity =>
|
||||||
|
i12.$$RemoteAlbumAssetEntityTableTableManager(
|
||||||
_db,
|
_db,
|
||||||
_db.remoteAlbumAssetEntity,
|
_db.remoteAlbumAssetEntity,
|
||||||
);
|
);
|
||||||
i12.$$RemoteAlbumUserEntityTableTableManager get remoteAlbumUserEntity => i12
|
i13.$$RemoteAlbumUserEntityTableTableManager get remoteAlbumUserEntity => i13
|
||||||
.$$RemoteAlbumUserEntityTableTableManager(_db, _db.remoteAlbumUserEntity);
|
.$$RemoteAlbumUserEntityTableTableManager(_db, _db.remoteAlbumUserEntity);
|
||||||
i13.$$RemoteAssetCloudIdEntityTableTableManager
|
|
||||||
get remoteAssetCloudIdEntity =>
|
|
||||||
i13.$$RemoteAssetCloudIdEntityTableTableManager(
|
|
||||||
_db,
|
|
||||||
_db.remoteAssetCloudIdEntity,
|
|
||||||
);
|
|
||||||
i14.$$MemoryEntityTableTableManager get memoryEntity =>
|
i14.$$MemoryEntityTableTableManager get memoryEntity =>
|
||||||
i14.$$MemoryEntityTableTableManager(_db, _db.memoryEntity);
|
i14.$$MemoryEntityTableTableManager(_db, _db.memoryEntity);
|
||||||
i15.$$MemoryAssetEntityTableTableManager get memoryAssetEntity =>
|
i15.$$MemoryAssetEntityTableTableManager get memoryAssetEntity =>
|
||||||
|
|||||||
@ -3833,17 +3833,16 @@ final class Schema10 extends i0.VersionedSchema {
|
|||||||
localAlbumEntity,
|
localAlbumEntity,
|
||||||
localAlbumAssetEntity,
|
localAlbumAssetEntity,
|
||||||
idxLocalAssetChecksum,
|
idxLocalAssetChecksum,
|
||||||
idxLocalAssetCloudId,
|
|
||||||
idxRemoteAssetOwnerChecksum,
|
idxRemoteAssetOwnerChecksum,
|
||||||
uQRemoteAssetsOwnerChecksum,
|
uQRemoteAssetsOwnerChecksum,
|
||||||
uQRemoteAssetsOwnerLibraryChecksum,
|
uQRemoteAssetsOwnerLibraryChecksum,
|
||||||
idxRemoteAssetChecksum,
|
idxRemoteAssetChecksum,
|
||||||
|
authUserEntity,
|
||||||
userMetadataEntity,
|
userMetadataEntity,
|
||||||
partnerEntity,
|
partnerEntity,
|
||||||
remoteExifEntity,
|
remoteExifEntity,
|
||||||
remoteAlbumAssetEntity,
|
remoteAlbumAssetEntity,
|
||||||
remoteAlbumUserEntity,
|
remoteAlbumUserEntity,
|
||||||
remoteAssetCloudIdEntity,
|
|
||||||
memoryEntity,
|
memoryEntity,
|
||||||
memoryAssetEntity,
|
memoryAssetEntity,
|
||||||
personEntity,
|
personEntity,
|
||||||
@ -3851,7 +3850,7 @@ final class Schema10 extends i0.VersionedSchema {
|
|||||||
storeEntity,
|
storeEntity,
|
||||||
idxLatLng,
|
idxLatLng,
|
||||||
];
|
];
|
||||||
late final Shape16 userEntity = Shape16(
|
late final Shape20 userEntity = Shape20(
|
||||||
source: i0.VersionedTable(
|
source: i0.VersionedTable(
|
||||||
entityName: 'user_entity',
|
entityName: 'user_entity',
|
||||||
withoutRowId: true,
|
withoutRowId: true,
|
||||||
@ -3860,11 +3859,10 @@ final class Schema10 extends i0.VersionedSchema {
|
|||||||
columns: [
|
columns: [
|
||||||
_column_0,
|
_column_0,
|
||||||
_column_1,
|
_column_1,
|
||||||
_column_2,
|
|
||||||
_column_3,
|
_column_3,
|
||||||
_column_84,
|
_column_84,
|
||||||
_column_85,
|
_column_85,
|
||||||
_column_5,
|
_column_91,
|
||||||
],
|
],
|
||||||
attachedDatabase: database,
|
attachedDatabase: database,
|
||||||
),
|
),
|
||||||
@ -3911,7 +3909,7 @@ final class Schema10 extends i0.VersionedSchema {
|
|||||||
),
|
),
|
||||||
alias: null,
|
alias: null,
|
||||||
);
|
);
|
||||||
late final Shape20 localAssetEntity = Shape20(
|
late final Shape2 localAssetEntity = Shape2(
|
||||||
source: i0.VersionedTable(
|
source: i0.VersionedTable(
|
||||||
entityName: 'local_asset_entity',
|
entityName: 'local_asset_entity',
|
||||||
withoutRowId: true,
|
withoutRowId: true,
|
||||||
@ -3929,7 +3927,6 @@ final class Schema10 extends i0.VersionedSchema {
|
|||||||
_column_22,
|
_column_22,
|
||||||
_column_14,
|
_column_14,
|
||||||
_column_23,
|
_column_23,
|
||||||
_column_91,
|
|
||||||
],
|
],
|
||||||
attachedDatabase: database,
|
attachedDatabase: database,
|
||||||
),
|
),
|
||||||
@ -3990,10 +3987,6 @@ final class Schema10 extends i0.VersionedSchema {
|
|||||||
'idx_local_asset_checksum',
|
'idx_local_asset_checksum',
|
||||||
'CREATE INDEX IF NOT EXISTS idx_local_asset_checksum ON local_asset_entity (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 (cloud_id)',
|
|
||||||
);
|
|
||||||
final i1.Index idxRemoteAssetOwnerChecksum = i1.Index(
|
final i1.Index idxRemoteAssetOwnerChecksum = i1.Index(
|
||||||
'idx_remote_asset_owner_checksum',
|
'idx_remote_asset_owner_checksum',
|
||||||
'CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_checksum ON remote_asset_entity (owner_id, checksum)',
|
'CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_checksum ON remote_asset_entity (owner_id, checksum)',
|
||||||
@ -4010,6 +4003,28 @@ final class Schema10 extends i0.VersionedSchema {
|
|||||||
'idx_remote_asset_checksum',
|
'idx_remote_asset_checksum',
|
||||||
'CREATE INDEX IF NOT EXISTS idx_remote_asset_checksum ON remote_asset_entity (checksum)',
|
'CREATE INDEX IF NOT EXISTS idx_remote_asset_checksum ON remote_asset_entity (checksum)',
|
||||||
);
|
);
|
||||||
|
late final Shape21 authUserEntity = Shape21(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'auth_user_entity',
|
||||||
|
withoutRowId: true,
|
||||||
|
isStrict: true,
|
||||||
|
tableConstraints: ['PRIMARY KEY(id)'],
|
||||||
|
columns: [
|
||||||
|
_column_0,
|
||||||
|
_column_1,
|
||||||
|
_column_3,
|
||||||
|
_column_2,
|
||||||
|
_column_84,
|
||||||
|
_column_85,
|
||||||
|
_column_92,
|
||||||
|
_column_93,
|
||||||
|
_column_7,
|
||||||
|
_column_94,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null,
|
||||||
|
);
|
||||||
late final Shape4 userMetadataEntity = Shape4(
|
late final Shape4 userMetadataEntity = Shape4(
|
||||||
source: i0.VersionedTable(
|
source: i0.VersionedTable(
|
||||||
entityName: 'user_metadata_entity',
|
entityName: 'user_metadata_entity',
|
||||||
@ -4088,17 +4103,6 @@ final class Schema10 extends i0.VersionedSchema {
|
|||||||
),
|
),
|
||||||
alias: null,
|
alias: null,
|
||||||
);
|
);
|
||||||
late final Shape21 remoteAssetCloudIdEntity = Shape21(
|
|
||||||
source: i0.VersionedTable(
|
|
||||||
entityName: 'remote_asset_cloud_id_entity',
|
|
||||||
withoutRowId: true,
|
|
||||||
isStrict: true,
|
|
||||||
tableConstraints: ['PRIMARY KEY(asset_id)'],
|
|
||||||
columns: [_column_36, _column_92],
|
|
||||||
attachedDatabase: database,
|
|
||||||
),
|
|
||||||
alias: null,
|
|
||||||
);
|
|
||||||
late final Shape11 memoryEntity = Shape11(
|
late final Shape11 memoryEntity = Shape11(
|
||||||
source: i0.VersionedTable(
|
source: i0.VersionedTable(
|
||||||
entityName: 'memory_entity',
|
entityName: 'memory_entity',
|
||||||
@ -4197,55 +4201,74 @@ final class Schema10 extends i0.VersionedSchema {
|
|||||||
|
|
||||||
class Shape20 extends i0.VersionedTable {
|
class Shape20 extends i0.VersionedTable {
|
||||||
Shape20({required super.source, required super.alias}) : super.aliased();
|
Shape20({required super.source, required super.alias}) : super.aliased();
|
||||||
i1.GeneratedColumn<String> get name =>
|
|
||||||
columnsByName['name']! as i1.GeneratedColumn<String>;
|
|
||||||
i1.GeneratedColumn<int> get type =>
|
|
||||||
columnsByName['type']! as i1.GeneratedColumn<int>;
|
|
||||||
i1.GeneratedColumn<DateTime> get createdAt =>
|
|
||||||
columnsByName['created_at']! as i1.GeneratedColumn<DateTime>;
|
|
||||||
i1.GeneratedColumn<DateTime> get updatedAt =>
|
|
||||||
columnsByName['updated_at']! as i1.GeneratedColumn<DateTime>;
|
|
||||||
i1.GeneratedColumn<int> get width =>
|
|
||||||
columnsByName['width']! as i1.GeneratedColumn<int>;
|
|
||||||
i1.GeneratedColumn<int> get height =>
|
|
||||||
columnsByName['height']! as i1.GeneratedColumn<int>;
|
|
||||||
i1.GeneratedColumn<int> get durationInSeconds =>
|
|
||||||
columnsByName['duration_in_seconds']! as i1.GeneratedColumn<int>;
|
|
||||||
i1.GeneratedColumn<String> get id =>
|
i1.GeneratedColumn<String> get id =>
|
||||||
columnsByName['id']! as i1.GeneratedColumn<String>;
|
columnsByName['id']! as i1.GeneratedColumn<String>;
|
||||||
i1.GeneratedColumn<String> get checksum =>
|
i1.GeneratedColumn<String> get name =>
|
||||||
columnsByName['checksum']! as i1.GeneratedColumn<String>;
|
columnsByName['name']! as i1.GeneratedColumn<String>;
|
||||||
i1.GeneratedColumn<bool> get isFavorite =>
|
i1.GeneratedColumn<String> get email =>
|
||||||
columnsByName['is_favorite']! as i1.GeneratedColumn<bool>;
|
columnsByName['email']! as i1.GeneratedColumn<String>;
|
||||||
i1.GeneratedColumn<int> get orientation =>
|
i1.GeneratedColumn<bool> get hasProfileImage =>
|
||||||
columnsByName['orientation']! as i1.GeneratedColumn<int>;
|
columnsByName['has_profile_image']! as i1.GeneratedColumn<bool>;
|
||||||
i1.GeneratedColumn<String> get cloudId =>
|
i1.GeneratedColumn<DateTime> get profileChangedAt =>
|
||||||
columnsByName['cloud_id']! as i1.GeneratedColumn<String>;
|
columnsByName['profile_changed_at']! as i1.GeneratedColumn<DateTime>;
|
||||||
|
i1.GeneratedColumn<int> get avatarColor =>
|
||||||
|
columnsByName['avatar_color']! as i1.GeneratedColumn<int>;
|
||||||
}
|
}
|
||||||
|
|
||||||
i1.GeneratedColumn<String> _column_91(String aliasedName) =>
|
i1.GeneratedColumn<int> _column_91(String aliasedName) =>
|
||||||
i1.GeneratedColumn<String>(
|
i1.GeneratedColumn<int>(
|
||||||
'cloud_id',
|
'avatar_color',
|
||||||
aliasedName,
|
aliasedName,
|
||||||
true,
|
false,
|
||||||
type: i1.DriftSqlType.string,
|
type: i1.DriftSqlType.int,
|
||||||
|
defaultValue: const CustomExpression('0'),
|
||||||
);
|
);
|
||||||
|
|
||||||
class Shape21 extends i0.VersionedTable {
|
class Shape21 extends i0.VersionedTable {
|
||||||
Shape21({required super.source, required super.alias}) : super.aliased();
|
Shape21({required super.source, required super.alias}) : super.aliased();
|
||||||
i1.GeneratedColumn<String> get assetId =>
|
i1.GeneratedColumn<String> get id =>
|
||||||
columnsByName['asset_id']! as i1.GeneratedColumn<String>;
|
columnsByName['id']! as i1.GeneratedColumn<String>;
|
||||||
i1.GeneratedColumn<String> get cloudId =>
|
i1.GeneratedColumn<String> get name =>
|
||||||
columnsByName['cloud_id']! as i1.GeneratedColumn<String>;
|
columnsByName['name']! as i1.GeneratedColumn<String>;
|
||||||
|
i1.GeneratedColumn<String> get email =>
|
||||||
|
columnsByName['email']! as i1.GeneratedColumn<String>;
|
||||||
|
i1.GeneratedColumn<bool> get isAdmin =>
|
||||||
|
columnsByName['is_admin']! as i1.GeneratedColumn<bool>;
|
||||||
|
i1.GeneratedColumn<bool> get hasProfileImage =>
|
||||||
|
columnsByName['has_profile_image']! as i1.GeneratedColumn<bool>;
|
||||||
|
i1.GeneratedColumn<DateTime> get profileChangedAt =>
|
||||||
|
columnsByName['profile_changed_at']! as i1.GeneratedColumn<DateTime>;
|
||||||
|
i1.GeneratedColumn<int> get avatarColor =>
|
||||||
|
columnsByName['avatar_color']! as i1.GeneratedColumn<int>;
|
||||||
|
i1.GeneratedColumn<int> get quotaSizeInBytes =>
|
||||||
|
columnsByName['quota_size_in_bytes']! as i1.GeneratedColumn<int>;
|
||||||
|
i1.GeneratedColumn<int> get quotaUsageInBytes =>
|
||||||
|
columnsByName['quota_usage_in_bytes']! as i1.GeneratedColumn<int>;
|
||||||
|
i1.GeneratedColumn<String> get pinCode =>
|
||||||
|
columnsByName['pin_code']! as i1.GeneratedColumn<String>;
|
||||||
}
|
}
|
||||||
|
|
||||||
i1.GeneratedColumn<String> _column_92(String aliasedName) =>
|
i1.GeneratedColumn<int> _column_92(String aliasedName) =>
|
||||||
|
i1.GeneratedColumn<int>(
|
||||||
|
'avatar_color',
|
||||||
|
aliasedName,
|
||||||
|
false,
|
||||||
|
type: i1.DriftSqlType.int,
|
||||||
|
);
|
||||||
|
i1.GeneratedColumn<int> _column_93(String aliasedName) =>
|
||||||
|
i1.GeneratedColumn<int>(
|
||||||
|
'quota_size_in_bytes',
|
||||||
|
aliasedName,
|
||||||
|
false,
|
||||||
|
type: i1.DriftSqlType.int,
|
||||||
|
defaultValue: const CustomExpression('0'),
|
||||||
|
);
|
||||||
|
i1.GeneratedColumn<String> _column_94(String aliasedName) =>
|
||||||
i1.GeneratedColumn<String>(
|
i1.GeneratedColumn<String>(
|
||||||
'cloud_id',
|
'pin_code',
|
||||||
aliasedName,
|
aliasedName,
|
||||||
true,
|
true,
|
||||||
type: i1.DriftSqlType.string,
|
type: i1.DriftSqlType.string,
|
||||||
defaultConstraints: i1.GeneratedColumn.constraintIsAlways('UNIQUE'),
|
|
||||||
);
|
);
|
||||||
i0.MigrationStepWithVersion migrationSteps({
|
i0.MigrationStepWithVersion migrationSteps({
|
||||||
required Future<void> Function(i1.Migrator m, Schema2 schema) from1To2,
|
required Future<void> Function(i1.Migrator m, Schema2 schema) from1To2,
|
||||||
|
|||||||
@ -202,14 +202,13 @@ class DriftRemoteAlbumRepository extends DriftDatabaseRepository {
|
|||||||
id: user.id,
|
id: user.id,
|
||||||
email: user.email,
|
email: user.email,
|
||||||
name: user.name,
|
name: user.name,
|
||||||
isAdmin: user.isAdmin,
|
|
||||||
updatedAt: user.updatedAt,
|
|
||||||
memoryEnabled: true,
|
memoryEnabled: true,
|
||||||
inTimeline: false,
|
inTimeline: false,
|
||||||
isPartnerSharedBy: false,
|
isPartnerSharedBy: false,
|
||||||
isPartnerSharedWith: false,
|
isPartnerSharedWith: false,
|
||||||
profileChangedAt: user.profileChangedAt,
|
profileChangedAt: user.profileChangedAt,
|
||||||
hasProfileImage: user.hasProfileImage,
|
hasProfileImage: user.hasProfileImage,
|
||||||
|
avatarColor: user.avatarColor,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
|
|||||||
@ -173,7 +173,7 @@ class DriftStoreRepository extends DriftDatabaseRepository implements IStoreRepo
|
|||||||
const (bool) => entity.intValue == 1,
|
const (bool) => entity.intValue == 1,
|
||||||
const (DateTime) => entity.intValue == null ? null : DateTime.fromMillisecondsSinceEpoch(entity.intValue!),
|
const (DateTime) => entity.intValue == null ? null : DateTime.fromMillisecondsSinceEpoch(entity.intValue!),
|
||||||
const (UserDto) =>
|
const (UserDto) =>
|
||||||
entity.stringValue == null ? null : await DriftUserRepository(_db).get(entity.stringValue!),
|
entity.stringValue == null ? null : await DriftAuthUserRepository(_db).get(entity.stringValue!),
|
||||||
_ => null,
|
_ => null,
|
||||||
}
|
}
|
||||||
as T?;
|
as T?;
|
||||||
@ -184,7 +184,7 @@ class DriftStoreRepository extends DriftDatabaseRepository implements IStoreRepo
|
|||||||
const (String) => (null, value as String),
|
const (String) => (null, value as String),
|
||||||
const (bool) => ((value as bool) ? 1 : 0, null),
|
const (bool) => ((value as bool) ? 1 : 0, null),
|
||||||
const (DateTime) => ((value as DateTime).millisecondsSinceEpoch, null),
|
const (DateTime) => ((value as DateTime).millisecondsSinceEpoch, null),
|
||||||
const (UserDto) => (null, (await DriftUserRepository(_db).upsert(value as UserDto)).id),
|
const (UserDto) => (null, (await DriftAuthUserRepository(_db).upsert(value as UserDto)).id),
|
||||||
_ => throw UnsupportedError("Unsupported primitive type: ${key.type} for key: ${key.name}"),
|
_ => throw UnsupportedError("Unsupported primitive type: ${key.type} for key: ${key.name}"),
|
||||||
};
|
};
|
||||||
return StoreEntityCompanion(id: Value(key.id), intValue: Value(intValue), stringValue: Value(strValue));
|
return StoreEntityCompanion(id: Value(key.id), intValue: Value(intValue), stringValue: Value(strValue));
|
||||||
|
|||||||
@ -18,7 +18,8 @@ class SyncApiRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> streamChanges(
|
Future<void> streamChanges(
|
||||||
Function(List<SyncEvent>, Function() abort) onData, {
|
Future<void> Function(List<SyncEvent>, Function() abort, Function() reset) onData, {
|
||||||
|
Function()? onReset,
|
||||||
int batchSize = kSyncEventBatchSize,
|
int batchSize = kSyncEventBatchSize,
|
||||||
http.Client? httpClient,
|
http.Client? httpClient,
|
||||||
}) async {
|
}) async {
|
||||||
@ -37,6 +38,7 @@ class SyncApiRepository {
|
|||||||
request.body = jsonEncode(
|
request.body = jsonEncode(
|
||||||
SyncStreamDto(
|
SyncStreamDto(
|
||||||
types: [
|
types: [
|
||||||
|
SyncRequestType.authUsersV1,
|
||||||
SyncRequestType.usersV1,
|
SyncRequestType.usersV1,
|
||||||
SyncRequestType.assetsV1,
|
SyncRequestType.assetsV1,
|
||||||
SyncRequestType.assetExifsV1,
|
SyncRequestType.assetExifsV1,
|
||||||
@ -70,6 +72,8 @@ class SyncApiRepository {
|
|||||||
shouldAbort = true;
|
shouldAbort = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final reset = onReset ?? () {};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final response = await client.send(request);
|
final response = await client.send(request);
|
||||||
|
|
||||||
@ -92,12 +96,12 @@ class SyncApiRepository {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
await onData(_parseLines(lines), abort);
|
await onData(_parseLines(lines), abort, reset);
|
||||||
lines.clear();
|
lines.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lines.isNotEmpty && !shouldAbort) {
|
if (lines.isNotEmpty && !shouldAbort) {
|
||||||
await onData(_parseLines(lines), abort);
|
await onData(_parseLines(lines), abort, reset);
|
||||||
}
|
}
|
||||||
} catch (error, stack) {
|
} catch (error, stack) {
|
||||||
_logger.severe("Error processing stream", error, stack);
|
_logger.severe("Error processing stream", error, stack);
|
||||||
@ -131,6 +135,7 @@ class SyncApiRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const _kResponseMap = <SyncEntityType, Function(Object)>{
|
const _kResponseMap = <SyncEntityType, Function(Object)>{
|
||||||
|
SyncEntityType.authUserV1: SyncAuthUserV1.fromJson,
|
||||||
SyncEntityType.userV1: SyncUserV1.fromJson,
|
SyncEntityType.userV1: SyncUserV1.fromJson,
|
||||||
SyncEntityType.userDeleteV1: SyncUserDeleteV1.fromJson,
|
SyncEntityType.userDeleteV1: SyncUserDeleteV1.fromJson,
|
||||||
SyncEntityType.partnerV1: SyncPartnerV1.fromJson,
|
SyncEntityType.partnerV1: SyncPartnerV1.fromJson,
|
||||||
@ -159,7 +164,8 @@ const _kResponseMap = <SyncEntityType, Function(Object)>{
|
|||||||
SyncEntityType.albumToAssetV1: SyncAlbumToAssetV1.fromJson,
|
SyncEntityType.albumToAssetV1: SyncAlbumToAssetV1.fromJson,
|
||||||
SyncEntityType.albumToAssetBackfillV1: SyncAlbumToAssetV1.fromJson,
|
SyncEntityType.albumToAssetBackfillV1: SyncAlbumToAssetV1.fromJson,
|
||||||
SyncEntityType.albumToAssetDeleteV1: SyncAlbumToAssetDeleteV1.fromJson,
|
SyncEntityType.albumToAssetDeleteV1: SyncAlbumToAssetDeleteV1.fromJson,
|
||||||
SyncEntityType.syncAckV1: _SyncAckV1.fromJson,
|
SyncEntityType.syncAckV1: _SyncEmptyDto.fromJson,
|
||||||
|
SyncEntityType.syncResetV1: _SyncEmptyDto.fromJson,
|
||||||
SyncEntityType.memoryV1: SyncMemoryV1.fromJson,
|
SyncEntityType.memoryV1: SyncMemoryV1.fromJson,
|
||||||
SyncEntityType.memoryDeleteV1: SyncMemoryDeleteV1.fromJson,
|
SyncEntityType.memoryDeleteV1: SyncMemoryDeleteV1.fromJson,
|
||||||
SyncEntityType.memoryToAssetV1: SyncMemoryAssetV1.fromJson,
|
SyncEntityType.memoryToAssetV1: SyncMemoryAssetV1.fromJson,
|
||||||
@ -175,8 +181,9 @@ const _kResponseMap = <SyncEntityType, Function(Object)>{
|
|||||||
SyncEntityType.personDeleteV1: SyncPersonDeleteV1.fromJson,
|
SyncEntityType.personDeleteV1: SyncPersonDeleteV1.fromJson,
|
||||||
SyncEntityType.assetFaceV1: SyncAssetFaceV1.fromJson,
|
SyncEntityType.assetFaceV1: SyncAssetFaceV1.fromJson,
|
||||||
SyncEntityType.assetFaceDeleteV1: SyncAssetFaceDeleteV1.fromJson,
|
SyncEntityType.assetFaceDeleteV1: SyncAssetFaceDeleteV1.fromJson,
|
||||||
|
SyncEntityType.syncCompleteV1: _SyncEmptyDto.fromJson,
|
||||||
};
|
};
|
||||||
|
|
||||||
class _SyncAckV1 {
|
class _SyncEmptyDto {
|
||||||
static _SyncAckV1? fromJson(dynamic _) => _SyncAckV1();
|
static _SyncEmptyDto? fromJson(dynamic _) => _SyncEmptyDto();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,14 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:drift/drift.dart';
|
import 'package:drift/drift.dart';
|
||||||
import 'package:immich_mobile/domain/models/album/album.model.dart';
|
import 'package:immich_mobile/domain/models/album/album.model.dart';
|
||||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||||
import 'package:immich_mobile/domain/models/memory.model.dart';
|
import 'package:immich_mobile/domain/models/memory.model.dart';
|
||||||
|
import 'package:immich_mobile/domain/models/user.model.dart';
|
||||||
import 'package:immich_mobile/domain/models/user_metadata.model.dart';
|
import 'package:immich_mobile/domain/models/user_metadata.model.dart';
|
||||||
import 'package:immich_mobile/infrastructure/entities/asset_face.entity.drift.dart';
|
import 'package:immich_mobile/infrastructure/entities/asset_face.entity.drift.dart';
|
||||||
|
import 'package:immich_mobile/infrastructure/entities/auth_user.entity.drift.dart';
|
||||||
import 'package:immich_mobile/infrastructure/entities/exif.entity.drift.dart';
|
import 'package:immich_mobile/infrastructure/entities/exif.entity.drift.dart';
|
||||||
import 'package:immich_mobile/infrastructure/entities/memory.entity.drift.dart';
|
import 'package:immich_mobile/infrastructure/entities/memory.entity.drift.dart';
|
||||||
import 'package:immich_mobile/infrastructure/entities/memory_asset.entity.drift.dart';
|
import 'package:immich_mobile/infrastructure/entities/memory_asset.entity.drift.dart';
|
||||||
@ -30,6 +33,65 @@ class SyncStreamRepository extends DriftDatabaseRepository {
|
|||||||
|
|
||||||
SyncStreamRepository(super.db) : _db = db;
|
SyncStreamRepository(super.db) : _db = db;
|
||||||
|
|
||||||
|
Future<void> reset() async {
|
||||||
|
_logger.fine("SyncResetV1 received. Resetting remote entities");
|
||||||
|
try {
|
||||||
|
await _db.exclusively(() async {
|
||||||
|
// foreign_keys PRAGMA is no-op within transactions
|
||||||
|
// https://www.sqlite.org/pragma.html#pragma_foreign_keys
|
||||||
|
await _db.customStatement('PRAGMA foreign_keys = OFF');
|
||||||
|
await transaction(() async {
|
||||||
|
await _db.assetFaceEntity.deleteAll();
|
||||||
|
await _db.memoryAssetEntity.deleteAll();
|
||||||
|
await _db.memoryEntity.deleteAll();
|
||||||
|
await _db.partnerEntity.deleteAll();
|
||||||
|
await _db.personEntity.deleteAll();
|
||||||
|
await _db.remoteAlbumAssetEntity.deleteAll();
|
||||||
|
await _db.remoteAlbumEntity.deleteAll();
|
||||||
|
await _db.remoteAlbumUserEntity.deleteAll();
|
||||||
|
await _db.remoteAssetEntity.deleteAll();
|
||||||
|
await _db.remoteExifEntity.deleteAll();
|
||||||
|
await _db.stackEntity.deleteAll();
|
||||||
|
await _db.userEntity.deleteAll();
|
||||||
|
await _db.userMetadataEntity.deleteAll();
|
||||||
|
});
|
||||||
|
await _db.customStatement('PRAGMA foreign_keys = ON');
|
||||||
|
});
|
||||||
|
} catch (error, stack) {
|
||||||
|
_logger.severe('Error: SyncResetV1', error, stack);
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateAuthUsersV1(Iterable<SyncAuthUserV1> data) async {
|
||||||
|
try {
|
||||||
|
await _db.batch((batch) {
|
||||||
|
for (final user in data) {
|
||||||
|
final companion = AuthUserEntityCompanion(
|
||||||
|
name: Value(user.name),
|
||||||
|
email: Value(user.email),
|
||||||
|
hasProfileImage: Value(user.hasProfileImage),
|
||||||
|
profileChangedAt: Value(user.profileChangedAt),
|
||||||
|
avatarColor: Value(user.avatarColor?.toAvatarColor() ?? AvatarColor.primary),
|
||||||
|
isAdmin: Value(user.isAdmin),
|
||||||
|
pinCode: Value(user.pinCode),
|
||||||
|
quotaSizeInBytes: Value(user.quotaSizeInBytes ?? 0),
|
||||||
|
quotaUsageInBytes: Value(user.quotaUsageInBytes),
|
||||||
|
);
|
||||||
|
|
||||||
|
batch.insert(
|
||||||
|
_db.authUserEntity,
|
||||||
|
companion.copyWith(id: Value(user.id)),
|
||||||
|
onConflict: DoUpdate((_) => companion),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (error, stack) {
|
||||||
|
_logger.severe('Error: SyncAuthUserV1', error, stack);
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> deleteUsersV1(Iterable<SyncUserDeleteV1> data) async {
|
Future<void> deleteUsersV1(Iterable<SyncUserDeleteV1> data) async {
|
||||||
try {
|
try {
|
||||||
await _db.userEntity.deleteWhere((row) => row.id.isIn(data.map((e) => e.userId)));
|
await _db.userEntity.deleteWhere((row) => row.id.isIn(data.map((e) => e.userId)));
|
||||||
@ -48,6 +110,7 @@ class SyncStreamRepository extends DriftDatabaseRepository {
|
|||||||
email: Value(user.email),
|
email: Value(user.email),
|
||||||
hasProfileImage: Value(user.hasProfileImage),
|
hasProfileImage: Value(user.hasProfileImage),
|
||||||
profileChangedAt: Value(user.profileChangedAt),
|
profileChangedAt: Value(user.profileChangedAt),
|
||||||
|
avatarColor: Value(user.avatarColor?.toAvatarColor() ?? AvatarColor.primary),
|
||||||
);
|
);
|
||||||
|
|
||||||
batch.insert(_db.userEntity, companion.copyWith(id: Value(user.id)), onConflict: DoUpdate((_) => companion));
|
batch.insert(_db.userEntity, companion.copyWith(id: Value(user.id)), onConflict: DoUpdate((_) => companion));
|
||||||
@ -610,3 +673,7 @@ extension on String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension on UserAvatarColor {
|
||||||
|
AvatarColor? toAvatarColor() => AvatarColor.values.firstWhereOrNull((c) => c.name == value);
|
||||||
|
}
|
||||||
|
|||||||
@ -2,8 +2,8 @@ import 'package:drift/drift.dart';
|
|||||||
import 'package:immich_mobile/constants/enums.dart';
|
import 'package:immich_mobile/constants/enums.dart';
|
||||||
import 'package:immich_mobile/domain/models/user.model.dart';
|
import 'package:immich_mobile/domain/models/user.model.dart';
|
||||||
import 'package:immich_mobile/domain/models/user_metadata.model.dart';
|
import 'package:immich_mobile/domain/models/user_metadata.model.dart';
|
||||||
|
import 'package:immich_mobile/infrastructure/entities/auth_user.entity.drift.dart';
|
||||||
import 'package:immich_mobile/infrastructure/entities/user.entity.dart' as entity;
|
import 'package:immich_mobile/infrastructure/entities/user.entity.dart' as entity;
|
||||||
import 'package:immich_mobile/infrastructure/entities/user.entity.drift.dart';
|
|
||||||
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
||||||
import 'package:immich_mobile/infrastructure/repositories/user_metadata.repository.dart';
|
import 'package:immich_mobile/infrastructure/repositories/user_metadata.repository.dart';
|
||||||
import 'package:isar/isar.dart';
|
import 'package:isar/isar.dart';
|
||||||
@ -68,12 +68,12 @@ class IsarUserRepository extends IsarDatabaseRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DriftUserRepository extends DriftDatabaseRepository {
|
class DriftAuthUserRepository extends DriftDatabaseRepository {
|
||||||
final Drift _db;
|
final Drift _db;
|
||||||
const DriftUserRepository(super.db) : _db = db;
|
const DriftAuthUserRepository(super.db) : _db = db;
|
||||||
|
|
||||||
Future<UserDto?> get(String id) async {
|
Future<UserDto?> get(String id) async {
|
||||||
final user = await _db.managers.userEntity.filter((user) => user.id.equals(id)).getSingleOrNull();
|
final user = await _db.managers.authUserEntity.filter((user) => user.id.equals(id)).getSingleOrNull();
|
||||||
|
|
||||||
if (user == null) return null;
|
if (user == null) return null;
|
||||||
|
|
||||||
@ -84,43 +84,30 @@ class DriftUserRepository extends DriftDatabaseRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<UserDto> upsert(UserDto user) async {
|
Future<UserDto> upsert(UserDto user) async {
|
||||||
await _db.userEntity.insertOnConflictUpdate(
|
await _db.authUserEntity.insertOnConflictUpdate(
|
||||||
UserEntityCompanion(
|
AuthUserEntityCompanion(
|
||||||
id: Value(user.id),
|
id: Value(user.id),
|
||||||
isAdmin: Value(user.isAdmin),
|
|
||||||
updatedAt: Value(user.updatedAt),
|
|
||||||
name: Value(user.name),
|
name: Value(user.name),
|
||||||
email: Value(user.email),
|
email: Value(user.email),
|
||||||
hasProfileImage: Value(user.hasProfileImage),
|
hasProfileImage: Value(user.hasProfileImage),
|
||||||
profileChangedAt: Value(user.profileChangedAt),
|
profileChangedAt: Value(user.profileChangedAt),
|
||||||
|
isAdmin: Value(user.isAdmin),
|
||||||
|
quotaSizeInBytes: Value(user.quotaSizeInBytes),
|
||||||
|
quotaUsageInBytes: Value(user.quotaUsageInBytes),
|
||||||
|
avatarColor: Value(user.avatarColor),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<UserDto>> getAll() async {
|
|
||||||
final users = await _db.userEntity.select().get();
|
|
||||||
final List<UserDto> result = [];
|
|
||||||
|
|
||||||
for (final user in users) {
|
|
||||||
final query = _db.userMetadataEntity.select()..where((e) => e.userId.equals(user.id));
|
|
||||||
final metadata = await query.map((row) => row.toDto()).get();
|
|
||||||
result.add(user.toDto(metadata));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
extension on AuthUserEntityData {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension on UserEntityData {
|
|
||||||
UserDto toDto([List<UserMetadata>? metadata]) {
|
UserDto toDto([List<UserMetadata>? metadata]) {
|
||||||
AvatarColor avatarColor = AvatarColor.primary;
|
|
||||||
bool memoryEnabled = true;
|
bool memoryEnabled = true;
|
||||||
|
|
||||||
if (metadata != null) {
|
if (metadata != null) {
|
||||||
for (final meta in metadata) {
|
for (final meta in metadata) {
|
||||||
if (meta.key == UserMetadataKey.preferences && meta.preferences != null) {
|
if (meta.key == UserMetadataKey.preferences && meta.preferences != null) {
|
||||||
avatarColor = meta.preferences?.userAvatarColor ?? AvatarColor.primary;
|
|
||||||
memoryEnabled = meta.preferences?.memoriesEnabled ?? true;
|
memoryEnabled = meta.preferences?.memoriesEnabled ?? true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,12 +117,13 @@ extension on UserEntityData {
|
|||||||
id: id,
|
id: id,
|
||||||
email: email,
|
email: email,
|
||||||
name: name,
|
name: name,
|
||||||
isAdmin: isAdmin,
|
|
||||||
updatedAt: updatedAt,
|
|
||||||
profileChangedAt: profileChangedAt,
|
profileChangedAt: profileChangedAt,
|
||||||
hasProfileImage: hasProfileImage,
|
hasProfileImage: hasProfileImage,
|
||||||
avatarColor: avatarColor,
|
avatarColor: avatarColor,
|
||||||
memoryEnabled: memoryEnabled,
|
memoryEnabled: memoryEnabled,
|
||||||
|
isAdmin: isAdmin,
|
||||||
|
quotaSizeInBytes: quotaSizeInBytes,
|
||||||
|
quotaUsageInBytes: quotaUsageInBytes,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import 'package:immich_mobile/domain/models/user.model.dart';
|
import 'package:immich_mobile/domain/models/user.model.dart';
|
||||||
import 'package:immich_mobile/domain/models/user_metadata.model.dart';
|
|
||||||
import 'package:openapi/api.dart';
|
import 'package:openapi/api.dart';
|
||||||
|
|
||||||
// TODO: Move to repository once all classes are refactored
|
// TODO: Move to repository once all classes are refactored
|
||||||
|
|||||||
@ -3,9 +3,8 @@ import 'package:easy_localization/easy_localization.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/domain/models/user.model.dart';
|
|
||||||
import 'package:immich_mobile/domain/models/album/album.model.dart';
|
import 'package:immich_mobile/domain/models/album/album.model.dart';
|
||||||
import 'package:immich_mobile/domain/models/user_metadata.model.dart';
|
import 'package:immich_mobile/domain/models/user.model.dart';
|
||||||
import 'package:immich_mobile/extensions/asyncvalue_extensions.dart';
|
import 'package:immich_mobile/extensions/asyncvalue_extensions.dart';
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/db.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/db.provider.dart';
|
||||||
@ -26,11 +25,9 @@ final driftUsersProvider = FutureProvider.autoDispose<List<UserDto>>((ref) async
|
|||||||
id: entity.id,
|
id: entity.id,
|
||||||
name: entity.name,
|
name: entity.name,
|
||||||
email: entity.email,
|
email: entity.email,
|
||||||
isAdmin: entity.isAdmin,
|
|
||||||
updatedAt: entity.updatedAt,
|
|
||||||
isPartnerSharedBy: false,
|
isPartnerSharedBy: false,
|
||||||
isPartnerSharedWith: false,
|
isPartnerSharedWith: false,
|
||||||
avatarColor: AvatarColor.primary,
|
avatarColor: entity.avatarColor,
|
||||||
memoryEnabled: true,
|
memoryEnabled: true,
|
||||||
inTimeline: true,
|
inTimeline: true,
|
||||||
profileChangedAt: entity.profileChangedAt,
|
profileChangedAt: entity.profileChangedAt,
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:drift/drift.dart';
|
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/domain/models/store.model.dart';
|
import 'package:immich_mobile/domain/models/store.model.dart';
|
||||||
import 'package:immich_mobile/entities/album.entity.dart';
|
import 'package:immich_mobile/entities/album.entity.dart';
|
||||||
@ -10,6 +9,7 @@ import 'package:immich_mobile/entities/store.entity.dart';
|
|||||||
import 'package:immich_mobile/infrastructure/entities/exif.entity.dart';
|
import 'package:immich_mobile/infrastructure/entities/exif.entity.dart';
|
||||||
import 'package:immich_mobile/infrastructure/entities/user.entity.dart';
|
import 'package:immich_mobile/infrastructure/entities/user.entity.dart';
|
||||||
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
||||||
|
import 'package:immich_mobile/infrastructure/repositories/sync_stream.repository.dart';
|
||||||
import 'package:immich_mobile/models/auth/auxilary_endpoint.model.dart';
|
import 'package:immich_mobile/models/auth/auxilary_endpoint.model.dart';
|
||||||
import 'package:immich_mobile/providers/db.provider.dart';
|
import 'package:immich_mobile/providers/db.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/db.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/db.provider.dart';
|
||||||
@ -25,25 +25,7 @@ class AuthRepository extends DatabaseRepository {
|
|||||||
const AuthRepository(super.db, this._drift);
|
const AuthRepository(super.db, this._drift);
|
||||||
|
|
||||||
Future<void> clearLocalData() async {
|
Future<void> clearLocalData() async {
|
||||||
// Drift deletions - child entities first (those with foreign keys)
|
await SyncStreamRepository(_drift).reset();
|
||||||
await Future.wait([
|
|
||||||
_drift.memoryAssetEntity.deleteAll(),
|
|
||||||
_drift.remoteAlbumAssetEntity.deleteAll(),
|
|
||||||
_drift.remoteAlbumUserEntity.deleteAll(),
|
|
||||||
_drift.remoteExifEntity.deleteAll(),
|
|
||||||
_drift.userMetadataEntity.deleteAll(),
|
|
||||||
_drift.partnerEntity.deleteAll(),
|
|
||||||
_drift.stackEntity.deleteAll(),
|
|
||||||
_drift.assetFaceEntity.deleteAll(),
|
|
||||||
]);
|
|
||||||
// Drift deletions - parent entities
|
|
||||||
await Future.wait([
|
|
||||||
_drift.memoryEntity.deleteAll(),
|
|
||||||
_drift.personEntity.deleteAll(),
|
|
||||||
_drift.remoteAlbumEntity.deleteAll(),
|
|
||||||
_drift.remoteAssetEntity.deleteAll(),
|
|
||||||
_drift.userEntity.deleteAll(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return db.writeTxn(() {
|
return db.writeTxn(() {
|
||||||
return Future.wait([
|
return Future.wait([
|
||||||
|
|||||||
@ -22,14 +22,14 @@ class PartnerApiRepository extends ApiRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<UserDto> create(String id) async {
|
Future<UserDto> create(String id) async {
|
||||||
final dto = await checkNull(_api.createPartner(id));
|
final dto = await checkNull(_api.createPartnerDeprecated(id));
|
||||||
return UserConverter.fromPartnerDto(dto);
|
return UserConverter.fromPartnerDto(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> delete(String id) => _api.removePartner(id);
|
Future<void> delete(String id) => _api.removePartner(id);
|
||||||
|
|
||||||
Future<UserDto> update(String id, {required bool inTimeline}) async {
|
Future<UserDto> update(String id, {required bool inTimeline}) async {
|
||||||
final dto = await checkNull(_api.updatePartner(id, UpdatePartnerDto(inTimeline: inTimeline)));
|
final dto = await checkNull(_api.updatePartner(id, PartnerUpdateDto(inTimeline: inTimeline)));
|
||||||
return UserConverter.fromPartnerDto(dto);
|
return UserConverter.fromPartnerDto(dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -147,7 +147,9 @@ class SyncService {
|
|||||||
dbUsers,
|
dbUsers,
|
||||||
compare: (UserDto a, UserDto b) => a.id.compareTo(b.id),
|
compare: (UserDto a, UserDto b) => a.id.compareTo(b.id),
|
||||||
both: (UserDto a, UserDto b) {
|
both: (UserDto a, UserDto b) {
|
||||||
if (!a.updatedAt.isAtSameMomentAs(b.updatedAt) ||
|
if ((a.updatedAt == null && b.updatedAt != null) ||
|
||||||
|
(a.updatedAt != null && b.updatedAt == null) ||
|
||||||
|
(a.updatedAt != null && b.updatedAt != null && !a.updatedAt!.isAtSameMomentAs(b.updatedAt!)) ||
|
||||||
a.isPartnerSharedBy != b.isPartnerSharedBy ||
|
a.isPartnerSharedBy != b.isPartnerSharedBy ||
|
||||||
a.isPartnerSharedWith != b.isPartnerSharedWith ||
|
a.isPartnerSharedWith != b.isPartnerSharedWith ||
|
||||||
a.inTimeline != b.inTimeline) {
|
a.inTimeline != b.inTimeline) {
|
||||||
|
|||||||
7
mobile/openapi/README.md
generated
7
mobile/openapi/README.md
generated
@ -126,6 +126,7 @@ Class | Method | HTTP request | Description
|
|||||||
*AuthenticationApi* | [**signUpAdmin**](doc//AuthenticationApi.md#signupadmin) | **POST** /auth/admin-sign-up |
|
*AuthenticationApi* | [**signUpAdmin**](doc//AuthenticationApi.md#signupadmin) | **POST** /auth/admin-sign-up |
|
||||||
*AuthenticationApi* | [**unlockAuthSession**](doc//AuthenticationApi.md#unlockauthsession) | **POST** /auth/session/unlock |
|
*AuthenticationApi* | [**unlockAuthSession**](doc//AuthenticationApi.md#unlockauthsession) | **POST** /auth/session/unlock |
|
||||||
*AuthenticationApi* | [**validateAccessToken**](doc//AuthenticationApi.md#validateaccesstoken) | **POST** /auth/validateToken |
|
*AuthenticationApi* | [**validateAccessToken**](doc//AuthenticationApi.md#validateaccesstoken) | **POST** /auth/validateToken |
|
||||||
|
*DeprecatedApi* | [**createPartnerDeprecated**](doc//DeprecatedApi.md#createpartnerdeprecated) | **POST** /partners/{id} |
|
||||||
*DeprecatedApi* | [**getRandom**](doc//DeprecatedApi.md#getrandom) | **GET** /assets/random |
|
*DeprecatedApi* | [**getRandom**](doc//DeprecatedApi.md#getrandom) | **GET** /assets/random |
|
||||||
*DownloadApi* | [**downloadArchive**](doc//DownloadApi.md#downloadarchive) | **POST** /download/archive |
|
*DownloadApi* | [**downloadArchive**](doc//DownloadApi.md#downloadarchive) | **POST** /download/archive |
|
||||||
*DownloadApi* | [**getDownloadInfo**](doc//DownloadApi.md#getdownloadinfo) | **POST** /download/info |
|
*DownloadApi* | [**getDownloadInfo**](doc//DownloadApi.md#getdownloadinfo) | **POST** /download/info |
|
||||||
@ -171,7 +172,8 @@ Class | Method | HTTP request | Description
|
|||||||
*OAuthApi* | [**redirectOAuthToMobile**](doc//OAuthApi.md#redirectoauthtomobile) | **GET** /oauth/mobile-redirect |
|
*OAuthApi* | [**redirectOAuthToMobile**](doc//OAuthApi.md#redirectoauthtomobile) | **GET** /oauth/mobile-redirect |
|
||||||
*OAuthApi* | [**startOAuth**](doc//OAuthApi.md#startoauth) | **POST** /oauth/authorize |
|
*OAuthApi* | [**startOAuth**](doc//OAuthApi.md#startoauth) | **POST** /oauth/authorize |
|
||||||
*OAuthApi* | [**unlinkOAuthAccount**](doc//OAuthApi.md#unlinkoauthaccount) | **POST** /oauth/unlink |
|
*OAuthApi* | [**unlinkOAuthAccount**](doc//OAuthApi.md#unlinkoauthaccount) | **POST** /oauth/unlink |
|
||||||
*PartnersApi* | [**createPartner**](doc//PartnersApi.md#createpartner) | **POST** /partners/{id} |
|
*PartnersApi* | [**createPartner**](doc//PartnersApi.md#createpartner) | **POST** /partners |
|
||||||
|
*PartnersApi* | [**createPartnerDeprecated**](doc//PartnersApi.md#createpartnerdeprecated) | **POST** /partners/{id} |
|
||||||
*PartnersApi* | [**getPartners**](doc//PartnersApi.md#getpartners) | **GET** /partners |
|
*PartnersApi* | [**getPartners**](doc//PartnersApi.md#getpartners) | **GET** /partners |
|
||||||
*PartnersApi* | [**removePartner**](doc//PartnersApi.md#removepartner) | **DELETE** /partners/{id} |
|
*PartnersApi* | [**removePartner**](doc//PartnersApi.md#removepartner) | **DELETE** /partners/{id} |
|
||||||
*PartnersApi* | [**updatePartner**](doc//PartnersApi.md#updatepartner) | **PUT** /partners/{id} |
|
*PartnersApi* | [**updatePartner**](doc//PartnersApi.md#updatepartner) | **PUT** /partners/{id} |
|
||||||
@ -416,8 +418,10 @@ Class | Method | HTTP request | Description
|
|||||||
- [OnThisDayDto](doc//OnThisDayDto.md)
|
- [OnThisDayDto](doc//OnThisDayDto.md)
|
||||||
- [OnboardingDto](doc//OnboardingDto.md)
|
- [OnboardingDto](doc//OnboardingDto.md)
|
||||||
- [OnboardingResponseDto](doc//OnboardingResponseDto.md)
|
- [OnboardingResponseDto](doc//OnboardingResponseDto.md)
|
||||||
|
- [PartnerCreateDto](doc//PartnerCreateDto.md)
|
||||||
- [PartnerDirection](doc//PartnerDirection.md)
|
- [PartnerDirection](doc//PartnerDirection.md)
|
||||||
- [PartnerResponseDto](doc//PartnerResponseDto.md)
|
- [PartnerResponseDto](doc//PartnerResponseDto.md)
|
||||||
|
- [PartnerUpdateDto](doc//PartnerUpdateDto.md)
|
||||||
- [PeopleResponse](doc//PeopleResponse.md)
|
- [PeopleResponse](doc//PeopleResponse.md)
|
||||||
- [PeopleResponseDto](doc//PeopleResponseDto.md)
|
- [PeopleResponseDto](doc//PeopleResponseDto.md)
|
||||||
- [PeopleUpdate](doc//PeopleUpdate.md)
|
- [PeopleUpdate](doc//PeopleUpdate.md)
|
||||||
@ -566,7 +570,6 @@ Class | Method | HTTP request | Description
|
|||||||
- [UpdateAlbumUserDto](doc//UpdateAlbumUserDto.md)
|
- [UpdateAlbumUserDto](doc//UpdateAlbumUserDto.md)
|
||||||
- [UpdateAssetDto](doc//UpdateAssetDto.md)
|
- [UpdateAssetDto](doc//UpdateAssetDto.md)
|
||||||
- [UpdateLibraryDto](doc//UpdateLibraryDto.md)
|
- [UpdateLibraryDto](doc//UpdateLibraryDto.md)
|
||||||
- [UpdatePartnerDto](doc//UpdatePartnerDto.md)
|
|
||||||
- [UsageByUserDto](doc//UsageByUserDto.md)
|
- [UsageByUserDto](doc//UsageByUserDto.md)
|
||||||
- [UserAdminCreateDto](doc//UserAdminCreateDto.md)
|
- [UserAdminCreateDto](doc//UserAdminCreateDto.md)
|
||||||
- [UserAdminDeleteDto](doc//UserAdminDeleteDto.md)
|
- [UserAdminDeleteDto](doc//UserAdminDeleteDto.md)
|
||||||
|
|||||||
3
mobile/openapi/lib/api.dart
generated
3
mobile/openapi/lib/api.dart
generated
@ -190,8 +190,10 @@ part 'model/o_auth_token_endpoint_auth_method.dart';
|
|||||||
part 'model/on_this_day_dto.dart';
|
part 'model/on_this_day_dto.dart';
|
||||||
part 'model/onboarding_dto.dart';
|
part 'model/onboarding_dto.dart';
|
||||||
part 'model/onboarding_response_dto.dart';
|
part 'model/onboarding_response_dto.dart';
|
||||||
|
part 'model/partner_create_dto.dart';
|
||||||
part 'model/partner_direction.dart';
|
part 'model/partner_direction.dart';
|
||||||
part 'model/partner_response_dto.dart';
|
part 'model/partner_response_dto.dart';
|
||||||
|
part 'model/partner_update_dto.dart';
|
||||||
part 'model/people_response.dart';
|
part 'model/people_response.dart';
|
||||||
part 'model/people_response_dto.dart';
|
part 'model/people_response_dto.dart';
|
||||||
part 'model/people_update.dart';
|
part 'model/people_update.dart';
|
||||||
@ -340,7 +342,6 @@ part 'model/update_album_dto.dart';
|
|||||||
part 'model/update_album_user_dto.dart';
|
part 'model/update_album_user_dto.dart';
|
||||||
part 'model/update_asset_dto.dart';
|
part 'model/update_asset_dto.dart';
|
||||||
part 'model/update_library_dto.dart';
|
part 'model/update_library_dto.dart';
|
||||||
part 'model/update_partner_dto.dart';
|
|
||||||
part 'model/usage_by_user_dto.dart';
|
part 'model/usage_by_user_dto.dart';
|
||||||
part 'model/user_admin_create_dto.dart';
|
part 'model/user_admin_create_dto.dart';
|
||||||
part 'model/user_admin_delete_dto.dart';
|
part 'model/user_admin_delete_dto.dart';
|
||||||
|
|||||||
53
mobile/openapi/lib/api/deprecated_api.dart
generated
53
mobile/openapi/lib/api/deprecated_api.dart
generated
@ -16,6 +16,59 @@ class DeprecatedApi {
|
|||||||
|
|
||||||
final ApiClient apiClient;
|
final ApiClient apiClient;
|
||||||
|
|
||||||
|
/// This property was deprecated in v1.141.0. This endpoint requires the `partner.create` permission.
|
||||||
|
///
|
||||||
|
/// Note: This method returns the HTTP [Response].
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
///
|
||||||
|
/// * [String] id (required):
|
||||||
|
Future<Response> createPartnerDeprecatedWithHttpInfo(String id,) async {
|
||||||
|
// ignore: prefer_const_declarations
|
||||||
|
final apiPath = r'/partners/{id}'
|
||||||
|
.replaceAll('{id}', id);
|
||||||
|
|
||||||
|
// ignore: prefer_final_locals
|
||||||
|
Object? postBody;
|
||||||
|
|
||||||
|
final queryParams = <QueryParam>[];
|
||||||
|
final headerParams = <String, String>{};
|
||||||
|
final formParams = <String, String>{};
|
||||||
|
|
||||||
|
const contentTypes = <String>[];
|
||||||
|
|
||||||
|
|
||||||
|
return apiClient.invokeAPI(
|
||||||
|
apiPath,
|
||||||
|
'POST',
|
||||||
|
queryParams,
|
||||||
|
postBody,
|
||||||
|
headerParams,
|
||||||
|
formParams,
|
||||||
|
contentTypes.isEmpty ? null : contentTypes.first,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This property was deprecated in v1.141.0. This endpoint requires the `partner.create` permission.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
///
|
||||||
|
/// * [String] id (required):
|
||||||
|
Future<PartnerResponseDto?> createPartnerDeprecated(String id,) async {
|
||||||
|
final response = await createPartnerDeprecatedWithHttpInfo(id,);
|
||||||
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
|
}
|
||||||
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
|
// FormatException when trying to decode an empty string.
|
||||||
|
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||||
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'PartnerResponseDto',) as PartnerResponseDto;
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/// This property was deprecated in v1.116.0. This endpoint requires the `asset.read` permission.
|
/// This property was deprecated in v1.116.0. This endpoint requires the `asset.read` permission.
|
||||||
///
|
///
|
||||||
/// Note: This method returns the HTTP [Response].
|
/// Note: This method returns the HTTP [Response].
|
||||||
|
|||||||
72
mobile/openapi/lib/api/partners_api.dart
generated
72
mobile/openapi/lib/api/partners_api.dart
generated
@ -22,8 +22,60 @@ class PartnersApi {
|
|||||||
///
|
///
|
||||||
/// Parameters:
|
/// Parameters:
|
||||||
///
|
///
|
||||||
|
/// * [PartnerCreateDto] partnerCreateDto (required):
|
||||||
|
Future<Response> createPartnerWithHttpInfo(PartnerCreateDto partnerCreateDto,) async {
|
||||||
|
// ignore: prefer_const_declarations
|
||||||
|
final apiPath = r'/partners';
|
||||||
|
|
||||||
|
// ignore: prefer_final_locals
|
||||||
|
Object? postBody = partnerCreateDto;
|
||||||
|
|
||||||
|
final queryParams = <QueryParam>[];
|
||||||
|
final headerParams = <String, String>{};
|
||||||
|
final formParams = <String, String>{};
|
||||||
|
|
||||||
|
const contentTypes = <String>['application/json'];
|
||||||
|
|
||||||
|
|
||||||
|
return apiClient.invokeAPI(
|
||||||
|
apiPath,
|
||||||
|
'POST',
|
||||||
|
queryParams,
|
||||||
|
postBody,
|
||||||
|
headerParams,
|
||||||
|
formParams,
|
||||||
|
contentTypes.isEmpty ? null : contentTypes.first,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This endpoint requires the `partner.create` permission.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
///
|
||||||
|
/// * [PartnerCreateDto] partnerCreateDto (required):
|
||||||
|
Future<PartnerResponseDto?> createPartner(PartnerCreateDto partnerCreateDto,) async {
|
||||||
|
final response = await createPartnerWithHttpInfo(partnerCreateDto,);
|
||||||
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
|
}
|
||||||
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
|
// FormatException when trying to decode an empty string.
|
||||||
|
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||||
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'PartnerResponseDto',) as PartnerResponseDto;
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This property was deprecated in v1.141.0. This endpoint requires the `partner.create` permission.
|
||||||
|
///
|
||||||
|
/// Note: This method returns the HTTP [Response].
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
///
|
||||||
/// * [String] id (required):
|
/// * [String] id (required):
|
||||||
Future<Response> createPartnerWithHttpInfo(String id,) async {
|
Future<Response> createPartnerDeprecatedWithHttpInfo(String id,) async {
|
||||||
// ignore: prefer_const_declarations
|
// ignore: prefer_const_declarations
|
||||||
final apiPath = r'/partners/{id}'
|
final apiPath = r'/partners/{id}'
|
||||||
.replaceAll('{id}', id);
|
.replaceAll('{id}', id);
|
||||||
@ -49,13 +101,13 @@ class PartnersApi {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This endpoint requires the `partner.create` permission.
|
/// This property was deprecated in v1.141.0. This endpoint requires the `partner.create` permission.
|
||||||
///
|
///
|
||||||
/// Parameters:
|
/// Parameters:
|
||||||
///
|
///
|
||||||
/// * [String] id (required):
|
/// * [String] id (required):
|
||||||
Future<PartnerResponseDto?> createPartner(String id,) async {
|
Future<PartnerResponseDto?> createPartnerDeprecated(String id,) async {
|
||||||
final response = await createPartnerWithHttpInfo(id,);
|
final response = await createPartnerDeprecatedWithHttpInfo(id,);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
@ -179,14 +231,14 @@ class PartnersApi {
|
|||||||
///
|
///
|
||||||
/// * [String] id (required):
|
/// * [String] id (required):
|
||||||
///
|
///
|
||||||
/// * [UpdatePartnerDto] updatePartnerDto (required):
|
/// * [PartnerUpdateDto] partnerUpdateDto (required):
|
||||||
Future<Response> updatePartnerWithHttpInfo(String id, UpdatePartnerDto updatePartnerDto,) async {
|
Future<Response> updatePartnerWithHttpInfo(String id, PartnerUpdateDto partnerUpdateDto,) async {
|
||||||
// ignore: prefer_const_declarations
|
// ignore: prefer_const_declarations
|
||||||
final apiPath = r'/partners/{id}'
|
final apiPath = r'/partners/{id}'
|
||||||
.replaceAll('{id}', id);
|
.replaceAll('{id}', id);
|
||||||
|
|
||||||
// ignore: prefer_final_locals
|
// ignore: prefer_final_locals
|
||||||
Object? postBody = updatePartnerDto;
|
Object? postBody = partnerUpdateDto;
|
||||||
|
|
||||||
final queryParams = <QueryParam>[];
|
final queryParams = <QueryParam>[];
|
||||||
final headerParams = <String, String>{};
|
final headerParams = <String, String>{};
|
||||||
@ -212,9 +264,9 @@ class PartnersApi {
|
|||||||
///
|
///
|
||||||
/// * [String] id (required):
|
/// * [String] id (required):
|
||||||
///
|
///
|
||||||
/// * [UpdatePartnerDto] updatePartnerDto (required):
|
/// * [PartnerUpdateDto] partnerUpdateDto (required):
|
||||||
Future<PartnerResponseDto?> updatePartner(String id, UpdatePartnerDto updatePartnerDto,) async {
|
Future<PartnerResponseDto?> updatePartner(String id, PartnerUpdateDto partnerUpdateDto,) async {
|
||||||
final response = await updatePartnerWithHttpInfo(id, updatePartnerDto,);
|
final response = await updatePartnerWithHttpInfo(id, partnerUpdateDto,);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
|
|||||||
6
mobile/openapi/lib/api_client.dart
generated
6
mobile/openapi/lib/api_client.dart
generated
@ -434,10 +434,14 @@ class ApiClient {
|
|||||||
return OnboardingDto.fromJson(value);
|
return OnboardingDto.fromJson(value);
|
||||||
case 'OnboardingResponseDto':
|
case 'OnboardingResponseDto':
|
||||||
return OnboardingResponseDto.fromJson(value);
|
return OnboardingResponseDto.fromJson(value);
|
||||||
|
case 'PartnerCreateDto':
|
||||||
|
return PartnerCreateDto.fromJson(value);
|
||||||
case 'PartnerDirection':
|
case 'PartnerDirection':
|
||||||
return PartnerDirectionTypeTransformer().decode(value);
|
return PartnerDirectionTypeTransformer().decode(value);
|
||||||
case 'PartnerResponseDto':
|
case 'PartnerResponseDto':
|
||||||
return PartnerResponseDto.fromJson(value);
|
return PartnerResponseDto.fromJson(value);
|
||||||
|
case 'PartnerUpdateDto':
|
||||||
|
return PartnerUpdateDto.fromJson(value);
|
||||||
case 'PeopleResponse':
|
case 'PeopleResponse':
|
||||||
return PeopleResponse.fromJson(value);
|
return PeopleResponse.fromJson(value);
|
||||||
case 'PeopleResponseDto':
|
case 'PeopleResponseDto':
|
||||||
@ -734,8 +738,6 @@ class ApiClient {
|
|||||||
return UpdateAssetDto.fromJson(value);
|
return UpdateAssetDto.fromJson(value);
|
||||||
case 'UpdateLibraryDto':
|
case 'UpdateLibraryDto':
|
||||||
return UpdateLibraryDto.fromJson(value);
|
return UpdateLibraryDto.fromJson(value);
|
||||||
case 'UpdatePartnerDto':
|
|
||||||
return UpdatePartnerDto.fromJson(value);
|
|
||||||
case 'UsageByUserDto':
|
case 'UsageByUserDto':
|
||||||
return UsageByUserDto.fromJson(value);
|
return UsageByUserDto.fromJson(value);
|
||||||
case 'UserAdminCreateDto':
|
case 'UserAdminCreateDto':
|
||||||
|
|||||||
99
mobile/openapi/lib/model/partner_create_dto.dart
generated
Normal file
99
mobile/openapi/lib/model/partner_create_dto.dart
generated
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
//
|
||||||
|
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||||
|
//
|
||||||
|
// @dart=2.18
|
||||||
|
|
||||||
|
// ignore_for_file: unused_element, unused_import
|
||||||
|
// ignore_for_file: always_put_required_named_parameters_first
|
||||||
|
// ignore_for_file: constant_identifier_names
|
||||||
|
// ignore_for_file: lines_longer_than_80_chars
|
||||||
|
|
||||||
|
part of openapi.api;
|
||||||
|
|
||||||
|
class PartnerCreateDto {
|
||||||
|
/// Returns a new [PartnerCreateDto] instance.
|
||||||
|
PartnerCreateDto({
|
||||||
|
required this.sharedWithId,
|
||||||
|
});
|
||||||
|
|
||||||
|
String sharedWithId;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) => identical(this, other) || other is PartnerCreateDto &&
|
||||||
|
other.sharedWithId == sharedWithId;
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode =>
|
||||||
|
// ignore: unnecessary_parenthesis
|
||||||
|
(sharedWithId.hashCode);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() => 'PartnerCreateDto[sharedWithId=$sharedWithId]';
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final json = <String, dynamic>{};
|
||||||
|
json[r'sharedWithId'] = this.sharedWithId;
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a new [PartnerCreateDto] instance and imports its values from
|
||||||
|
/// [value] if it's a [Map], null otherwise.
|
||||||
|
// ignore: prefer_constructors_over_static_methods
|
||||||
|
static PartnerCreateDto? fromJson(dynamic value) {
|
||||||
|
upgradeDto(value, "PartnerCreateDto");
|
||||||
|
if (value is Map) {
|
||||||
|
final json = value.cast<String, dynamic>();
|
||||||
|
|
||||||
|
return PartnerCreateDto(
|
||||||
|
sharedWithId: mapValueOfType<String>(json, r'sharedWithId')!,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<PartnerCreateDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||||
|
final result = <PartnerCreateDto>[];
|
||||||
|
if (json is List && json.isNotEmpty) {
|
||||||
|
for (final row in json) {
|
||||||
|
final value = PartnerCreateDto.fromJson(row);
|
||||||
|
if (value != null) {
|
||||||
|
result.add(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.toList(growable: growable);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Map<String, PartnerCreateDto> mapFromJson(dynamic json) {
|
||||||
|
final map = <String, PartnerCreateDto>{};
|
||||||
|
if (json is Map && json.isNotEmpty) {
|
||||||
|
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||||
|
for (final entry in json.entries) {
|
||||||
|
final value = PartnerCreateDto.fromJson(entry.value);
|
||||||
|
if (value != null) {
|
||||||
|
map[entry.key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
// maps a json object with a list of PartnerCreateDto-objects as value to a dart map
|
||||||
|
static Map<String, List<PartnerCreateDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||||
|
final map = <String, List<PartnerCreateDto>>{};
|
||||||
|
if (json is Map && json.isNotEmpty) {
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
json = json.cast<String, dynamic>();
|
||||||
|
for (final entry in json.entries) {
|
||||||
|
map[entry.key] = PartnerCreateDto.listFromJson(entry.value, growable: growable,);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The list of required keys that must be present in a JSON.
|
||||||
|
static const requiredKeys = <String>{
|
||||||
|
'sharedWithId',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@ -10,16 +10,16 @@
|
|||||||
|
|
||||||
part of openapi.api;
|
part of openapi.api;
|
||||||
|
|
||||||
class UpdatePartnerDto {
|
class PartnerUpdateDto {
|
||||||
/// Returns a new [UpdatePartnerDto] instance.
|
/// Returns a new [PartnerUpdateDto] instance.
|
||||||
UpdatePartnerDto({
|
PartnerUpdateDto({
|
||||||
required this.inTimeline,
|
required this.inTimeline,
|
||||||
});
|
});
|
||||||
|
|
||||||
bool inTimeline;
|
bool inTimeline;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) => identical(this, other) || other is UpdatePartnerDto &&
|
bool operator ==(Object other) => identical(this, other) || other is PartnerUpdateDto &&
|
||||||
other.inTimeline == inTimeline;
|
other.inTimeline == inTimeline;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -28,7 +28,7 @@ class UpdatePartnerDto {
|
|||||||
(inTimeline.hashCode);
|
(inTimeline.hashCode);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => 'UpdatePartnerDto[inTimeline=$inTimeline]';
|
String toString() => 'PartnerUpdateDto[inTimeline=$inTimeline]';
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final json = <String, dynamic>{};
|
final json = <String, dynamic>{};
|
||||||
@ -36,26 +36,26 @@ class UpdatePartnerDto {
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a new [UpdatePartnerDto] instance and imports its values from
|
/// Returns a new [PartnerUpdateDto] instance and imports its values from
|
||||||
/// [value] if it's a [Map], null otherwise.
|
/// [value] if it's a [Map], null otherwise.
|
||||||
// ignore: prefer_constructors_over_static_methods
|
// ignore: prefer_constructors_over_static_methods
|
||||||
static UpdatePartnerDto? fromJson(dynamic value) {
|
static PartnerUpdateDto? fromJson(dynamic value) {
|
||||||
upgradeDto(value, "UpdatePartnerDto");
|
upgradeDto(value, "PartnerUpdateDto");
|
||||||
if (value is Map) {
|
if (value is Map) {
|
||||||
final json = value.cast<String, dynamic>();
|
final json = value.cast<String, dynamic>();
|
||||||
|
|
||||||
return UpdatePartnerDto(
|
return PartnerUpdateDto(
|
||||||
inTimeline: mapValueOfType<bool>(json, r'inTimeline')!,
|
inTimeline: mapValueOfType<bool>(json, r'inTimeline')!,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<UpdatePartnerDto> listFromJson(dynamic json, {bool growable = false,}) {
|
static List<PartnerUpdateDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||||
final result = <UpdatePartnerDto>[];
|
final result = <PartnerUpdateDto>[];
|
||||||
if (json is List && json.isNotEmpty) {
|
if (json is List && json.isNotEmpty) {
|
||||||
for (final row in json) {
|
for (final row in json) {
|
||||||
final value = UpdatePartnerDto.fromJson(row);
|
final value = PartnerUpdateDto.fromJson(row);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
result.add(value);
|
result.add(value);
|
||||||
}
|
}
|
||||||
@ -64,12 +64,12 @@ class UpdatePartnerDto {
|
|||||||
return result.toList(growable: growable);
|
return result.toList(growable: growable);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Map<String, UpdatePartnerDto> mapFromJson(dynamic json) {
|
static Map<String, PartnerUpdateDto> mapFromJson(dynamic json) {
|
||||||
final map = <String, UpdatePartnerDto>{};
|
final map = <String, PartnerUpdateDto>{};
|
||||||
if (json is Map && json.isNotEmpty) {
|
if (json is Map && json.isNotEmpty) {
|
||||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||||
for (final entry in json.entries) {
|
for (final entry in json.entries) {
|
||||||
final value = UpdatePartnerDto.fromJson(entry.value);
|
final value = PartnerUpdateDto.fromJson(entry.value);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
map[entry.key] = value;
|
map[entry.key] = value;
|
||||||
}
|
}
|
||||||
@ -78,14 +78,14 @@ class UpdatePartnerDto {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
// maps a json object with a list of UpdatePartnerDto-objects as value to a dart map
|
// maps a json object with a list of PartnerUpdateDto-objects as value to a dart map
|
||||||
static Map<String, List<UpdatePartnerDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
static Map<String, List<PartnerUpdateDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||||
final map = <String, List<UpdatePartnerDto>>{};
|
final map = <String, List<PartnerUpdateDto>>{};
|
||||||
if (json is Map && json.isNotEmpty) {
|
if (json is Map && json.isNotEmpty) {
|
||||||
// ignore: parameter_assignments
|
// ignore: parameter_assignments
|
||||||
json = json.cast<String, dynamic>();
|
json = json.cast<String, dynamic>();
|
||||||
for (final entry in json.entries) {
|
for (final entry in json.entries) {
|
||||||
map[entry.key] = UpdatePartnerDto.listFromJson(entry.value, growable: growable,);
|
map[entry.key] = PartnerUpdateDto.listFromJson(entry.value, growable: growable,);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
@ -30,8 +30,9 @@ void main() {
|
|||||||
late SyncStreamService sut;
|
late SyncStreamService sut;
|
||||||
late SyncStreamRepository mockSyncStreamRepo;
|
late SyncStreamRepository mockSyncStreamRepo;
|
||||||
late SyncApiRepository mockSyncApiRepo;
|
late SyncApiRepository mockSyncApiRepo;
|
||||||
late Function(List<SyncEvent>, Function()) handleEventsCallback;
|
late Future<void> Function(List<SyncEvent>, Function(), Function()) handleEventsCallback;
|
||||||
late _MockAbortCallbackWrapper mockAbortCallbackWrapper;
|
late _MockAbortCallbackWrapper mockAbortCallbackWrapper;
|
||||||
|
late _MockAbortCallbackWrapper mockResetCallbackWrapper;
|
||||||
|
|
||||||
successHandler(Invocation _) async => true;
|
successHandler(Invocation _) async => true;
|
||||||
|
|
||||||
@ -39,6 +40,7 @@ void main() {
|
|||||||
mockSyncStreamRepo = MockSyncStreamRepository();
|
mockSyncStreamRepo = MockSyncStreamRepository();
|
||||||
mockSyncApiRepo = MockSyncApiRepository();
|
mockSyncApiRepo = MockSyncApiRepository();
|
||||||
mockAbortCallbackWrapper = _MockAbortCallbackWrapper();
|
mockAbortCallbackWrapper = _MockAbortCallbackWrapper();
|
||||||
|
mockResetCallbackWrapper = _MockAbortCallbackWrapper();
|
||||||
|
|
||||||
when(() => mockAbortCallbackWrapper()).thenReturn(false);
|
when(() => mockAbortCallbackWrapper()).thenReturn(false);
|
||||||
|
|
||||||
@ -46,6 +48,10 @@ void main() {
|
|||||||
handleEventsCallback = invocation.positionalArguments.first;
|
handleEventsCallback = invocation.positionalArguments.first;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
when(() => mockSyncApiRepo.streamChanges(any(), onReset: any(named: 'onReset'))).thenAnswer((invocation) async {
|
||||||
|
handleEventsCallback = invocation.positionalArguments.first;
|
||||||
|
});
|
||||||
|
|
||||||
when(() => mockSyncApiRepo.ack(any())).thenAnswer((_) async => {});
|
when(() => mockSyncApiRepo.ack(any())).thenAnswer((_) async => {});
|
||||||
|
|
||||||
when(() => mockSyncStreamRepo.updateUsersV1(any())).thenAnswer(successHandler);
|
when(() => mockSyncStreamRepo.updateUsersV1(any())).thenAnswer(successHandler);
|
||||||
@ -86,7 +92,7 @@ void main() {
|
|||||||
|
|
||||||
Future<void> simulateEvents(List<SyncEvent> events) async {
|
Future<void> simulateEvents(List<SyncEvent> events) async {
|
||||||
await sut.sync();
|
await sut.sync();
|
||||||
await handleEventsCallback(events, mockAbortCallbackWrapper.call);
|
await handleEventsCallback(events, mockAbortCallbackWrapper.call, mockResetCallbackWrapper.call);
|
||||||
}
|
}
|
||||||
|
|
||||||
group("SyncStreamService - _handleEvents", () {
|
group("SyncStreamService - _handleEvents", () {
|
||||||
@ -156,7 +162,7 @@ void main() {
|
|||||||
when(() => cancellationChecker()).thenReturn(true);
|
when(() => cancellationChecker()).thenReturn(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
await handleEventsCallback(events, mockAbortCallbackWrapper.call);
|
await handleEventsCallback(events, mockAbortCallbackWrapper.call, mockResetCallbackWrapper.call);
|
||||||
|
|
||||||
verify(() => mockSyncStreamRepo.deleteUsersV1(any())).called(1);
|
verify(() => mockSyncStreamRepo.deleteUsersV1(any())).called(1);
|
||||||
verifyNever(() => mockSyncStreamRepo.updateUsersV1(any()));
|
verifyNever(() => mockSyncStreamRepo.updateUsersV1(any()));
|
||||||
@ -188,7 +194,11 @@ void main() {
|
|||||||
|
|
||||||
final events = [SyncStreamStub.userDeleteV1, SyncStreamStub.userV1Admin, SyncStreamStub.partnerDeleteV1];
|
final events = [SyncStreamStub.userDeleteV1, SyncStreamStub.userV1Admin, SyncStreamStub.partnerDeleteV1];
|
||||||
|
|
||||||
final processingFuture = handleEventsCallback(events, mockAbortCallbackWrapper.call);
|
final processingFuture = handleEventsCallback(
|
||||||
|
events,
|
||||||
|
mockAbortCallbackWrapper.call,
|
||||||
|
mockResetCallbackWrapper.call,
|
||||||
|
);
|
||||||
await pumpEventQueue();
|
await pumpEventQueue();
|
||||||
|
|
||||||
expect(handler1Started, isTrue);
|
expect(handler1Started, isTrue);
|
||||||
|
|||||||
816
mobile/test/drift/main/generated/schema_v10.dart
generated
816
mobile/test/drift/main/generated/schema_v10.dart
generated
File diff suppressed because it is too large
Load Diff
1
mobile/test/fixtures/user.stub.dart
vendored
1
mobile/test/fixtures/user.stub.dart
vendored
@ -1,5 +1,4 @@
|
|||||||
import 'package:immich_mobile/domain/models/user.model.dart';
|
import 'package:immich_mobile/domain/models/user.model.dart';
|
||||||
import 'package:immich_mobile/domain/models/user_metadata.model.dart';
|
|
||||||
|
|
||||||
abstract final class UserStub {
|
abstract final class UserStub {
|
||||||
const UserStub._();
|
const UserStub._();
|
||||||
|
|||||||
@ -63,7 +63,9 @@ void main() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<void> streamChanges(Function(List<SyncEvent>, Function() abort) onDataCallback) {
|
Future<void> streamChanges(
|
||||||
|
Future<void> Function(List<SyncEvent>, Function() abort, Function() reset) onDataCallback,
|
||||||
|
) {
|
||||||
return sut.streamChanges(onDataCallback, batchSize: testBatchSize, httpClient: mockHttpClient);
|
return sut.streamChanges(onDataCallback, batchSize: testBatchSize, httpClient: mockHttpClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +74,7 @@ void main() {
|
|||||||
bool abortWasCalledInCallback = false;
|
bool abortWasCalledInCallback = false;
|
||||||
List<SyncEvent> receivedEventsBatch1 = [];
|
List<SyncEvent> receivedEventsBatch1 = [];
|
||||||
|
|
||||||
onDataCallback(List<SyncEvent> events, Function() abort) {
|
Future<void> onDataCallback(List<SyncEvent> events, Function() abort, Function() _) async {
|
||||||
onDataCallCount++;
|
onDataCallCount++;
|
||||||
if (onDataCallCount == 1) {
|
if (onDataCallCount == 1) {
|
||||||
receivedEventsBatch1 = events;
|
receivedEventsBatch1 = events;
|
||||||
@ -116,7 +118,7 @@ void main() {
|
|||||||
int onDataCallCount = 0;
|
int onDataCallCount = 0;
|
||||||
bool abortWasCalledInCallback = false;
|
bool abortWasCalledInCallback = false;
|
||||||
|
|
||||||
onDataCallback(List<SyncEvent> events, Function() abort) {
|
Future<void> onDataCallback(List<SyncEvent> events, Function() abort, Function() _) async {
|
||||||
onDataCallCount++;
|
onDataCallCount++;
|
||||||
if (onDataCallCount == 1) {
|
if (onDataCallCount == 1) {
|
||||||
abort();
|
abort();
|
||||||
@ -158,7 +160,7 @@ void main() {
|
|||||||
List<SyncEvent> receivedEventsBatch1 = [];
|
List<SyncEvent> receivedEventsBatch1 = [];
|
||||||
List<SyncEvent> receivedEventsBatch2 = [];
|
List<SyncEvent> receivedEventsBatch2 = [];
|
||||||
|
|
||||||
onDataCallback(List<SyncEvent> events, Function() _) {
|
Future<void> onDataCallback(List<SyncEvent> events, Function() _, Function() __) async {
|
||||||
onDataCallCount++;
|
onDataCallCount++;
|
||||||
if (onDataCallCount == 1) {
|
if (onDataCallCount == 1) {
|
||||||
receivedEventsBatch1 = events;
|
receivedEventsBatch1 = events;
|
||||||
@ -202,7 +204,7 @@ void main() {
|
|||||||
final streamError = Exception("Network Error");
|
final streamError = Exception("Network Error");
|
||||||
int onDataCallCount = 0;
|
int onDataCallCount = 0;
|
||||||
|
|
||||||
onDataCallback(List<SyncEvent> events, Function() _) {
|
Future<void> onDataCallback(List<SyncEvent> events, Function() _, Function() __) async {
|
||||||
onDataCallCount++;
|
onDataCallCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,8 +231,7 @@ void main() {
|
|||||||
when(() => mockStreamedResponse.stream).thenAnswer((_) => http.ByteStream(errorBodyController.stream));
|
when(() => mockStreamedResponse.stream).thenAnswer((_) => http.ByteStream(errorBodyController.stream));
|
||||||
|
|
||||||
int onDataCallCount = 0;
|
int onDataCallCount = 0;
|
||||||
|
Future<void> onDataCallback(List<SyncEvent> events, Function() _, Function() __) async {
|
||||||
onDataCallback(List<SyncEvent> events, Function() _) {
|
|
||||||
onDataCallCount++;
|
onDataCallCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4994,6 +4994,48 @@
|
|||||||
],
|
],
|
||||||
"x-immich-permission": "partner.read",
|
"x-immich-permission": "partner.read",
|
||||||
"description": "This endpoint requires the `partner.read` permission."
|
"description": "This endpoint requires the `partner.read` permission."
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
|
"operationId": "createPartner",
|
||||||
|
"parameters": [],
|
||||||
|
"requestBody": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/PartnerCreateDto"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/PartnerResponseDto"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"bearer": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cookie": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"api_key": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Partners"
|
||||||
|
],
|
||||||
|
"x-immich-permission": "partner.create",
|
||||||
|
"description": "This endpoint requires the `partner.create` permission."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/partners/{id}": {
|
"/partners/{id}": {
|
||||||
@ -5033,7 +5075,9 @@
|
|||||||
"description": "This endpoint requires the `partner.delete` permission."
|
"description": "This endpoint requires the `partner.delete` permission."
|
||||||
},
|
},
|
||||||
"post": {
|
"post": {
|
||||||
"operationId": "createPartner",
|
"deprecated": true,
|
||||||
|
"description": "This property was deprecated in v1.141.0. This endpoint requires the `partner.create` permission.",
|
||||||
|
"operationId": "createPartnerDeprecated",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
@ -5069,10 +5113,13 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Partners"
|
"Partners",
|
||||||
|
"Deprecated"
|
||||||
],
|
],
|
||||||
"x-immich-permission": "partner.create",
|
"x-immich-lifecycle": {
|
||||||
"description": "This endpoint requires the `partner.create` permission."
|
"deprecatedAt": "v1.141.0"
|
||||||
|
},
|
||||||
|
"x-immich-permission": "partner.create"
|
||||||
},
|
},
|
||||||
"put": {
|
"put": {
|
||||||
"operationId": "updatePartner",
|
"operationId": "updatePartner",
|
||||||
@ -5091,7 +5138,7 @@
|
|||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/UpdatePartnerDto"
|
"$ref": "#/components/schemas/PartnerUpdateDto"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -12853,6 +12900,18 @@
|
|||||||
],
|
],
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
|
"PartnerCreateDto": {
|
||||||
|
"properties": {
|
||||||
|
"sharedWithId": {
|
||||||
|
"format": "uuid",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"sharedWithId"
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
"PartnerDirection": {
|
"PartnerDirection": {
|
||||||
"enum": [
|
"enum": [
|
||||||
"shared-by",
|
"shared-by",
|
||||||
@ -12899,6 +12958,17 @@
|
|||||||
],
|
],
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
|
"PartnerUpdateDto": {
|
||||||
|
"properties": {
|
||||||
|
"inTimeline": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"inTimeline"
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
"PeopleResponse": {
|
"PeopleResponse": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"enabled": {
|
"enabled": {
|
||||||
@ -17241,17 +17311,6 @@
|
|||||||
},
|
},
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
"UpdatePartnerDto": {
|
|
||||||
"properties": {
|
|
||||||
"inTimeline": {
|
|
||||||
"type": "boolean"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"inTimeline"
|
|
||||||
],
|
|
||||||
"type": "object"
|
|
||||||
},
|
|
||||||
"UsageByUserDto": {
|
"UsageByUserDto": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"photos": {
|
"photos": {
|
||||||
|
|||||||
@ -811,7 +811,10 @@ export type PartnerResponseDto = {
|
|||||||
profileChangedAt: string;
|
profileChangedAt: string;
|
||||||
profileImagePath: string;
|
profileImagePath: string;
|
||||||
};
|
};
|
||||||
export type UpdatePartnerDto = {
|
export type PartnerCreateDto = {
|
||||||
|
sharedWithId: string;
|
||||||
|
};
|
||||||
|
export type PartnerUpdateDto = {
|
||||||
inTimeline: boolean;
|
inTimeline: boolean;
|
||||||
};
|
};
|
||||||
export type PeopleResponseDto = {
|
export type PeopleResponseDto = {
|
||||||
@ -3122,6 +3125,21 @@ export function getPartners({ direction }: {
|
|||||||
...opts
|
...opts
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* This endpoint requires the `partner.create` permission.
|
||||||
|
*/
|
||||||
|
export function createPartner({ partnerCreateDto }: {
|
||||||
|
partnerCreateDto: PartnerCreateDto;
|
||||||
|
}, opts?: Oazapfts.RequestOpts) {
|
||||||
|
return oazapfts.ok(oazapfts.fetchJson<{
|
||||||
|
status: 201;
|
||||||
|
data: PartnerResponseDto;
|
||||||
|
}>("/partners", oazapfts.json({
|
||||||
|
...opts,
|
||||||
|
method: "POST",
|
||||||
|
body: partnerCreateDto
|
||||||
|
})));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* This endpoint requires the `partner.delete` permission.
|
* This endpoint requires the `partner.delete` permission.
|
||||||
*/
|
*/
|
||||||
@ -3134,9 +3152,9 @@ export function removePartner({ id }: {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* This endpoint requires the `partner.create` permission.
|
* This property was deprecated in v1.141.0. This endpoint requires the `partner.create` permission.
|
||||||
*/
|
*/
|
||||||
export function createPartner({ id }: {
|
export function createPartnerDeprecated({ id }: {
|
||||||
id: string;
|
id: string;
|
||||||
}, opts?: Oazapfts.RequestOpts) {
|
}, opts?: Oazapfts.RequestOpts) {
|
||||||
return oazapfts.ok(oazapfts.fetchJson<{
|
return oazapfts.ok(oazapfts.fetchJson<{
|
||||||
@ -3150,9 +3168,9 @@ export function createPartner({ id }: {
|
|||||||
/**
|
/**
|
||||||
* This endpoint requires the `partner.update` permission.
|
* This endpoint requires the `partner.update` permission.
|
||||||
*/
|
*/
|
||||||
export function updatePartner({ id, updatePartnerDto }: {
|
export function updatePartner({ id, partnerUpdateDto }: {
|
||||||
id: string;
|
id: string;
|
||||||
updatePartnerDto: UpdatePartnerDto;
|
partnerUpdateDto: PartnerUpdateDto;
|
||||||
}, opts?: Oazapfts.RequestOpts) {
|
}, opts?: Oazapfts.RequestOpts) {
|
||||||
return oazapfts.ok(oazapfts.fetchJson<{
|
return oazapfts.ok(oazapfts.fetchJson<{
|
||||||
status: 200;
|
status: 200;
|
||||||
@ -3160,7 +3178,7 @@ export function updatePartner({ id, updatePartnerDto }: {
|
|||||||
}>(`/partners/${encodeURIComponent(id)}`, oazapfts.json({
|
}>(`/partners/${encodeURIComponent(id)}`, oazapfts.json({
|
||||||
...opts,
|
...opts,
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
body: updatePartnerDto
|
body: partnerUpdateDto
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -191,7 +191,7 @@ export const defaults = Object.freeze<SystemConfig>({
|
|||||||
targetVideoCodec: VideoCodec.H264,
|
targetVideoCodec: VideoCodec.H264,
|
||||||
acceptedVideoCodecs: [VideoCodec.H264],
|
acceptedVideoCodecs: [VideoCodec.H264],
|
||||||
targetAudioCodec: AudioCodec.Aac,
|
targetAudioCodec: AudioCodec.Aac,
|
||||||
acceptedAudioCodecs: [AudioCodec.Aac, AudioCodec.Mp3, AudioCodec.LibOpus, AudioCodec.PcmS16le],
|
acceptedAudioCodecs: [AudioCodec.Aac, AudioCodec.Mp3, AudioCodec.LibOpus],
|
||||||
acceptedContainers: [VideoContainer.Mov, VideoContainer.Ogg, VideoContainer.Webm],
|
acceptedContainers: [VideoContainer.Mov, VideoContainer.Ogg, VideoContainer.Webm],
|
||||||
targetResolution: '720',
|
targetResolution: '720',
|
||||||
maxBitrate: '0',
|
maxBitrate: '0',
|
||||||
|
|||||||
101
server/src/controllers/partner.controller.spec.ts
Normal file
101
server/src/controllers/partner.controller.spec.ts
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
import { PartnerController } from 'src/controllers/partner.controller';
|
||||||
|
import { LoggingRepository } from 'src/repositories/logging.repository';
|
||||||
|
import { PartnerService } from 'src/services/partner.service';
|
||||||
|
import request from 'supertest';
|
||||||
|
import { errorDto } from 'test/medium/responses';
|
||||||
|
import { factory } from 'test/small.factory';
|
||||||
|
import { automock, ControllerContext, controllerSetup, mockBaseService } from 'test/utils';
|
||||||
|
|
||||||
|
describe(PartnerController.name, () => {
|
||||||
|
let ctx: ControllerContext;
|
||||||
|
const service = mockBaseService(PartnerService);
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
ctx = await controllerSetup(PartnerController, [
|
||||||
|
{ provide: PartnerService, useValue: service },
|
||||||
|
{ provide: LoggingRepository, useValue: automock(LoggingRepository, { strict: false }) },
|
||||||
|
]);
|
||||||
|
return () => ctx.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
service.resetAllMocks();
|
||||||
|
ctx.reset();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('GET /partners', () => {
|
||||||
|
it('should be an authenticated route', async () => {
|
||||||
|
await request(ctx.getHttpServer()).get('/partners');
|
||||||
|
expect(ctx.authenticate).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should require a direction`, async () => {
|
||||||
|
const { status, body } = await request(ctx.getHttpServer()).get(`/partners`).set('Authorization', `Bearer token`);
|
||||||
|
expect(status).toBe(400);
|
||||||
|
expect(body).toEqual(
|
||||||
|
errorDto.badRequest([
|
||||||
|
'direction should not be empty',
|
||||||
|
expect.stringContaining('direction must be one of the following values:'),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should require direction to be an enum`, async () => {
|
||||||
|
const { status, body } = await request(ctx.getHttpServer())
|
||||||
|
.get(`/partners`)
|
||||||
|
.query({ direction: 'invalid' })
|
||||||
|
.set('Authorization', `Bearer token`);
|
||||||
|
expect(status).toBe(400);
|
||||||
|
expect(body).toEqual(
|
||||||
|
errorDto.badRequest([expect.stringContaining('direction must be one of the following values:')]),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('POST /partners', () => {
|
||||||
|
it('should be an authenticated route', async () => {
|
||||||
|
await request(ctx.getHttpServer()).post('/partners');
|
||||||
|
expect(ctx.authenticate).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should require sharedWithId to be a uuid`, async () => {
|
||||||
|
const { status, body } = await request(ctx.getHttpServer())
|
||||||
|
.post(`/partners`)
|
||||||
|
.send({ sharedWithId: 'invalid' })
|
||||||
|
.set('Authorization', `Bearer token`);
|
||||||
|
expect(status).toBe(400);
|
||||||
|
expect(body).toEqual(errorDto.badRequest([expect.stringContaining('must be a UUID')]));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('PUT /partners/:id', () => {
|
||||||
|
it('should be an authenticated route', async () => {
|
||||||
|
await request(ctx.getHttpServer()).put(`/partners/${factory.uuid()}`);
|
||||||
|
expect(ctx.authenticate).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should require id to be a uuid`, async () => {
|
||||||
|
const { status, body } = await request(ctx.getHttpServer())
|
||||||
|
.put(`/partners/invalid`)
|
||||||
|
.send({ inTimeline: true })
|
||||||
|
.set('Authorization', `Bearer token`);
|
||||||
|
expect(status).toBe(400);
|
||||||
|
expect(body).toEqual(errorDto.badRequest([expect.stringContaining('must be a UUID')]));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('DELETE /partners/:id', () => {
|
||||||
|
it('should be an authenticated route', async () => {
|
||||||
|
await request(ctx.getHttpServer()).delete(`/partners/${factory.uuid()}`);
|
||||||
|
expect(ctx.authenticate).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should require id to be a uuid`, async () => {
|
||||||
|
const { status, body } = await request(ctx.getHttpServer())
|
||||||
|
.delete(`/partners/invalid`)
|
||||||
|
.set('Authorization', `Bearer token`);
|
||||||
|
expect(status).toBe(400);
|
||||||
|
expect(body).toEqual(errorDto.badRequest([expect.stringContaining('must be a UUID')]));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -1,7 +1,8 @@
|
|||||||
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put, Query } from '@nestjs/common';
|
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put, Query } from '@nestjs/common';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
|
import { EndpointLifecycle } from 'src/decorators';
|
||||||
import { AuthDto } from 'src/dtos/auth.dto';
|
import { AuthDto } from 'src/dtos/auth.dto';
|
||||||
import { PartnerResponseDto, PartnerSearchDto, UpdatePartnerDto } from 'src/dtos/partner.dto';
|
import { PartnerCreateDto, PartnerResponseDto, PartnerSearchDto, PartnerUpdateDto } from 'src/dtos/partner.dto';
|
||||||
import { Permission } from 'src/enum';
|
import { Permission } from 'src/enum';
|
||||||
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
||||||
import { PartnerService } from 'src/services/partner.service';
|
import { PartnerService } from 'src/services/partner.service';
|
||||||
@ -18,10 +19,17 @@ export class PartnerController {
|
|||||||
return this.service.search(auth, dto);
|
return this.service.search(auth, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post(':id')
|
@Post()
|
||||||
@Authenticated({ permission: Permission.PartnerCreate })
|
@Authenticated({ permission: Permission.PartnerCreate })
|
||||||
createPartner(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<PartnerResponseDto> {
|
createPartner(@Auth() auth: AuthDto, @Body() dto: PartnerCreateDto): Promise<PartnerResponseDto> {
|
||||||
return this.service.create(auth, id);
|
return this.service.create(auth, dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post(':id')
|
||||||
|
@EndpointLifecycle({ deprecatedAt: 'v1.141.0' })
|
||||||
|
@Authenticated({ permission: Permission.PartnerCreate })
|
||||||
|
createPartnerDeprecated(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<PartnerResponseDto> {
|
||||||
|
return this.service.create(auth, { sharedWithId: id });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put(':id')
|
@Put(':id')
|
||||||
@ -29,7 +37,7 @@ export class PartnerController {
|
|||||||
updatePartner(
|
updatePartner(
|
||||||
@Auth() auth: AuthDto,
|
@Auth() auth: AuthDto,
|
||||||
@Param() { id }: UUIDParamDto,
|
@Param() { id }: UUIDParamDto,
|
||||||
@Body() dto: UpdatePartnerDto,
|
@Body() dto: PartnerUpdateDto,
|
||||||
): Promise<PartnerResponseDto> {
|
): Promise<PartnerResponseDto> {
|
||||||
return this.service.update(auth, id, dto);
|
return this.service.update(auth, id, dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,14 @@
|
|||||||
import { IsNotEmpty } from 'class-validator';
|
import { IsNotEmpty } from 'class-validator';
|
||||||
import { UserResponseDto } from 'src/dtos/user.dto';
|
import { UserResponseDto } from 'src/dtos/user.dto';
|
||||||
import { PartnerDirection } from 'src/repositories/partner.repository';
|
import { PartnerDirection } from 'src/repositories/partner.repository';
|
||||||
import { ValidateEnum } from 'src/validation';
|
import { ValidateEnum, ValidateUUID } from 'src/validation';
|
||||||
|
|
||||||
export class UpdatePartnerDto {
|
export class PartnerCreateDto {
|
||||||
|
@ValidateUUID()
|
||||||
|
sharedWithId!: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PartnerUpdateDto {
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
inTimeline!: boolean;
|
inTimeline!: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -591,6 +591,7 @@ from
|
|||||||
where
|
where
|
||||||
"user"."updateId" < $1
|
"user"."updateId" < $1
|
||||||
and "user"."updateId" > $2
|
and "user"."updateId" > $2
|
||||||
|
and "id" = $3
|
||||||
order by
|
order by
|
||||||
"user"."updateId" asc
|
"user"."updateId" asc
|
||||||
|
|
||||||
|
|||||||
@ -412,6 +412,7 @@ class AuthUserSync extends BaseSync {
|
|||||||
return this.upsertQuery('user', options)
|
return this.upsertQuery('user', options)
|
||||||
.select(columns.syncUser)
|
.select(columns.syncUser)
|
||||||
.select(['isAdmin', 'pinCode', 'oauthId', 'storageLabel', 'quotaSizeInBytes', 'quotaUsageInBytes'])
|
.select(['isAdmin', 'pinCode', 'oauthId', 'storageLabel', 'quotaSizeInBytes', 'quotaUsageInBytes'])
|
||||||
|
.where('id', '=', options.userId)
|
||||||
.stream();
|
.stream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,7 +118,7 @@ export class BackupService extends BaseService {
|
|||||||
{
|
{
|
||||||
env: {
|
env: {
|
||||||
PATH: process.env.PATH,
|
PATH: process.env.PATH,
|
||||||
PGPASSWORD: isUrlConnection ? undefined : config.password,
|
PGPASSWORD: isUrlConnection ? new URL(config.url).password : config.password,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@ -53,7 +53,7 @@ describe(PartnerService.name, () => {
|
|||||||
mocks.partner.get.mockResolvedValue(void 0);
|
mocks.partner.get.mockResolvedValue(void 0);
|
||||||
mocks.partner.create.mockResolvedValue(partner);
|
mocks.partner.create.mockResolvedValue(partner);
|
||||||
|
|
||||||
await expect(sut.create(auth, user2.id)).resolves.toBeDefined();
|
await expect(sut.create(auth, { sharedWithId: user2.id })).resolves.toBeDefined();
|
||||||
|
|
||||||
expect(mocks.partner.create).toHaveBeenCalledWith({
|
expect(mocks.partner.create).toHaveBeenCalledWith({
|
||||||
sharedById: partner.sharedById,
|
sharedById: partner.sharedById,
|
||||||
@ -69,7 +69,7 @@ describe(PartnerService.name, () => {
|
|||||||
|
|
||||||
mocks.partner.get.mockResolvedValue(partner);
|
mocks.partner.get.mockResolvedValue(partner);
|
||||||
|
|
||||||
await expect(sut.create(auth, user2.id)).rejects.toBeInstanceOf(BadRequestException);
|
await expect(sut.create(auth, { sharedWithId: user2.id })).rejects.toBeInstanceOf(BadRequestException);
|
||||||
|
|
||||||
expect(mocks.partner.create).not.toHaveBeenCalled();
|
expect(mocks.partner.create).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { BadRequestException, Injectable } from '@nestjs/common';
|
import { BadRequestException, Injectable } from '@nestjs/common';
|
||||||
import { Partner } from 'src/database';
|
import { Partner } from 'src/database';
|
||||||
import { AuthDto } from 'src/dtos/auth.dto';
|
import { AuthDto } from 'src/dtos/auth.dto';
|
||||||
import { PartnerResponseDto, PartnerSearchDto, UpdatePartnerDto } from 'src/dtos/partner.dto';
|
import { PartnerCreateDto, PartnerResponseDto, PartnerSearchDto, PartnerUpdateDto } from 'src/dtos/partner.dto';
|
||||||
import { mapUser } from 'src/dtos/user.dto';
|
import { mapUser } from 'src/dtos/user.dto';
|
||||||
import { Permission } from 'src/enum';
|
import { Permission } from 'src/enum';
|
||||||
import { PartnerDirection, PartnerIds } from 'src/repositories/partner.repository';
|
import { PartnerDirection, PartnerIds } from 'src/repositories/partner.repository';
|
||||||
@ -9,7 +9,7 @@ import { BaseService } from 'src/services/base.service';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PartnerService extends BaseService {
|
export class PartnerService extends BaseService {
|
||||||
async create(auth: AuthDto, sharedWithId: string): Promise<PartnerResponseDto> {
|
async create(auth: AuthDto, { sharedWithId }: PartnerCreateDto): Promise<PartnerResponseDto> {
|
||||||
const partnerId: PartnerIds = { sharedById: auth.user.id, sharedWithId };
|
const partnerId: PartnerIds = { sharedById: auth.user.id, sharedWithId };
|
||||||
const exists = await this.partnerRepository.get(partnerId);
|
const exists = await this.partnerRepository.get(partnerId);
|
||||||
if (exists) {
|
if (exists) {
|
||||||
@ -39,7 +39,7 @@ export class PartnerService extends BaseService {
|
|||||||
.map((partner) => this.mapPartner(partner, direction));
|
.map((partner) => this.mapPartner(partner, direction));
|
||||||
}
|
}
|
||||||
|
|
||||||
async update(auth: AuthDto, sharedById: string, dto: UpdatePartnerDto): Promise<PartnerResponseDto> {
|
async update(auth: AuthDto, sharedById: string, dto: PartnerUpdateDto): Promise<PartnerResponseDto> {
|
||||||
await this.requireAccess({ auth, permission: Permission.PartnerUpdate, ids: [sharedById] });
|
await this.requireAccess({ auth, permission: Permission.PartnerUpdate, ids: [sharedById] });
|
||||||
const partnerId: PartnerIds = { sharedById, sharedWithId: auth.user.id };
|
const partnerId: PartnerIds = { sharedById, sharedWithId: auth.user.id };
|
||||||
|
|
||||||
|
|||||||
@ -52,7 +52,7 @@ const updatedConfig = Object.freeze<SystemConfig>({
|
|||||||
threads: 0,
|
threads: 0,
|
||||||
preset: 'ultrafast',
|
preset: 'ultrafast',
|
||||||
targetAudioCodec: AudioCodec.Aac,
|
targetAudioCodec: AudioCodec.Aac,
|
||||||
acceptedAudioCodecs: [AudioCodec.Aac, AudioCodec.Mp3, AudioCodec.LibOpus, AudioCodec.PcmS16le],
|
acceptedAudioCodecs: [AudioCodec.Aac, AudioCodec.Mp3, AudioCodec.LibOpus],
|
||||||
targetResolution: '720',
|
targetResolution: '720',
|
||||||
targetVideoCodec: VideoCodec.H264,
|
targetVideoCodec: VideoCodec.H264,
|
||||||
acceptedVideoCodecs: [VideoCodec.H264],
|
acceptedVideoCodecs: [VideoCodec.H264],
|
||||||
|
|||||||
@ -84,4 +84,23 @@ describe(SyncEntityType.AuthUserV1, () => {
|
|||||||
expect.objectContaining({ type: SyncEntityType.SyncCompleteV1 }),
|
expect.objectContaining({ type: SyncEntityType.SyncCompleteV1 }),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should only sync the auth user', async () => {
|
||||||
|
const { auth, user, ctx } = await setup(await getKyselyDB());
|
||||||
|
|
||||||
|
await ctx.newUser();
|
||||||
|
|
||||||
|
const response = await ctx.syncStream(auth, [SyncRequestType.AuthUsersV1]);
|
||||||
|
expect(response).toEqual([
|
||||||
|
{
|
||||||
|
ack: expect.any(String),
|
||||||
|
data: expect.objectContaining({
|
||||||
|
id: user.id,
|
||||||
|
isAdmin: false,
|
||||||
|
}),
|
||||||
|
type: 'AuthUserV1',
|
||||||
|
},
|
||||||
|
expect.objectContaining({ type: SyncEntityType.SyncCompleteV1 }),
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -104,7 +104,7 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
for (const user of users) {
|
for (const user of users) {
|
||||||
await createPartner({ id: user.id });
|
await createPartner({ partnerCreateDto: { sharedWithId: user.id } });
|
||||||
}
|
}
|
||||||
|
|
||||||
await refreshPartners();
|
await refreshPartners();
|
||||||
@ -115,7 +115,7 @@
|
|||||||
|
|
||||||
const handleShowOnTimelineChanged = async (partner: PartnerSharing, inTimeline: boolean) => {
|
const handleShowOnTimelineChanged = async (partner: PartnerSharing, inTimeline: boolean) => {
|
||||||
try {
|
try {
|
||||||
await updatePartner({ id: partner.user.id, updatePartnerDto: { inTimeline } });
|
await updatePartner({ id: partner.user.id, partnerUpdateDto: { inTimeline } });
|
||||||
|
|
||||||
partner.inTimeline = inTimeline;
|
partner.inTimeline = inTimeline;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user