import { ElementRef, EventEmitter, InjectionToken, Injector, NgZone, Provider, TemplateRef, Type } from "@angular/core"; import { HttpClient, HttpHeaders } from "@angular/common/http"; import { ActivatedRouteSnapshot, Data, LoadChildrenCallback, Route, Routes, UrlTree } from "@angular/router"; import { Observable } from "rxjs"; import { DurationLikeObject } from "luxon"; import { MaybePromise, StringKeys } from "./helper-types"; export type DurationUnit = StringKeys; export interface TypedFactoryProvider { provide?: any; useFactory: (...args: any[]) => T; deps: any[]; } export interface TypedValueProvider { provide?: any; useValue: T; } export interface TypedExistingProvider { provide?: any; useExisting: Type; } export interface TypedClassProvider { provide?: any; useClass: Type; } export interface TypedTokenProvider { provide?: any; useToken: InjectionToken; } export type TypedProvider = TypedFactoryProvider | TypedValueProvider | TypedExistingProvider | TypedClassProvider | TypedTokenProvider | Type; export type CachedFactory = (injector: Injector) => ReadonlyArray; export interface ResolveFactory { type?: Function; func: (...args: any[]) => T; params?: any[]; } export interface IResolveFactory extends Omit { func: Function; } export declare class CanvasColor { r: number; g: number; b: number; a: number; constructor(r: number, g: number, b: number, a?: number); } export interface IIconService { isDisabled: boolean; iconsLoaded: EventEmitter; getIcon(icon: string, activeIcon: string, active: boolean): Promise; getIconUrl(icon: string, modifier?: SvgSourceModifier): Promise; getIconImage(icon: string, modifier?: SvgSourceModifier): Promise; } export interface ITranslation { lang: string; translation: string; } export interface ITranslations { [key: string]: string; } export type GlobalTranslations = Record; export interface ILanguageSetting { unavailable?: string; [key: string]: string | boolean | number; } export interface ILanguageSettings { languages: string[]; devLanguages: string[]; defaultLanguage: string; settings?: { [lang: string]: ILanguageSetting; }; } export interface ILanguageService { currentLanguage: string; editLanguage: string; enableTranslations: boolean; disableTranslations: boolean; defaultLanguage: string; dictionary: ITranslations; readonly languages: ReadonlyArray; readonly httpClient: HttpClient; replaceLanguages(languages: string[]): void; addLanguages(languages: string[]): void; getTranslationSync(key: string, params?: Object): string; getTranslation(key: string, params?: Object): Promise; getTranslations(...keys: string[]): Promise; getTranslationFromObject(translations: ITranslations, params?: any, lang?: string): string; getTranslationFromArray(translations: ITranslation[], params?: any, lang?: string): string; } export interface IUserData { _id?: string; id?: string; email?: string; [key: string]: any; } export interface IAuthService { isAuthenticated: boolean; checkAuthenticated(): Promise; } export type RouteValidator = (auth: IAuthService, route?: IRoute, next?: ActivatedRouteSnapshot) => Promise; export interface IRouteData extends Data { returnState?: string[]; guards?: Array | RouteValidator>; } export interface IRoute extends Route { data?: IRouteData; } export interface IRouteStateInfo { route: IRoute; guard: any; dirty: boolean; first: boolean; component?: any; } export interface MenuItem { path: string; page: string; label: string; side: string; external: boolean; data: IRouteData; } export interface IAclComponent { onUserInitialized(): void; onUserChanged(): void; } export interface IAclService { getCurrentMenu(): Promise>; } export type NavigationUrlParam = any[] | string | UrlTree; export declare enum StorageMode { Local = 0, Session = 1 } export type ToastType = "info" | "success" | "warning" | "error"; export interface IToasterService { error(message: string, params?: any): void; info(message: string, params?: any): void; success(message: string, params?: any): void; warning(message: string, params?: any): void; handleAsyncMethod(method: AsyncMethod, context?: any): void; } export interface IDialogButtonConfig { icon?: string; text?: string; classes?: string; method?: AsyncMethod; testId?: string; } export interface IDialogConfig { id?: string; title?: string; message: string; messageContext?: any; buttons?: IDialogButtonConfig[]; onClose?: AsyncMethod; size?: string; type?: string; templates?: { [id: string]: TemplateRef; }; } export interface IConfirmMessageConfig { id?: string; title?: string; messageContext?: any; size?: string; templates?: { [id: string]: TemplateRef; }; okText?: string; okClasses?: string; cancelText?: string; cancelClasses?: string; } export interface IConfirmDialogConfig extends IConfirmMessageConfig { message: string; method?: AsyncMethod; cancelMethod?: AsyncMethod; } export interface IDialogService { dialog(config: IDialogConfig): DR; confirm(config: IConfirmDialogConfig): DR; confirmMsg(message: string, config?: IConfirmMessageConfig): Promise; } export interface IPromiseService { zone: NgZone; count: number; onChanged: EventEmitter; create(executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; all(promises: Promise[]): Promise; resolve(value: T | PromiseLike): Promise; reject(value: T | PromiseLike): Promise; } export interface IAsyncMessage { message: string; context?: any; } export type AsyncMethod = (context?: any, ev?: MouseEvent) => Promise; export interface IconMap { [key: string]: string; } export interface IconProps { name: string; } export type ButtonType = "primary" | "secondary" | "transparent"; export type ButtonSize = "normal" | "small"; export interface ButtonProps { label: string; tooltip: string; icon: string; disabled: boolean; type: ButtonType; size: ButtonSize; } export type TabValue = string | number; export interface TabOption extends Omit, "size" | "state" | "style"> { value: TabValue; classes?: string | string[]; } export type ChipValue = string | number; export type ChipStatus = "valid" | "invalid"; export interface ChipOption { label: string; value?: ChipValue; classes?: string; disabled?: boolean; picture?: string; group?: ChipOption[]; } export type DropdownAttachTo = "root" | HTMLElement | ElementRef | null; export interface UnorderedListTemplate { readonly type: string; readonly selector: string; readonly templateRef: TemplateRef; } export interface UnorderedListTemplates { [type: string]: TemplateRef; } export type UnorderedListStyle = "table" | "list"; export type UploadType = string | Blob; export interface IFileUploadResult { _id?: string; id?: string; contentType?: string; createdAt?: Date; filename?: string; file?: Blob; } export interface IFileUploadProcess { file: File; progress: number; preview?: string; promise?: Promise; } export interface IAjaxRequestDetails { request: XMLHttpRequest; method: string; url: string; } export type AjaxRequestCallback = (details: IAjaxRequestDetails, params: any) => void; export type ScriptType = "text/javascript" | "module"; export interface ILoadableElement extends HTMLElement { readyState?: string; onreadystatechange?: Function; } export interface ILoaderPromises { [src: string]: { elem: T; promise: Promise; }; } export interface ISearchObservable { search: string; getSearchResults(token: string): Promise; } export declare function FactoryDependencies(...dependencies: Array | Provider>): MethodDecorator; export declare function ObjectType(type: string): ClassDecorator; export interface ITimer { id?: any; func?: Function; time?: number; run?: () => void; set?: (func: Function, time: number) => void; clear?: () => void; } export interface IExtraProperties { [prop: string]: any; } export interface IGroupMap { [column: string]: any; } export type TranslationQuery = string | ITranslations | ITranslation[]; export interface IPageInfo { text: string; number: number; active: boolean; } export interface IPaginationData { total: number; items: any[]; meta?: any; } export type PaginationDataLoader = (page: number, itemsPerPage: number) => Promise; export declare class PaginationItemContext { readonly item: any; readonly parallelItem: any; readonly count: number; index: number; dataIndex: number; constructor(item: any, parallelItem: any, count: number, index: number, dataIndex: number); get first(): boolean; get last(): boolean; get even(): boolean; get odd(): boolean; get row(): any; get parallelRow(): any; } export interface IPoint { readonly x: number; readonly y: number; } export interface ShapeIntersection { hit: boolean; pa?: IPoint; pb?: IPoint; point?: IPoint; } export interface IShape extends IPoint { readonly center: IPoint; getPath(x: number, y: number, ratio?: number): Path2D; support(dir: IPoint, logs?: boolean): IPoint; expand(value: number): IShape; move(pos: IPoint): IShape; intersection(shape: IShape, logs?: boolean): ShapeIntersection; intersects(shape: IShape, logs?: boolean): boolean; distance(shape: IShape): number; } export type CanvasResizeMode = "fit" | "fill"; export type CanvasItemDirection = "horizontal" | "vertical" | "free" | "none"; export type CanvasPaintFunc = (ctx: CanvasRenderingContext2D) => MaybePromise; export type RangeCoords = [from: number, to: number]; export interface RectCoords { x: number; y: number; width: number; height: number; id?: string; } /** * Rectangle frame interface */ export interface Frame extends IShape { width: number; height: number; rotation: number; } /** * Interface for an interactive canvas params */ export interface InteractiveCanvasParams { xRange?: RangeCoords; yRange?: RangeCoords; excludedAreas?: ReadonlyArray; [key: string]: any; } /** * Interface for an area that covers a part of the interactive canvas */ export interface InteractiveCanvasArea { readonly id: string; readonly shapes: ReadonlyArray; } /** * Interface for an interactive canvas item */ export interface InteractiveCanvasItem extends InteractiveCanvasArea { readonly position: IPoint; readonly rotation: number; readonly frame: Frame; readonly isValid: boolean; readonly validPosition: IPoint; readonly validRotation: number; readonly hovered: boolean; readonly selected: boolean; readonly active: boolean; readonly canvas: InteractiveCanvas; readonly index: number; readonly canvasParams: InteractiveCanvasParams; readonly hitShapes: ReadonlyArray; draw(ctx: CanvasRenderingContext2D, shape: IShape): MaybePromise; } export type InteractiveCanvasItems = ReadonlyArray; /** * Interface for an interactive canvas component * Some properties are optional for compatibility with other kind of renderer functions */ export interface InteractiveCanvas { readonly isInfinite?: boolean; readonly realWidth?: number; readonly realHeight?: number; readonly items?: InteractiveCanvasItems; readonly canvas: HTMLCanvasElement; readonly lockedItem?: InteractiveCanvasItem; selectedItem?: InteractiveCanvasItem; hoveredItem?: InteractiveCanvasItem; readonly xRange?: RangeCoords; readonly yRange?: RangeCoords; readonly ratio: number; readonly styles: CSSStyleDeclaration; readonly ctx: CanvasRenderingContext2D; readonly canvasWidth: number; readonly canvasHeight: number; readonly fullHeight: number; readonly viewRatio: number; readonly rotation: number; readonly basePan: number; readonly cycles?: ReadonlyArray; readonly excludedAreas?: ReadonlyArray; rendered?: boolean; tempPaint(cb: CanvasPaintFunc): Promise; } export type InteractiveCanvasRenderer = (renderCanvas: InteractiveCanvas, renderCtx: Record) => MaybePromise; export interface InteractivePanEvent { canvas: InteractiveCanvas; item: InteractiveCanvasItem; deltaX?: number; deltaY?: number; [key: string]: any; } export interface InteractiveCanvasPointer { clientX: number; clientY: number; } export interface HttpRequestHeaders { [header: string]: string | string[]; } export interface HttpRequestQuery { [key: string]: any; } /** * Base http request options that get sent to backend */ export interface HttpClientRequestOptions { method?: string; body?: any; headers?: HttpRequestHeaders | HttpHeaders; originalHeaders?: HttpRequestHeaders; params?: HttpRequestQuery; observe?: "body" | "response"; /** * Used for uploads */ reportProgress?: boolean; /** * Specifies the type of response */ responseType?: "arraybuffer" | "blob" | "json" | "text"; withCredentials?: boolean; timeout?: number; } /** * Extended http request options that the consumer can use */ export interface HttpRequestOptions extends HttpClientRequestOptions { /** * Read a specific property from the body if observe equals to 'body' and responseType equals to 'json' */ read?: string; /** * Specifies when the cache for the request expires as an Observable */ cache?: Observable; } /** * Defines the type of uploadable content */ export type UploadData = Record | ArrayBuffer | FormData; export interface IIssueContext { url: string; } export interface IProgress { percentage?: number; loaded?: number; total?: number; } export type ProgressListener = (progress: IProgress) => void; export type CacheExpireMode = boolean | "auth" | Date; export interface IHttpService { readonly language: ILanguageService; readonly requestHeaders: Readonly; readonly requestParams: Readonly; setHeader(name: string, value?: string | string[]): void; setParam(name: string, value?: any): void; cached(mode: CacheExpireMode): Observable; url(url: string): string; makeListParams(page: number, itemsPerPage: number, orderBy?: string, orderDescending?: boolean, filter?: string): HttpRequestQuery; } export interface SvgDefinition { source: SVGSVGElement; width: number; height: number; } export type SvgSourceModifier = (svg: SVGSVGElement, width: number, height: number) => string; export interface ExpressRequest { [key: string]: any; } export interface IBaseHttpClient extends HttpClient { readonly requestHeaders: Readonly; readonly requestParams: Readonly; setHeader(name: string, value?: string | string[]): void; getHeader(name: string): string; setParam(name: string, value?: any): void; setExtraRequestParam(name: string, value?: any): void; makeHeaders(): HttpHeaders; } export interface IApiService extends IHttpService { client: IBaseHttpClient; get(url: string, options?: HttpRequestOptions): Promise; delete(url: string, options?: HttpRequestOptions): Promise; post(url: string, body?: any, options?: HttpRequestOptions): Promise; put(url: string, body?: any, options?: HttpRequestOptions): Promise; patch(url: string, body?: any, options?: HttpRequestOptions): Promise; upload(url: string, body: any, listener?: ProgressListener, options?: HttpRequestOptions): Promise; list(url: string, params: HttpRequestQuery, options?: HttpRequestOptions): Promise; } export interface DynamicSchemaRef { dynamicSchema?: string; dynamicSchemaUrl?: string; dynamicSchemaName?: string; } export interface OpenApiSchemaRef { $ref?: string; } export interface OpenApiSchemaProperty extends DynamicSchemaRef, OpenApiSchemaRef { id: string; type?: string; format?: string; column?: boolean; additionalProperties?: any; allOf?: ReadonlyArray; oneOf?: ReadonlyArray; items?: OpenApiSchemaProperty; enum?: string[]; [key: string]: any; } export interface OpenApiSchema { properties: { [name: string]: OpenApiSchemaProperty; }; required: string[]; [key: string]: any; } export interface OpenApiSchemas { [name: string]: OpenApiSchema; } export type OpenApiSchemaSelector = (name: string, schemas: OpenApiSchemas, injector: Injector) => OpenApiSchema; export type TableFilterType = "text" | "enum" | "checkbox"; export interface ITableOrders { [column: string]: string; } export interface ITableColumn { title: string; sort?: string; filter?: boolean; filterType?: TableFilterType; enum?: string[]; enumPrefix?: string; [key: string]: any; } export interface ITableColumns { [column: string]: ITableColumn; } export type TableColumns = ITableOrders | ITableColumns | string[]; export interface ITableTemplate { column: string | string[]; pure: boolean; ref: TemplateRef; } export interface ITableTemplates { [column: string]: ITableTemplate; } export interface ITableDataQuery { [column: string]: string | string[] | boolean; } export type TableDataItems = ReadonlyArray; export type TableDataLoader = (page: number, rowsPerPage: number, orderBy: string, orderDescending: boolean, filter: string, query: ITableDataQuery) => Promise; export type DragDropEvent = { [key in K]: T; } & { ev: DragEvent; elem: HTMLElement; source?: T; }; export type DragEventHandler = (ev: DragDropEvent) => R; export type ITableDragEvent = DragDropEvent; export type DynamicTableDragHandler = DragEventHandler; export declare class ResourceIfContext { resource: string; url: string; } export type CssSelector = [tagName: string, attrName?: string, attrValue?: string]; export type CssSelectorList = CssSelector[]; export interface DynamicModuleInfo { moduleId: string; loadChildren: LoadChildrenCallback; routes?: Routes; initialNavigation?: boolean; } export interface DynamicComponentLocation { moduleId: string; selector: string; } export interface DynamicEntryComponents { components: Type[]; moduleId: string; } export declare class IConfiguration { cdnUrl?: string; baseUrl?: string; baseDomain?: string; translationUrl?: string; translationExt?: string; [key: string]: any; } export interface IConfigService { readonly http: IBaseHttpClient; readonly config: IConfiguration; readonly injector: Injector; readonly load: () => Promise; readonly rootElement: any; cloneRootElem(): any; prepareUrl(url: string, ending: string): string; getConfigValue(key: string): any; getQueryParameter(name: string, url?: string): string; } export type ResizeEventStrategy = "scroll" | "object" | "observer"; export type ErrorHandlerCallback = (error: string) => any; export type GlobalComponentModifier = (component: any) => any; export type AppInitializerFunc = () => Promise | void; export interface IModuleConfig { apiService?: Type; authService?: Type; iconService?: Type; languageService?: Type; toasterService?: Type; promiseService?: Type; configService?: Type; dialogService?: Type; iconType?: Type; iconMap?: IconMap; buttonType?: Type; initializeApp?: (injector: Injector) => AppInitializerFunc; baseUrl?: (injector: Injector) => string; resizeDelay?: number; resizeStrategy?: ResizeEventStrategy; socketPath?: string; staticSchemas?: OpenApiSchemas; schemaSelector?: OpenApiSchemaSelector; } export declare class ValuedPromise extends Promise { value: T; }