High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
refactor(server): move timeline operations to their own controller/service (#8325)
Daniel Dietzlerb8c5363a1566
diff --git a/e2e/src/api/specs/asset.e2e-spec.ts b/e2e/src/api/specs/asset.e2e-spec.tsindex a13bb58eb1..ddc8dd3ef6 100644--- a/e2e/src/api/specs/asset.e2e-spec.ts+++ b/e2e/src/api/specs/asset.e2e-spec.ts@@ -5,7 +5,6 @@ import {LibraryResponseDto,LoginResponseDto,SharedLinkType,- TimeBucketSize,getAllLibraries,getAssetInfo,updateAssets,@@ -942,146 +941,6 @@ describe('/asset', () => {});});- describe('GET /asset/time-buckets', () => {- it('should require authentication', async () => {- const { status, body } = await request(app).get('/asset/time-buckets').query({ size: TimeBucketSize.Month });- expect(status).toBe(401);- expect(body).toEqual(errorDto.unauthorized);- });-- it('should get time buckets by month', async () => {- const { status, body } = await request(app)- .get('/asset/time-buckets')- .set('Authorization', `Bearer ${timeBucketUser.accessToken}`)- .query({ size: TimeBucketSize.Month });-- expect(status).toBe(200);- expect(body).toEqual(- expect.arrayContaining([- { count: 3, timeBucket: '1970-02-01T00:00:00.000Z' },- { count: 1, timeBucket: '1970-01-01T00:00:00.000Z' },- ]),- );- });-- it('should not allow access for unrelated shared links', async () => {- const sharedLink = await utils.createSharedLink(user1.accessToken, {- type: SharedLinkType.Individual,- assetIds: user1Assets.map(({ id }) => id),- });-- const { status, body } = await request(app)- .get('/asset/time-buckets')- .query({ key: sharedLink.key, size: TimeBucketSize.Month });-- expect(status).toBe(400);- expect(body).toEqual(errorDto.noPermission);- });-- it('should get time buckets by day', async () => {- const { status, body } = await request(app)- .get('/asset/time-buckets')- .set('Authorization', `Bearer ${timeBucketUser.accessToken}`)- .query({ size: TimeBucketSize.Day });-- expect(status).toBe(200);- expect(body).toEqual([- { count: 2, timeBucket: '1970-02-11T00:00:00.000Z' },- { count: 1, timeBucket: '1970-02-10T00:00:00.000Z' },- { count: 1, timeBucket: '1970-01-01T00:00:00.000Z' },- ]);- });- });-- describe('GET /asset/time-bucket', () => {- it('should require authentication', async () => {- const { status, body } = await request(app).get('/asset/time-bucket').query({- size: TimeBucketSize.Month,- timeBucket: '1900-01-01T00:00:00.000Z',- });-- expect(status).toBe(401);- expect(body).toEqual(errorDto.unauthorized);- });-- it('should handle 5 digit years', async () => {- const { status, body } = await request(app)- .get('/asset/time-bucket')- .query({ size: TimeBucketSize.Month, timeBucket: '+012345-01-01T00:00:00.000Z' })- .set('Authorization', `Bearer ${timeBucketUser.accessToken}`);-- expect(status).toBe(200);- expect(body).toEqual([]);- });-- // TODO enable date string validation while still accepting 5 digit years- // it('should fail if time bucket is invalid', async () => {- // const { status, body } = await request(app)- // .get('/asset/time-bucket')- // .set('Authorization', `Bearer ${user1.accessToken}`)- // .query({ size: TimeBucketSize.Month, timeBucket: 'foo' });-- // expect(status).toBe(400);- // expect(body).toEqual(errorDto.badRequest);- // });-- it('should return time bucket', async () => {- const { status, body } = await request(app)- .get('/asset/time-bucket')- .set('Authorization', `Bearer ${timeBucketUser.accessToken}`)- .query({ size: TimeBucketSize.Month, timeBucket: '1970-02-10T00:00:00.000Z' });-- expect(status).toBe(200);- expect(body).toEqual([]);- });-- it('should return error if time bucket is requested with partners asset and archived', async () => {- const req1 = await request(app)- .get('/asset/time-buckets')- .set('Authorization', `Bearer ${timeBucketUser.accessToken}`)- .query({ size: TimeBucketSize.Month, withPartners: true, isArchived: true });-- expect(req1.status).toBe(400);- expect(req1.body).toEqual(errorDto.badRequest());-- const req2 = await request(app)- .get('/asset/time-buckets')- .set('Authorization', `Bearer ${user1.accessToken}`)- .query({ size: TimeBucketSize.Month, withPartners: true, isArchived: undefined });-- expect(req2.status).toBe(400);- expect(req2.body).toEqual(errorDto.badRequest());- });-- it('should return error if time bucket is requested with partners asset and favorite', async () => {- const req1 = await request(app)- .get('/asset/time-buckets')- .set('Authorization', `Bearer ${timeBucketUser.accessToken}`)- .query({ size: TimeBucketSize.Month, withPartners: true, isFavorite: true });-- expect(req1.status).toBe(400);- expect(req1.body).toEqual(errorDto.badRequest());-- const req2 = await request(app)- .get('/asset/time-buckets')- .set('Authorization', `Bearer ${timeBucketUser.accessToken}`)- .query({ size: TimeBucketSize.Month, withPartners: true, isFavorite: false });-- expect(req2.status).toBe(400);- expect(req2.body).toEqual(errorDto.badRequest());- });-- it('should return error if time bucket is requested with partners asset and trash', async () => {- const req = await request(app)- .get('/asset/time-buckets')- .set('Authorization', `Bearer ${user1.accessToken}`)- .query({ size: TimeBucketSize.Month, withPartners: true, isTrashed: true });-- expect(req.status).toBe(400);- expect(req.body).toEqual(errorDto.badRequest());- });- });-describe('GET /asset', () => {it('should return stack data', async () => {const { status, body } = await request(app).get('/asset').set('Authorization', `Bearer ${stackUser.accessToken}`);diff --git a/e2e/src/api/specs/timeline.e2e-spec.ts b/e2e/src/api/specs/timeline.e2e-spec.tsnew file mode 100644index 0000000000..84daa19f44--- /dev/null+++ b/e2e/src/api/specs/timeline.e2e-spec.ts@@ -0,0 +1,193 @@+import { AssetFileUploadResponseDto, LoginResponseDto, SharedLinkType, TimeBucketSize } from '@immich/sdk';+import { DateTime } from 'luxon';+import { createUserDto } from 'src/fixtures';+import { errorDto } from 'src/responses';+import { app, utils } from 'src/utils';+import request from 'supertest';+import { beforeAll, describe, expect, it } from 'vitest';++// TODO this should probably be a test util function+const today = DateTime.fromObject({+ year: 2023,+ month: 11,+ day: 3,+}) as DateTime<true>;+const yesterday = today.minus({ days: 1 });++describe('/timeline', () => {+ let admin: LoginResponseDto;+ let user: LoginResponseDto;+ let timeBucketUser: LoginResponseDto;++ let userAssets: AssetFileUploadResponseDto[];++ beforeAll(async () => {+ await utils.resetDatabase();+ admin = await utils.adminSetup({ onboarding: false });+ [user, timeBucketUser] = await Promise.all([+ utils.userSetup(admin.accessToken, createUserDto.create('1')),+ utils.userSetup(admin.accessToken, createUserDto.create('time-bucket')),+ ]);++ userAssets = await Promise.all([+ utils.createAsset(user.accessToken),+ utils.createAsset(user.accessToken),+ utils.createAsset(user.accessToken, {+ isFavorite: true,+ isReadOnly: true,+ fileCreatedAt: yesterday.toISO(),+ fileModifiedAt: yesterday.toISO(),+ assetData: { filename: 'example.mp4' },+ }),+ utils.createAsset(user.accessToken),+ utils.createAsset(user.accessToken),+ ]);++ await Promise.all([+ utils.createAsset(timeBucketUser.accessToken, { fileCreatedAt: new Date('1970-01-01').toISOString() }),+ utils.createAsset(timeBucketUser.accessToken, { fileCreatedAt: new Date('1970-02-10').toISOString() }),+ utils.createAsset(timeBucketUser.accessToken, { fileCreatedAt: new Date('1970-02-11').toISOString() }),+ utils.createAsset(timeBucketUser.accessToken, { fileCreatedAt: new Date('1970-02-11').toISOString() }),+ ]);+ });++ describe('GET /timeline/buckets', () => {+ it('should require authentication', async () => {+ const { status, body } = await request(app).get('/timeline/buckets').query({ size: TimeBucketSize.Month });+ expect(status).toBe(401);+ expect(body).toEqual(errorDto.unauthorized);+ });++ it('should get time buckets by month', async () => {+ const { status, body } = await request(app)+ .get('/timeline/buckets')+ .set('Authorization', `Bearer ${timeBucketUser.accessToken}`)+ .query({ size: TimeBucketSize.Month });++ expect(status).toBe(200);+ expect(body).toEqual(+ expect.arrayContaining([+ { count: 3, timeBucket: '1970-02-01T00:00:00.000Z' },+ { count: 1, timeBucket: '1970-01-01T00:00:00.000Z' },+ ]),+ );+ });++ it('should not allow access for unrelated shared links', async () => {+ const sharedLink = await utils.createSharedLink(user.accessToken, {+ type: SharedLinkType.Individual,+ assetIds: userAssets.map(({ id }) => id),+ });++ const { status, body } = await request(app)+ .get('/timeline/buckets')+ .query({ key: sharedLink.key, size: TimeBucketSize.Month });++ expect(status).toBe(400);+ expect(body).toEqual(errorDto.noPermission);+ });++ it('should get time buckets by day', async () => {+ const { status, body } = await request(app)+ .get('/timeline/buckets')+ .set('Authorization', `Bearer ${timeBucketUser.accessToken}`)+ .query({ size: TimeBucketSize.Day });++ expect(status).toBe(200);+ expect(body).toEqual([+ { count: 2, timeBucket: '1970-02-11T00:00:00.000Z' },+ { count: 1, timeBucket: '1970-02-10T00:00:00.000Z' },+ { count: 1, timeBucket: '1970-01-01T00:00:00.000Z' },+ ]);+ });++ it('should return error if time bucket is requested with partners asset and archived', async () => {+ const req1 = await request(app)+ .get('/timeline/buckets')+ .set('Authorization', `Bearer ${timeBucketUser.accessToken}`)+ .query({ size: TimeBucketSize.Month, withPartners: true, isArchived: true });++ expect(req1.status).toBe(400);+ expect(req1.body).toEqual(errorDto.badRequest());++ const req2 = await request(app)+ .get('/timeline/buckets')+ .set('Authorization', `Bearer ${user.accessToken}`)+ .query({ size: TimeBucketSize.Month, withPartners: true, isArchived: undefined });++ expect(req2.status).toBe(400);+ expect(req2.body).toEqual(errorDto.badRequest());+ });++ it('should return error if time bucket is requested with partners asset and favorite', async () => {+ const req1 = await request(app)+ .get('/timeline/buckets')+ .set('Authorization', `Bearer ${timeBucketUser.accessToken}`)+ .query({ size: TimeBucketSize.Month, withPartners: true, isFavorite: true });++ expect(req1.status).toBe(400);+ expect(req1.body).toEqual(errorDto.badRequest());++ const req2 = await request(app)+ .get('/timeline/buckets')+ .set('Authorization', `Bearer ${timeBucketUser.accessToken}`)+ .query({ size: TimeBucketSize.Month, withPartners: true, isFavorite: false });++ expect(req2.status).toBe(400);+ expect(req2.body).toEqual(errorDto.badRequest());+ });++ it('should return error if time bucket is requested with partners asset and trash', async () => {+ const req = await request(app)+ .get('/timeline/buckets')+ .set('Authorization', `Bearer ${user.accessToken}`)+ .query({ size: TimeBucketSize.Month, withPartners: true, isTrashed: true });++ expect(req.status).toBe(400);+ expect(req.body).toEqual(errorDto.badRequest());+ });+ });++ describe('GET /timeline/bucket', () => {+ it('should require authentication', async () => {+ const { status, body } = await request(app).get('/timeline/bucket').query({+ size: TimeBucketSize.Month,+ timeBucket: '1900-01-01T00:00:00.000Z',+ });++ expect(status).toBe(401);+ expect(body).toEqual(errorDto.unauthorized);+ });++ it('should handle 5 digit years', async () => {+ const { status, body } = await request(app)+ .get('/timeline/bucket')+ .query({ size: TimeBucketSize.Month, timeBucket: '+012345-01-01T00:00:00.000Z' })+ .set('Authorization', `Bearer ${timeBucketUser.accessToken}`);++ expect(status).toBe(200);+ expect(body).toEqual([]);+ });++ // TODO enable date string validation while still accepting 5 digit years+ // it('should fail if time bucket is invalid', async () => {+ // const { status, body } = await request(app)+ // .get('/timeline/bucket')+ // .set('Authorization', `Bearer ${user.accessToken}`)+ // .query({ size: TimeBucketSize.Month, timeBucket: 'foo' });++ // expect(status).toBe(400);+ // expect(body).toEqual(errorDto.badRequest);+ // });++ it('should return time bucket', async () => {+ const { status, body } = await request(app)+ .get('/timeline/bucket')+ .set('Authorization', `Bearer ${timeBucketUser.accessToken}`)+ .query({ size: TimeBucketSize.Month, timeBucket: '1970-02-10T00:00:00.000Z' });++ expect(status).toBe(200);+ expect(body).toEqual([]);+ });+ });+});diff --git a/mobile/openapi/.openapi-generator/FILES b/mobile/openapi/.openapi-generator/FILESindex ddebdaf77d..9ec77670fb 100644--- a/mobile/openapi/.openapi-generator/FILES+++ b/mobile/openapi/.openapi-generator/FILES@@ -169,6 +169,7 @@ doc/TagTypeEnum.mddoc/ThumbnailFormat.mddoc/TimeBucketResponseDto.mddoc/TimeBucketSize.md+doc/TimelineApi.mddoc/ToneMapping.mddoc/TranscodeHWAccel.mddoc/TranscodePolicy.md@@ -211,6 +212,7 @@ lib/api/server_info_api.dartlib/api/shared_link_api.dartlib/api/system_config_api.dartlib/api/tag_api.dart+lib/api/timeline_api.dartlib/api/trash_api.dartlib/api/user_api.dartlib/api_client.dart@@ -556,6 +558,7 @@ test/tag_type_enum_test.darttest/thumbnail_format_test.darttest/time_bucket_response_dto_test.darttest/time_bucket_size_test.dart+test/timeline_api_test.darttest/tone_mapping_test.darttest/transcode_hw_accel_test.darttest/transcode_policy_test.dartdiff --git a/mobile/openapi/README.md b/mobile/openapi/README.mdindex adb7a80fe7..bfdac06c48 100644--- a/mobile/openapi/README.md+++ b/mobile/openapi/README.md@@ -105,8 +105,6 @@ Class | Method | HTTP request | Description*AssetApi* | [**getMapMarkers**](doc//AssetApi.md#getmapmarkers) | **GET** /asset/map-marker |*AssetApi* | [**getMemoryLane**](doc//AssetApi.md#getmemorylane) | **GET** /asset/memory-lane |*AssetApi* | [**getRandom**](doc//AssetApi.md#getrandom) | **GET** /asset/random |-*AssetApi* | [**getTimeBucket**](doc//AssetApi.md#gettimebucket) | **GET** /asset/time-bucket |-*AssetApi* | [**getTimeBuckets**](doc//AssetApi.md#gettimebuckets) | **GET** /asset/time-buckets |*AssetApi* | [**runAssetJobs**](doc//AssetApi.md#runassetjobs) | **POST** /asset/jobs |*AssetApi* | [**searchAssets**](doc//AssetApi.md#searchassets) | **GET** /assets |*AssetApi* | [**serveFile**](doc//AssetApi.md#servefile) | **GET** /asset/file/{id} |@@ -199,6 +197,8 @@ Class | Method | HTTP request | Description*TagApi* | [**tagAssets**](doc//TagApi.md#tagassets) | **PUT** /tag/{id}/assets |*TagApi* | [**untagAssets**](doc//TagApi.md#untagassets) | **DELETE** /tag/{id}/assets |*TagApi* | [**updateTag**](doc//TagApi.md#updatetag) | **PATCH** /tag/{id} |+*TimelineApi* | [**getTimeBucket**](doc//TimelineApi.md#gettimebucket) | **GET** /timeline/bucket |+*TimelineApi* | [**getTimeBuckets**](doc//TimelineApi.md#gettimebuckets) | **GET** /timeline/buckets |*TrashApi* | [**emptyTrash**](doc//TrashApi.md#emptytrash) | **POST** /trash/empty |*TrashApi* | [**restoreAssets**](doc//TrashApi.md#restoreassets) | **POST** /trash/restore/assets |*TrashApi* | [**restoreTrash**](doc//TrashApi.md#restoretrash) | **POST** /trash/restore |diff --git a/mobile/openapi/doc/AssetApi.md b/mobile/openapi/doc/AssetApi.mdindex 1aaf195f3a..0778485c37 100644--- a/mobile/openapi/doc/AssetApi.md+++ b/mobile/openapi/doc/AssetApi.md@@ -23,8 +23,6 @@ Method | HTTP request | Description[**getMapMarkers**](AssetApi.md#getmapmarkers) | **GET** /asset/map-marker |[**getMemoryLane**](AssetApi.md#getmemorylane) | **GET** /asset/memory-lane |[**getRandom**](AssetApi.md#getrandom) | **GET** /asset/random |-[**getTimeBucket**](AssetApi.md#gettimebucket) | **GET** /asset/time-bucket |-[**getTimeBuckets**](AssetApi.md#gettimebuckets) | **GET** /asset/time-buckets |[**runAssetJobs**](AssetApi.md#runassetjobs) | **POST** /asset/jobs |[**searchAssets**](AssetApi.md#searchassets) | **GET** /assets |[**serveFile**](AssetApi.md#servefile) | **GET** /asset/file/{id} |@@ -833,158 +831,6 @@ Name | Type | Description | Notes[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)-# **getTimeBucket**-> List<AssetResponseDto> getTimeBucket(size, timeBucket, albumId, isArchived, isFavorite, isTrashed, key, order, personId, userId, withPartners, withStacked)----### Example-```dart-import 'package:openapi/api.dart';-// TODO Configure API key authorization: cookie-//defaultApiClient.getAuthentication<ApiKeyAuth>('cookie').apiKey = 'YOUR_API_KEY';-// uncomment below to setup prefix (e.g. Bearer) for API key, if needed-//defaultApiClient.getAuthentication<ApiKeyAuth>('cookie').apiKeyPrefix = 'Bearer';-// TODO Configure API key authorization: api_key-//defaultApiClient.getAuthentication<ApiKeyAuth>('api_key').apiKey = 'YOUR_API_KEY';-// uncomment below to setup prefix (e.g. Bearer) for API key, if needed-//defaultApiClient.getAuthentication<ApiKeyAuth>('api_key').apiKeyPrefix = 'Bearer';-// TODO Configure HTTP Bearer authorization: bearer-// Case 1. Use String Token-//defaultApiClient.getAuthentication<HttpBearerAuth>('bearer').setAccessToken('YOUR_ACCESS_TOKEN');-// Case 2. Use Function which generate token.-// String yourTokenGeneratorFunction() { ... }-//defaultApiClient.getAuthentication<HttpBearerAuth>('bearer').setAccessToken(yourTokenGeneratorFunction);--final api_instance = AssetApi();-final size = ; // TimeBucketSize |-final timeBucket = timeBucket_example; // String |-final albumId = 38400000-8cf0-11bd-b23e-10b96e4ef00d; // String |-final isArchived = true; // bool |-final isFavorite = true; // bool |-final isTrashed = true; // bool |-final key = key_example; // String |-final order = ; // AssetOrder |-final personId = 38400000-8cf0-11bd-b23e-10b96e4ef00d; // String |-final userId = 38400000-8cf0-11bd-b23e-10b96e4ef00d; // String |-final withPartners = true; // bool |-final withStacked = true; // bool |--try {- final result = api_instance.getTimeBucket(size, timeBucket, albumId, isArchived, isFavorite, isTrashed, key, order, personId, userId, withPartners, withStacked);- print(result);-} catch (e) {- print('Exception when calling AssetApi->getTimeBucket: $e\n');-}-```--### Parameters--Name | Type | Description | Notes-------------- | ------------- | ------------- | -------------- **size** | [**TimeBucketSize**](.md)| |- **timeBucket** | **String**| |- **albumId** | **String**| | [optional]- **isArchived** | **bool**| | [optional]- **isFavorite** | **bool**| | [optional]- **isTrashed** | **bool**| | [optional]- **key** | **String**| | [optional]- **order** | [**AssetOrder**](.md)| | [optional]- **personId** | **String**| | [optional]- **userId** | **String**| | [optional]- **withPartners** | **bool**| | [optional]- **withStacked** | **bool**| | [optional]--### Return type--[**List<AssetResponseDto>**](AssetResponseDto.md)--### Authorization--[cookie](../README.md#cookie), [api_key](../README.md#api_key), [bearer](../README.md#bearer)--### HTTP request headers-- - **Content-Type**: Not defined- - **Accept**: application/json--[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)--# **getTimeBuckets**-> List<TimeBucketResponseDto> getTimeBuckets(size, albumId, isArchived, isFavorite, isTrashed, key, order, personId, userId, withPartners, withStacked)----### Example-```dart-import 'package:openapi/api.dart';-// TODO Configure API key authorization: cookie-//defaultApiClient.getAuthentication<ApiKeyAuth>('cookie').apiKey = 'YOUR_API_KEY';-// uncomment below to setup prefix (e.g. Bearer) for API key, if needed-//defaultApiClient.getAuthentication<ApiKeyAuth>('cookie').apiKeyPrefix = 'Bearer';-// TODO Configure API key authorization: api_key-//defaultApiClient.getAuthentication<ApiKeyAuth>('api_key').apiKey = 'YOUR_API_KEY';-// uncomment below to setup prefix (e.g. Bearer) for API key, if needed-//defaultApiClient.getAuthentication<ApiKeyAuth>('api_key').apiKeyPrefix = 'Bearer';-// TODO Configure HTTP Bearer authorization: bearer-// Case 1. Use String Token-//defaultApiClient.getAuthentication<HttpBearerAuth>('bearer').setAccessToken('YOUR_ACCESS_TOKEN');-// Case 2. Use Function which generate token.-// String yourTokenGeneratorFunction() { ... }-//defaultApiClient.getAuthentication<HttpBearerAuth>('bearer').setAccessToken(yourTokenGeneratorFunction);--final api_instance = AssetApi();-final size = ; // TimeBucketSize |-final albumId = 38400000-8cf0-11bd-b23e-10b96e4ef00d; // String |-final isArchived = true; // bool |-final isFavorite = true; // bool |-final isTrashed = true; // bool |-final key = key_example; // String |-final order = ; // AssetOrder |-final personId = 38400000-8cf0-11bd-b23e-10b96e4ef00d; // String |-final userId = 38400000-8cf0-11bd-b23e-10b96e4ef00d; // String |-final withPartners = true; // bool |-final withStacked = true; // bool |--try {- final result = api_instance.getTimeBuckets(size, albumId, isArchived, isFavorite, isTrashed, key, order, personId, userId, withPartners, withStacked);- print(result);-} catch (e) {- print('Exception when calling AssetApi->getTimeBuckets: $e\n');-}-```--### Parameters--Name | Type | Description | Notes-------------- | ------------- | ------------- | -------------- **size** | [**TimeBucketSize**](.md)| |- **albumId** | **String**| | [optional]- **isArchived** | **bool**| | [optional]- **isFavorite** | **bool**| | [optional]- **isTrashed** | **bool**| | [optional]- **key** | **String**| | [optional]- **order** | [**AssetOrder**](.md)| | [optional]- **personId** | **String**| | [optional]- **userId** | **String**| | [optional]- **withPartners** | **bool**| | [optional]- **withStacked** | **bool**| | [optional]--### Return type--[**List<TimeBucketResponseDto>**](TimeBucketResponseDto.md)--### Authorization--[cookie](../README.md#cookie), [api_key](../README.md#api_key), [bearer](../README.md#bearer)--### HTTP request headers-- - **Content-Type**: Not defined- - **Accept**: application/json--[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)-# **runAssetJobs**> runAssetJobs(assetJobsDto)diff --git a/mobile/openapi/doc/TimelineApi.md b/mobile/openapi/doc/TimelineApi.mdnew file mode 100644index 0000000000..e98efe7e23--- /dev/null+++ b/mobile/openapi/doc/TimelineApi.md@@ -0,0 +1,167 @@+# openapi.api.TimelineApi++## Load the API package+```dart+import 'package:openapi/api.dart';+```++All URIs are relative to */api*++Method | HTTP request | Description+------------- | ------------- | -------------+[**getTimeBucket**](TimelineApi.md#gettimebucket) | **GET** /timeline/bucket |+[**getTimeBuckets**](TimelineApi.md#gettimebuckets) | **GET** /timeline/buckets |+++# **getTimeBucket**+> List<AssetResponseDto> getTimeBucket(size, timeBucket, albumId, isArchived, isFavorite, isTrashed, key, order, personId, userId, withPartners, withStacked)++++### Example+```dart+import 'package:openapi/api.dart';+// TODO Configure API key authorization: cookie+//defaultApiClient.getAuthentication<ApiKeyAuth>('cookie').apiKey = 'YOUR_API_KEY';+// uncomment below to setup prefix (e.g. Bearer) for API key, if needed+//defaultApiClient.getAuthentication<ApiKeyAuth>('cookie').apiKeyPrefix = 'Bearer';+// TODO Configure API key authorization: api_key+//defaultApiClient.getAuthentication<ApiKeyAuth>('api_key').apiKey = 'YOUR_API_KEY';+// uncomment below to setup prefix (e.g. Bearer) for API key, if needed+//defaultApiClient.getAuthentication<ApiKeyAuth>('api_key').apiKeyPrefix = 'Bearer';+// TODO Configure HTTP Bearer authorization: bearer+// Case 1. Use String Token+//defaultApiClient.getAuthentication<HttpBearerAuth>('bearer').setAccessToken('YOUR_ACCESS_TOKEN');+// Case 2. Use Function which generate token.+// String yourTokenGeneratorFunction() { ... }+//defaultApiClient.getAuthentication<HttpBearerAuth>('bearer').setAccessToken(yourTokenGeneratorFunction);++final api_instance = TimelineApi();+final size = ; // TimeBucketSize |+final timeBucket = timeBucket_example; // String |+final albumId = 38400000-8cf0-11bd-b23e-10b96e4ef00d; // String |+final isArchived = true; // bool |+final isFavorite = true; // bool |+final isTrashed = true; // bool |+final key = key_example; // String |+final order = ; // AssetOrder |+final personId = 38400000-8cf0-11bd-b23e-10b96e4ef00d; // String |+final userId = 38400000-8cf0-11bd-b23e-10b96e4ef00d; // String |+final withPartners = true; // bool |+final withStacked = true; // bool |++try {+ final result = api_instance.getTimeBucket(size, timeBucket, albumId, isArchived, isFavorite, isTrashed, key, order, personId, userId, withPartners, withStacked);+ print(result);+} catch (e) {+ print('Exception when calling TimelineApi->getTimeBucket: $e\n');+}+```++### Parameters++Name | Type | Description | Notes+------------- | ------------- | ------------- | -------------+ **size** | [**TimeBucketSize**](.md)| |+ **timeBucket** | **String**| |+ **albumId** | **String**| | [optional]+ **isArchived** | **bool**| | [optional]+ **isFavorite** | **bool**| | [optional]+ **isTrashed** | **bool**| | [optional]+ **key** | **String**| | [optional]+ **order** | [**AssetOrder**](.md)| | [optional]+ **personId** | **String**| | [optional]+ **userId** | **String**| | [optional]+ **withPartners** | **bool**| | [optional]+ **withStacked** | **bool**| | [optional]++### Return type++[**List<AssetResponseDto>**](AssetResponseDto.md)++### Authorization++[cookie](../README.md#cookie), [api_key](../README.md#api_key), [bearer](../README.md#bearer)++### HTTP request headers++ - **Content-Type**: Not defined+ - **Accept**: application/json++[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)++# **getTimeBuckets**+> List<TimeBucketResponseDto> getTimeBuckets(size, albumId, isArchived, isFavorite, isTrashed, key, order, personId, userId, withPartners, withStacked)++++### Example+```dart+import 'package:openapi/api.dart';+// TODO Configure API key authorization: cookie+//defaultApiClient.getAuthentication<ApiKeyAuth>('cookie').apiKey = 'YOUR_API_KEY';+// uncomment below to setup prefix (e.g. Bearer) for API key, if needed+//defaultApiClient.getAuthentication<ApiKeyAuth>('cookie').apiKeyPrefix = 'Bearer';+// TODO Configure API key authorization: api_key+//defaultApiClient.getAuthentication<ApiKeyAuth>('api_key').apiKey = 'YOUR_API_KEY';+// uncomment below to setup prefix (e.g. Bearer) for API key, if needed+//defaultApiClient.getAuthentication<ApiKeyAuth>('api_key').apiKeyPrefix = 'Bearer';+// TODO Configure HTTP Bearer authorization: bearer+// Case 1. Use String Token+//defaultApiClient.getAuthentication<HttpBearerAuth>('bearer').setAccessToken('YOUR_ACCESS_TOKEN');+// Case 2. Use Function which generate token.+// String yourTokenGeneratorFunction() { ... }+//defaultApiClient.getAuthentication<HttpBearerAuth>('bearer').setAccessToken(yourTokenGeneratorFunction);++final api_instance = TimelineApi();+final size = ; // TimeBucketSize |+final albumId = 38400000-8cf0-11bd-b23e-10b96e4ef00d; // String |+final isArchived = true; // bool |+final isFavorite = true; // bool |+final isTrashed = true; // bool |+final key = key_example; // String |+final order = ; // AssetOrder |+final personId = 38400000-8cf0-11bd-b23e-10b96e4ef00d; // String |+final userId = 38400000-8cf0-11bd-b23e-10b96e4ef00d; // String |+final withPartners = true; // bool |+final withStacked = true; // bool |++try {+ final result = api_instance.getTimeBuckets(size, albumId, isArchived, isFavorite, isTrashed, key, order, personId, userId, withPartners, withStacked);+ print(result);+} catch (e) {+ print('Exception when calling TimelineApi->getTimeBuckets: $e\n');+}+```++### Parameters++Name | Type | Description | Notes+------------- | ------------- | ------------- | -------------+ **size** | [**TimeBucketSize**](.md)| |+ **albumId** | **String**| | [optional]+ **isArchived** | **bool**| | [optional]+ **isFavorite** | **bool**| | [optional]+ **isTrashed** | **bool**| | [optional]+ **key** | **String**| | [optional]+ **order** | [**AssetOrder**](.md)| | [optional]+ **personId** | **String**| | [optional]+ **userId** | **String**| | [optional]+ **withPartners** | **bool**| | [optional]+ **withStacked** | **bool**| | [optional]++### Return type++[**List<TimeBucketResponseDto>**](TimeBucketResponseDto.md)++### Authorization++[cookie](../README.md#cookie), [api_key](../README.md#api_key), [bearer](../README.md#bearer)++### HTTP request headers++ - **Content-Type**: Not defined+ - **Accept**: application/json++[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)+diff --git a/mobile/openapi/lib/api.dart b/mobile/openapi/lib/api.dartindex 5b49d8d67f..2abc20fde8 100644--- a/mobile/openapi/lib/api.dart+++ b/mobile/openapi/lib/api.dart@@ -47,6 +47,7 @@ part 'api/server_info_api.dart';part 'api/shared_link_api.dart';part 'api/system_config_api.dart';part 'api/tag_api.dart';+part 'api/timeline_api.dart';part 'api/trash_api.dart';part 'api/user_api.dart';diff --git a/mobile/openapi/lib/api/asset_api.dart b/mobile/openapi/lib/api/asset_api.dartindex b0395bfcbe..e16ccc73e5 100644--- a/mobile/openapi/lib/api/asset_api.dart+++ b/mobile/openapi/lib/api/asset_api.dart@@ -835,255 +835,6 @@ class AssetApi {return null;}- /// Performs an HTTP 'GET /asset/time-bucket' operation and returns the [Response].- /// Parameters:- ///- /// * [TimeBucketSize] size (required):- ///- /// * [String] timeBucket (required):- ///- /// * [String] albumId:- ///- /// * [bool] isArchived:- ///- /// * [bool] isFavorite:- ///- /// * [bool] isTrashed:- ///- /// * [String] key:- ///- /// * [AssetOrder] order:- ///- /// * [String] personId:- ///- /// * [String] userId:- ///- /// * [bool] withPartners:- ///- /// * [bool] withStacked:- Future<Response> getTimeBucketWithHttpInfo(TimeBucketSize size, String timeBucket, { String? albumId, bool? isArchived, bool? isFavorite, bool? isTrashed, String? key, AssetOrder? order, String? personId, String? userId, bool? withPartners, bool? withStacked, }) async {- // ignore: prefer_const_declarations- final path = r'/asset/time-bucket';-- // ignore: prefer_final_locals- Object? postBody;-- final queryParams = <QueryParam>[];- final headerParams = <String, String>{};- final formParams = <String, String>{};-- if (albumId != null) {- queryParams.addAll(_queryParams('', 'albumId', albumId));- }- if (isArchived != null) {- queryParams.addAll(_queryParams('', 'isArchived', isArchived));- }- if (isFavorite != null) {- queryParams.addAll(_queryParams('', 'isFavorite', isFavorite));- }- if (isTrashed != null) {- queryParams.addAll(_queryParams('', 'isTrashed', isTrashed));- }- if (key != null) {- queryParams.addAll(_queryParams('', 'key', key));- }- if (order != null) {- queryParams.addAll(_queryParams('', 'order', order));- }- if (personId != null) {- queryParams.addAll(_queryParams('', 'personId', personId));- }- queryParams.addAll(_queryParams('', 'size', size));- queryParams.addAll(_queryParams('', 'timeBucket', timeBucket));- if (userId != null) {- queryParams.addAll(_queryParams('', 'userId', userId));- }- if (withPartners != null) {- queryParams.addAll(_queryParams('', 'withPartners', withPartners));- }- if (withStacked != null) {- queryParams.addAll(_queryParams('', 'withStacked', withStacked));- }-- const contentTypes = <String>[];--- return apiClient.invokeAPI(- path,- 'GET',- queryParams,- postBody,- headerParams,- formParams,- contentTypes.isEmpty ? null : contentTypes.first,- );- }-- /// Parameters:- ///- /// * [TimeBucketSize] size (required):- ///- /// * [String] timeBucket (required):- ///- /// * [String] albumId:- ///- /// * [bool] isArchived:- ///- /// * [bool] isFavorite:- ///- /// * [bool] isTrashed:- ///- /// * [String] key:- ///- /// * [AssetOrder] order:- ///- /// * [String] personId:- ///- /// * [String] userId:- ///- /// * [bool] withPartners:- ///- /// * [bool] withStacked:- Future<List<AssetResponseDto>?> getTimeBucket(TimeBucketSize size, String timeBucket, { String? albumId, bool? isArchived, bool? isFavorite, bool? isTrashed, String? key, AssetOrder? order, String? personId, String? userId, bool? withPartners, bool? withStacked, }) async {- final response = await getTimeBucketWithHttpInfo(size, timeBucket, albumId: albumId, isArchived: isArchived, isFavorite: isFavorite, isTrashed: isTrashed, key: key, order: order, personId: personId, userId: userId, withPartners: withPartners, withStacked: withStacked, );- 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) {- final responseBody = await _decodeBodyBytes(response);- return (await apiClient.deserializeAsync(responseBody, 'List<AssetResponseDto>') as List)- .cast<AssetResponseDto>()- .toList(growable: false);-- }- return null;- }-- /// Performs an HTTP 'GET /asset/time-buckets' operation and returns the [Response].- /// Parameters:- ///- /// * [TimeBucketSize] size (required):- ///- /// * [String] albumId:- ///- /// * [bool] isArchived:- ///- /// * [bool] isFavorite:- ///- /// * [bool] isTrashed:- ///- /// * [String] key:- ///- /// * [AssetOrder] order:- ///- /// * [String] personId:- ///- /// * [String] userId:- ///- /// * [bool] withPartners:- ///- /// * [bool] withStacked:- Future<Response> getTimeBucketsWithHttpInfo(TimeBucketSize size, { String? albumId, bool? isArchived, bool? isFavorite, bool? isTrashed, String? key, AssetOrder? order, String? personId, String? userId, bool? withPartners, bool? withStacked, }) async {- // ignore: prefer_const_declarations- final path = r'/asset/time-buckets';-- // ignore: prefer_final_locals- Object? postBody;-- final queryParams = <QueryParam>[];- final headerParams = <String, String>{};- final formParams = <String, String>{};-- if (albumId != null) {- queryParams.addAll(_queryParams('', 'albumId', albumId));- }- if (isArchived != null) {- queryParams.addAll(_queryParams('', 'isArchived', isArchived));- }- if (isFavorite != null) {- queryParams.addAll(_queryParams('', 'isFavorite', isFavorite));- }- if (isTrashed != null) {- queryParams.addAll(_queryParams('', 'isTrashed', isTrashed));- }- if (key != null) {- queryParams.addAll(_queryParams('', 'key', key));- }- if (order != null) {- queryParams.addAll(_queryParams('', 'order', order));- }- if (personId != null) {- queryParams.addAll(_queryParams('', 'personId', personId));- }- queryParams.addAll(_queryParams('', 'size', size));- if (userId != null) {- queryParams.addAll(_queryParams('', 'userId', userId));- }- if (withPartners != null) {- queryParams.addAll(_queryParams('', 'withPartners', withPartners));- }- if (withStacked != null) {- queryParams.addAll(_queryParams('', 'withStacked', withStacked));- }-- const contentTypes = <String>[];--- return apiClient.invokeAPI(- path,- 'GET',- queryParams,- postBody,- headerParams,- formParams,- contentTypes.isEmpty ? null : contentTypes.first,- );- }-- /// Parameters:- ///- /// * [TimeBucketSize] size (required):- ///- /// * [String] albumId:- ///- /// * [bool] isArchived:- ///- /// * [bool] isFavorite:- ///- /// * [bool] isTrashed:- ///- /// * [String] key:- ///- /// * [AssetOrder] order:- ///- /// * [String] personId:- ///- /// * [String] userId:- ///- /// * [bool] withPartners:- ///- /// * [bool] withStacked:- Future<List<TimeBucketResponseDto>?> getTimeBuckets(TimeBucketSize size, { String? albumId, bool? isArchived, bool? isFavorite, bool? isTrashed, String? key, AssetOrder? order, String? personId, String? userId, bool? withPartners, bool? withStacked, }) async {- final response = await getTimeBucketsWithHttpInfo(size, albumId: albumId, isArchived: isArchived, isFavorite: isFavorite, isTrashed: isTrashed, key: key, order: order, personId: personId, userId: userId, withPartners: withPartners, withStacked: withStacked, );- 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) {- final responseBody = await _decodeBodyBytes(response);- return (await apiClient.deserializeAsync(responseBody, 'List<TimeBucketResponseDto>') as List)- .cast<TimeBucketResponseDto>()- .toList(growable: false);-- }- return null;- }-/// Performs an HTTP 'POST /asset/jobs' operation and returns the [Response]./// Parameters:///diff --git a/mobile/openapi/lib/api/timeline_api.dart b/mobile/openapi/lib/api/timeline_api.dartnew file mode 100644index 0000000000..0813f3e00c--- /dev/null+++ b/mobile/openapi/lib/api/timeline_api.dart@@ -0,0 +1,267 @@+//+// AUTO-GENERATED FILE, DO NOT MODIFY!+//+// @dart=2.12++// 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 TimelineApi {+ TimelineApi([ApiClient? apiClient]) : apiClient = apiClient ?? defaultApiClient;++ final ApiClient apiClient;++ /// Performs an HTTP 'GET /timeline/bucket' operation and returns the [Response].+ /// Parameters:+ ///+ /// * [TimeBucketSize] size (required):+ ///+ /// * [String] timeBucket (required):+ ///+ /// * [String] albumId:+ ///+ /// * [bool] isArchived:+ ///+ /// * [bool] isFavorite:+ ///+ /// * [bool] isTrashed:+ ///+ /// * [String] key:+ ///+ /// * [AssetOrder] order:+ ///+ /// * [String] personId:+ ///+ /// * [String] userId:+ ///+ /// * [bool] withPartners:+ ///+ /// * [bool] withStacked:+ Future<Response> getTimeBucketWithHttpInfo(TimeBucketSize size, String timeBucket, { String? albumId, bool? isArchived, bool? isFavorite, bool? isTrashed, String? key, AssetOrder? order, String? personId, String? userId, bool? withPartners, bool? withStacked, }) async {+ // ignore: prefer_const_declarations+ final path = r'/timeline/bucket';++ // ignore: prefer_final_locals+ Object? postBody;++ final queryParams = <QueryParam>[];+ final headerParams = <String, String>{};+ final formParams = <String, String>{};++ if (albumId != null) {+ queryParams.addAll(_queryParams('', 'albumId', albumId));+ }+ if (isArchived != null) {+ queryParams.addAll(_queryParams('', 'isArchived', isArchived));+ }+ if (isFavorite != null) {+ queryParams.addAll(_queryParams('', 'isFavorite', isFavorite));+ }+ if (isTrashed != null) {+ queryParams.addAll(_queryParams('', 'isTrashed', isTrashed));+ }+ if (key != null) {+ queryParams.addAll(_queryParams('', 'key', key));+ }+ if (order != null) {+ queryParams.addAll(_queryParams('', 'order', order));+ }+ if (personId != null) {+ queryParams.addAll(_queryParams('', 'personId', personId));+ }+ queryParams.addAll(_queryParams('', 'size', size));+ queryParams.addAll(_queryParams('', 'timeBucket', timeBucket));+ if (userId != null) {+ queryParams.addAll(_queryParams('', 'userId', userId));+ }+ if (withPartners != null) {+ queryParams.addAll(_queryParams('', 'withPartners', withPartners));+ }+ if (withStacked != null) {+ queryParams.addAll(_queryParams('', 'withStacked', withStacked));+ }++ const contentTypes = <String>[];+++ return apiClient.invokeAPI(+ path,+ 'GET',+ queryParams,+ postBody,+ headerParams,+ formParams,+ contentTypes.isEmpty ? null : contentTypes.first,+ );+ }++ /// Parameters:+ ///+ /// * [TimeBucketSize] size (required):+ ///+ /// * [String] timeBucket (required):+ ///+ /// * [String] albumId:+ ///+ /// * [bool] isArchived:+ ///+ /// * [bool] isFavorite:+ ///+ /// * [bool] isTrashed:+ ///+ /// * [String] key:+ ///+ /// * [AssetOrder] order:+ ///+ /// * [String] personId:+ ///+ /// * [String] userId:+ ///+ /// * [bool] withPartners:+ ///+ /// * [bool] withStacked:+ Future<List<AssetResponseDto>?> getTimeBucket(TimeBucketSize size, String timeBucket, { String? albumId, bool? isArchived, bool? isFavorite, bool? isTrashed, String? key, AssetOrder? order, String? personId, String? userId, bool? withPartners, bool? withStacked, }) async {+ final response = await getTimeBucketWithHttpInfo(size, timeBucket, albumId: albumId, isArchived: isArchived, isFavorite: isFavorite, isTrashed: isTrashed, key: key, order: order, personId: personId, userId: userId, withPartners: withPartners, withStacked: withStacked, );+ 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) {+ final responseBody = await _decodeBodyBytes(response);+ return (await apiClient.deserializeAsync(responseBody, 'List<AssetResponseDto>') as List)+ .cast<AssetResponseDto>()+ .toList(growable: false);++ }+ return null;+ }++ /// Performs an HTTP 'GET /timeline/buckets' operation and returns the [Response].+ /// Parameters:+ ///+ /// * [TimeBucketSize] size (required):+ ///+ /// * [String] albumId:+ ///+ /// * [bool] isArchived:+ ///+ /// * [bool] isFavorite:+ ///+ /// * [bool] isTrashed:+ ///+ /// * [String] key:+ ///+ /// * [AssetOrder] order:+ ///+ /// * [String] personId:+ ///+ /// * [String] userId:+ ///+ /// * [bool] withPartners:+ ///+ /// * [bool] withStacked:+ Future<Response> getTimeBucketsWithHttpInfo(TimeBucketSize size, { String? albumId, bool? isArchived, bool? isFavorite, bool? isTrashed, String? key, AssetOrder? order, String? personId, String? userId, bool? withPartners, bool? withStacked, }) async {+ // ignore: prefer_const_declarations+ final path = r'/timeline/buckets';++ // ignore: prefer_final_locals+ Object? postBody;++ final queryParams = <QueryParam>[];+ final headerParams = <String, String>{};+ final formParams = <String, String>{};++ if (albumId != null) {+ queryParams.addAll(_queryParams('', 'albumId', albumId));+ }+ if (isArchived != null) {+ queryParams.addAll(_queryParams('', 'isArchived', isArchived));+ }+ if (isFavorite != null) {+ queryParams.addAll(_queryParams('', 'isFavorite', isFavorite));+ }+ if (isTrashed != null) {+ queryParams.addAll(_queryParams('', 'isTrashed', isTrashed));+ }+ if (key != null) {+ queryParams.addAll(_queryParams('', 'key', key));+ }+ if (order != null) {+ queryParams.addAll(_queryParams('', 'order', order));+ }+ if (personId != null) {+ queryParams.addAll(_queryParams('', 'personId', personId));+ }+ queryParams.addAll(_queryParams('', 'size', size));+ if (userId != null) {+ queryParams.addAll(_queryParams('', 'userId', userId));+ }+ if (withPartners != null) {+ queryParams.addAll(_queryParams('', 'withPartners', withPartners));+ }+ if (withStacked != null) {+ queryParams.addAll(_queryParams('', 'withStacked', withStacked));+ }++ const contentTypes = <String>[];+++ return apiClient.invokeAPI(+ path,+ 'GET',+ queryParams,+ postBody,+ headerParams,+ formParams,+ contentTypes.isEmpty ? null : contentTypes.first,+ );+ }++ /// Parameters:+ ///+ /// * [TimeBucketSize] size (required):+ ///+ /// * [String] albumId:+ ///+ /// * [bool] isArchived:+ ///+ /// * [bool] isFavorite:+ ///+ /// * [bool] isTrashed:+ ///+ /// * [String] key:+ ///+ /// * [AssetOrder] order:+ ///+ /// * [String] personId:+ ///+ /// * [String] userId:+ ///+ /// * [bool] withPartners:+ ///+ /// * [bool] withStacked:+ Future<List<TimeBucketResponseDto>?> getTimeBuckets(TimeBucketSize size, { String? albumId, bool? isArchived, bool? isFavorite, bool? isTrashed, String? key, AssetOrder? order, String? personId, String? userId, bool? withPartners, bool? withStacked, }) async {+ final response = await getTimeBucketsWithHttpInfo(size, albumId: albumId, isArchived: isArchived, isFavorite: isFavorite, isTrashed: isTrashed, key: key, order: order, personId: personId, userId: userId, withPartners: withPartners, withStacked: withStacked, );+ 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) {+ final responseBody = await _decodeBodyBytes(response);+ return (await apiClient.deserializeAsync(responseBody, 'List<TimeBucketResponseDto>') as List)+ .cast<TimeBucketResponseDto>()+ .toList(growable: false);++ }+ return null;+ }+}diff --git a/mobile/openapi/test/asset_api_test.dart b/mobile/openapi/test/asset_api_test.dartindex d210d0e4d9..41d0ac8f5c 100644--- a/mobile/openapi/test/asset_api_test.dart+++ b/mobile/openapi/test/asset_api_test.dart@@ -95,16 +95,6 @@ void main() {// TODO});- //Future<List<AssetResponseDto>> getTimeBucket(TimeBucketSize size, String timeBucket, { String albumId, bool isArchived, bool isFavorite, bool isTrashed, String key, AssetOrder order, String personId, String userId, bool withPartners, bool withStacked }) async- test('test getTimeBucket', () async {- // TODO- });-- //Future<List<TimeBucketResponseDto>> getTimeBuckets(TimeBucketSize size, { String albumId, bool isArchived, bool isFavorite, bool isTrashed, String key, AssetOrder order, String personId, String userId, bool withPartners, bool withStacked }) async- test('test getTimeBuckets', () async {- // TODO- });-//Future runAssetJobs(AssetJobsDto assetJobsDto) asynctest('test runAssetJobs', () async {// TODOdiff --git a/mobile/openapi/test/timeline_api_test.dart b/mobile/openapi/test/timeline_api_test.dartnew file mode 100644index 0000000000..ae217b2e40--- /dev/null+++ b/mobile/openapi/test/timeline_api_test.dart@@ -0,0 +1,31 @@+//+// AUTO-GENERATED FILE, DO NOT MODIFY!+//+// @dart=2.12++// 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++import 'package:openapi/api.dart';+import 'package:test/test.dart';+++/// tests for TimelineApi+void main() {+ // final instance = TimelineApi();++ group('tests for TimelineApi', () {+ //Future<List<AssetResponseDto>> getTimeBucket(TimeBucketSize size, String timeBucket, { String albumId, bool isArchived, bool isFavorite, bool isTrashed, String key, AssetOrder order, String personId, String userId, bool withPartners, bool withStacked }) async+ test('test getTimeBucket', () async {+ // TODO+ });++ //Future<List<TimeBucketResponseDto>> getTimeBuckets(TimeBucketSize size, { String albumId, bool isArchived, bool isFavorite, bool isTrashed, String key, AssetOrder order, String personId, String userId, bool withPartners, bool withStacked }) async+ test('test getTimeBuckets', () async {+ // TODO+ });++ });+}diff --git a/open-api/immich-openapi-specs.json b/open-api/immich-openapi-specs.jsonindex 3bd92a9d95..0bd6524db4 100644--- a/open-api/immich-openapi-specs.json+++ b/open-api/immich-openapi-specs.json@@ -1720,286 +1720,6 @@]}},- "/asset/time-bucket": {- "get": {- "operationId": "getTimeBucket",- "parameters": [- {- "name": "albumId",- "required": false,- "in": "query",- "schema": {- "format": "uuid",- "type": "string"- }- },- {- "name": "isArchived",- "required": false,- "in": "query",- "schema": {- "type": "boolean"- }- },- {- "name": "isFavorite",- "required": false,- "in": "query",- "schema": {- "type": "boolean"- }- },- {- "name": "isTrashed",- "required": false,- "in": "query",- "schema": {- "type": "boolean"- }- },- {- "name": "key",- "required": false,- "in": "query",- "schema": {- "type": "string"- }- },- {- "name": "order",- "required": false,- "in": "query",- "schema": {- "$ref": "#/components/schemas/AssetOrder"- }- },- {- "name": "personId",- "required": false,- "in": "query",- "schema": {- "format": "uuid",- "type": "string"- }- },- {- "name": "size",- "required": true,- "in": "query",- "schema": {- "$ref": "#/components/schemas/TimeBucketSize"- }- },- {- "name": "timeBucket",- "required": true,- "in": "query",- "schema": {- "type": "string"- }- },- {- "name": "userId",- "required": false,- "in": "query",- "schema": {- "format": "uuid",- "type": "string"- }- },- {- "name": "withPartners",- "required": false,- "in": "query",- "schema": {- "type": "boolean"- }- },- {- "name": "withStacked",- "required": false,- "in": "query",- "schema": {- "type": "boolean"- }- }- ],- "responses": {- "200": {- "content": {- "application/json": {- "schema": {- "items": {- "$ref": "#/components/schemas/AssetResponseDto"- },- "type": "array"- }- }- },- "description": ""- }- },- "security": [- {- "bearer": []- },- {- "cookie": []- },- {- "api_key": []- },- {- "bearer": []- },- {- "cookie": []- },- {- "api_key": []- }- ],- "tags": [- "Asset"- ]- }- },- "/asset/time-buckets": {- "get": {- "operationId": "getTimeBuckets",- "parameters": [- {- "name": "albumId",- "required": false,- "in": "query",- "schema": {- "format": "uuid",- "type": "string"- }- },- {- "name": "isArchived",- "required": false,- "in": "query",- "schema": {- "type": "boolean"- }- },- {- "name": "isFavorite",- "required": false,- "in": "query",- "schema": {- "type": "boolean"- }- },- {- "name": "isTrashed",- "required": false,- "in": "query",- "schema": {- "type": "boolean"- }- },- {- "name": "key",- "required": false,- "in": "query",- "schema": {- "type": "string"- }- },- {- "name": "order",- "required": false,- "in": "query",- "schema": {- "$ref": "#/components/schemas/AssetOrder"- }- },- {- "name": "personId",- "required": false,- "in": "query",- "schema": {- "format": "uuid",- "type": "string"- }- },- {- "name": "size",- "required": true,- "in": "query",- "schema": {- "$ref": "#/components/schemas/TimeBucketSize"- }- },- {- "name": "userId",- "required": false,- "in": "query",- "schema": {- "format": "uuid",- "type": "string"- }- },- {- "name": "withPartners",- "required": false,- "in": "query",- "schema": {- "type": "boolean"- }- },- {- "name": "withStacked",- "required": false,- "in": "query",- "schema": {- "type": "boolean"- }- }- ],- "responses": {- "200": {- "content": {- "application/json": {- "schema": {- "items": {- "$ref": "#/components/schemas/TimeBucketResponseDto"- },- "type": "array"- }- }- },- "description": ""- }- },- "security": [- {- "bearer": []- },- {- "cookie": []- },- {- "api_key": []- },- {- "bearer": []- },- {- "cookie": []- },- {- "api_key": []- }- ],- "tags": [- "Asset"- ]- }- },"/asset/upload": {"post": {"operationId": "uploadFile",@@ -5824,7 +5544,112 @@"content": {"application/json": {"schema": {- "$ref": "#/components/schemas/TagResponseDto"+ "$ref": "#/components/schemas/TagResponseDto"+ }+ }+ },+ "description": ""+ }+ },+ "security": [+ {+ "bearer": []+ },+ {+ "cookie": []+ },+ {+ "api_key": []+ }+ ],+ "tags": [+ "Tag"+ ]+ },+ "patch": {+ "operationId": "updateTag",+ "parameters": [+ {+ "name": "id",+ "required": true,+ "in": "path",+ "schema": {+ "format": "uuid",+ "type": "string"+ }+ }+ ],+ "requestBody": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/UpdateTagDto"+ }+ }+ },+ "required": true+ },+ "responses": {+ "200": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/TagResponseDto"+ }+ }+ },+ "description": ""+ }+ },+ "security": [+ {+ "bearer": []+ },+ {+ "cookie": []+ },+ {+ "api_key": []+ }+ ],+ "tags": [+ "Tag"+ ]+ }+ },+ "/tag/{id}/assets": {+ "delete": {+ "operationId": "untagAssets",+ "parameters": [+ {+ "name": "id",+ "required": true,+ "in": "path",+ "schema": {+ "format": "uuid",+ "type": "string"+ }+ }+ ],+ "requestBody": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/AssetIdsDto"+ }+ }+ },+ "required": true+ },+ "responses": {+ "200": {+ "content": {+ "application/json": {+ "schema": {+ "items": {+ "$ref": "#/components/schemas/AssetIdsResponseDto"+ },+ "type": "array"}}},@@ -5846,8 +5671,8 @@"Tag"]},- "patch": {- "operationId": "updateTag",+ "get": {+ "operationId": "getTagAssets","parameters": [{"name": "id",@@ -5859,22 +5684,15 @@}}],- "requestBody": {- "content": {- "application/json": {- "schema": {- "$ref": "#/components/schemas/UpdateTagDto"- }- }- },- "required": true- },"responses": {"200": {"content": {"application/json": {"schema": {- "$ref": "#/components/schemas/TagResponseDto"+ "items": {+ "$ref": "#/components/schemas/AssetResponseDto"+ },+ "type": "array"}}},@@ -5895,11 +5713,9 @@"tags": ["Tag"]- }- },- "/tag/{id}/assets": {- "delete": {- "operationId": "untagAssets",+ },+ "put": {+ "operationId": "tagAssets","parameters": [{"name": "id",@@ -5950,18 +5766,110 @@"tags": ["Tag"]- },+ }+ },+ "/timeline/bucket": {"get": {- "operationId": "getTagAssets",+ "operationId": "getTimeBucket","parameters": [{- "name": "id",+ "name": "albumId",+ "required": false,+ "in": "query",+ "schema": {+ "format": "uuid",+ "type": "string"+ }+ },+ {+ "name": "isArchived",+ "required": false,+ "in": "query",+ "schema": {+ "type": "boolean"+ }+ },+ {+ "name": "isFavorite",+ "required": false,+ "in": "query",+ "schema": {+ "type": "boolean"+ }+ },+ {+ "name": "isTrashed",+ "required": false,+ "in": "query",+ "schema": {+ "type": "boolean"+ }+ },+ {+ "name": "key",+ "required": false,+ "in": "query",+ "schema": {+ "type": "string"+ }+ },+ {+ "name": "order",+ "required": false,+ "in": "query",+ "schema": {+ "$ref": "#/components/schemas/AssetOrder"+ }+ },+ {+ "name": "personId",+ "required": false,+ "in": "query",+ "schema": {+ "format": "uuid",+ "type": "string"+ }+ },+ {+ "name": "size","required": true,- "in": "path",+ "in": "query",+ "schema": {+ "$ref": "#/components/schemas/TimeBucketSize"+ }+ },+ {+ "name": "timeBucket",+ "required": true,+ "in": "query",+ "schema": {+ "type": "string"+ }+ },+ {+ "name": "userId",+ "required": false,+ "in": "query","schema": {"format": "uuid","type": "string"}+ },+ {+ "name": "withPartners",+ "required": false,+ "in": "query",+ "schema": {+ "type": "boolean"+ }+ },+ {+ "name": "withStacked",+ "required": false,+ "in": "query",+ "schema": {+ "type": "boolean"+ }}],"responses": {@@ -5980,6 +5888,15 @@}},"security": [+ {+ "bearer": []+ },+ {+ "cookie": []+ },+ {+ "api_key": []+ },{"bearer": []},@@ -5991,39 +5908,113 @@}],"tags": [- "Tag"+ "Timeline"]- },- "put": {- "operationId": "tagAssets",+ }+ },+ "/timeline/buckets": {+ "get": {+ "operationId": "getTimeBuckets","parameters": [{- "name": "id",+ "name": "albumId",+ "required": false,+ "in": "query",+ "schema": {+ "format": "uuid",+ "type": "string"+ }+ },+ {+ "name": "isArchived",+ "required": false,+ "in": "query",+ "schema": {+ "type": "boolean"+ }+ },+ {+ "name": "isFavorite",+ "required": false,+ "in": "query",+ "schema": {+ "type": "boolean"+ }+ },+ {+ "name": "isTrashed",+ "required": false,+ "in": "query",+ "schema": {+ "type": "boolean"+ }+ },+ {+ "name": "key",+ "required": false,+ "in": "query",+ "schema": {+ "type": "string"+ }+ },+ {+ "name": "order",+ "required": false,+ "in": "query",+ "schema": {+ "$ref": "#/components/schemas/AssetOrder"+ }+ },+ {+ "name": "personId",+ "required": false,+ "in": "query",+ "schema": {+ "format": "uuid",+ "type": "string"+ }+ },+ {+ "name": "size","required": true,- "in": "path",+ "in": "query",+ "schema": {+ "$ref": "#/components/schemas/TimeBucketSize"+ }+ },+ {+ "name": "userId",+ "required": false,+ "in": "query","schema": {"format": "uuid","type": "string"}- }- ],- "requestBody": {- "content": {- "application/json": {- "schema": {- "$ref": "#/components/schemas/AssetIdsDto"- }+ },+ {+ "name": "withPartners",+ "required": false,+ "in": "query",+ "schema": {+ "type": "boolean"}},- "required": true- },+ {+ "name": "withStacked",+ "required": false,+ "in": "query",+ "schema": {+ "type": "boolean"+ }+ }+ ],"responses": {"200": {"content": {"application/json": {"schema": {"items": {- "$ref": "#/components/schemas/AssetIdsResponseDto"+ "$ref": "#/components/schemas/TimeBucketResponseDto"},"type": "array"}@@ -6033,6 +6024,15 @@}},"security": [+ {+ "bearer": []+ },+ {+ "cookie": []+ },+ {+ "api_key": []+ },{"bearer": []},@@ -6044,7 +6044,7 @@}],"tags": [- "Tag"+ "Timeline"]}},diff --git a/open-api/typescript-sdk/src/fetch-client.ts b/open-api/typescript-sdk/src/fetch-client.tsindex 4164a3d1c9..00794f1208 100644--- a/open-api/typescript-sdk/src/fetch-client.ts+++ b/open-api/typescript-sdk/src/fetch-client.ts@@ -284,10 +284,6 @@ export type AssetStatsResponseDto = {total: number;videos: number;};-export type TimeBucketResponseDto = {- count: number;- timeBucket: string;-};export type CreateAssetDto = {assetData: Blob;deviceAssetId: string;@@ -971,6 +967,10 @@ export type CreateTagDto = {export type UpdateTagDto = {name?: string;};+export type TimeBucketResponseDto = {+ count: number;+ timeBucket: string;+};export type CreateUserDto = {email: string;memoriesEnabled?: boolean;@@ -1456,72 +1456,6 @@ export function getAssetThumbnail({ format, id, key }: {...opts}));}-export function getTimeBucket({ albumId, isArchived, isFavorite, isTrashed, key, order, personId, size, timeBucket, userId, withPartners, withStacked }: {- albumId?: string;- isArchived?: boolean;- isFavorite?: boolean;- isTrashed?: boolean;- key?: string;- order?: AssetOrder;- personId?: string;- size: TimeBucketSize;- timeBucket: string;- userId?: string;- withPartners?: boolean;- withStacked?: boolean;-}, opts?: Oazapfts.RequestOpts) {- return oazapfts.ok(oazapfts.fetchJson<{- status: 200;- data: AssetResponseDto[];- }>(`/asset/time-bucket${QS.query(QS.explode({- albumId,- isArchived,- isFavorite,- isTrashed,- key,- order,- personId,- size,- timeBucket,- userId,- withPartners,- withStacked- }))}`, {- ...opts- }));-}-export function getTimeBuckets({ albumId, isArchived, isFavorite, isTrashed, key, order, personId, size, userId, withPartners, withStacked }: {- albumId?: string;- isArchived?: boolean;- isFavorite?: boolean;- isTrashed?: boolean;- key?: string;- order?: AssetOrder;- personId?: string;- size: TimeBucketSize;- userId?: string;- withPartners?: boolean;- withStacked?: boolean;-}, opts?: Oazapfts.RequestOpts) {- return oazapfts.ok(oazapfts.fetchJson<{- status: 200;- data: TimeBucketResponseDto[];- }>(`/asset/time-buckets${QS.query(QS.explode({- albumId,- isArchived,- isFavorite,- isTrashed,- key,- order,- personId,- size,- userId,- withPartners,- withStacked- }))}`, {- ...opts- }));-}export function uploadFile({ key, createAssetDto }: {key?: string;createAssetDto: CreateAssetDto;@@ -2595,6 +2529,72 @@ export function tagAssets({ id, assetIdsDto }: {body: assetIdsDto})));}+export function getTimeBucket({ albumId, isArchived, isFavorite, isTrashed, key, order, personId, size, timeBucket, userId, withPartners, withStacked }: {+ albumId?: string;+ isArchived?: boolean;+ isFavorite?: boolean;+ isTrashed?: boolean;+ key?: string;+ order?: AssetOrder;+ personId?: string;+ size: TimeBucketSize;+ timeBucket: string;+ userId?: string;+ withPartners?: boolean;+ withStacked?: boolean;+}, opts?: Oazapfts.RequestOpts) {+ return oazapfts.ok(oazapfts.fetchJson<{+ status: 200;+ data: AssetResponseDto[];+ }>(`/timeline/bucket${QS.query(QS.explode({+ albumId,+ isArchived,+ isFavorite,+ isTrashed,+ key,+ order,+ personId,+ size,+ timeBucket,+ userId,+ withPartners,+ withStacked+ }))}`, {+ ...opts+ }));+}+export function getTimeBuckets({ albumId, isArchived, isFavorite, isTrashed, key, order, personId, size, userId, withPartners, withStacked }: {+ albumId?: string;+ isArchived?: boolean;+ isFavorite?: boolean;+ isTrashed?: boolean;+ key?: string;+ order?: AssetOrder;+ personId?: string;+ size: TimeBucketSize;+ userId?: string;+ withPartners?: boolean;+ withStacked?: boolean;+}, opts?: Oazapfts.RequestOpts) {+ return oazapfts.ok(oazapfts.fetchJson<{+ status: 200;+ data: TimeBucketResponseDto[];+ }>(`/timeline/buckets${QS.query(QS.explode({+ albumId,+ isArchived,+ isFavorite,+ isTrashed,+ key,+ order,+ personId,+ size,+ userId,+ withPartners,+ withStacked+ }))}`, {+ ...opts+ }));+}export function emptyTrash(opts?: Oazapfts.RequestOpts) {return oazapfts.ok(oazapfts.fetchText("/trash/empty", {...opts,@@ -2789,10 +2789,6 @@ export enum ThumbnailFormat {Jpeg = "JPEG",Webp = "WEBP"}-export enum TimeBucketSize {- Day = "DAY",- Month = "MONTH"-}export enum EntityType {Asset = "ASSET",Album = "ALBUM"@@ -2911,3 +2907,7 @@ export enum MapTheme {Light = "light",Dark = "dark"}+export enum TimeBucketSize {+ Day = "DAY",+ Month = "MONTH"+}diff --git a/server/src/app.module.ts b/server/src/app.module.tsindex aedd6adf1f..f7aa5f5949 100644--- a/server/src/app.module.ts+++ b/server/src/app.module.ts@@ -31,6 +31,7 @@ import { ServerInfoController } from 'src/controllers/server-info.controller';import { SharedLinkController } from 'src/controllers/shared-link.controller';import { SystemConfigController } from 'src/controllers/system-config.controller';import { TagController } from 'src/controllers/tag.controller';+import { TimelineController } from 'src/controllers/timeline.controller';import { TrashController } from 'src/controllers/trash.controller';import { UserController } from 'src/controllers/user.controller';import { databaseConfig } from 'src/database.config';@@ -121,6 +122,7 @@ import { StorageTemplateService } from 'src/services/storage-template.service';import { StorageService } from 'src/services/storage.service';import { SystemConfigService } from 'src/services/system-config.service';import { TagService } from 'src/services/tag.service';+import { TimelineService } from 'src/services/timeline.service';import { TrashService } from 'src/services/trash.service';import { UserService } from 'src/services/user.service';import { otelConfig } from 'src/utils/instrumentation';@@ -157,6 +159,7 @@ const controllers = [SharedLinkController,SystemConfigController,TagController,+ TimelineController,TrashController,UserController,PersonController,@@ -189,6 +192,7 @@ const services: Provider[] = [StorageTemplateService,SystemConfigService,TagService,+ TimelineService,TrashService,UserService,];diff --git a/server/src/controllers/asset.controller.ts b/server/src/controllers/asset.controller.tsindex 37e1691137..8e446d23f9 100644--- a/server/src/controllers/asset.controller.ts+++ b/server/src/controllers/asset.controller.ts@@ -14,7 +14,6 @@ import {import { AuthDto } from 'src/dtos/auth.dto';import { MapMarkerDto, MapMarkerResponseDto, MemoryLaneDto, MetadataSearchDto } from 'src/dtos/search.dto';import { UpdateStackParentDto } from 'src/dtos/stack.dto';-import { TimeBucketAssetDto, TimeBucketDto, TimeBucketResponseDto } from 'src/dtos/time-bucket.dto';import { Auth, Authenticated, SharedLinkRoute } from 'src/middleware/auth.guard';import { Route } from 'src/middleware/file-upload.interceptor';import { AssetService } from 'src/services/asset.service';@@ -71,18 +70,6 @@ export class AssetController {return this.service.getStatistics(auth, dto);}- @Authenticated({ isShared: true })- @Get('time-buckets')- getTimeBuckets(@Auth() auth: AuthDto, @Query() dto: TimeBucketDto): Promise<TimeBucketResponseDto[]> {- return this.service.getTimeBuckets(auth, dto);- }-- @Authenticated({ isShared: true })- @Get('time-bucket')- getTimeBucket(@Auth() auth: AuthDto, @Query() dto: TimeBucketAssetDto): Promise<AssetResponseDto[]> {- return this.service.getTimeBucket(auth, dto) as Promise<AssetResponseDto[]>;- }-@Post('jobs')@HttpCode(HttpStatus.NO_CONTENT)runAssetJobs(@Auth() auth: AuthDto, @Body() dto: AssetJobsDto): Promise<void> {diff --git a/server/src/controllers/timeline.controller.ts b/server/src/controllers/timeline.controller.tsnew file mode 100644index 0000000000..173c6738de--- /dev/null+++ b/server/src/controllers/timeline.controller.ts@@ -0,0 +1,26 @@+import { Controller, Get, Query } from '@nestjs/common';+import { ApiTags } from '@nestjs/swagger';+import { AssetResponseDto } from 'src/dtos/asset-response.dto';+import { AuthDto } from 'src/dtos/auth.dto';+import { TimeBucketAssetDto, TimeBucketDto, TimeBucketResponseDto } from 'src/dtos/time-bucket.dto';+import { Auth, Authenticated } from 'src/middleware/auth.guard';+import { TimelineService } from 'src/services/timeline.service';++@ApiTags('Timeline')+@Controller('timeline')+@Authenticated()+export class TimelineController {+ constructor(private service: TimelineService) {}++ @Authenticated({ isShared: true })+ @Get('buckets')+ getTimeBuckets(@Auth() auth: AuthDto, @Query() dto: TimeBucketDto): Promise<TimeBucketResponseDto[]> {+ return this.service.getTimeBuckets(auth, dto);+ }++ @Authenticated({ isShared: true })+ @Get('bucket')+ getTimeBucket(@Auth() auth: AuthDto, @Query() dto: TimeBucketAssetDto): Promise<AssetResponseDto[]> {+ return this.service.getTimeBucket(auth, dto) as Promise<AssetResponseDto[]>;+ }+}diff --git a/server/src/services/asset.service.spec.ts b/server/src/services/asset.service.spec.tsindex d5bce3d1ec..f7e502e693 100644--- a/server/src/services/asset.service.spec.ts+++ b/server/src/services/asset.service.spec.ts@@ -4,7 +4,7 @@ import { mapAsset } from 'src/dtos/asset-response.dto';import { AssetJobName, AssetStatsResponseDto, UploadFieldName } from 'src/dtos/asset.dto';import { AssetEntity, AssetType } from 'src/entities/asset.entity';import { IAssetStackRepository } from 'src/interfaces/asset-stack.interface';-import { AssetStats, IAssetRepository, TimeBucketSize } from 'src/interfaces/asset.interface';+import { AssetStats, IAssetRepository } from 'src/interfaces/asset.interface';import { ClientEvent, IEventRepository } from 'src/interfaces/event.interface';import { IJobRepository, JobItem, JobName } from 'src/interfaces/job.interface';import { IPartnerRepository } from 'src/interfaces/partner.interface';@@ -335,129 +335,6 @@ describe(AssetService.name, () => {});});- describe('getTimeBuckets', () => {- it("should return buckets if userId and albumId aren't set", async () => {- assetMock.getTimeBuckets.mockResolvedValue([{ timeBucket: 'bucket', count: 1 }]);-- await expect(- sut.getTimeBuckets(authStub.admin, {- size: TimeBucketSize.DAY,- }),- ).resolves.toEqual(expect.arrayContaining([{ timeBucket: 'bucket', count: 1 }]));- expect(assetMock.getTimeBuckets).toBeCalledWith({ size: TimeBucketSize.DAY, userIds: [authStub.admin.user.id] });- });- });-- describe('getTimeBucket', () => {- it('should return the assets for a album time bucket if user has album.read', async () => {- accessMock.album.checkOwnerAccess.mockResolvedValue(new Set(['album-id']));- assetMock.getTimeBucket.mockResolvedValue([assetStub.image]);-- await expect(- sut.getTimeBucket(authStub.admin, { size: TimeBucketSize.DAY, timeBucket: 'bucket', albumId: 'album-id' }),- ).resolves.toEqual(expect.arrayContaining([expect.objectContaining({ id: 'asset-id' })]));-- expect(accessMock.album.checkOwnerAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['album-id']));- expect(assetMock.getTimeBucket).toBeCalledWith('bucket', {- size: TimeBucketSize.DAY,- timeBucket: 'bucket',- albumId: 'album-id',- });- });-- it('should return the assets for a archive time bucket if user has archive.read', async () => {- assetMock.getTimeBucket.mockResolvedValue([assetStub.image]);-- await expect(- sut.getTimeBucket(authStub.admin, {- size: TimeBucketSize.DAY,- timeBucket: 'bucket',- isArchived: true,- userId: authStub.admin.user.id,- }),- ).resolves.toEqual(expect.arrayContaining([expect.objectContaining({ id: 'asset-id' })]));- expect(assetMock.getTimeBucket).toBeCalledWith('bucket', {- size: TimeBucketSize.DAY,- timeBucket: 'bucket',- isArchived: true,- userIds: [authStub.admin.user.id],- });- });-- it('should return the assets for a library time bucket if user has library.read', async () => {- assetMock.getTimeBucket.mockResolvedValue([assetStub.image]);-- await expect(- sut.getTimeBucket(authStub.admin, {- size: TimeBucketSize.DAY,- timeBucket: 'bucket',- userId: authStub.admin.user.id,- }),- ).resolves.toEqual(expect.arrayContaining([expect.objectContaining({ id: 'asset-id' })]));- expect(assetMock.getTimeBucket).toBeCalledWith('bucket', {- size: TimeBucketSize.DAY,- timeBucket: 'bucket',- userIds: [authStub.admin.user.id],- });- });-- it('should throw an error if withParners is true and isArchived true or undefined', async () => {- await expect(- sut.getTimeBucket(authStub.admin, {- size: TimeBucketSize.DAY,- timeBucket: 'bucket',- isArchived: true,- withPartners: true,- userId: authStub.admin.user.id,- }),- ).rejects.toThrowError(BadRequestException);-- await expect(- sut.getTimeBucket(authStub.admin, {- size: TimeBucketSize.DAY,- timeBucket: 'bucket',- isArchived: undefined,- withPartners: true,- userId: authStub.admin.user.id,- }),- ).rejects.toThrowError(BadRequestException);- });-- it('should throw an error if withParners is true and isFavorite is either true or false', async () => {- await expect(- sut.getTimeBucket(authStub.admin, {- size: TimeBucketSize.DAY,- timeBucket: 'bucket',- isFavorite: true,- withPartners: true,- userId: authStub.admin.user.id,- }),- ).rejects.toThrowError(BadRequestException);-- await expect(- sut.getTimeBucket(authStub.admin, {- size: TimeBucketSize.DAY,- timeBucket: 'bucket',- isFavorite: false,- withPartners: true,- userId: authStub.admin.user.id,- }),- ).rejects.toThrowError(BadRequestException);- });-- it('should throw an error if withParners is true and isTrash is true', async () => {- await expect(- sut.getTimeBucket(authStub.admin, {- size: TimeBucketSize.DAY,- timeBucket: 'bucket',- isTrashed: true,- withPartners: true,- userId: authStub.admin.user.id,- }),- ).rejects.toThrowError(BadRequestException);- });- });-describe('getStatistics', () => {it('should get the statistics for a user, excluding archived assets', async () => {assetMock.getStatistics.mockResolvedValue(stats);diff --git a/server/src/services/asset.service.ts b/server/src/services/asset.service.tsindex 17fe147c01..b8a9dec874 100644--- a/server/src/services/asset.service.ts+++ b/server/src/services/asset.service.ts@@ -25,12 +25,11 @@ import {import { AuthDto } from 'src/dtos/auth.dto';import { MapMarkerDto, MapMarkerResponseDto, MemoryLaneDto } from 'src/dtos/search.dto';import { UpdateStackParentDto } from 'src/dtos/stack.dto';-import { TimeBucketAssetDto, TimeBucketDto, TimeBucketResponseDto } from 'src/dtos/time-bucket.dto';import { AssetEntity } from 'src/entities/asset.entity';import { LibraryType } from 'src/entities/library.entity';import { IAccessRepository } from 'src/interfaces/access.interface';import { IAssetStackRepository } from 'src/interfaces/asset-stack.interface';-import { IAssetRepository, TimeBucketOptions } from 'src/interfaces/asset.interface';+import { IAssetRepository } from 'src/interfaces/asset.interface';import { ClientEvent, IEventRepository } from 'src/interfaces/event.interface';import {IAssetDeletionJob,@@ -195,72 +194,6 @@ export class AssetService {}));}- private async timeBucketChecks(auth: AuthDto, dto: TimeBucketDto) {- if (dto.albumId) {- await this.access.requirePermission(auth, Permission.ALBUM_READ, [dto.albumId]);- } else {- dto.userId = dto.userId || auth.user.id;- }-- if (dto.userId) {- await this.access.requirePermission(auth, Permission.TIMELINE_READ, [dto.userId]);- if (dto.isArchived !== false) {- await this.access.requirePermission(auth, Permission.ARCHIVE_READ, [dto.userId]);- }- }-- if (dto.withPartners) {- const requestedArchived = dto.isArchived === true || dto.isArchived === undefined;- const requestedFavorite = dto.isFavorite === true || dto.isFavorite === false;- const requestedTrash = dto.isTrashed === true;-- if (requestedArchived || requestedFavorite || requestedTrash) {- throw new BadRequestException(- 'withPartners is only supported for non-archived, non-trashed, non-favorited assets',- );- }- }- }-- async getTimeBuckets(auth: AuthDto, dto: TimeBucketDto): Promise<TimeBucketResponseDto[]> {- await this.timeBucketChecks(auth, dto);- const timeBucketOptions = await this.buildTimeBucketOptions(auth, dto);-- return this.assetRepository.getTimeBuckets(timeBucketOptions);- }-- async getTimeBucket(- auth: AuthDto,- dto: TimeBucketAssetDto,- ): Promise<AssetResponseDto[] | SanitizedAssetResponseDto[]> {- await this.timeBucketChecks(auth, dto);- const timeBucketOptions = await this.buildTimeBucketOptions(auth, dto);- const assets = await this.assetRepository.getTimeBucket(dto.timeBucket, timeBucketOptions);- return !auth.sharedLink || auth.sharedLink?.showExif- ? assets.map((asset) => mapAsset(asset, { withStack: true, auth }))- : assets.map((asset) => mapAsset(asset, { stripMetadata: true, auth }));- }-- async buildTimeBucketOptions(auth: AuthDto, dto: TimeBucketDto): Promise<TimeBucketOptions> {- const { userId, ...options } = dto;- let userIds: string[] | undefined = undefined;-- if (userId) {- userIds = [userId];-- if (dto.withPartners) {- const partners = await this.partnerRepository.getAll(auth.user.id);- const partnersIds = partners- .filter((partner) => partner.sharedBy && partner.sharedWith && partner.inTimeline)- .map((partner) => partner.sharedById);-- userIds.push(...partnersIds);- }- }-- return { ...options, userIds };- }-async getStatistics(auth: AuthDto, dto: AssetStatsDto) {const stats = await this.assetRepository.getStatistics(auth.user.id, dto);return mapStats(stats);diff --git a/server/src/services/timeline.service.spec.ts b/server/src/services/timeline.service.spec.tsnew file mode 100644index 0000000000..c6f058022f--- /dev/null+++ b/server/src/services/timeline.service.spec.ts@@ -0,0 +1,149 @@+import { BadRequestException } from '@nestjs/common';+import { IAssetRepository, TimeBucketSize } from 'src/interfaces/asset.interface';+import { IPartnerRepository } from 'src/interfaces/partner.interface';+import { TimelineService } from 'src/services/timeline.service';+import { assetStub } from 'test/fixtures/asset.stub';+import { authStub } from 'test/fixtures/auth.stub';+import { IAccessRepositoryMock, newAccessRepositoryMock } from 'test/repositories/access.repository.mock';+import { newAssetRepositoryMock } from 'test/repositories/asset.repository.mock';+import { newPartnerRepositoryMock } from 'test/repositories/partner.repository.mock';++describe(TimelineService.name, () => {+ let sut: TimelineService;+ let accessMock: IAccessRepositoryMock;+ let assetMock: jest.Mocked<IAssetRepository>;+ let partnerMock: jest.Mocked<IPartnerRepository>;+ beforeEach(() => {+ accessMock = newAccessRepositoryMock();+ assetMock = newAssetRepositoryMock();+ partnerMock = newPartnerRepositoryMock();++ sut = new TimelineService(accessMock, assetMock, partnerMock);+ });++ describe('getTimeBuckets', () => {+ it("should return buckets if userId and albumId aren't set", async () => {+ assetMock.getTimeBuckets.mockResolvedValue([{ timeBucket: 'bucket', count: 1 }]);++ await expect(+ sut.getTimeBuckets(authStub.admin, {+ size: TimeBucketSize.DAY,+ }),+ ).resolves.toEqual(expect.arrayContaining([{ timeBucket: 'bucket', count: 1 }]));+ expect(assetMock.getTimeBuckets).toHaveBeenCalledWith({+ size: TimeBucketSize.DAY,+ userIds: [authStub.admin.user.id],+ });+ });+ });++ describe('getTimeBucket', () => {+ it('should return the assets for a album time bucket if user has album.read', async () => {+ accessMock.album.checkOwnerAccess.mockResolvedValue(new Set(['album-id']));+ assetMock.getTimeBucket.mockResolvedValue([assetStub.image]);++ await expect(+ sut.getTimeBucket(authStub.admin, { size: TimeBucketSize.DAY, timeBucket: 'bucket', albumId: 'album-id' }),+ ).resolves.toEqual(expect.arrayContaining([expect.objectContaining({ id: 'asset-id' })]));++ expect(accessMock.album.checkOwnerAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['album-id']));+ expect(assetMock.getTimeBucket).toHaveBeenCalledWith('bucket', {+ size: TimeBucketSize.DAY,+ timeBucket: 'bucket',+ albumId: 'album-id',+ });+ });++ it('should return the assets for a archive time bucket if user has archive.read', async () => {+ assetMock.getTimeBucket.mockResolvedValue([assetStub.image]);++ await expect(+ sut.getTimeBucket(authStub.admin, {+ size: TimeBucketSize.DAY,+ timeBucket: 'bucket',+ isArchived: true,+ userId: authStub.admin.user.id,+ }),+ ).resolves.toEqual(expect.arrayContaining([expect.objectContaining({ id: 'asset-id' })]));+ expect(assetMock.getTimeBucket).toHaveBeenCalledWith('bucket', {+ size: TimeBucketSize.DAY,+ timeBucket: 'bucket',+ isArchived: true,+ userIds: [authStub.admin.user.id],+ });+ });++ it('should return the assets for a library time bucket if user has library.read', async () => {+ assetMock.getTimeBucket.mockResolvedValue([assetStub.image]);++ await expect(+ sut.getTimeBucket(authStub.admin, {+ size: TimeBucketSize.DAY,+ timeBucket: 'bucket',+ userId: authStub.admin.user.id,+ }),+ ).resolves.toEqual(expect.arrayContaining([expect.objectContaining({ id: 'asset-id' })]));+ expect(assetMock.getTimeBucket).toHaveBeenCalledWith('bucket', {+ size: TimeBucketSize.DAY,+ timeBucket: 'bucket',+ userIds: [authStub.admin.user.id],+ });+ });++ it('should throw an error if withParners is true and isArchived true or undefined', async () => {+ await expect(+ sut.getTimeBucket(authStub.admin, {+ size: TimeBucketSize.DAY,+ timeBucket: 'bucket',+ isArchived: true,+ withPartners: true,+ userId: authStub.admin.user.id,+ }),+ ).rejects.toThrow(BadRequestException);++ await expect(+ sut.getTimeBucket(authStub.admin, {+ size: TimeBucketSize.DAY,+ timeBucket: 'bucket',+ isArchived: undefined,+ withPartners: true,+ userId: authStub.admin.user.id,+ }),+ ).rejects.toThrow(BadRequestException);+ });++ it('should throw an error if withParners is true and isFavorite is either true or false', async () => {+ await expect(+ sut.getTimeBucket(authStub.admin, {+ size: TimeBucketSize.DAY,+ timeBucket: 'bucket',+ isFavorite: true,+ withPartners: true,+ userId: authStub.admin.user.id,+ }),+ ).rejects.toThrow(BadRequestException);++ await expect(+ sut.getTimeBucket(authStub.admin, {+ size: TimeBucketSize.DAY,+ timeBucket: 'bucket',+ isFavorite: false,+ withPartners: true,+ userId: authStub.admin.user.id,+ }),+ ).rejects.toThrow(BadRequestException);+ });++ it('should throw an error if withParners is true and isTrash is true', async () => {+ await expect(+ sut.getTimeBucket(authStub.admin, {+ size: TimeBucketSize.DAY,+ timeBucket: 'bucket',+ isTrashed: true,+ withPartners: true,+ userId: authStub.admin.user.id,+ }),+ ).rejects.toThrow(BadRequestException);+ });+ });+});diff --git a/server/src/services/timeline.service.ts b/server/src/services/timeline.service.tsnew file mode 100644index 0000000000..95c4081e6a--- /dev/null+++ b/server/src/services/timeline.service.ts@@ -0,0 +1,86 @@+import { BadRequestException, Inject } from '@nestjs/common';+import { AccessCore, Permission } from 'src/cores/access.core';+import { AssetResponseDto, SanitizedAssetResponseDto, mapAsset } from 'src/dtos/asset-response.dto';+import { AuthDto } from 'src/dtos/auth.dto';+import { TimeBucketAssetDto, TimeBucketDto, TimeBucketResponseDto } from 'src/dtos/time-bucket.dto';+import { IAccessRepository } from 'src/interfaces/access.interface';+import { IAssetRepository, TimeBucketOptions } from 'src/interfaces/asset.interface';+import { IPartnerRepository } from 'src/interfaces/partner.interface';++export class TimelineService {+ private accessCore: AccessCore;++ constructor(+ @Inject(IAccessRepository) accessRepository: IAccessRepository,+ @Inject(IAssetRepository) private repository: IAssetRepository,+ @Inject(IPartnerRepository) private partnerRepository: IPartnerRepository,+ ) {+ this.accessCore = AccessCore.create(accessRepository);+ }++ async getTimeBuckets(auth: AuthDto, dto: TimeBucketDto): Promise<TimeBucketResponseDto[]> {+ await this.timeBucketChecks(auth, dto);+ const timeBucketOptions = await this.buildTimeBucketOptions(auth, dto);++ return this.repository.getTimeBuckets(timeBucketOptions);+ }++ async getTimeBucket(+ auth: AuthDto,+ dto: TimeBucketAssetDto,+ ): Promise<AssetResponseDto[] | SanitizedAssetResponseDto[]> {+ await this.timeBucketChecks(auth, dto);+ const timeBucketOptions = await this.buildTimeBucketOptions(auth, dto);+ const assets = await this.repository.getTimeBucket(dto.timeBucket, timeBucketOptions);+ return !auth.sharedLink || auth.sharedLink?.showExif+ ? assets.map((asset) => mapAsset(asset, { withStack: true, auth }))+ : assets.map((asset) => mapAsset(asset, { stripMetadata: true, auth }));+ }++ private async buildTimeBucketOptions(auth: AuthDto, dto: TimeBucketDto): Promise<TimeBucketOptions> {+ const { userId, ...options } = dto;+ let userIds: string[] | undefined = undefined;++ if (userId) {+ userIds = [userId];++ if (dto.withPartners) {+ const partners = await this.partnerRepository.getAll(auth.user.id);+ const partnersIds = partners+ .filter((partner) => partner.sharedBy && partner.sharedWith && partner.inTimeline)+ .map((partner) => partner.sharedById);++ userIds.push(...partnersIds);+ }+ }++ return { ...options, userIds };+ }++ private async timeBucketChecks(auth: AuthDto, dto: TimeBucketDto) {+ if (dto.albumId) {+ await this.accessCore.requirePermission(auth, Permission.ALBUM_READ, [dto.albumId]);+ } else {+ dto.userId = dto.userId || auth.user.id;+ }++ if (dto.userId) {+ await this.accessCore.requirePermission(auth, Permission.TIMELINE_READ, [dto.userId]);+ if (dto.isArchived !== false) {+ await this.accessCore.requirePermission(auth, Permission.ARCHIVE_READ, [dto.userId]);+ }+ }++ if (dto.withPartners) {+ const requestedArchived = dto.isArchived === true || dto.isArchived === undefined;+ const requestedFavorite = dto.isFavorite === true || dto.isFavorite === false;+ const requestedTrash = dto.isTrashed === true;++ if (requestedArchived || requestedFavorite || requestedTrash) {+ throw new BadRequestException(+ 'withPartners is only supported for non-archived, non-trashed, non-favorited assets',+ );+ }+ }+ }+}