@mediusinc/mng-commons 3.0.0-rc.8 → 3.0.0-rc.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/lib/components/action/models/action-execution.model.mjs +1 -1
- package/esm2022/lib/components/form/autocomplete/autocomplete.component.mjs +13 -2
- package/esm2022/lib/components/form/dropdown/dropdown.component.mjs +16 -5
- package/esm2022/lib/components/form/formly/fields/formly-field-lookup-dialog/formly-field-lookup-dialog.component.mjs +10 -3
- package/esm2022/lib/components/form/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.mjs +7 -5
- package/esm2022/lib/components/form/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.mjs +15 -6
- package/esm2022/lib/components/tableview/table/table.component.mjs +9 -4
- package/esm2022/lib/descriptors/action/action.descriptor.mjs +6 -6
- package/esm2022/lib/descriptors/editor/editor.descriptor.mjs +2 -2
- package/esm2022/lib/descriptors/filter/filter.descriptor.mjs +4 -4
- package/esm2022/lib/descriptors/table/column.descriptor.mjs +2 -2
- package/esm2022/lib/descriptors/tableview/tableview.descriptor.mjs +2 -2
- package/esm2022/lib/error/error.handler.mjs +7 -10
- package/esm2022/lib/models/error.model.mjs +44 -2
- package/esm2022/lib/models/index.mjs +1 -2
- package/esm2022/lib/models/log.model.mjs +1 -1
- package/esm2022/lib/provide-commons.mjs +8 -3
- package/esm2022/lib/router/route-builder.mjs +3 -3
- package/esm2022/lib/router/routes-builder.mjs +2 -2
- package/esm2022/lib/services/action-error-mapper.service.mjs +3 -2
- package/esm2022/lib/services/action-executor.service.mjs +40 -25
- package/esm2022/lib/services/configuration.service.mjs +7 -13
- package/esm2022/lib/services/index.mjs +2 -1
- package/esm2022/lib/services/internal/commons-init.service.mjs +4 -3
- package/esm2022/lib/services/log-publisher-console.service.mjs +40 -0
- package/esm2022/lib/services/logger.service.mjs +57 -50
- package/esm2022/lib/services/tokens/index.mjs +2 -1
- package/esm2022/lib/services/tokens/log-publisher.token.mjs +3 -0
- package/esm2022/lib/services/version.service.mjs +7 -2
- package/esm2022/lib/utils/action-data-provider.util.mjs +7 -7
- package/esm2022/lib/utils/error.util.mjs +247 -0
- package/esm2022/lib/utils/i18n.util.mjs +7 -9
- package/esm2022/lib/utils/index.mjs +2 -1
- package/esm2022/lib/utils/notification.util.mjs +1 -1
- package/esm2022/lib/utils/route.util.mjs +2 -2
- package/esm2022/lib/utils/string.util.mjs +32 -1
- package/esm2022/lib/utils/tableview.util.mjs +2 -2
- package/esm2022/lib/utils/type.util.mjs +2 -2
- package/fesm2022/mediusinc-mng-commons.mjs +657 -270
- package/fesm2022/mediusinc-mng-commons.mjs.map +1 -1
- package/lib/components/action/models/action-execution.model.d.ts +2 -2
- package/lib/components/form/formly/fields/formly-field-lookup-dialog/formly-field-lookup-dialog.component.d.ts +1 -0
- package/lib/components/form/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.d.ts +1 -0
- package/lib/components/tableview/table/table.component.d.ts +1 -0
- package/lib/descriptors/editor/field.descriptor.d.ts +1 -1
- package/lib/descriptors/table/column.descriptor.d.ts +1 -1
- package/lib/models/error.model.d.ts +44 -9
- package/lib/models/index.d.ts +0 -1
- package/lib/models/log.model.d.ts +14 -8
- package/lib/services/action-error-mapper.service.d.ts +10 -3
- package/lib/services/action-executor.service.d.ts +3 -2
- package/lib/services/index.d.ts +1 -0
- package/lib/services/internal/commons-init.service.d.ts +1 -0
- package/lib/services/log-publisher-console.service.d.ts +4 -0
- package/lib/services/logger.service.d.ts +11 -8
- package/lib/services/tokens/index.d.ts +1 -0
- package/lib/services/tokens/log-publisher.token.d.ts +3 -0
- package/lib/services/version.service.d.ts +1 -0
- package/lib/utils/error.util.d.ts +116 -0
- package/lib/utils/i18n.util.d.ts +3 -3
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/notification.util.d.ts +2 -2
- package/lib/utils/string.util.d.ts +5 -0
- package/package.json +1 -1
- package/esm2022/lib/models/internal-error.model.mjs +0 -30
- package/lib/models/internal-error.model.d.ts +0 -26
|
@@ -5,7 +5,7 @@ import { BehaviorSubject, Observable, ReplaySubject, Subscription } from 'rxjs';
|
|
|
5
5
|
import { MediusQueryParam } from '../../../api/models';
|
|
6
6
|
import { IDataProvider } from '../../../data-providers';
|
|
7
7
|
import { ActionDescriptor } from '../../../descriptors/action';
|
|
8
|
-
import { IActionEditorComponent,
|
|
8
|
+
import { IActionEditorComponent, IMngError, IViewContainer } from '../../../models';
|
|
9
9
|
import { IdType } from '../../../types';
|
|
10
10
|
export declare class ActionError {
|
|
11
11
|
readonly error: any;
|
|
@@ -86,7 +86,7 @@ export declare class ActionContext<T, S> {
|
|
|
86
86
|
executionStart(): void;
|
|
87
87
|
executionNext(next: T | null | undefined, finish?: boolean): void;
|
|
88
88
|
executionComplete(): void;
|
|
89
|
-
executionError(err:
|
|
89
|
+
executionError(err: IMngError): void;
|
|
90
90
|
finish(): void;
|
|
91
91
|
isClosed(): boolean;
|
|
92
92
|
}
|
|
@@ -13,6 +13,7 @@ import * as i0 from "@angular/core";
|
|
|
13
13
|
export declare class MngFormlyFieldLookupDialogComponent<T, ET> extends FieldType<MngFormlyFieldConfig> implements OnInit, AfterViewInit, OnDestroy {
|
|
14
14
|
private injector;
|
|
15
15
|
mngTable?: MngTableComponent<any, any>;
|
|
16
|
+
private readonly logger;
|
|
16
17
|
descriptor: FieldLookupDescriptor<T, ET>;
|
|
17
18
|
config: FieldLookupConfig;
|
|
18
19
|
fieldLabelFormControl: FormControl;
|
|
@@ -9,6 +9,7 @@ import { MngFormlyFieldConfig } from '../../models';
|
|
|
9
9
|
import * as i0 from "@angular/core";
|
|
10
10
|
export declare class MngFormlyFieldTableDialogMultiselectComponent<T, ET> extends FieldType<MngFormlyFieldConfig> implements OnInit, AfterViewInit, OnDestroy {
|
|
11
11
|
private injector;
|
|
12
|
+
private readonly logger;
|
|
12
13
|
descriptor: FieldManyToManyEditorDescriptor<T, ET>;
|
|
13
14
|
itemsSubject: Subject<Array<T>>;
|
|
14
15
|
itemsAsync: Observable<Array<T>>;
|
|
@@ -27,6 +27,7 @@ export declare class MngTableComponent<T, S> implements OnInit, OnChanges, After
|
|
|
27
27
|
private localStorageService;
|
|
28
28
|
readonly filterDisplayRow: TableFilterDisplayEnum;
|
|
29
29
|
readonly cmpTypeName = "MngTableComponent";
|
|
30
|
+
private readonly logger;
|
|
30
31
|
initialDescriptor: TableDescriptor<T>;
|
|
31
32
|
descriptor?: TableDescriptor<T>;
|
|
32
33
|
items?: Observable<Array<T>> | Array<T>;
|
|
@@ -201,7 +201,7 @@ export declare class FieldInputDescriptor<ET> extends AFieldDescriptor<string |
|
|
|
201
201
|
get locale(): string | undefined;
|
|
202
202
|
get currency(): string | undefined;
|
|
203
203
|
get currencyFromProperty(): string | undefined;
|
|
204
|
-
get currencyDisplay(): "symbol" | "
|
|
204
|
+
get currencyDisplay(): "symbol" | "name" | "code";
|
|
205
205
|
asHidden(): this;
|
|
206
206
|
asLabel(): this;
|
|
207
207
|
asText(): this;
|
|
@@ -70,7 +70,7 @@ export declare class ColumnDescriptor<T, TT> {
|
|
|
70
70
|
get customComponentType(): Type<IColumnValueComponent<TT>> | undefined;
|
|
71
71
|
get locale(): string | undefined;
|
|
72
72
|
get currencyCode(): string | undefined;
|
|
73
|
-
get currencyDisplay(): "symbol" | "
|
|
73
|
+
get currencyDisplay(): "symbol" | "name" | "code" | undefined;
|
|
74
74
|
get currencyFromProperty(): string | undefined;
|
|
75
75
|
get hasCopyToClipboard(): boolean;
|
|
76
76
|
get template(): string | undefined;
|
|
@@ -1,15 +1,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { HttpErrorResponse } from '@angular/common/http';
|
|
2
|
+
import { ActionContext } from '../components/action/models';
|
|
3
|
+
export type MngErrorTypes = 'MngInternalError' | 'MngActionError' | 'MngHttpError';
|
|
4
|
+
/**
|
|
5
|
+
* Main use for mng error from action execution.
|
|
6
|
+
* If http error is thrown, add it in cause.
|
|
7
|
+
*/
|
|
8
|
+
export interface IMngError extends Error {
|
|
9
|
+
type: MngErrorTypes;
|
|
6
10
|
messageCode?: number | string;
|
|
7
11
|
message: string;
|
|
8
|
-
notification?: Message;
|
|
9
12
|
details?: any;
|
|
10
|
-
status?: number;
|
|
11
|
-
statusDescription?: string;
|
|
12
13
|
stack?: string;
|
|
13
|
-
url?: string;
|
|
14
14
|
cause?: Error | unknown;
|
|
15
15
|
}
|
|
16
|
+
export interface MngErrorBaseOptions {
|
|
17
|
+
name?: string;
|
|
18
|
+
messageCode?: number | string;
|
|
19
|
+
details?: any;
|
|
20
|
+
cause?: Error;
|
|
21
|
+
stack?: string;
|
|
22
|
+
location?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare abstract class AMngErrorBase extends Error implements IMngError {
|
|
25
|
+
abstract readonly type: MngErrorTypes;
|
|
26
|
+
readonly messageCode?: number | string;
|
|
27
|
+
readonly location?: string;
|
|
28
|
+
readonly details?: any;
|
|
29
|
+
protected constructor(message: string, options?: MngErrorBaseOptions);
|
|
30
|
+
}
|
|
31
|
+
export declare class MngInternalError extends AMngErrorBase implements IMngError {
|
|
32
|
+
readonly type = "MngInternalError";
|
|
33
|
+
constructor(message: string, options?: MngErrorBaseOptions);
|
|
34
|
+
}
|
|
35
|
+
export declare class MngHttpError extends AMngErrorBase implements IMngError {
|
|
36
|
+
readonly type = "MngHttpError";
|
|
37
|
+
readonly httpError: HttpErrorResponse;
|
|
38
|
+
constructor(message: string, httpError: HttpErrorResponse, options?: MngErrorBaseOptions);
|
|
39
|
+
}
|
|
40
|
+
export interface MngActionErrorOptions extends MngErrorBaseOptions {
|
|
41
|
+
actionContext?: ActionContext<any, any>;
|
|
42
|
+
httpError?: HttpErrorResponse;
|
|
43
|
+
}
|
|
44
|
+
export declare class MngActionError extends AMngErrorBase implements IMngError {
|
|
45
|
+
readonly type = "MngActionError";
|
|
46
|
+
readonly actionId: string;
|
|
47
|
+
readonly actionContext?: ActionContext<any, any>;
|
|
48
|
+
readonly httpError?: HttpErrorResponse;
|
|
49
|
+
constructor(message: string, actionName: string, options?: MngActionErrorOptions);
|
|
50
|
+
}
|
package/lib/models/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export * from './column-value.model';
|
|
|
2
2
|
export * from './config.model';
|
|
3
3
|
export * from './enum.model';
|
|
4
4
|
export * from './error.model';
|
|
5
|
-
export * from './internal-error.model';
|
|
6
5
|
export * from './log.model';
|
|
7
6
|
export * from './menu.model';
|
|
8
7
|
export * from './user.model';
|
|
@@ -9,10 +9,12 @@ export declare enum LogLevelEnum {
|
|
|
9
9
|
export interface MngLogEntry {
|
|
10
10
|
level: LogLevelEnum;
|
|
11
11
|
message: string;
|
|
12
|
-
|
|
13
|
-
category?: string;
|
|
12
|
+
messageDetails?: string;
|
|
14
13
|
timestamp: Date;
|
|
15
14
|
timestampFormatted?: string;
|
|
15
|
+
category?: string;
|
|
16
|
+
error?: Error;
|
|
17
|
+
data?: any[];
|
|
16
18
|
}
|
|
17
19
|
export interface MngLogConfig {
|
|
18
20
|
level?: LogLevelEnum;
|
|
@@ -25,10 +27,14 @@ export interface MngLogConfig {
|
|
|
25
27
|
}
|
|
26
28
|
export interface IMngLoggerService {
|
|
27
29
|
create(context: string): IMngLoggerService;
|
|
28
|
-
trace(
|
|
29
|
-
debug(
|
|
30
|
-
log(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
trace(msgOrError: string | Error, ...data: any[]): void;
|
|
31
|
+
debug(msgOrError: string | Error, ...data: any[]): void;
|
|
32
|
+
log(msgOrError: string | Error, logLevel: LogLevelEnum, category: string | undefined, ...data: any[]): void;
|
|
33
|
+
logEntry(logEntry: Partial<MngLogEntry>): void;
|
|
34
|
+
info(msgOrError: string | Error, ...data: any[]): void;
|
|
35
|
+
warn(msgOrError: string | Error, ...data: any[]): void;
|
|
36
|
+
error(msgOrError: string | Error, ...data: any[]): void;
|
|
37
|
+
}
|
|
38
|
+
export interface IMngLogPublisher {
|
|
39
|
+
addEntry(entry: MngLogEntry): void;
|
|
34
40
|
}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IMngError } from '../models';
|
|
2
2
|
/**
|
|
3
3
|
* Service for transforming errors in action execution.
|
|
4
4
|
* Can be used to transform errors to Commons MngError interface for correct error message display.
|
|
5
5
|
*/
|
|
6
6
|
export declare abstract class MngActionErrorMapperService {
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Can be used to enrich data from error and make it more "stable". Most use cases cover extracting message or message code of an
|
|
9
|
+
* error out of http response body/headers.
|
|
10
|
+
*
|
|
11
|
+
* @param error Original error (cause).
|
|
12
|
+
* @param mngError Commons mng error that wraps original error.
|
|
13
|
+
*/
|
|
14
|
+
abstract toMngError(error?: any, mngError?: IMngError): IMngError;
|
|
8
15
|
}
|
|
9
16
|
export declare class DefaultActionMngErrorMapperService extends MngActionErrorMapperService {
|
|
10
|
-
toMngError(error?: any, mngError?:
|
|
17
|
+
toMngError(error?: any, mngError?: IMngError): IMngError;
|
|
11
18
|
}
|
|
@@ -5,7 +5,7 @@ import { DialogService } from 'primeng/dynamicdialog';
|
|
|
5
5
|
import { ActionContext, ActionContextValidation, ActionInstance, ActionParameters } from '../components/action/models';
|
|
6
6
|
import { IDataProvider, IEditorDataProvider } from '../data-providers';
|
|
7
7
|
import { ActionDescriptor, ActionEditorDescriptor } from '../descriptors/action';
|
|
8
|
-
import { IActionEditorComponent,
|
|
8
|
+
import { IActionEditorComponent, IMngError } from '../models';
|
|
9
9
|
import { MngParametrizePipe } from '../pipes';
|
|
10
10
|
import { MngActionErrorMapperService } from './action-error-mapper.service';
|
|
11
11
|
import { MngCommonsService } from './commons.service';
|
|
@@ -158,10 +158,11 @@ export declare class MngActionExecutorService {
|
|
|
158
158
|
/**
|
|
159
159
|
* Transform error of any type to mng error by using error mapper that could be provided by final project.
|
|
160
160
|
* @param error error of any type.
|
|
161
|
+
* @param context Action context.
|
|
161
162
|
*
|
|
162
163
|
* @return mapped MngError.
|
|
163
164
|
*/
|
|
164
|
-
toMngActionError(error?: any):
|
|
165
|
+
toMngActionError(error?: any, context?: ActionContext<any, any>): IMngError;
|
|
165
166
|
/**
|
|
166
167
|
* Creates or gets existing action instance.
|
|
167
168
|
* @param instance Action instance.
|
package/lib/services/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { IMngLoggerService, LogLevelEnum } from '../models';
|
|
1
|
+
import { IMngLogPublisher, IMngLoggerService, LogLevelEnum, MngLogEntry } from '../models';
|
|
2
2
|
import { MngConfigurationService } from './configuration.service';
|
|
3
3
|
export declare class MngLoggerService implements IMngLoggerService {
|
|
4
4
|
private static _instance;
|
|
5
5
|
private static _isInit;
|
|
6
6
|
private static _configurationService?;
|
|
7
|
+
private static _publishers;
|
|
7
8
|
private static _entriesBuffer;
|
|
8
9
|
private static _categoryInstances;
|
|
9
10
|
private static _timestampFormat;
|
|
@@ -15,16 +16,18 @@ export declare class MngLoggerService implements IMngLoggerService {
|
|
|
15
16
|
static configure(config: {
|
|
16
17
|
timestampFormat?: string;
|
|
17
18
|
}): void;
|
|
18
|
-
static init(configurationService: MngConfigurationService): void;
|
|
19
|
+
static init(configurationService: MngConfigurationService, publishers: IMngLogPublisher[]): void;
|
|
19
20
|
private static _flushBuffer;
|
|
20
21
|
static create(category: string): MngLoggerService;
|
|
21
22
|
create(category: string): MngLoggerService;
|
|
22
23
|
private _processLog;
|
|
24
|
+
private _getTimestamps;
|
|
23
25
|
private _log;
|
|
24
|
-
trace(
|
|
25
|
-
debug(
|
|
26
|
-
log(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
trace(msgOrError: string | Error, ...data: any[]): void;
|
|
27
|
+
debug(msgOrError: string | Error, ...data: any[]): void;
|
|
28
|
+
log(msgOrError: string | Error, logLevel?: LogLevelEnum, category?: string | undefined, ...data: any[]): void;
|
|
29
|
+
logEntry<E extends Partial<MngLogEntry>>(logEntry: E): void;
|
|
30
|
+
info(msgOrError: string | Error, ...data: any[]): void;
|
|
31
|
+
warn(msgOrError: string | Error, ...data: any[]): void;
|
|
32
|
+
error(msgOrError: string | Error, ...data: any[]): void;
|
|
30
33
|
}
|
|
@@ -5,6 +5,7 @@ import * as i0 from "@angular/core";
|
|
|
5
5
|
export declare class MngVersionService {
|
|
6
6
|
private http;
|
|
7
7
|
private configurationService;
|
|
8
|
+
private readonly logger;
|
|
8
9
|
private cache;
|
|
9
10
|
constructor(http: HttpClient, configurationService: MngConfigurationService);
|
|
10
11
|
loadVersion(path: string, baseConfigKey?: string, jsonPath?: string): Observable<unknown>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { HttpErrorResponse } from '@angular/common/http';
|
|
2
|
+
import { AMngErrorBase, LogLevelEnum, MngActionError } from '../models';
|
|
3
|
+
export declare class ErrorUtil {
|
|
4
|
+
/**
|
|
5
|
+
* Converts RxJS subscription error to MngError.
|
|
6
|
+
* @param error Error.
|
|
7
|
+
* @param name Optional name to write in mngError.
|
|
8
|
+
* @param details Optional details of error.
|
|
9
|
+
*/
|
|
10
|
+
static fromSubscribeError(error: any, name?: string, details?: any): AMngErrorBase;
|
|
11
|
+
/**
|
|
12
|
+
* Checks if error is Http error (Angular or Mng).
|
|
13
|
+
* @param error
|
|
14
|
+
*/
|
|
15
|
+
static isHttpErrorResponse(error: any): boolean | HttpErrorResponse | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Gets HttpErrorResponse from error (Angular or Mng).
|
|
18
|
+
* @param error Error.
|
|
19
|
+
*/
|
|
20
|
+
static getHttpErrorResponse(error: any): HttpErrorResponse | null;
|
|
21
|
+
/**
|
|
22
|
+
* Gets HttpErrorResponse status from error (Angular or Mng).
|
|
23
|
+
* @param error Error.
|
|
24
|
+
*/
|
|
25
|
+
static getHttpErrorResponseStatus(error: any): number | null;
|
|
26
|
+
/**
|
|
27
|
+
* Get error log level. All is error, except if error is http error with status >=400 and <500.
|
|
28
|
+
* @param error Error.
|
|
29
|
+
*/
|
|
30
|
+
static getErrorLogLevel(error: any): LogLevelEnum;
|
|
31
|
+
/**
|
|
32
|
+
* Get error name (prototype name or type from mng error if name is not provided).
|
|
33
|
+
* @param error Error.
|
|
34
|
+
*/
|
|
35
|
+
static getErrorName(error: any): string;
|
|
36
|
+
/**
|
|
37
|
+
* Writes http error to string with all headers and body.
|
|
38
|
+
* @param error Http response error.
|
|
39
|
+
* @param opts Options for hiding parts of error:
|
|
40
|
+
* - hideMessage Hides message of error (message include url, status and status text!).
|
|
41
|
+
* - hideHeaders Hides headers.
|
|
42
|
+
* - hideBody Hides JSON representation of body.
|
|
43
|
+
*/
|
|
44
|
+
static httpErrorResponseToString(error: HttpErrorResponse, opts?: HttpErrorResponseToStringOptions): string;
|
|
45
|
+
/**
|
|
46
|
+
* Error to string.
|
|
47
|
+
* @param error Error.
|
|
48
|
+
* @param opts Options for hiding parts of error:
|
|
49
|
+
* - hideMessage Hides message of error.
|
|
50
|
+
* - hideName Hides error name.
|
|
51
|
+
* - hideCause Hides cause of an error (if present, see @link(errorCauseToString) for other options).
|
|
52
|
+
* - hideStack Hides stack of an error (if present).
|
|
53
|
+
* - hideDetails Hides JSON detail's representation of error (if present).
|
|
54
|
+
* - hideLocation Hides location (URL) where error was thrown.
|
|
55
|
+
* - hideHttp Hides http error portion of error if http error response (see @link(httpErrorResponseToString) for other options).
|
|
56
|
+
*/
|
|
57
|
+
static errorToString(error: Error, opts?: ErrorToStringOptions): string;
|
|
58
|
+
/**
|
|
59
|
+
* Mng error to string.
|
|
60
|
+
* @param error Mng error.
|
|
61
|
+
* @param opts Options for hiding parts of error:
|
|
62
|
+
* - hideMessage Hides message of error.
|
|
63
|
+
* - hideName Hides error name.
|
|
64
|
+
* - hideCause Hides cause of an error (if present, see @link(errorCauseToString) for other options).
|
|
65
|
+
* - hideStack Hides stack of an error (if present).
|
|
66
|
+
* - hideDetails Hides JSON detail's representation of error (if present).
|
|
67
|
+
* - hideLocation Hides location (URL) where error was thrown.
|
|
68
|
+
* - hideHttp Hides http error portion of error if http error response (see @link(httpErrorResponseToString) for other options).
|
|
69
|
+
* - hideItems Hides all item information (http body, action context data).
|
|
70
|
+
* - hideActionData See @link(mngActionErrorContextToString) for additional info.
|
|
71
|
+
* - hideQueryParams See @link(mngActionErrorContextToString) for additional info.
|
|
72
|
+
*/
|
|
73
|
+
static mngErrorToString(error: AMngErrorBase, opts?: MngErrorToStringOptions): string;
|
|
74
|
+
/**
|
|
75
|
+
* Writes Mng action error info from context as string.
|
|
76
|
+
* @param error Mng action error.
|
|
77
|
+
* @param opts Options for hiding parts of error:
|
|
78
|
+
* - hideItems Hides all item related information (item, form item, submit item, ...).
|
|
79
|
+
* - hideActionData Hides action data.
|
|
80
|
+
* - hideQueryParams Hides query params.
|
|
81
|
+
*/
|
|
82
|
+
static mngActionErrorContextToString(error: MngActionError, opts?: MngActionErrorContextToStringOptions): string;
|
|
83
|
+
/**
|
|
84
|
+
* Writes cause of an error as string.
|
|
85
|
+
* @param error Error.
|
|
86
|
+
* @param opts Options for hiding parts of error:
|
|
87
|
+
* - causeOnErrorOnly Prints only if cause is instance of error.
|
|
88
|
+
* - causeAsJson Print error cause as a JSON (by default, if error only message and name will be printed).
|
|
89
|
+
*/
|
|
90
|
+
static errorCauseToString(error: Error, opts?: ErrorCauseToStringOptions): string;
|
|
91
|
+
}
|
|
92
|
+
export type ErrorToStringOptions = MngErrorToStringOptions;
|
|
93
|
+
export type MngErrorToStringOptions = ErrorToStringOptionsBase & HttpErrorResponseToStringOptions & MngActionErrorContextToStringOptions & ErrorCauseToStringOptions & {
|
|
94
|
+
hideDetails?: boolean;
|
|
95
|
+
hideLocation?: boolean;
|
|
96
|
+
};
|
|
97
|
+
export interface ErrorToStringOptionsBase {
|
|
98
|
+
hideName?: boolean;
|
|
99
|
+
hideStack?: boolean;
|
|
100
|
+
hideCause?: boolean;
|
|
101
|
+
hideHttp?: boolean;
|
|
102
|
+
}
|
|
103
|
+
export interface HttpErrorResponseToStringOptions {
|
|
104
|
+
hideMessage?: boolean;
|
|
105
|
+
hideHeaders?: boolean;
|
|
106
|
+
hideBody?: boolean;
|
|
107
|
+
}
|
|
108
|
+
export interface MngActionErrorContextToStringOptions {
|
|
109
|
+
hideItems?: boolean;
|
|
110
|
+
hideActionData?: boolean;
|
|
111
|
+
hideQueryParams?: boolean;
|
|
112
|
+
}
|
|
113
|
+
export interface ErrorCauseToStringOptions {
|
|
114
|
+
causeOnErrorOnly?: boolean;
|
|
115
|
+
causeAsJson?: boolean;
|
|
116
|
+
}
|
package/lib/utils/i18n.util.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { TranslateService } from '@ngx-translate/core';
|
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { ModelDescriptor } from '../descriptors';
|
|
4
4
|
import { ActionDescriptor, ActionEditorDescriptor } from '../descriptors/action';
|
|
5
|
-
import {
|
|
5
|
+
import { IMngError } from '../models';
|
|
6
6
|
import { ClassType } from '../types';
|
|
7
7
|
import { I18nType } from '../types/i18n.type';
|
|
8
8
|
export declare namespace I18nUtils {
|
|
@@ -80,7 +80,7 @@ export declare namespace I18nUtils {
|
|
|
80
80
|
private static getKeysByPriority;
|
|
81
81
|
}
|
|
82
82
|
class Error {
|
|
83
|
-
static get(translate: TranslateService, error:
|
|
84
|
-
static getParams(error:
|
|
83
|
+
static get(translate: TranslateService, error: IMngError, params?: any): string | null;
|
|
84
|
+
static getParams(error: IMngError, params?: any): any;
|
|
85
85
|
}
|
|
86
86
|
}
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -2,12 +2,12 @@ import { TranslateService } from '@ngx-translate/core';
|
|
|
2
2
|
import { Message } from 'primeng/api';
|
|
3
3
|
import { ActionDescriptor } from '../descriptors/action';
|
|
4
4
|
import { TableDescriptor } from '../descriptors/table';
|
|
5
|
-
import {
|
|
5
|
+
import { IMngError, IViewContainer } from '../models';
|
|
6
6
|
export declare class NotificationUtil {
|
|
7
7
|
static notification(viewContainer?: IViewContainer<any, any>, title?: string, message?: string, severity?: 'success' | 'warn' | 'error', icon?: string): Message;
|
|
8
8
|
static tableNotificationError(translate: TranslateService, table: TableDescriptor<any>, error: any, viewContainer?: IViewContainer<any, any>): Message;
|
|
9
9
|
static actionNotificationSuccess(translate: TranslateService, action: ActionDescriptor<any>, functionName: string, customTitleKey?: string, customMessageKey?: string, viewContainer?: IViewContainer<any, any>, item?: any): Message;
|
|
10
|
-
static actionNotificationError(translate: TranslateService, action: ActionDescriptor<any>, error:
|
|
10
|
+
static actionNotificationError(translate: TranslateService, action: ActionDescriptor<any>, error: IMngError, functionName: string, viewContainer?: IViewContainer<any, any>, item?: any, severity?: 'warn' | 'error'): Message;
|
|
11
11
|
static getFormEditorInfoMessage(translate: TranslateService, title: string, message: string, params?: any): Message;
|
|
12
12
|
static getFormEditorWarningMessage(translate: TranslateService, title: string, message: string): Message;
|
|
13
13
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export declare class StringUtil {
|
|
2
2
|
static escapeHtml(value: string): any;
|
|
3
3
|
static escapeHtmlAny(value?: any): any;
|
|
4
|
+
/**
|
|
5
|
+
* Stringifies a value - primitives with toString, dates with dateUtil, objects with JSON.stringify.
|
|
6
|
+
* @param value Any value.
|
|
7
|
+
*/
|
|
8
|
+
static stringify(value: any): string;
|
|
4
9
|
}
|
package/package.json
CHANGED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export class MngInternalError extends Error {
|
|
2
|
-
constructor(message, name = 'Commons Internal Error', options) {
|
|
3
|
-
super(message);
|
|
4
|
-
this.type = 'MngInternalError';
|
|
5
|
-
this.name = name;
|
|
6
|
-
this.id = options?.id;
|
|
7
|
-
this.messageCode = options?.messageCode;
|
|
8
|
-
this.notification = options?.notification ?? this.generateNotification();
|
|
9
|
-
this.details = options?.details;
|
|
10
|
-
this.status = options?.status;
|
|
11
|
-
this.statusDescription = options?.statusDescription;
|
|
12
|
-
this.url = options?.url;
|
|
13
|
-
this.cause = options?.cause;
|
|
14
|
-
this.stack = options?.stack ?? (options?.cause ? options.cause.stack : new Error(message).stack);
|
|
15
|
-
}
|
|
16
|
-
get messageLog() {
|
|
17
|
-
let message = this.message;
|
|
18
|
-
if (this.cause && this.cause instanceof Error) {
|
|
19
|
-
message += `\nCaused by ${this.cause.name}: ${this.cause.message}`;
|
|
20
|
-
}
|
|
21
|
-
if (this.stack) {
|
|
22
|
-
message += `\nStack trace:\n${this.stack}`;
|
|
23
|
-
}
|
|
24
|
-
return message;
|
|
25
|
-
}
|
|
26
|
-
generateNotification() {
|
|
27
|
-
return { severity: 'error', summary: this.name, detail: this.message, life: 10000 };
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJuYWwtZXJyb3IubW9kZWwuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvbGliL21vZGVscy9pbnRlcm5hbC1lcnJvci5tb2RlbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFLQSxNQUFNLE9BQU8sZ0JBQWlCLFNBQVEsS0FBSztJQVV2QyxZQUNJLE9BQWUsRUFDZixJQUFJLEdBQUcsd0JBQXdCLEVBQy9CLE9BVUM7UUFFRCxLQUFLLENBQUMsT0FBTyxDQUFDLENBQUM7UUF4QkgsU0FBSSxHQUFHLGtCQUFrQixDQUFDO1FBeUJ0QyxJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQztRQUVqQixJQUFJLENBQUMsRUFBRSxHQUFHLE9BQU8sRUFBRSxFQUFFLENBQUM7UUFDdEIsSUFBSSxDQUFDLFdBQVcsR0FBRyxPQUFPLEVBQUUsV0FBVyxDQUFDO1FBQ3hDLElBQUksQ0FBQyxZQUFZLEdBQUcsT0FBTyxFQU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ZSAmJiB0aGlzLmNhdXNlIGluc3RhbmNlb2YgRXJyb3IpIHtcbiAgICAgICAgICAgIG1lc3NhZ2UgKz0gYFxcbkNhdXNlZCBieSAke3RoaXMuY2F1c2UubmFtZX06ICR7dGhpcy5jYXVzZS5tZXNzYWdlfWA7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuc3RhY2spIHtcbiAgICAgICAgICAgIG1lc3NhZ2UgKz0gYFxcblN0YWNrIHRyYWNlOlxcbiR7dGhpcy5zdGFja31gO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIG1lc3NhZ2U7XG4gICAgfVxuXG4gICAgcHJpdmF0ZSBnZW5lcmF0ZU5vdGlmaWNhdGlvbigpOiBNZXNzYWdlIHtcbiAgICAgICAgcmV0dXJuIHtzZXZlcml0eTogJ2Vycm9yJywgc3VtbWFyeTogdGhpcy5uYW1lLCBkZXRhaWw6IHRoaXMubWVzc2FnZSwgbGlmZTogMTAwMDB9O1xuICAgIH1cbn1cbiJdfQ==
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Message } from 'primeng/api';
|
|
2
|
-
import { IdType } from '../types';
|
|
3
|
-
import { MngError } from './index';
|
|
4
|
-
export declare class MngInternalError extends Error implements MngError {
|
|
5
|
-
readonly type = "MngInternalError";
|
|
6
|
-
id?: IdType;
|
|
7
|
-
messageCode?: number | string;
|
|
8
|
-
notification?: Message;
|
|
9
|
-
details?: any;
|
|
10
|
-
status?: number;
|
|
11
|
-
statusDescription?: string;
|
|
12
|
-
url?: string;
|
|
13
|
-
constructor(message: string, name?: string, options?: {
|
|
14
|
-
id?: IdType;
|
|
15
|
-
messageCode?: number | string;
|
|
16
|
-
notification?: Message;
|
|
17
|
-
details?: any;
|
|
18
|
-
status?: number;
|
|
19
|
-
statusDescription?: string;
|
|
20
|
-
url?: string;
|
|
21
|
-
cause?: Error;
|
|
22
|
-
stack?: string;
|
|
23
|
-
});
|
|
24
|
-
get messageLog(): string;
|
|
25
|
-
private generateNotification;
|
|
26
|
-
}
|