mirror of
https://github.com/immich-app/immich.git
synced 2025-01-12 15:32:36 +02:00
refactor: deprecate getUserAssetsByDeviceId (#5273)
* refactor: deprecated getUserAssetsByDeviceId * prevent breaking changes * chore: add deprecation * prevent breaking changes * prevent breaking changes --------- Co-authored-by: shalong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
parent
155ccbc870
commit
0108211c0f
102
cli/src/api/open-api/api.ts
generated
102
cli/src/api/open-api/api.ts
generated
@ -6808,6 +6808,48 @@ export const AssetApiAxiosParamCreator = function (configuration?: Configuration
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
||||||
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||||
|
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: toPathString(localVarUrlObj),
|
||||||
|
options: localVarRequestOptions,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Get all asset of a device that are in the database, ID only.
|
||||||
|
* @param {string} deviceId
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
getAllUserAssetsByDeviceId: async (deviceId: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||||
|
// verify required parameter 'deviceId' is not null or undefined
|
||||||
|
assertParamExists('getAllUserAssetsByDeviceId', 'deviceId', deviceId)
|
||||||
|
const localVarPath = `/asset/device/{deviceId}`
|
||||||
|
.replace(`{${"deviceId"}}`, encodeURIComponent(String(deviceId)));
|
||||||
|
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||||
|
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||||
|
let baseOptions;
|
||||||
|
if (configuration) {
|
||||||
|
baseOptions = configuration.baseOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
|
||||||
|
const localVarHeaderParameter = {} as any;
|
||||||
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
|
// authentication cookie required
|
||||||
|
|
||||||
|
// authentication api_key required
|
||||||
|
await setApiKeyToObject(localVarHeaderParameter, "x-api-key", configuration)
|
||||||
|
|
||||||
|
// authentication bearer required
|
||||||
|
// http bearer authentication required
|
||||||
|
await setBearerAuthToObject(localVarHeaderParameter, configuration)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
||||||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||||
@ -7477,9 +7519,11 @@ export const AssetApiAxiosParamCreator = function (configuration?: Configuration
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Get all asset of a device that are in the database, ID only.
|
*
|
||||||
|
* @summary Use /asset/device/:deviceId instead - Remove in 1.92 release
|
||||||
* @param {string} deviceId
|
* @param {string} deviceId
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
|
* @deprecated
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
getUserAssetsByDeviceId: async (deviceId: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
getUserAssetsByDeviceId: async (deviceId: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||||
@ -8311,6 +8355,16 @@ export const AssetApiFp = function(configuration?: Configuration) {
|
|||||||
const localVarAxiosArgs = await localVarAxiosParamCreator.getAllAssets(skip, take, userId, isFavorite, isArchived, updatedAfter, updatedBefore, ifNoneMatch, options);
|
const localVarAxiosArgs = await localVarAxiosParamCreator.getAllAssets(skip, take, userId, isFavorite, isArchived, updatedAfter, updatedBefore, ifNoneMatch, options);
|
||||||
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Get all asset of a device that are in the database, ID only.
|
||||||
|
* @param {string} deviceId
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async getAllUserAssetsByDeviceId(deviceId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<string>>> {
|
||||||
|
const localVarAxiosArgs = await localVarAxiosParamCreator.getAllUserAssetsByDeviceId(deviceId, options);
|
||||||
|
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Get a single asset\'s information
|
* Get a single asset\'s information
|
||||||
* @param {string} id
|
* @param {string} id
|
||||||
@ -8458,9 +8512,11 @@ export const AssetApiFp = function(configuration?: Configuration) {
|
|||||||
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Get all asset of a device that are in the database, ID only.
|
*
|
||||||
|
* @summary Use /asset/device/:deviceId instead - Remove in 1.92 release
|
||||||
* @param {string} deviceId
|
* @param {string} deviceId
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
|
* @deprecated
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
async getUserAssetsByDeviceId(deviceId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<string>>> {
|
async getUserAssetsByDeviceId(deviceId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<string>>> {
|
||||||
@ -8686,6 +8742,15 @@ export const AssetApiFactory = function (configuration?: Configuration, basePath
|
|||||||
getAllAssets(requestParameters: AssetApiGetAllAssetsRequest = {}, options?: AxiosRequestConfig): AxiosPromise<Array<AssetResponseDto>> {
|
getAllAssets(requestParameters: AssetApiGetAllAssetsRequest = {}, options?: AxiosRequestConfig): AxiosPromise<Array<AssetResponseDto>> {
|
||||||
return localVarFp.getAllAssets(requestParameters.skip, requestParameters.take, requestParameters.userId, requestParameters.isFavorite, requestParameters.isArchived, requestParameters.updatedAfter, requestParameters.updatedBefore, requestParameters.ifNoneMatch, options).then((request) => request(axios, basePath));
|
return localVarFp.getAllAssets(requestParameters.skip, requestParameters.take, requestParameters.userId, requestParameters.isFavorite, requestParameters.isArchived, requestParameters.updatedAfter, requestParameters.updatedBefore, requestParameters.ifNoneMatch, options).then((request) => request(axios, basePath));
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Get all asset of a device that are in the database, ID only.
|
||||||
|
* @param {AssetApiGetAllUserAssetsByDeviceIdRequest} requestParameters Request parameters.
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
getAllUserAssetsByDeviceId(requestParameters: AssetApiGetAllUserAssetsByDeviceIdRequest, options?: AxiosRequestConfig): AxiosPromise<Array<string>> {
|
||||||
|
return localVarFp.getAllUserAssetsByDeviceId(requestParameters.deviceId, options).then((request) => request(axios, basePath));
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Get a single asset\'s information
|
* Get a single asset\'s information
|
||||||
* @param {AssetApiGetAssetByIdRequest} requestParameters Request parameters.
|
* @param {AssetApiGetAssetByIdRequest} requestParameters Request parameters.
|
||||||
@ -8792,9 +8857,11 @@ export const AssetApiFactory = function (configuration?: Configuration, basePath
|
|||||||
return localVarFp.getTimeBuckets(requestParameters.size, requestParameters.userId, requestParameters.albumId, requestParameters.personId, requestParameters.isArchived, requestParameters.isFavorite, requestParameters.isTrashed, requestParameters.withStacked, requestParameters.withPartners, requestParameters.key, options).then((request) => request(axios, basePath));
|
return localVarFp.getTimeBuckets(requestParameters.size, requestParameters.userId, requestParameters.albumId, requestParameters.personId, requestParameters.isArchived, requestParameters.isFavorite, requestParameters.isTrashed, requestParameters.withStacked, requestParameters.withPartners, requestParameters.key, options).then((request) => request(axios, basePath));
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Get all asset of a device that are in the database, ID only.
|
*
|
||||||
|
* @summary Use /asset/device/:deviceId instead - Remove in 1.92 release
|
||||||
* @param {AssetApiGetUserAssetsByDeviceIdRequest} requestParameters Request parameters.
|
* @param {AssetApiGetUserAssetsByDeviceIdRequest} requestParameters Request parameters.
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
|
* @deprecated
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
getUserAssetsByDeviceId(requestParameters: AssetApiGetUserAssetsByDeviceIdRequest, options?: AxiosRequestConfig): AxiosPromise<Array<string>> {
|
getUserAssetsByDeviceId(requestParameters: AssetApiGetUserAssetsByDeviceIdRequest, options?: AxiosRequestConfig): AxiosPromise<Array<string>> {
|
||||||
@ -9030,6 +9097,20 @@ export interface AssetApiGetAllAssetsRequest {
|
|||||||
readonly ifNoneMatch?: string
|
readonly ifNoneMatch?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request parameters for getAllUserAssetsByDeviceId operation in AssetApi.
|
||||||
|
* @export
|
||||||
|
* @interface AssetApiGetAllUserAssetsByDeviceIdRequest
|
||||||
|
*/
|
||||||
|
export interface AssetApiGetAllUserAssetsByDeviceIdRequest {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof AssetApiGetAllUserAssetsByDeviceId
|
||||||
|
*/
|
||||||
|
readonly deviceId: string
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request parameters for getAssetById operation in AssetApi.
|
* Request parameters for getAssetById operation in AssetApi.
|
||||||
* @export
|
* @export
|
||||||
@ -9974,6 +10055,17 @@ export class AssetApi extends BaseAPI {
|
|||||||
return AssetApiFp(this.configuration).getAllAssets(requestParameters.skip, requestParameters.take, requestParameters.userId, requestParameters.isFavorite, requestParameters.isArchived, requestParameters.updatedAfter, requestParameters.updatedBefore, requestParameters.ifNoneMatch, options).then((request) => request(this.axios, this.basePath));
|
return AssetApiFp(this.configuration).getAllAssets(requestParameters.skip, requestParameters.take, requestParameters.userId, requestParameters.isFavorite, requestParameters.isArchived, requestParameters.updatedAfter, requestParameters.updatedBefore, requestParameters.ifNoneMatch, options).then((request) => request(this.axios, this.basePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all asset of a device that are in the database, ID only.
|
||||||
|
* @param {AssetApiGetAllUserAssetsByDeviceIdRequest} requestParameters Request parameters.
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
* @memberof AssetApi
|
||||||
|
*/
|
||||||
|
public getAllUserAssetsByDeviceId(requestParameters: AssetApiGetAllUserAssetsByDeviceIdRequest, options?: AxiosRequestConfig) {
|
||||||
|
return AssetApiFp(this.configuration).getAllUserAssetsByDeviceId(requestParameters.deviceId, options).then((request) => request(this.axios, this.basePath));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a single asset\'s information
|
* Get a single asset\'s information
|
||||||
* @param {AssetApiGetAssetByIdRequest} requestParameters Request parameters.
|
* @param {AssetApiGetAssetByIdRequest} requestParameters Request parameters.
|
||||||
@ -10104,9 +10196,11 @@ export class AssetApi extends BaseAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all asset of a device that are in the database, ID only.
|
*
|
||||||
|
* @summary Use /asset/device/:deviceId instead - Remove in 1.92 release
|
||||||
* @param {AssetApiGetUserAssetsByDeviceIdRequest} requestParameters Request parameters.
|
* @param {AssetApiGetUserAssetsByDeviceIdRequest} requestParameters Request parameters.
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
|
* @deprecated
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
* @memberof AssetApi
|
* @memberof AssetApi
|
||||||
*/
|
*/
|
||||||
|
@ -169,4 +169,4 @@ SPEC CHECKSUMS:
|
|||||||
|
|
||||||
PODFILE CHECKSUM: 599d8aeb73728400c15364e734525722250a5382
|
PODFILE CHECKSUM: 599d8aeb73728400c15364e734525722250a5382
|
||||||
|
|
||||||
COCOAPODS: 1.12.1
|
COCOAPODS: 1.11.3
|
||||||
|
@ -42,6 +42,9 @@ class BackupService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return await _apiService.assetApi.getUserAssetsByDeviceId(deviceId);
|
return await _apiService.assetApi.getUserAssetsByDeviceId(deviceId);
|
||||||
|
|
||||||
|
// TODO! Start using this in 1.92.0
|
||||||
|
// return await _apiService.assetApi.getAllUserAssetsByDeviceId(deviceId);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint('Error [getDeviceBackupAsset] ${e.toString()}');
|
debugPrint('Error [getDeviceBackupAsset] ${e.toString()}');
|
||||||
return null;
|
return null;
|
||||||
|
BIN
mobile/openapi/README.md
generated
BIN
mobile/openapi/README.md
generated
Binary file not shown.
BIN
mobile/openapi/doc/AssetApi.md
generated
BIN
mobile/openapi/doc/AssetApi.md
generated
Binary file not shown.
BIN
mobile/openapi/lib/api/asset_api.dart
generated
BIN
mobile/openapi/lib/api/asset_api.dart
generated
Binary file not shown.
BIN
mobile/openapi/test/asset_api_test.dart
generated
BIN
mobile/openapi/test/asset_api_test.dart
generated
Binary file not shown.
@ -1219,6 +1219,51 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/asset/device/{deviceId}": {
|
||||||
|
"get": {
|
||||||
|
"description": "Get all asset of a device that are in the database, ID only.",
|
||||||
|
"operationId": "getAllUserAssetsByDeviceId",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "deviceId",
|
||||||
|
"required": true,
|
||||||
|
"in": "path",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": "array"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"bearer": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cookie": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"api_key": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Asset"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"/asset/download/archive": {
|
"/asset/download/archive": {
|
||||||
"post": {
|
"post": {
|
||||||
"operationId": "downloadArchive",
|
"operationId": "downloadArchive",
|
||||||
@ -2281,7 +2326,7 @@
|
|||||||
},
|
},
|
||||||
"/asset/{deviceId}": {
|
"/asset/{deviceId}": {
|
||||||
"get": {
|
"get": {
|
||||||
"description": "Get all asset of a device that are in the database, ID only.",
|
"deprecated": true,
|
||||||
"operationId": "getUserAssetsByDeviceId",
|
"operationId": "getUserAssetsByDeviceId",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
@ -2289,7 +2334,6 @@
|
|||||||
"required": true,
|
"required": true,
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"schema": {
|
"schema": {
|
||||||
"format": "uuid",
|
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2320,6 +2364,7 @@
|
|||||||
"api_key": []
|
"api_key": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"summary": "Use /asset/device/:deviceId instead - Remove in 1.92 release",
|
||||||
"tags": [
|
"tags": [
|
||||||
"Asset"
|
"Asset"
|
||||||
]
|
]
|
||||||
|
@ -1067,4 +1067,18 @@ describe(AssetService.name, () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('get assets by device id', async () => {
|
||||||
|
const assets = [assetStub.image, assetStub.image1];
|
||||||
|
|
||||||
|
assetMock.getAllByDeviceId.mockImplementation(() =>
|
||||||
|
Promise.resolve<string[]>(Array.from(assets.map((asset) => asset.deviceAssetId))),
|
||||||
|
);
|
||||||
|
|
||||||
|
const deviceId = 'device-id';
|
||||||
|
const result = await sut.getUserAssetsByDeviceId(authStub.user1, deviceId);
|
||||||
|
|
||||||
|
expect(result.length).toEqual(2);
|
||||||
|
expect(result).toEqual(assets.map((asset) => asset.deviceAssetId));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -386,6 +386,10 @@ export class AssetService {
|
|||||||
return assets.map((a) => mapAsset(a));
|
return assets.map((a) => mapAsset(a));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getUserAssetsByDeviceId(authUser: AuthUserDto, deviceId: string) {
|
||||||
|
return this.assetRepository.getAllByDeviceId(authUser.id, deviceId);
|
||||||
|
}
|
||||||
|
|
||||||
async update(authUser: AuthUserDto, id: string, dto: UpdateAssetDto): Promise<AssetResponseDto> {
|
async update(authUser: AuthUserDto, id: string, dto: UpdateAssetDto): Promise<AssetResponseDto> {
|
||||||
await this.access.requirePermission(authUser, Permission.ASSET_UPDATE, id);
|
await this.access.requirePermission(authUser, Permission.ASSET_UPDATE, id);
|
||||||
|
|
||||||
|
@ -162,6 +162,7 @@ export interface IAssetRepository {
|
|||||||
getByLibraryIdAndOriginalPath(libraryId: string, originalPath: string): Promise<AssetEntity | null>;
|
getByLibraryIdAndOriginalPath(libraryId: string, originalPath: string): Promise<AssetEntity | null>;
|
||||||
deleteAll(ownerId: string): Promise<void>;
|
deleteAll(ownerId: string): Promise<void>;
|
||||||
getAll(pagination: PaginationOptions, options?: AssetSearchOptions): Paginated<AssetEntity>;
|
getAll(pagination: PaginationOptions, options?: AssetSearchOptions): Paginated<AssetEntity>;
|
||||||
|
getAllByDeviceId(userId: string, deviceId: string): Promise<string[]>;
|
||||||
updateAll(ids: string[], options: Partial<AssetEntity>): Promise<void>;
|
updateAll(ids: string[], options: Partial<AssetEntity>): Promise<void>;
|
||||||
save(asset: Pick<AssetEntity, 'id'> & Partial<AssetEntity>): Promise<AssetEntity>;
|
save(asset: Pick<AssetEntity, 'id'> & Partial<AssetEntity>): Promise<AssetEntity>;
|
||||||
remove(asset: AssetEntity): Promise<void>;
|
remove(asset: AssetEntity): Promise<void>;
|
||||||
|
@ -14,7 +14,7 @@ import {
|
|||||||
UseInterceptors,
|
UseInterceptors,
|
||||||
ValidationPipe,
|
ValidationPipe,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiBody, ApiConsumes, ApiHeader, ApiOkResponse, ApiTags } from '@nestjs/swagger';
|
import { ApiBody, ApiConsumes, ApiHeader, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||||
import { Response as Res } from 'express';
|
import { Response as Res } from 'express';
|
||||||
import { AuthUser, Authenticated, SharedLinkRoute } from '../../app.guard';
|
import { AuthUser, Authenticated, SharedLinkRoute } from '../../app.guard';
|
||||||
import { UUIDParamDto } from '../../controllers/dto/uuid-param.dto';
|
import { UUIDParamDto } from '../../controllers/dto/uuid-param.dto';
|
||||||
@ -147,9 +147,10 @@ export class AssetController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all asset of a device that are in the database, ID only.
|
* @deprecated Use /asset/device/:deviceId instead - Remove at 1.92 release
|
||||||
*/
|
*/
|
||||||
@Get('/:deviceId')
|
@Get('/:deviceId')
|
||||||
|
@ApiOperation({ deprecated: true, summary: 'Use /asset/device/:deviceId instead - Remove in 1.92 release' })
|
||||||
getUserAssetsByDeviceId(@AuthUser() authUser: AuthUserDto, @Param() { deviceId }: DeviceIdDto) {
|
getUserAssetsByDeviceId(@AuthUser() authUser: AuthUserDto, @Param() { deviceId }: DeviceIdDto) {
|
||||||
return this.assetService.getUserAssetsByDeviceId(authUser, deviceId);
|
return this.assetService.getUserAssetsByDeviceId(authUser, deviceId);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { IsNotEmpty, IsString } from 'class-validator';
|
||||||
import { IsNotEmpty, IsUUID } from 'class-validator';
|
|
||||||
|
|
||||||
export class DeviceIdDto {
|
export class DeviceIdDto {
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@IsUUID('4')
|
@IsString()
|
||||||
@ApiProperty({ format: 'uuid' })
|
|
||||||
deviceId!: string;
|
deviceId!: string;
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ import {
|
|||||||
StreamableFile,
|
StreamableFile,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiOkResponse, ApiTags } from '@nestjs/swagger';
|
import { ApiOkResponse, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { DeviceIdDto } from '../api-v1/asset/dto/device-id.dto';
|
||||||
import { AuthUser, Authenticated, SharedLinkRoute } from '../app.guard';
|
import { AuthUser, Authenticated, SharedLinkRoute } from '../app.guard';
|
||||||
import { UseValidation, asStreamableFile } from '../app.utils';
|
import { UseValidation, asStreamableFile } from '../app.utils';
|
||||||
import { Route } from '../interceptors';
|
import { Route } from '../interceptors';
|
||||||
@ -100,6 +101,14 @@ export class AssetController {
|
|||||||
return this.service.downloadFile(authUser, id).then(asStreamableFile);
|
return this.service.downloadFile(authUser, id).then(asStreamableFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all asset of a device that are in the database, ID only.
|
||||||
|
*/
|
||||||
|
@Get('/device/:deviceId')
|
||||||
|
getAllUserAssetsByDeviceId(@AuthUser() authUser: AuthUserDto, @Param() { deviceId }: DeviceIdDto) {
|
||||||
|
return this.service.getUserAssetsByDeviceId(authUser, deviceId);
|
||||||
|
}
|
||||||
|
|
||||||
@Get('statistics')
|
@Get('statistics')
|
||||||
getAssetStatistics(@AuthUser() authUser: AuthUserDto, @Query() dto: AssetStatsDto): Promise<AssetStatsResponseDto> {
|
getAssetStatistics(@AuthUser() authUser: AuthUserDto, @Query() dto: AssetStatsDto): Promise<AssetStatsResponseDto> {
|
||||||
return this.service.getStatistics(authUser, dto);
|
return this.service.getStatistics(authUser, dto);
|
||||||
|
@ -19,11 +19,6 @@ import { UseValidation } from '../app.utils';
|
|||||||
export class SearchController {
|
export class SearchController {
|
||||||
constructor(private service: SearchService) {}
|
constructor(private service: SearchService) {}
|
||||||
|
|
||||||
@Get('person')
|
|
||||||
searchPerson(@AuthUser() authUser: AuthUserDto, @Query() dto: SearchPeopleDto): Promise<PersonResponseDto[]> {
|
|
||||||
return this.service.searchPerson(authUser, dto);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
search(@AuthUser() authUser: AuthUserDto, @Query() dto: SearchDto): Promise<SearchResponseDto> {
|
search(@AuthUser() authUser: AuthUserDto, @Query() dto: SearchDto): Promise<SearchResponseDto> {
|
||||||
return this.service.search(authUser, dto);
|
return this.service.search(authUser, dto);
|
||||||
@ -33,4 +28,9 @@ export class SearchController {
|
|||||||
getExploreData(@AuthUser() authUser: AuthUserDto): Promise<SearchExploreResponseDto[]> {
|
getExploreData(@AuthUser() authUser: AuthUserDto): Promise<SearchExploreResponseDto[]> {
|
||||||
return this.service.getExploreData(authUser) as Promise<SearchExploreResponseDto[]>;
|
return this.service.getExploreData(authUser) as Promise<SearchExploreResponseDto[]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('person')
|
||||||
|
searchPerson(@AuthUser() authUser: AuthUserDto, @Query() dto: SearchPeopleDto): Promise<PersonResponseDto[]> {
|
||||||
|
return this.service.searchPerson(authUser, dto);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -326,6 +326,27 @@ export class AssetRepository implements IAssetRepository {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get assets by device's Id on the database
|
||||||
|
* @param ownerId
|
||||||
|
* @param deviceId
|
||||||
|
*
|
||||||
|
* @returns Promise<string[]> - Array of assetIds belong to the device
|
||||||
|
*/
|
||||||
|
async getAllByDeviceId(ownerId: string, deviceId: string): Promise<string[]> {
|
||||||
|
const items = await this.repository.find({
|
||||||
|
select: { deviceAssetId: true },
|
||||||
|
where: {
|
||||||
|
ownerId,
|
||||||
|
deviceId,
|
||||||
|
isVisible: true,
|
||||||
|
},
|
||||||
|
withDeleted: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
return items.map((asset) => asset.deviceAssetId);
|
||||||
|
}
|
||||||
|
|
||||||
getById(id: string): Promise<AssetEntity | null> {
|
getById(id: string): Promise<AssetEntity | null> {
|
||||||
return this.repository.findOne({
|
return this.repository.findOne({
|
||||||
where: { id },
|
where: { id },
|
||||||
|
@ -18,6 +18,7 @@ export const newAssetRepositoryMock = (): jest.Mocked<IAssetRepository> => {
|
|||||||
getFirstAssetForAlbumId: jest.fn(),
|
getFirstAssetForAlbumId: jest.fn(),
|
||||||
getLastUpdatedAssetForAlbumId: jest.fn(),
|
getLastUpdatedAssetForAlbumId: jest.fn(),
|
||||||
getAll: jest.fn().mockResolvedValue({ items: [], hasNextPage: false }),
|
getAll: jest.fn().mockResolvedValue({ items: [], hasNextPage: false }),
|
||||||
|
getAllByDeviceId: jest.fn(),
|
||||||
updateAll: jest.fn(),
|
updateAll: jest.fn(),
|
||||||
getByLibraryId: jest.fn(),
|
getByLibraryId: jest.fn(),
|
||||||
getByLibraryIdAndOriginalPath: jest.fn(),
|
getByLibraryIdAndOriginalPath: jest.fn(),
|
||||||
|
102
web/src/api/open-api/api.ts
generated
102
web/src/api/open-api/api.ts
generated
@ -6808,6 +6808,48 @@ export const AssetApiAxiosParamCreator = function (configuration?: Configuration
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
||||||
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||||
|
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: toPathString(localVarUrlObj),
|
||||||
|
options: localVarRequestOptions,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Get all asset of a device that are in the database, ID only.
|
||||||
|
* @param {string} deviceId
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
getAllUserAssetsByDeviceId: async (deviceId: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||||
|
// verify required parameter 'deviceId' is not null or undefined
|
||||||
|
assertParamExists('getAllUserAssetsByDeviceId', 'deviceId', deviceId)
|
||||||
|
const localVarPath = `/asset/device/{deviceId}`
|
||||||
|
.replace(`{${"deviceId"}}`, encodeURIComponent(String(deviceId)));
|
||||||
|
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||||
|
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||||
|
let baseOptions;
|
||||||
|
if (configuration) {
|
||||||
|
baseOptions = configuration.baseOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
|
||||||
|
const localVarHeaderParameter = {} as any;
|
||||||
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
|
// authentication cookie required
|
||||||
|
|
||||||
|
// authentication api_key required
|
||||||
|
await setApiKeyToObject(localVarHeaderParameter, "x-api-key", configuration)
|
||||||
|
|
||||||
|
// authentication bearer required
|
||||||
|
// http bearer authentication required
|
||||||
|
await setBearerAuthToObject(localVarHeaderParameter, configuration)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
||||||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||||
@ -7477,9 +7519,11 @@ export const AssetApiAxiosParamCreator = function (configuration?: Configuration
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Get all asset of a device that are in the database, ID only.
|
*
|
||||||
|
* @summary Use /asset/device/:deviceId instead - Remove in 1.92 release
|
||||||
* @param {string} deviceId
|
* @param {string} deviceId
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
|
* @deprecated
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
getUserAssetsByDeviceId: async (deviceId: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
getUserAssetsByDeviceId: async (deviceId: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||||
@ -8311,6 +8355,16 @@ export const AssetApiFp = function(configuration?: Configuration) {
|
|||||||
const localVarAxiosArgs = await localVarAxiosParamCreator.getAllAssets(skip, take, userId, isFavorite, isArchived, updatedAfter, updatedBefore, ifNoneMatch, options);
|
const localVarAxiosArgs = await localVarAxiosParamCreator.getAllAssets(skip, take, userId, isFavorite, isArchived, updatedAfter, updatedBefore, ifNoneMatch, options);
|
||||||
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Get all asset of a device that are in the database, ID only.
|
||||||
|
* @param {string} deviceId
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async getAllUserAssetsByDeviceId(deviceId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<string>>> {
|
||||||
|
const localVarAxiosArgs = await localVarAxiosParamCreator.getAllUserAssetsByDeviceId(deviceId, options);
|
||||||
|
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Get a single asset\'s information
|
* Get a single asset\'s information
|
||||||
* @param {string} id
|
* @param {string} id
|
||||||
@ -8458,9 +8512,11 @@ export const AssetApiFp = function(configuration?: Configuration) {
|
|||||||
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Get all asset of a device that are in the database, ID only.
|
*
|
||||||
|
* @summary Use /asset/device/:deviceId instead - Remove in 1.92 release
|
||||||
* @param {string} deviceId
|
* @param {string} deviceId
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
|
* @deprecated
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
async getUserAssetsByDeviceId(deviceId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<string>>> {
|
async getUserAssetsByDeviceId(deviceId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<string>>> {
|
||||||
@ -8686,6 +8742,15 @@ export const AssetApiFactory = function (configuration?: Configuration, basePath
|
|||||||
getAllAssets(requestParameters: AssetApiGetAllAssetsRequest = {}, options?: AxiosRequestConfig): AxiosPromise<Array<AssetResponseDto>> {
|
getAllAssets(requestParameters: AssetApiGetAllAssetsRequest = {}, options?: AxiosRequestConfig): AxiosPromise<Array<AssetResponseDto>> {
|
||||||
return localVarFp.getAllAssets(requestParameters.skip, requestParameters.take, requestParameters.userId, requestParameters.isFavorite, requestParameters.isArchived, requestParameters.updatedAfter, requestParameters.updatedBefore, requestParameters.ifNoneMatch, options).then((request) => request(axios, basePath));
|
return localVarFp.getAllAssets(requestParameters.skip, requestParameters.take, requestParameters.userId, requestParameters.isFavorite, requestParameters.isArchived, requestParameters.updatedAfter, requestParameters.updatedBefore, requestParameters.ifNoneMatch, options).then((request) => request(axios, basePath));
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Get all asset of a device that are in the database, ID only.
|
||||||
|
* @param {AssetApiGetAllUserAssetsByDeviceIdRequest} requestParameters Request parameters.
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
getAllUserAssetsByDeviceId(requestParameters: AssetApiGetAllUserAssetsByDeviceIdRequest, options?: AxiosRequestConfig): AxiosPromise<Array<string>> {
|
||||||
|
return localVarFp.getAllUserAssetsByDeviceId(requestParameters.deviceId, options).then((request) => request(axios, basePath));
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Get a single asset\'s information
|
* Get a single asset\'s information
|
||||||
* @param {AssetApiGetAssetByIdRequest} requestParameters Request parameters.
|
* @param {AssetApiGetAssetByIdRequest} requestParameters Request parameters.
|
||||||
@ -8792,9 +8857,11 @@ export const AssetApiFactory = function (configuration?: Configuration, basePath
|
|||||||
return localVarFp.getTimeBuckets(requestParameters.size, requestParameters.userId, requestParameters.albumId, requestParameters.personId, requestParameters.isArchived, requestParameters.isFavorite, requestParameters.isTrashed, requestParameters.withStacked, requestParameters.withPartners, requestParameters.key, options).then((request) => request(axios, basePath));
|
return localVarFp.getTimeBuckets(requestParameters.size, requestParameters.userId, requestParameters.albumId, requestParameters.personId, requestParameters.isArchived, requestParameters.isFavorite, requestParameters.isTrashed, requestParameters.withStacked, requestParameters.withPartners, requestParameters.key, options).then((request) => request(axios, basePath));
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Get all asset of a device that are in the database, ID only.
|
*
|
||||||
|
* @summary Use /asset/device/:deviceId instead - Remove in 1.92 release
|
||||||
* @param {AssetApiGetUserAssetsByDeviceIdRequest} requestParameters Request parameters.
|
* @param {AssetApiGetUserAssetsByDeviceIdRequest} requestParameters Request parameters.
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
|
* @deprecated
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
getUserAssetsByDeviceId(requestParameters: AssetApiGetUserAssetsByDeviceIdRequest, options?: AxiosRequestConfig): AxiosPromise<Array<string>> {
|
getUserAssetsByDeviceId(requestParameters: AssetApiGetUserAssetsByDeviceIdRequest, options?: AxiosRequestConfig): AxiosPromise<Array<string>> {
|
||||||
@ -9030,6 +9097,20 @@ export interface AssetApiGetAllAssetsRequest {
|
|||||||
readonly ifNoneMatch?: string
|
readonly ifNoneMatch?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request parameters for getAllUserAssetsByDeviceId operation in AssetApi.
|
||||||
|
* @export
|
||||||
|
* @interface AssetApiGetAllUserAssetsByDeviceIdRequest
|
||||||
|
*/
|
||||||
|
export interface AssetApiGetAllUserAssetsByDeviceIdRequest {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof AssetApiGetAllUserAssetsByDeviceId
|
||||||
|
*/
|
||||||
|
readonly deviceId: string
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request parameters for getAssetById operation in AssetApi.
|
* Request parameters for getAssetById operation in AssetApi.
|
||||||
* @export
|
* @export
|
||||||
@ -9974,6 +10055,17 @@ export class AssetApi extends BaseAPI {
|
|||||||
return AssetApiFp(this.configuration).getAllAssets(requestParameters.skip, requestParameters.take, requestParameters.userId, requestParameters.isFavorite, requestParameters.isArchived, requestParameters.updatedAfter, requestParameters.updatedBefore, requestParameters.ifNoneMatch, options).then((request) => request(this.axios, this.basePath));
|
return AssetApiFp(this.configuration).getAllAssets(requestParameters.skip, requestParameters.take, requestParameters.userId, requestParameters.isFavorite, requestParameters.isArchived, requestParameters.updatedAfter, requestParameters.updatedBefore, requestParameters.ifNoneMatch, options).then((request) => request(this.axios, this.basePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all asset of a device that are in the database, ID only.
|
||||||
|
* @param {AssetApiGetAllUserAssetsByDeviceIdRequest} requestParameters Request parameters.
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
* @memberof AssetApi
|
||||||
|
*/
|
||||||
|
public getAllUserAssetsByDeviceId(requestParameters: AssetApiGetAllUserAssetsByDeviceIdRequest, options?: AxiosRequestConfig) {
|
||||||
|
return AssetApiFp(this.configuration).getAllUserAssetsByDeviceId(requestParameters.deviceId, options).then((request) => request(this.axios, this.basePath));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a single asset\'s information
|
* Get a single asset\'s information
|
||||||
* @param {AssetApiGetAssetByIdRequest} requestParameters Request parameters.
|
* @param {AssetApiGetAssetByIdRequest} requestParameters Request parameters.
|
||||||
@ -10104,9 +10196,11 @@ export class AssetApi extends BaseAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all asset of a device that are in the database, ID only.
|
*
|
||||||
|
* @summary Use /asset/device/:deviceId instead - Remove in 1.92 release
|
||||||
* @param {AssetApiGetUserAssetsByDeviceIdRequest} requestParameters Request parameters.
|
* @param {AssetApiGetUserAssetsByDeviceIdRequest} requestParameters Request parameters.
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
|
* @deprecated
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
* @memberof AssetApi
|
* @memberof AssetApi
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user