import { BaseModel } from './BaseModel'; import { ModelManager } from './ModelManager'; import { ServiceStore } from '../store/ServiceStore'; import { ServiceParent, ServiceModelUpdateOptions } from '../types/models/ServiceModel'; import { PrimaryKey } from '../types/models/ModelManager'; import Dictionary from '../types/Dictionary'; /** * ServiceModel * Model with service interface to retrieve data from backend api */ export declare class ServiceModel extends BaseModel { /** * Default URL definition for backend APIs * Fill either LIST/DETAIL or BASE url or use other urls by overwriting getListUrl/getDetailUrl */ protected static urls: { BASE?: string | null; LIST?: string | null; DETAIL?: string | null; } | string; /** * List of parent names to be used in url */ protected static parentNames: string[]; /** * Duration to cache requested data in seconds. 0: no cache. null: Cache forever */ protected static cacheDuration: number | null; /** * Cache store class to use */ protected static storeClass: typeof ServiceStore; /** * Saved instance of ModelManager */ private static __modelManager; /** * Saved instance of ServiceStore cache */ private static __store; /** * Parents of current model instance */ protected _parents: ServiceParent; /** * Manager class of model */ static ModelManager: typeof ModelManager; /** * Constructor */ constructor(data?: Dictionary, parents?: ServiceParent); /** * Getter to simulate static class property with fixed inheritance */ static get store(): ServiceStore; /** * Function to return list url of model according to parents */ static getListUrl(parents?: ServiceParent): Promise; /** * Function to return detail url of model according to parents */ static getDetailUrl(pk: PrimaryKey, parents?: ServiceParent): Promise; /** * Retrieve instance of ModelManager */ static get objects(): ModelManager; /** * Return model parents */ get parents(): ServiceParent; /** * Set deep copy of model parents to avoid unwanted mutations */ set parents(parents: ServiceParent); /** * Check whether all required parent values have been given * @param parents */ static checkServiceParents(parents?: ServiceParent): boolean; /** * Map data by field names for partial update */ mapPartialUpdateFields(data: Dictionary, updateFields: string[]): Promise>; /** * Reload model data from service. Overwrites changes made to model data * Returns true if successful */ reload(): Promise; /** * Call either .create() or .update() by checking whether primary key is set or not * Returns true if create has been called */ save(): Promise; /** * Create current model instance by calling objects.create() * Updates model data from response if set * Returns true if successful */ create(): Promise; /** * Update current model instance by calling objects.update() * Updates model data from response if set * Returns true if successful */ update(options?: ServiceModelUpdateOptions): Promise; /** * Delete current model instance by calling objects.delete() * Returns true if successful */ delete(): Promise; /** * Create instance of store class */ protected static createStoreModule(): ServiceStore; }