src / image_search / models.ts
src / image_search / models.ts
/**
* Image Search data models for Browse.
* Mapped from Python `image_search/models.py`.
*/
export interface ImageSearchResultOptions {
title: string;
imageUrl: string;
sourceUrl: string;
sourceDomain?: string;
width?: number;
height?: number;
thumbnailUrl?: string;
raw?: Record<string, unknown>;
}
/**
* Standardized normalized image search result representation.
* Mapped from Python `ImageSearchResult` dataclass.
*/
export interface ImageSearchResult {
title: string;
imageUrl: string;
sourceUrl: string;
sourceDomain?: string;
width?: number;
height?: number;
thumbnailUrl?: string;
raw?: Record<string, unknown>;
}
export interface LocalImageOptions {
title: string;
localFilename: string;
localPath: string;
originalUrl: string;
provider: string;
width?: number;
height?: number;
sourceUrl?: string;
sourceDomain?: string;
}
/**
* Representation of a locally downloaded and cached search result image.
* Mapped from Python `LocalImage` dataclass.
*/
export class LocalImage {
public title: string;
public localFilename: string;
public localPath: string;
public originalUrl: string;
public provider: string;
public width?: number;
public height?: number;
public sourceUrl?: string;
public sourceDomain?: string;
constructor(options: LocalImageOptions) {
this.title = options.title;
this.localFilename = options.localFilename;
this.localPath = options.localPath;
this.originalUrl = options.originalUrl;
this.provider = options.provider;
this.width = options.width;
this.height = options.height;
this.sourceUrl = options.sourceUrl;
this.sourceDomain = options.sourceDomain;
}
/**
* Serialize LocalImage instance into a clean dictionary for LLM and MCP consumption.
* Mapped from Python `LocalImage.to_dict()`.
*/
public toDict(): Record<string, unknown> {
const data: Record<string, unknown> = {
title: this.title,
local_filename: this.localFilename,
local_path: this.localPath,
original_url: this.originalUrl,
provider: this.provider,
};
if (this.width !== undefined) {
data.width = this.width;
}
if (this.height !== undefined) {
data.height = this.height;
}
if (this.sourceUrl) {
data.source_url = this.sourceUrl;
}
if (this.sourceDomain) {
data.source_domain = this.sourceDomain;
}
return data;
}
}
/**
* Image Search data models for Browse.
* Mapped from Python `image_search/models.py`.
*/
export interface ImageSearchResultOptions {
title: string;
imageUrl: string;
sourceUrl: string;
sourceDomain?: string;
width?: number;
height?: number;
thumbnailUrl?: string;
raw?: Record<string, unknown>;
}
/**
* Standardized normalized image search result representation.
* Mapped from Python `ImageSearchResult` dataclass.
*/
export interface ImageSearchResult {
title: string;
imageUrl: string;
sourceUrl: string;
sourceDomain?: string;
width?: number;
height?: number;
thumbnailUrl?: string;
raw?: Record<string, unknown>;
}
export interface LocalImageOptions {
title: string;
localFilename: string;
localPath: string;
originalUrl: string;
provider: string;
width?: number;
height?: number;
sourceUrl?: string;
sourceDomain?: string;
}
/**
* Representation of a locally downloaded and cached search result image.
* Mapped from Python `LocalImage` dataclass.
*/
export class LocalImage {
public title: string;
public localFilename: string;
public localPath: string;
public originalUrl: string;
public provider: string;
public width?: number;
public height?: number;
public sourceUrl?: string;
public sourceDomain?: string;
constructor(options: LocalImageOptions) {
this.title = options.title;
this.localFilename = options.localFilename;
this.localPath = options.localPath;
this.originalUrl = options.originalUrl;
this.provider = options.provider;
this.width = options.width;
this.height = options.height;
this.sourceUrl = options.sourceUrl;
this.sourceDomain = options.sourceDomain;
}
/**
* Serialize LocalImage instance into a clean dictionary for LLM and MCP consumption.
* Mapped from Python `LocalImage.to_dict()`.
*/
public toDict(): Record<string, unknown> {
const data: Record<string, unknown> = {
title: this.title,
local_filename: this.localFilename,
local_path: this.localPath,
original_url: this.originalUrl,
provider: this.provider,
};
if (this.width !== undefined) {
data.width = this.width;
}
if (this.height !== undefined) {
data.height = this.height;
}
if (this.sourceUrl) {
data.source_url = this.sourceUrl;
}
if (this.sourceDomain) {
data.source_domain = this.sourceDomain;
}
return data;
}
}