UNPKG

@crowdin/app-project-module

Version:

Module that generates for you all common endpoints for serving standalone Crowdin App

45 lines (44 loc) 2.05 kB
import { AxiosError } from 'axios'; import { Config, CrowdinClientRequest, CrowdinContextInfo, UnauthorizedConfig } from '../types'; import { IntegrationRequest } from '../modules/integration/types'; import { Request } from 'express'; export type LogFunction = (message: string) => void; export type LogErrorFunction = (error: any) => void; export type LogContext = { userId: string; orgId: string; projectId: number; }; export declare function initialize(config: Config | UnauthorizedConfig): void; export declare function prepareContext(context: CrowdinContextInfo): LogContext; export declare function withContext(context: CrowdinContextInfo): LogFunction; export declare function withContextError(context: CrowdinContextInfo): LogFunction; export declare function log(message: string, context?: CrowdinContextInfo): void; export declare function logError(e: any, context?: CrowdinContextInfo): void; export declare function isAxiosError(e: any): e is CustomAxiosError; export declare function isInternalErrorMessage(message: string): boolean; export declare function getErrorMessage(err: any): string; interface CustomAxiosError extends AxiosError { data?: any; } export declare class AppModuleError extends Error { data: any; appData: any; isAxiosError: boolean; constructor(error: CustomAxiosError | Error | string, data?: any); } export declare class AppUserModuleError extends AppModuleError { constructor(error: CustomAxiosError | Error | string, data?: any); } export declare class AppModuleAggregateError extends Error { errors: Error[] | AppModuleError[] | AppUserModuleError[]; constructor(errors: Error[] | AppModuleError[] | AppUserModuleError[], message: string); } export declare function handleUserError({ action, error, crowdinId, clientId, }: { action: string; error: Error | string; crowdinId: string; clientId?: string; }): Promise<void>; export declare function temporaryErrorDebug(msg: string, req: Request | IntegrationRequest | CrowdinClientRequest): void; export {};