// Copyright © 2022-2026 Partium, Inc. DBA Partium import { Observable } from 'rxjs'; import { PFile } from '../../core/models/p-file'; import { PartiumConfig } from '../../core/models/partium-config'; import { BaseLoginInitService } from '../../core/services/base-login-init.service'; import { DownloadStatus } from '../../core/services/http/file-transfer/file-transfer.service.interface'; import { BACKEND_SERVICE } from '../../core/services/http/https.service.interface'; import { ServiceProvider } from '../../core/services/service-provider'; import { EventContext, Organization } from '../../core'; export interface AssetEventContext extends EventContext { /** Organization id used for V2 event logging (e.g. image-dimensions log). */ organizationId: string; searchSessionId?: string; } export interface ImageUploadApiResponse { assetId: string; } export interface ImageDownloadUrlsApiResponse { urls: Record; } /** * Service for creating and uploading assets of different types. */ export interface AssetService { /** * Upload an image that can be reused in subsequent searches without uploading it again. * The returned assetId can be passed as `searchImageAssetId` in the search-input of performSearch. * It is also possible to use the image for other purpose, such as CSA-metadata. * * Only available on platforms that support multipart-upload (see PFile.supportsMultipartUpload). * On other platforms an SdkError with code MULTIPART_UPLOAD_NOT_SUPPORTED is emitted. * * @param image the image to upload * @param organizationName (optional) organization name to associate with the uploaded image. * If not provided, the authenticated user's default organization is used by the backend. * @param assetEventContext AssetEventContext for V2 event logging. Must include `organizationId`; pass `searchSessionId` to associate the image-dimensions-log with an existing search-session. * @returns Observable that resolves with the assetId of the uploaded image */ uploadImage(image: PFile, organizationName: string | undefined, assetEventContext: AssetEventContext): Observable; /** * Download an image by its assetId and preferred size. * * @param assetId the assetId of the image that should be downloaded * @param size the names of the sizes this image is available in eg: "original", "thumbnail", "medium" * @param origin the origin of the image (defaults to PARTIUM; pass DATA for data-backend images) * @returns an Observable that resolves with the DownloadStatus of the download, which contains * the progress and the PFile as soon as it is finished */ downloadImage(assetId: string, size?: string, origin?: BACKEND_SERVICE): Observable; /** * Get the download urls of an image by its assetId. * * @param assetId the assetId of the image that should be downloaded * @returns an Observable that resolves with the download urls of the image in the form of { size: url } */ getImageDownloadUrls(assetId: string): Observable>; } export declare class AssetServiceImpl extends BaseLoginInitService implements AssetService { private httpsService; private fileTransferService; private fileService; private logService; constructor(serviceProvider: ServiceProvider); onCreate(): void; /** * Called on login */ init(config: PartiumConfig, userEmail: string, currentOrganization$: Observable): Observable; uploadImage(image: PFile, organizationName: string | undefined, assetEventContext: AssetEventContext): Observable; downloadImage(assetId: string, size?: string, origin?: BACKEND_SERVICE): Observable; getImageDownloadUrls(assetId: string): Observable>; /** * Check if the asset is an image and, in that case, log its dimensions. * Fire-and-forget: failures only get logged to the console and never affect the upload itself. * * @param image PFile * @param assetEventContext AssetEventContext */ private logImageDimensions; /** * Get the download url of an image by its assetId. * * @param assetId the assetId of the image that should be downloaded * @param size the names of the sizes this image is available in eg: "original", "thumbnail", "medium" * @returns Observable that resolves with an object containing the url, where the image * can be downloaded and the assetId of the image */ private getImageUrl; /** * Get the temporary download url of an image by its assetId and preferred size * * @param assetId the assetId of image * @param size the names of the sizes this image is available in eg: "original", "thumbnail", "medium" * @returns Observable that resolves with an object containing the temporary url, where the image * can be downloaded and the assetId of the image */ private getDataImageUrl; private resolveDownloadUrlForSize; }