import type { PaginationOptions, RequestCallbacks } from '../shared.d.ts';

export interface App {
    uid: string;
    name: string;
    index_url: string;
    title?: string;
    description?: string;
    icon?: string;
    maximize_on_start?: boolean;
    background?: boolean;
    filetype_associations?: string[];
    metadata?: Record<string, unknown>;
    created_at?: string;
    open_count?: number;
    user_count?: number;
}

export interface AppListOptions extends PaginationOptions {
    stats_period?: string;
    icon_size?: null | 16 | 32 | 64 | 128 | 256 | 512;
}

export interface CreateAppOptions extends RequestCallbacks<App> {
    name: string;
    indexURL: string;
    title?: string;
    description?: string;
    icon?: string;
    maximizeOnStart?: boolean;
    background?: boolean;
    filetypeAssociations?: string[];
    metadata?: Record<string, unknown>;
    dedupeName?: boolean;
}

export interface UpdateAppAttributes extends RequestCallbacks<App> {
    name?: string;
    indexURL?: string;
    title?: string;
    description?: string;
    icon?: string;
    maximizeOnStart?: boolean;
    background?: boolean;
    filetypeAssociations?: string[];
    metadata?: Record<string, unknown>;
}

export class Apps {
    list (options?: AppListOptions): Promise<App[]>;
    create (name: string, indexURL: string, title?: string): Promise<App>;
    create (options: CreateAppOptions): Promise<App>;
    update (name: string, attributes: UpdateAppAttributes): Promise<App>;
    get (name: string, options?: AppListOptions): Promise<App>;
    delete (name: string): Promise<{ success?: boolean }>;
    getDeveloperProfile (options?: RequestCallbacks<Record<string, unknown>>): Promise<Record<string, unknown>>;
}
