import { HttpResponse, HttpInterceptorFn } from '@angular/common/http'; import { Observable } from 'rxjs'; import * as i0 from '@angular/core'; /** * Provides HTTP functions for the application. It automatically adds headers * needed by the back-end, and any authentication tokens or credentials. */ declare class TbxHttpClient { static withCredentials: boolean; private readonly http; /** * Convert the error to a standard {@link TbxError} and rethrows the error. * @param error The error to handle. * @returns A new {@link Observable} of type {@link TbxError}. */ private static handleError; /** * Constructs a GET request which interprets the body as JSON and returns it. * @param url - The URL to send the request to. * @param params - Any parameters to send along with the query. * @param options - Any options to add to the request. If not options given, * the standard headers and options will be applied. * @returns The body as JSON, or a {@link Observable} if an error is encountered. */ get(url: string, params?: any, options?: {}): Observable; /** * Constructs a GET request which interprets the body as JSON * and returns the full response. * @param url - The URL to send the request to. * @returns The full response of the request as an {@link Observable}, * or a {@link Observable} if an error is encountered. */ getFull(url: string): Observable>; /** * Construct a POST request and includes the {@param body} as the payload. * @param url - The URL to send the request to. * @param body - The data to send as the body/payload. * @param options - Any options to add to the request. If not options given, * the standard headers and options will be applied. * @returns The response as an {@link Observable}, or an error {@link Observable} * if an error is encountered. */ post(url: string, body: any, options?: {}): Observable; /** * Construct a PUT request and includes the {@param body} as the payload. * @param url The URL to send the request to. * @param body The data to send as the body/payload. * @param options - Any options to add to the request. If not options given, * the standard headers and options will be applied. * @returns The response as an {@link Observable}, or an error {@link Observable} * if an error is encountered. */ put(url: string, body: any, options?: {}): Observable; /** * Construct a DELETE request. * @param url The URL to send the request to. * @param options - Any options to add to the request. If not options given, * the standard headers and options will be applied. * @returns The response as an {@link Observable}, or an error {@link Observable} * if an error is encountered. */ delete(url: string, options?: {}): Observable; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Represents validation information sent by the server for a specific entity model. */ interface TbxMetadata { /** Gets or sets the name of the field. */ name: string | null; /** Gets or sets the date type of the field. */ dataType: string | null; /** Gets or sets the label/caption for the field. */ label?: string | null; /** Gets or sets the maximum length for the field value. */ maxLength?: number | null; /** Gets or sets the minimum length for the field value. */ minLength?: number | null; /** Gets or sets the max range for the field value. */ maxRange?: number | null; /** Gets or sets the min length for the field value. */ minRange?: number | null; /** Gets or sets the message to display when max length is reached. */ maxLenMessage?: string | null; /** Gets or sets the message to display when min length is reached. */ minLenMessage?: string | null; /** Gets or sets the message to display when max range is reached. */ rangeMessage?: string | null; /** Gets or sets a value indicating whether the field is required. */ required: boolean; /** Gets or sets the message to display when the field is not provided. */ requiredMessage: string | null; /** Gets or sets the actual value of the field. */ value: unknown; } /** The metadata received from the server when adding/editing an entity. */ interface TbxModelMetadata { /** Gets or sets all validation rules for the entity. */ metadata: TbxMetadata[]; /** The entity model values. */ model: unknown; } /** Models a validation error. */ interface TbxValidationError { /** The error key (usually the control name that is invalid). */ key: string; /** The error message. */ message: string; } /** * Models an application error. */ declare class TbxError implements Error { /** The error message such as 'Http failure response'. */ readonly message: string; /** The error name such as HttpErrorResponse. */ readonly name: string; /** The HTTP error status code. */ readonly status: number; /** The HTTP error status text. */ readonly statusText: string; /** The URL where the error occurred. */ readonly url: string; /** The error stack. */ readonly stack: string; /** An array of messages, if any. */ readonly messages: string[]; /** The area/location where the error occurred. */ readonly area: string; /** Indicates whether the error is fatal. */ readonly isFatal: boolean; /** An array of validation errors, if any. */ readonly validationErrors: TbxValidationError[]; /** The actual error object. */ readonly error: unknown; /** * Initializes a new instance of the {@link TbxError} class. * @param message The error message such as 'Http failure response'. * @param init The optional initialization parameters. */ constructor(message: string, init?: { name?: string; /** The error status code. */ status?: number; /** The error status text. */ statusText?: string; /** The URL where the error occurred if a request. */ url?: string; /** The error stack, if any. */ stack?: string; /** An array of error messages. */ messages?: string[]; /** Area where the error occurred. */ area?: string; /** Indicates whether the error is fatal. */ isFatal?: boolean; /** An array of validation errors. */ validationErrors?: TbxValidationError[]; /** The original error object such as HttpErrorResponse. */ error?: never; }); } /** * Parses the given error to a {@link TbxError} object. * @param error The error object to convert. * @param area The message to append to the error. The message is prefixed with * 'while' - for example, if area is 'getting project data' the error will read: * 'An error has occurred while getting project data.' * @returns A {@link TbxError} object. */ declare const parseApiError: (error: any, area?: string) => TbxError; /** * Represents information about a URL endpoint available in the server that is * normally retrieved from ASP.NET Web API ToolBox endpoint. */ interface TbxUrlModel { /** Gets or sets the name of the endpoint. */ name: string; /** Gets or sets the URL template expected by MVC. */ template: string; /** Gets or sets the actual URL. */ url: string; } /** * Represents information about a return URL */ interface TbxReturnUrl { /** The return URL. */ ru: string; /** The parent return URL. */ pru?: string; } /** * Provides functions to get URLs defined in the server. */ declare class TbxUrlService { /** Gets or sets a list of all available server endpoints. */ routes: TbxUrlModel[]; /** The base HREF for the application. */ baseHref: string; /** * Gets a value indicating whether the base HREF should be included when resolving. */ includeBaseHref: boolean; /** Gets the home relative URL such as "/". */ get home(): string; /** Gets the home absolute URL (e.g., http://localhost:4200/) */ get homeAbsolute(): string; /** Gets the URL to submit log entries to the server. */ get log(): string; /** Gets the URL to submit emails to the server. */ get sendMail(): string; /** Gets the URL to submit errors to the server. */ get submitError(): string; /** * Simple function to combine URL segments for the service. * @param path1 - The first path. * @param path2 - The optional second path. * @param path3 - An optional third path. * @returns The properly combined URL. */ static combine(path1: string, path2?: string, path3?: string): string; /** * Gets the URL by the specified name appending an optional segment. * @param name - The name of the endpoint to resolve. * @param appendUrl - An optional segment to append to the URL. * @throws The specified URL name does not exist in the server. * @returns The URL of the endpoint or undefined. */ get(name: string, appendUrl?: string): string; /** * Resolves the URL by the specified name. * @param name - The name of the endpoint to resolve. * @returns The URL of the endpoint or undefined. */ resolve(name: string): string | undefined; /** * Finds the route by the specified name. * @param name The of the route to find. * @returns The url model if found, otherwise undefined. */ find(name: string): TbxUrlModel | undefined; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare const getBaseUrl: () => string; declare const getBaseUrlFromWindow: () => string; /** * Intercepts HTTP requests sent from this application and logs to the console * how long it took to complete in milliseconds. */ declare const tbxTimingInterceptor: HttpInterceptorFn; export { TbxError, TbxHttpClient, TbxUrlService, getBaseUrl, getBaseUrlFromWindow, parseApiError, tbxTimingInterceptor }; export type { TbxMetadata, TbxModelMetadata, TbxReturnUrl, TbxUrlModel, TbxValidationError };