2024-03-20 16:02:51 -05:00
|
|
|
import { AssetFaceEntity } from 'src/entities/asset-face.entity';
|
2024-08-15 06:57:01 -04:00
|
|
|
import { AssetEntity } from 'src/entities/asset.entity';
|
2024-03-20 16:02:51 -05:00
|
|
|
import { GeodataPlacesEntity } from 'src/entities/geodata-places.entity';
|
2024-09-18 09:57:52 -04:00
|
|
|
import { AssetStatus, AssetType } from 'src/enum';
|
2024-03-20 22:15:09 -05:00
|
|
|
import { Paginated } from 'src/utils/pagination';
|
2024-02-12 20:50:47 -05:00
|
|
|
|
|
|
|
export const ISearchRepository = 'ISearchRepository';
|
2023-03-02 21:47:08 -05:00
|
|
|
|
|
|
|
export interface SearchResult<T> {
|
|
|
|
/** total matches */
|
|
|
|
total: number;
|
|
|
|
/** collection size */
|
|
|
|
count: number;
|
|
|
|
/** current page */
|
|
|
|
page: number;
|
|
|
|
/** items for page */
|
|
|
|
items: T[];
|
2023-05-17 13:07:17 -04:00
|
|
|
/** score */
|
|
|
|
distances: number[];
|
2023-03-02 21:47:08 -05:00
|
|
|
facets: SearchFacet[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SearchFacet {
|
|
|
|
fieldName: string;
|
|
|
|
counts: Array<{
|
|
|
|
count: number;
|
|
|
|
value: string;
|
|
|
|
}>;
|
|
|
|
}
|
|
|
|
|
2023-12-08 11:15:46 -05:00
|
|
|
export type SearchExploreItemSet<T> = Array<{
|
|
|
|
value: string;
|
|
|
|
data: T;
|
|
|
|
}>;
|
|
|
|
|
2023-03-05 15:44:31 -05:00
|
|
|
export interface SearchExploreItem<T> {
|
|
|
|
fieldName: string;
|
2023-12-08 11:15:46 -05:00
|
|
|
items: SearchExploreItemSet<T>;
|
2023-03-02 21:47:08 -05:00
|
|
|
}
|
2024-02-12 20:50:47 -05:00
|
|
|
|
|
|
|
export interface SearchAssetIDOptions {
|
|
|
|
checksum?: Buffer;
|
|
|
|
deviceAssetId?: string;
|
|
|
|
id?: string;
|
|
|
|
}
|
|
|
|
|
2024-02-17 11:00:55 -06:00
|
|
|
export interface SearchUserIdOptions {
|
2024-02-12 20:50:47 -05:00
|
|
|
deviceId?: string;
|
2024-06-21 01:02:05 +02:00
|
|
|
libraryId?: string | null;
|
2024-02-17 11:00:55 -06:00
|
|
|
userIds?: string[];
|
2024-02-12 20:50:47 -05:00
|
|
|
}
|
|
|
|
|
2024-02-17 11:00:55 -06:00
|
|
|
export type SearchIdOptions = SearchAssetIDOptions & SearchUserIdOptions;
|
2024-02-12 20:50:47 -05:00
|
|
|
|
|
|
|
export interface SearchStatusOptions {
|
|
|
|
isArchived?: boolean;
|
|
|
|
isEncoded?: boolean;
|
|
|
|
isFavorite?: boolean;
|
|
|
|
isMotion?: boolean;
|
|
|
|
isOffline?: boolean;
|
|
|
|
isVisible?: boolean;
|
2024-02-17 11:00:55 -06:00
|
|
|
isNotInAlbum?: boolean;
|
2024-02-12 20:50:47 -05:00
|
|
|
type?: AssetType;
|
2024-09-18 09:57:52 -04:00
|
|
|
status?: AssetStatus;
|
2024-02-12 20:50:47 -05:00
|
|
|
withArchived?: boolean;
|
|
|
|
withDeleted?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SearchOneToOneRelationOptions {
|
|
|
|
withExif?: boolean;
|
2024-03-05 23:44:56 -06:00
|
|
|
withStacked?: boolean;
|
2024-02-12 20:50:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface SearchRelationOptions extends SearchOneToOneRelationOptions {
|
|
|
|
withFaces?: boolean;
|
|
|
|
withPeople?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SearchDateOptions {
|
|
|
|
createdBefore?: Date;
|
|
|
|
createdAfter?: Date;
|
|
|
|
takenBefore?: Date;
|
|
|
|
takenAfter?: Date;
|
|
|
|
trashedBefore?: Date;
|
|
|
|
trashedAfter?: Date;
|
|
|
|
updatedBefore?: Date;
|
|
|
|
updatedAfter?: Date;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SearchPathOptions {
|
|
|
|
encodedVideoPath?: string;
|
|
|
|
originalFileName?: string;
|
|
|
|
originalPath?: string;
|
2024-04-02 00:56:56 -04:00
|
|
|
previewPath?: string;
|
|
|
|
thumbnailPath?: string;
|
2024-02-12 20:50:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface SearchExifOptions {
|
2024-08-01 21:27:40 -06:00
|
|
|
city?: string | null;
|
|
|
|
country?: string | null;
|
|
|
|
lensModel?: string | null;
|
|
|
|
make?: string | null;
|
|
|
|
model?: string | null;
|
|
|
|
state?: string | null;
|
2024-02-12 20:50:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface SearchEmbeddingOptions {
|
2024-06-06 23:09:47 -04:00
|
|
|
embedding: number[];
|
2024-02-12 20:50:47 -05:00
|
|
|
userIds: string[];
|
|
|
|
}
|
|
|
|
|
2024-02-17 11:00:55 -06:00
|
|
|
export interface SearchPeopleOptions {
|
|
|
|
personIds?: string[];
|
|
|
|
}
|
|
|
|
|
2024-02-12 20:50:47 -05:00
|
|
|
export interface SearchOrderOptions {
|
|
|
|
orderDirection?: 'ASC' | 'DESC';
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SearchPaginationOptions {
|
|
|
|
page: number;
|
|
|
|
size: number;
|
|
|
|
}
|
|
|
|
|
2024-02-18 13:22:25 -05:00
|
|
|
type BaseAssetSearchOptions = SearchDateOptions &
|
2024-02-17 11:00:55 -06:00
|
|
|
SearchIdOptions &
|
2024-02-12 20:50:47 -05:00
|
|
|
SearchExifOptions &
|
|
|
|
SearchOrderOptions &
|
|
|
|
SearchPathOptions &
|
2024-02-17 11:00:55 -06:00
|
|
|
SearchStatusOptions &
|
|
|
|
SearchUserIdOptions &
|
|
|
|
SearchPeopleOptions;
|
2024-02-12 20:50:47 -05:00
|
|
|
|
2024-02-18 13:22:25 -05:00
|
|
|
export type AssetSearchOptions = BaseAssetSearchOptions & SearchRelationOptions;
|
|
|
|
|
|
|
|
export type AssetSearchOneToOneRelationOptions = BaseAssetSearchOptions & SearchOneToOneRelationOptions;
|
|
|
|
|
2024-02-12 20:50:47 -05:00
|
|
|
export type AssetSearchBuilderOptions = Omit<AssetSearchOptions, 'orderDirection'>;
|
|
|
|
|
|
|
|
export type SmartSearchOptions = SearchDateOptions &
|
|
|
|
SearchEmbeddingOptions &
|
|
|
|
SearchExifOptions &
|
|
|
|
SearchOneToOneRelationOptions &
|
|
|
|
SearchStatusOptions &
|
2024-02-17 11:00:55 -06:00
|
|
|
SearchUserIdOptions &
|
|
|
|
SearchPeopleOptions;
|
2024-02-12 20:50:47 -05:00
|
|
|
|
|
|
|
export interface FaceEmbeddingSearch extends SearchEmbeddingOptions {
|
|
|
|
hasPerson?: boolean;
|
|
|
|
numResults: number;
|
|
|
|
maxDistance?: number;
|
|
|
|
}
|
|
|
|
|
2024-05-16 13:08:37 -04:00
|
|
|
export interface AssetDuplicateSearch {
|
|
|
|
assetId: string;
|
2024-06-06 23:09:47 -04:00
|
|
|
embedding: number[];
|
2024-05-16 13:08:37 -04:00
|
|
|
maxDistance?: number;
|
2024-05-26 18:04:23 -04:00
|
|
|
type: AssetType;
|
|
|
|
userIds: string[];
|
2024-05-16 13:08:37 -04:00
|
|
|
}
|
|
|
|
|
2024-02-12 20:50:47 -05:00
|
|
|
export interface FaceSearchResult {
|
|
|
|
distance: number;
|
|
|
|
face: AssetFaceEntity;
|
|
|
|
}
|
|
|
|
|
2024-05-16 13:08:37 -04:00
|
|
|
export interface AssetDuplicateResult {
|
|
|
|
assetId: string;
|
|
|
|
duplicateId: string | null;
|
|
|
|
distance: number;
|
|
|
|
}
|
|
|
|
|
2024-02-12 20:50:47 -05:00
|
|
|
export interface ISearchRepository {
|
|
|
|
searchMetadata(pagination: SearchPaginationOptions, options: AssetSearchOptions): Paginated<AssetEntity>;
|
|
|
|
searchSmart(pagination: SearchPaginationOptions, options: SmartSearchOptions): Paginated<AssetEntity>;
|
2024-05-16 13:08:37 -04:00
|
|
|
searchDuplicates(options: AssetDuplicateSearch): Promise<AssetDuplicateResult[]>;
|
2024-02-12 20:50:47 -05:00
|
|
|
searchFaces(search: FaceEmbeddingSearch): Promise<FaceSearchResult[]>;
|
2024-09-30 00:29:35 -04:00
|
|
|
searchRandom(size: number, options: AssetSearchOptions): Promise<AssetEntity[]>;
|
2024-03-23 14:37:06 -04:00
|
|
|
upsert(assetId: string, embedding: number[]): Promise<void>;
|
2024-02-24 01:42:37 +01:00
|
|
|
searchPlaces(placeName: string): Promise<GeodataPlacesEntity[]>;
|
2024-03-19 23:23:57 -04:00
|
|
|
getAssetsByCity(userIds: string[]): Promise<AssetEntity[]>;
|
2024-02-27 10:24:23 -05:00
|
|
|
deleteAllSearchEmbeddings(): Promise<void>;
|
2024-08-04 17:00:36 -04:00
|
|
|
getDimensionSize(): Promise<number>;
|
|
|
|
setDimensionSize(dimSize: number): Promise<void>;
|
2024-09-18 08:44:22 -04:00
|
|
|
getCountries(userIds: string[]): Promise<Array<string | null>>;
|
|
|
|
getStates(userIds: string[], country?: string): Promise<Array<string | null>>;
|
|
|
|
getCities(userIds: string[], country?: string, state?: string): Promise<Array<string | null>>;
|
|
|
|
getCameraMakes(userIds: string[], model?: string): Promise<Array<string | null>>;
|
|
|
|
getCameraModels(userIds: string[], make?: string): Promise<Array<string | null>>;
|
2024-02-12 20:50:47 -05:00
|
|
|
}
|