monkey-front-core 0.0.470 → 0.0.471
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/esm2020/lib/core/services/store/index.mjs +2 -1
- package/esm2020/lib/core/services/store/monkeyecx-store-base.service.mjs +169 -0
- package/esm2020/lib/core/services/store/monkeyecx-store.selector.mjs +9 -3
- package/fesm2015/monkey-front-core.mjs +177 -3
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +173 -3
- package/fesm2020/monkey-front-core.mjs.map +1 -1
- package/lib/core/services/store/index.d.ts +1 -0
- package/lib/core/services/store/monkeyecx-store-base.service.d.ts +47 -0
- package/lib/core/services/store/monkeyecx-store.selector.d.ts +4 -4
- package/monkey-front-core-0.0.471.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.470.tgz +0 -0
|
@@ -5640,6 +5640,170 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
5640
5640
|
}]
|
|
5641
5641
|
}], ctorParameters: function () { return [{ type: MonkeyEcxService }, { type: MonkeyEcxLoggedHandlingService }]; }, propDecorators: { doCall: [], doGenericCall: [] } });
|
|
5642
5642
|
|
|
5643
|
+
/**
|
|
5644
|
+
* Classe genérica que recebe duas interfaces como tipos genéricos.
|
|
5645
|
+
*
|
|
5646
|
+
* @typeparam T deve ser a mesma interface utilizada na Entity da Store
|
|
5647
|
+
* @typeparam K faz referência ao tipo de configuração.
|
|
5648
|
+
*
|
|
5649
|
+
* @description interfaces de configuração:
|
|
5650
|
+
* ```
|
|
5651
|
+
* MonkeyEcxCollectionStore e MonkeyEcxEntityStore
|
|
5652
|
+
* ```
|
|
5653
|
+
*/
|
|
5654
|
+
class MonkeyEcxCommonsStoreBaseService extends MonkeyEcxCommonsService {
|
|
5655
|
+
constructor(monkeyecxService, tokenStorage, store, config) {
|
|
5656
|
+
super(monkeyecxService, tokenStorage);
|
|
5657
|
+
this.store = store;
|
|
5658
|
+
const { actions, selectors } = config;
|
|
5659
|
+
this.action = actions;
|
|
5660
|
+
this.selector = selectors;
|
|
5661
|
+
}
|
|
5662
|
+
handleResponseData(resp, updateLinks = true) {
|
|
5663
|
+
try {
|
|
5664
|
+
let data;
|
|
5665
|
+
if (resp?._embedded) {
|
|
5666
|
+
const { _embedded, _links, page } = resp;
|
|
5667
|
+
const key = Object.keys(_embedded)[0];
|
|
5668
|
+
data = _embedded[key];
|
|
5669
|
+
if (updateLinks) {
|
|
5670
|
+
this.updateLinks?.(_links);
|
|
5671
|
+
}
|
|
5672
|
+
this.updatePage?.(page);
|
|
5673
|
+
}
|
|
5674
|
+
else
|
|
5675
|
+
data = resp;
|
|
5676
|
+
this.update?.(data);
|
|
5677
|
+
}
|
|
5678
|
+
catch (e) {
|
|
5679
|
+
throw new Error(`MECX Core - Method handleResponseData -> ${e}`);
|
|
5680
|
+
}
|
|
5681
|
+
}
|
|
5682
|
+
updateControl(data) {
|
|
5683
|
+
try {
|
|
5684
|
+
this.store.dispatch(this.action.updateControl({
|
|
5685
|
+
data
|
|
5686
|
+
}));
|
|
5687
|
+
}
|
|
5688
|
+
catch (e) {
|
|
5689
|
+
throw new Error(`MECX Core - Method updateControl -> ${e}`);
|
|
5690
|
+
}
|
|
5691
|
+
}
|
|
5692
|
+
mappingData(args) {
|
|
5693
|
+
try {
|
|
5694
|
+
const handle = (item) => {
|
|
5695
|
+
let id = '';
|
|
5696
|
+
const { href } = new MonkeyEcxLinksModel(item)?.getAction('self') || {
|
|
5697
|
+
href: ''
|
|
5698
|
+
};
|
|
5699
|
+
if (href) {
|
|
5700
|
+
id = href.split('/').pop() || '';
|
|
5701
|
+
}
|
|
5702
|
+
return {
|
|
5703
|
+
...item,
|
|
5704
|
+
id
|
|
5705
|
+
};
|
|
5706
|
+
};
|
|
5707
|
+
if (args instanceof Array) {
|
|
5708
|
+
return args.map((item) => {
|
|
5709
|
+
return handle(item);
|
|
5710
|
+
});
|
|
5711
|
+
}
|
|
5712
|
+
return handle(args);
|
|
5713
|
+
}
|
|
5714
|
+
catch (e) {
|
|
5715
|
+
throw new Error(`MECX Core - Method mappingData -> ${e}`);
|
|
5716
|
+
}
|
|
5717
|
+
}
|
|
5718
|
+
update(args) {
|
|
5719
|
+
try {
|
|
5720
|
+
let typeAction = 'updateOne';
|
|
5721
|
+
if (args instanceof Array) {
|
|
5722
|
+
typeAction = 'updateAll';
|
|
5723
|
+
}
|
|
5724
|
+
this.store.dispatch(this.action[typeAction]({
|
|
5725
|
+
data: this.mappingData(args)
|
|
5726
|
+
}));
|
|
5727
|
+
}
|
|
5728
|
+
catch (e) {
|
|
5729
|
+
throw new Error(`MECX Core - Method update -> ${e}`);
|
|
5730
|
+
}
|
|
5731
|
+
}
|
|
5732
|
+
updatePage(data) {
|
|
5733
|
+
try {
|
|
5734
|
+
this.store.dispatch(this.action.updatePage({
|
|
5735
|
+
data
|
|
5736
|
+
}));
|
|
5737
|
+
}
|
|
5738
|
+
catch (e) {
|
|
5739
|
+
throw new Error(`MECX Core - Method updatePage -> ${e}`);
|
|
5740
|
+
}
|
|
5741
|
+
}
|
|
5742
|
+
updateLinks(data) {
|
|
5743
|
+
try {
|
|
5744
|
+
this.store.dispatch(this.action.updateLinks({
|
|
5745
|
+
data
|
|
5746
|
+
}));
|
|
5747
|
+
}
|
|
5748
|
+
catch (e) {
|
|
5749
|
+
throw new Error(`MECX Core - Method updateLinks -> ${e}`);
|
|
5750
|
+
}
|
|
5751
|
+
}
|
|
5752
|
+
async loadData(url, updateLinks = true) {
|
|
5753
|
+
this.updateControl({ isLoading: true });
|
|
5754
|
+
try {
|
|
5755
|
+
const data = await this.monkeyecxService?.get(url).toPromise();
|
|
5756
|
+
this.handleResponseData(data, updateLinks);
|
|
5757
|
+
}
|
|
5758
|
+
catch (e) {
|
|
5759
|
+
throw new Error(`${e?.message}`);
|
|
5760
|
+
}
|
|
5761
|
+
this.updateControl({ isLoading: false });
|
|
5762
|
+
}
|
|
5763
|
+
async loadPageData(pagination) {
|
|
5764
|
+
const { store, selector } = this;
|
|
5765
|
+
const data = await store
|
|
5766
|
+
.select(selector.selectLinks())
|
|
5767
|
+
.pipe(take(1))
|
|
5768
|
+
.toPromise();
|
|
5769
|
+
const { action } = pagination;
|
|
5770
|
+
const { href } = new MonkeyEcxLinksModel({ _links: data }).getAction(action) || {
|
|
5771
|
+
href: ''
|
|
5772
|
+
};
|
|
5773
|
+
if (href) {
|
|
5774
|
+
this.loadData(href);
|
|
5775
|
+
}
|
|
5776
|
+
}
|
|
5777
|
+
/**
|
|
5778
|
+
* @description Neste método precisamos incluir a lógica para conferir se precisa limpar a
|
|
5779
|
+
* entidade ou não
|
|
5780
|
+
* E depois precisa invocar o método loadData
|
|
5781
|
+
* @param (url) ou de acordo com a action criada
|
|
5782
|
+
* @example
|
|
5783
|
+
* ```
|
|
5784
|
+
* const hasDifference = .....
|
|
5785
|
+
* if(hasDifference) {
|
|
5786
|
+
* store.dispatch(clear)
|
|
5787
|
+
* }
|
|
5788
|
+
*
|
|
5789
|
+
* this.loadData(...)
|
|
5790
|
+
* ```
|
|
5791
|
+
*/
|
|
5792
|
+
load(args) {
|
|
5793
|
+
throw new Error('MECX Core - Method load not implemented.');
|
|
5794
|
+
}
|
|
5795
|
+
loadPage(args) {
|
|
5796
|
+
throw new Error('MECX Core - Method loadPage not implemented.');
|
|
5797
|
+
}
|
|
5798
|
+
}
|
|
5799
|
+
__decorate([
|
|
5800
|
+
MonkeyEcxCoreService({
|
|
5801
|
+
requestInProgress: {
|
|
5802
|
+
showProgress: true
|
|
5803
|
+
}
|
|
5804
|
+
})
|
|
5805
|
+
], MonkeyEcxCommonsStoreBaseService.prototype, "loadData", null);
|
|
5806
|
+
|
|
5643
5807
|
class MonkeyEcxCommonsActions {
|
|
5644
5808
|
static getActions(actionName) {
|
|
5645
5809
|
const clear = createAction(`[${actionName}] Clear All`, props());
|
|
@@ -5694,12 +5858,18 @@ class MonkeyEcxCommonsSelectors {
|
|
|
5694
5858
|
};
|
|
5695
5859
|
const selectLinks = (props) => {
|
|
5696
5860
|
return createSelector(selectState, (state) => {
|
|
5697
|
-
|
|
5861
|
+
if (props?.identifier) {
|
|
5862
|
+
return state.links?.[props.identifier];
|
|
5863
|
+
}
|
|
5864
|
+
return state.links;
|
|
5698
5865
|
});
|
|
5699
5866
|
};
|
|
5700
5867
|
const selectPage = (props) => {
|
|
5701
5868
|
return createSelector(selectState, (state) => {
|
|
5702
|
-
|
|
5869
|
+
if (props?.identifier) {
|
|
5870
|
+
return state.page?.[props.identifier];
|
|
5871
|
+
}
|
|
5872
|
+
return state.page;
|
|
5703
5873
|
});
|
|
5704
5874
|
};
|
|
5705
5875
|
const linksHasDifference = (props) => {
|
|
@@ -6462,5 +6632,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
6462
6632
|
* Generated bundle index. Do not edit.
|
|
6463
6633
|
*/
|
|
6464
6634
|
|
|
6465
|
-
export { AlertsComponent, AlertsModule, ClosedToMaintenanceComponent, ClosedToMaintenanceModule, CurrencyConfigComponent, CurrencyConfigModule, decoratorsUtils as DecoratorsUtils, Link, MonkeyEcxAlertsService, MonkeyEcxAuthGuard, MonkeyEcxAuthGuardByRole, MonkeyEcxAuthGuardCompany, MonkeyEcxAuthGuardLogin, MonkeyEcxAuthenticationService, MonkeyEcxBlobSecurePipe, MonkeyEcxCommonsActions, MonkeyEcxCommonsResolveBaseService, MonkeyEcxCommonsResolveService, MonkeyEcxCommonsSelectors, MonkeyEcxCommonsService, MonkeyEcxCommonsStoreService, MonkeyEcxConfigModule, MonkeyEcxConfigService, MonkeyEcxCookieStorageService, MonkeyEcxCoreCharts, MonkeyEcxCoreClearDecorators, MonkeyEcxCoreLog, MonkeyEcxCoreService, MonkeyEcxCoreServiceConstructor, MonkeyEcxCoreServicePaged, MonkeyEcxCoreServiceQueue, MonkeyEcxCurrencyConfigService, MonkeyEcxDirectivesModule, MonkeyEcxDiscoveryParamsService, MonkeyEcxDisplayFirstNamePipe, MonkeyEcxDisplayInitialsPipe, MonkeyEcxDisplaySupportPhone, MonkeyEcxDragDropDirective, MonkeyEcxErrorConfigService, MonkeyEcxErrorHandlingModule, MonkeyEcxErrorHandlingService, MonkeyEcxFeatureByProgramDirective, MonkeyEcxFeatureDirective, MonkeyEcxFeatureToggleService, MonkeyEcxFormatAddressPipe, MonkeyEcxFormatBeaufityJSONPipe, MonkeyEcxFormatCurrency, MonkeyEcxFormatCurrencyPipe, MonkeyEcxFormatDateGroupPipe, MonkeyEcxFormatDateTimelapsePipe, MonkeyEcxFormatDateUnixTimelapsePipe, MonkeyEcxFormatDocumentPipe, MonkeyEcxFormatDocumentTypePipe, MonkeyEcxFormatNumberPipe, MonkeyEcxFormatPhonePipe, MonkeyEcxFormatSizePipe, MonkeyEcxFormatTaxPipe, MonkeyEcxFormatUpper, MonkeyEcxFormatValue, MonkeyEcxFormatZipCodePipe, MonkeyEcxHandlingService, MonkeyEcxHttpConfigErrorInterceptor, MonkeyEcxHttpConfigHeaderInterceptor, MonkeyEcxHttpConfigInterceptorModule, MonkeyEcxHttpConfigLoadingInProgressInterceptor, MonkeyEcxHttpConfigQueueInterceptor, MonkeyEcxHttpErrorHandlingService, MonkeyEcxLinksModel, MonkeyEcxLoggedHandlingService, MonkeyEcxLogsConfigService, MonkeyEcxMaintenanceConfigService, MonkeyEcxModel, MonkeyEcxOnlyAlphaNumericDirective, MonkeyEcxOnlyNumbersDirective, MonkeyEcxOthersErrorsHandlingService, MonkeyEcxPaginationService, MonkeyEcxPipesModule, MonkeyEcxPopoverDirective, MonkeyEcxPopoverOptionsDirective, MonkeyEcxProgressBarComponent, MonkeyEcxProgressBarModule, MonkeyEcxProgressBarService, MonkeyEcxRequestDownloadHandlingService, MonkeyEcxRequestDownloadedHandlingService, MonkeyEcxRequestPagedHandling, MonkeyEcxRequestQueueHandlingService, MonkeyEcxRequestQueueModalHandlingService, MonkeyEcxRequestScheduleService, MonkeyEcxSecurityConsoleConfigService, MonkeyEcxSecurityDirective, MonkeyEcxService, MonkeyEcxServiceDownload, MonkeyEcxServiceUpload, MonkeyEcxServiceWorkerConfigService, MonkeyEcxSpecificationSearch, MonkeyEcxTextTruncatePipe, MonkeyEcxTokenStorageService, MonkeyEcxTooltipDirective, MonkeyEcxTruncateQtdPipe, MonkeyEcxUtils, MonkeyEcxi18nConfigService, MonkeyFrontCoreModule, OpSearch, POPOVER_OPTIONS, statics as Statics, validateUtils as ValidateUtils, Validators, VersionChangedComponent, VersionChangedModule, comboValidator, dateRangeValidator, dateStartEndValidator, dateValidator, differentFromZero, documentValidator, documentValidatorByType, emailValidator, passwordConfirmValidator, registerValidator, requiredWithTrimValidator, index as store, trueValidator, urlValidator, valueGreaterThanZero, zipCodeValidator };
|
|
6635
|
+
export { AlertsComponent, AlertsModule, ClosedToMaintenanceComponent, ClosedToMaintenanceModule, CurrencyConfigComponent, CurrencyConfigModule, decoratorsUtils as DecoratorsUtils, Link, MonkeyEcxAlertsService, MonkeyEcxAuthGuard, MonkeyEcxAuthGuardByRole, MonkeyEcxAuthGuardCompany, MonkeyEcxAuthGuardLogin, MonkeyEcxAuthenticationService, MonkeyEcxBlobSecurePipe, MonkeyEcxCommonsActions, MonkeyEcxCommonsResolveBaseService, MonkeyEcxCommonsResolveService, MonkeyEcxCommonsSelectors, MonkeyEcxCommonsService, MonkeyEcxCommonsStoreBaseService, MonkeyEcxCommonsStoreService, MonkeyEcxConfigModule, MonkeyEcxConfigService, MonkeyEcxCookieStorageService, MonkeyEcxCoreCharts, MonkeyEcxCoreClearDecorators, MonkeyEcxCoreLog, MonkeyEcxCoreService, MonkeyEcxCoreServiceConstructor, MonkeyEcxCoreServicePaged, MonkeyEcxCoreServiceQueue, MonkeyEcxCurrencyConfigService, MonkeyEcxDirectivesModule, MonkeyEcxDiscoveryParamsService, MonkeyEcxDisplayFirstNamePipe, MonkeyEcxDisplayInitialsPipe, MonkeyEcxDisplaySupportPhone, MonkeyEcxDragDropDirective, MonkeyEcxErrorConfigService, MonkeyEcxErrorHandlingModule, MonkeyEcxErrorHandlingService, MonkeyEcxFeatureByProgramDirective, MonkeyEcxFeatureDirective, MonkeyEcxFeatureToggleService, MonkeyEcxFormatAddressPipe, MonkeyEcxFormatBeaufityJSONPipe, MonkeyEcxFormatCurrency, MonkeyEcxFormatCurrencyPipe, MonkeyEcxFormatDateGroupPipe, MonkeyEcxFormatDateTimelapsePipe, MonkeyEcxFormatDateUnixTimelapsePipe, MonkeyEcxFormatDocumentPipe, MonkeyEcxFormatDocumentTypePipe, MonkeyEcxFormatNumberPipe, MonkeyEcxFormatPhonePipe, MonkeyEcxFormatSizePipe, MonkeyEcxFormatTaxPipe, MonkeyEcxFormatUpper, MonkeyEcxFormatValue, MonkeyEcxFormatZipCodePipe, MonkeyEcxHandlingService, MonkeyEcxHttpConfigErrorInterceptor, MonkeyEcxHttpConfigHeaderInterceptor, MonkeyEcxHttpConfigInterceptorModule, MonkeyEcxHttpConfigLoadingInProgressInterceptor, MonkeyEcxHttpConfigQueueInterceptor, MonkeyEcxHttpErrorHandlingService, MonkeyEcxLinksModel, MonkeyEcxLoggedHandlingService, MonkeyEcxLogsConfigService, MonkeyEcxMaintenanceConfigService, MonkeyEcxModel, MonkeyEcxOnlyAlphaNumericDirective, MonkeyEcxOnlyNumbersDirective, MonkeyEcxOthersErrorsHandlingService, MonkeyEcxPaginationService, MonkeyEcxPipesModule, MonkeyEcxPopoverDirective, MonkeyEcxPopoverOptionsDirective, MonkeyEcxProgressBarComponent, MonkeyEcxProgressBarModule, MonkeyEcxProgressBarService, MonkeyEcxRequestDownloadHandlingService, MonkeyEcxRequestDownloadedHandlingService, MonkeyEcxRequestPagedHandling, MonkeyEcxRequestQueueHandlingService, MonkeyEcxRequestQueueModalHandlingService, MonkeyEcxRequestScheduleService, MonkeyEcxSecurityConsoleConfigService, MonkeyEcxSecurityDirective, MonkeyEcxService, MonkeyEcxServiceDownload, MonkeyEcxServiceUpload, MonkeyEcxServiceWorkerConfigService, MonkeyEcxSpecificationSearch, MonkeyEcxTextTruncatePipe, MonkeyEcxTokenStorageService, MonkeyEcxTooltipDirective, MonkeyEcxTruncateQtdPipe, MonkeyEcxUtils, MonkeyEcxi18nConfigService, MonkeyFrontCoreModule, OpSearch, POPOVER_OPTIONS, statics as Statics, validateUtils as ValidateUtils, Validators, VersionChangedComponent, VersionChangedModule, comboValidator, dateRangeValidator, dateStartEndValidator, dateValidator, differentFromZero, documentValidator, documentValidatorByType, emailValidator, passwordConfirmValidator, registerValidator, requiredWithTrimValidator, index as store, trueValidator, urlValidator, valueGreaterThanZero, zipCodeValidator };
|
|
6466
6636
|
//# sourceMappingURL=monkey-front-core.mjs.map
|