@sankhyalabs/core 5.20.0-dev.46 → 5.20.0-dev.48
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/.docs/classes/Change.md +11 -11
- package/.docs/classes/DataUnit.md +133 -133
- package/.docs/classes/SelectionInfo.md +12 -12
- package/.docs/classes/ServiceCanceledException.md +193 -0
- package/.docs/enumerations/ChangeOperation.md +4 -4
- package/.docs/enumerations/SelectionMode.md +2 -2
- package/.docs/globals.md +1 -0
- package/.docs/interfaces/DUActionInterceptor.md +1 -1
- package/.docs/interfaces/PageRequest.md +3 -3
- package/.docs/interfaces/QuickFilter.md +3 -3
- package/.docs/interfaces/Record.md +4 -4
- package/.docs/interfaces/SavedRecord.md +5 -5
- package/.docs/interfaces/WaitingChange.md +3 -3
- package/.docs/type-aliases/DataUnitEventOptions.md +1 -1
- package/dist/dataunit/DataUnit.d.ts +1 -1
- package/dist/dataunit/DataUnit.js +14 -11
- package/dist/dataunit/DataUnit.js.map +1 -1
- package/dist/exceptions/ServiceCanceledException.d.ts +14 -0
- package/dist/exceptions/ServiceCanceledException.js +13 -0
- package/dist/exceptions/ServiceCanceledException.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/reports/test-report.xml +87 -87
- package/src/dataunit/DataUnit.ts +17 -13
- package/src/exceptions/ServiceCanceledException.ts +25 -0
- package/src/index.ts +3 -1
package/src/dataunit/DataUnit.ts
CHANGED
|
@@ -27,6 +27,7 @@ import { DataUnitStorage } from "./DataUnitStorage.js";
|
|
|
27
27
|
import { getInvalidFieldMessage, InvalidFieldsReducer } from "./state/slice/InvalidFieldsSlice.js";
|
|
28
28
|
import { getLoadingProperties, LoadingPropertiesReducer } from "./state/slice/LoadingProperties.js";
|
|
29
29
|
import SortingUtils from "../utils/SortingUtils.js";
|
|
30
|
+
import ServiceCanceledException from "../exceptions/ServiceCanceledException.js";
|
|
30
31
|
|
|
31
32
|
/***
|
|
32
33
|
* `DataUnit`: Atua como uma camada de abstração entre o back-end e a interface do usuário.
|
|
@@ -39,7 +40,7 @@ export default class DataUnit {
|
|
|
39
40
|
|
|
40
41
|
private _uuid: string;
|
|
41
42
|
private _name: string;
|
|
42
|
-
private _observers:
|
|
43
|
+
private _observers: Map<string, (action: DataUnitAction, options?:DataUnitEventOptions) => void>;
|
|
43
44
|
private _sortingProvider?: SortingProvider;
|
|
44
45
|
private _filterProviders: Map<string, FilterProvider>;
|
|
45
46
|
private _stateManager: StateManager;
|
|
@@ -79,7 +80,7 @@ export default class DataUnit {
|
|
|
79
80
|
SnapshotReducer
|
|
80
81
|
]
|
|
81
82
|
);
|
|
82
|
-
this._observers =
|
|
83
|
+
this._observers = new Map();
|
|
83
84
|
this._filterProviders = new Map<string, FilterProvider>();
|
|
84
85
|
this._sortingProvider = undefined;
|
|
85
86
|
this._defaultSorting = [];
|
|
@@ -117,7 +118,7 @@ export default class DataUnit {
|
|
|
117
118
|
public releaseCallbacks(){
|
|
118
119
|
if(!this._allowReleaseCallbacks) return;
|
|
119
120
|
|
|
120
|
-
this._observers =
|
|
121
|
+
this._observers = new Map();
|
|
121
122
|
this._filterProviders = new Map<string, FilterProvider>();
|
|
122
123
|
this._sortingProvider = undefined;
|
|
123
124
|
this._interceptors = new Map();
|
|
@@ -485,7 +486,12 @@ export default class DataUnit {
|
|
|
485
486
|
const {errorCode} = cause;
|
|
486
487
|
this.dispatchAction(Action.SAVING_ERROR);
|
|
487
488
|
this.dispatchAction(Action.LOADING_PROPERTIES_CLEANED);
|
|
488
|
-
|
|
489
|
+
if(cause instanceof ServiceCanceledException){
|
|
490
|
+
console.debug("Service canceled: " + cause.message)
|
|
491
|
+
resolve()
|
|
492
|
+
} else{
|
|
493
|
+
fail(new ErrorException("Erro ao salvar alterações", cause, errorCode))
|
|
494
|
+
}
|
|
489
495
|
});
|
|
490
496
|
} else {
|
|
491
497
|
this.dispatchAction(Action.LOADING_PROPERTIES_CLEANED);
|
|
@@ -1538,15 +1544,12 @@ export default class DataUnit {
|
|
|
1538
1544
|
private doDispatchAction(action: DataUnitAction, options:DataUnitEventOptions = {}): void {
|
|
1539
1545
|
this._stateManager.process(action);
|
|
1540
1546
|
this?._parentDataUnit?.dispatchAction(Action.CHILD_CHANGED, { srcAction: action, srcDataUnit: this });
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
if some observer throws exceptions,
|
|
1544
|
-
should be continued
|
|
1545
|
-
*/
|
|
1547
|
+
|
|
1548
|
+
this._observers.forEach((f) => {
|
|
1546
1549
|
try {
|
|
1547
1550
|
f(action, options);
|
|
1548
1551
|
} catch (e) {
|
|
1549
|
-
console.warn("[DataUnit] error while
|
|
1552
|
+
console.warn("[DataUnit] error while calling observer", e);
|
|
1550
1553
|
}
|
|
1551
1554
|
});
|
|
1552
1555
|
}
|
|
@@ -1584,7 +1587,8 @@ export default class DataUnit {
|
|
|
1584
1587
|
*
|
|
1585
1588
|
*/
|
|
1586
1589
|
public subscribe(observer: (action: DataUnitAction, options?:DataUnitEventOptions) => void | Promise<void>) {
|
|
1587
|
-
|
|
1590
|
+
|
|
1591
|
+
this._observers.set(observer.toString(), observer);
|
|
1588
1592
|
}
|
|
1589
1593
|
|
|
1590
1594
|
/**
|
|
@@ -1594,8 +1598,8 @@ export default class DataUnit {
|
|
|
1594
1598
|
* @param observer - Observer que se deseja remover.
|
|
1595
1599
|
*
|
|
1596
1600
|
*/
|
|
1597
|
-
public unsubscribe(observer:
|
|
1598
|
-
this._observers
|
|
1601
|
+
public unsubscribe(observer: (action: DataUnitAction, options?:DataUnitEventOptions) => void | Promise<void>) {
|
|
1602
|
+
this._observers.delete(observer.toString());
|
|
1599
1603
|
}
|
|
1600
1604
|
|
|
1601
1605
|
/**
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ServiceCanceledException`: Exceção lançada quando ocorre o cancelamento de um serviço.
|
|
3
|
+
*/
|
|
4
|
+
export default class ServiceCanceledException extends Error {
|
|
5
|
+
|
|
6
|
+
/** Nome da exceção. */
|
|
7
|
+
public name: string;
|
|
8
|
+
|
|
9
|
+
/** Titulo do erro. */
|
|
10
|
+
public title: string;
|
|
11
|
+
|
|
12
|
+
/** Descrição do erro. */
|
|
13
|
+
public message: string;
|
|
14
|
+
|
|
15
|
+
/** Código do erro, indica o erro disparado pelo backend. */
|
|
16
|
+
public errorCode: string;
|
|
17
|
+
|
|
18
|
+
constructor(title: string, message: string, errorCode: string = "") {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = "Service Canceled";
|
|
21
|
+
this.title = title;
|
|
22
|
+
this.message = message;
|
|
23
|
+
this.errorCode = errorCode;
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ import ObjectUtils from "./utils/ObjectUtils.js";
|
|
|
19
19
|
import WarningException from "./exceptions/WarningException.js";
|
|
20
20
|
import WaitingChangeException from "./exceptions/WaitingChangeException.js";
|
|
21
21
|
import ErrorException from "./exceptions/ErrorException.js";
|
|
22
|
+
import ServiceCanceledException from "./exceptions/ServiceCanceledException.js";
|
|
22
23
|
import { ErrorTracking } from "./traking/ErrorTraking.js";
|
|
23
24
|
import { PaginationInfo } from "./dataunit/loading/PaginationInfo.js";
|
|
24
25
|
import { LoadDataRequest } from "./dataunit/loading/LoadDataRequest.js";
|
|
@@ -112,5 +113,6 @@ export {
|
|
|
112
113
|
OverflowDirection,
|
|
113
114
|
OverFlowWatcherParams,
|
|
114
115
|
OVERFLOWED_CLASS_NAME,
|
|
115
|
-
DataUnitEventOptions
|
|
116
|
+
DataUnitEventOptions,
|
|
117
|
+
ServiceCanceledException
|
|
116
118
|
};
|