@versatiledatakit/shared
Version:
Versatile Data Kit Shared library enables reusability of shared features like: NgRx Redux, Error Handlers, Utils, Generic Components, etc.
51 lines (50 loc) • 2.34 kB
TypeScript
import { Type } from '@angular/core';
import { FilterMethods } from '../../../utils';
import { TaurusObject } from '../../object';
import { ServiceHttpErrorCodes } from '../../error';
import * as i0 from "@angular/core";
/**
* ** Store type for auto-generated codes for every method, where key is the method name and value is different error codes for auto-supported scenarios.
*/
export declare type ErrorCodes<CType, KExclude extends keyof any = ExcludedMethods> = Readonly<Record<keyof FilterMethods<CType, KExclude>, Readonly<Record<keyof ServiceHttpErrorCodes, string>>>>;
/**
* ** Excluded methods from auto-generated error codes.
*/
export declare type ExcludedMethods = 'constructor' | 'errorCodes' | 'dispose' | 'ngOnDestroy' | 'cleanSubscriptions' | 'removeSubscriptionRef' | 'registerErrorCodes';
/**
* ** Base Class for Angular Service related classes.
*
* - Add abstraction for TaurusBaseApiService subclasses to auto-register their methods' error codes in relationship one method to many error codes for auto-supported scenarios.
* - There could be added additional error codes from subclasses.
*/
export declare class TaurusBaseApiService<CType extends TaurusBaseApiService = any> extends TaurusObject {
/**
* @inheritDoc
*/
static readonly CLASS_NAME: string;
/**
* @inheritDoc
*/
static readonly PUBLIC_NAME: string;
/**
* ** Class error codes Mapping.
*
* - There are auto-generated error codes for every method name in runtime, where method name is the key, and the multiple values where each value is bound to unique error code.
* - Subclasses could override in definition time or in runtime to add additional error codes.
*/
readonly errorCodes: ErrorCodes<CType>;
/**
* ** Constructor.
*/
protected constructor(className?: string);
/**
* ** Register error codes for service.
*
* - Exclude system methods.
* - Exclude private methods which names start with underscore (e.g. _methodName(): void;)
* @protected
*/
protected registerErrorCodes(service: Type<CType>): void;
static ɵfac: i0.ɵɵFactoryDeclaration<TaurusBaseApiService<any>, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<TaurusBaseApiService<any>, never, never, {}, {}, never>;
}