monkey-front-core 0.0.469 → 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.
@@ -3128,6 +3128,112 @@ __decorate([
3128
3128
  })
3129
3129
  ], MonkeyEcxCommonsService.prototype, "getGenericData", null);
3130
3130
 
3131
+ class MonkeyEcxCommonsResolveBaseService extends MonkeyEcxCommonsService {
3132
+ constructor(monkeyecxService, tokenStorage, config) {
3133
+ super(monkeyecxService, tokenStorage);
3134
+ this.route = null;
3135
+ this.currentRoute = null;
3136
+ this.paginationService = inject(MonkeyEcxPaginationService);
3137
+ this.translateService = inject(TranslateService);
3138
+ this.router = inject(Router);
3139
+ this.store = inject(Store);
3140
+ this.monkeyDiscovery = inject(MonkeyEcxDiscoveryParamsService);
3141
+ const { actions } = config;
3142
+ this.action = actions;
3143
+ }
3144
+ getData() {
3145
+ return __awaiter(this, void 0, void 0, function* () {
3146
+ try {
3147
+ const { store, route, action, tokenStorage } = this;
3148
+ const { companyId, governmentId } = yield (tokenStorage === null || tokenStorage === void 0 ? void 0 : tokenStorage.getToken());
3149
+ if (!route)
3150
+ return;
3151
+ const url = MonkeyEcxUtils.replaceVariables(route, { companyId, governmentId });
3152
+ store.dispatch(action.load({ url }));
3153
+ }
3154
+ catch (e) {
3155
+ throw new Error(`MECX Core - Method getData -> ${e}`);
3156
+ }
3157
+ });
3158
+ }
3159
+ loadPage(actionType) {
3160
+ return __awaiter(this, void 0, void 0, function* () {
3161
+ try {
3162
+ const { store, action } = this;
3163
+ store.dispatch(action.loadPagination({
3164
+ pagination: {
3165
+ action: actionType
3166
+ }
3167
+ }));
3168
+ }
3169
+ catch (e) {
3170
+ throw new Error(`MECX Core - Method loadPage -> ${e}`);
3171
+ }
3172
+ });
3173
+ }
3174
+ /**
3175
+ * @description Inicializar a class genérica
3176
+ * @param (args: MonkeyEcxInitialResolverConfig)
3177
+ * => route é obrigátorio pois ele quem inicializa a store.
3178
+ * A searchClass só se faz necessaria quando for usar filtros
3179
+ */
3180
+ init(args) {
3181
+ try {
3182
+ const { searchClass, route } = args;
3183
+ this.route = route;
3184
+ if (searchClass) {
3185
+ // eslint-disable-next-line new-cap
3186
+ const searchInstance = new searchClass(this.__search);
3187
+ this.route = `${route}${searchInstance.buildParams()}`;
3188
+ this.__onSearchChanged$.next(searchInstance);
3189
+ }
3190
+ this.getData();
3191
+ }
3192
+ catch (e) {
3193
+ throw new Error(`${e === null || e === void 0 ? void 0 : e.message}`);
3194
+ }
3195
+ }
3196
+ resolve(route, state, otherArgs) {
3197
+ this.__search = route === null || route === void 0 ? void 0 : route.queryParams;
3198
+ const [currentRoute] = (state === null || state === void 0 ? void 0 : state.url.split('?')) || [null];
3199
+ this.currentRoute = currentRoute;
3200
+ super.resolve(route, state, otherArgs);
3201
+ }
3202
+ /**
3203
+ * @description Atualizar os filtros da tela
3204
+ * @param (search: T, route?: string)
3205
+ * => route é opcional, passar ele apenas se a rota for diferente do padrão
3206
+ */
3207
+ setSearch(search, route) {
3208
+ try {
3209
+ const { currentRoute, router } = this;
3210
+ this.setSearchByUrl(router, route || `${currentRoute}`, search);
3211
+ }
3212
+ catch (e) {
3213
+ throw new Error(`MECX Core - Method setSearch -> ${e}`);
3214
+ }
3215
+ }
3216
+ /**
3217
+ * @description Navegação para details.
3218
+ * Por padrão sera redirecionado para '${currentRoute}/details'
3219
+ * @param (detailsData: T, route?: string)
3220
+ * => route é opcional, passar ele apenas se a rota for diferente do padrão
3221
+ */
3222
+ navigateToDetails(detailsData, route) {
3223
+ try {
3224
+ const { router, currentRoute } = this;
3225
+ router.navigate([route || `${currentRoute}/details`], {
3226
+ state: {
3227
+ detailsData
3228
+ }
3229
+ });
3230
+ }
3231
+ catch (e) {
3232
+ throw new Error(`MECX Core - Method navigateToDetails -> ${e}`);
3233
+ }
3234
+ }
3235
+ }
3236
+
3131
3237
  class MonkeyEcxCommonsResolveService extends MonkeyEcxCommonsService {
3132
3238
  constructor(monkeyecxService, tokenStorage, config) {
3133
3239
  super(monkeyecxService, tokenStorage);
@@ -5460,6 +5566,174 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
5460
5566
  }]
5461
5567
  }], ctorParameters: function () { return [{ type: MonkeyEcxService }, { type: MonkeyEcxLoggedHandlingService }]; }, propDecorators: { doCall: [], doGenericCall: [] } });
5462
5568
 
5569
+ /**
5570
+ * Classe genérica que recebe duas interfaces como tipos genéricos.
5571
+ *
5572
+ * @typeparam T deve ser a mesma interface utilizada na Entity da Store
5573
+ * @typeparam K faz referência ao tipo de configuração.
5574
+ *
5575
+ * @description interfaces de configuração:
5576
+ * ```
5577
+ * MonkeyEcxCollectionStore e MonkeyEcxEntityStore
5578
+ * ```
5579
+ */
5580
+ class MonkeyEcxCommonsStoreBaseService extends MonkeyEcxCommonsService {
5581
+ constructor(monkeyecxService, tokenStorage, store, config) {
5582
+ super(monkeyecxService, tokenStorage);
5583
+ this.store = store;
5584
+ const { actions, selectors } = config;
5585
+ this.action = actions;
5586
+ this.selector = selectors;
5587
+ }
5588
+ handleResponseData(resp, updateLinks = true) {
5589
+ var _a, _b, _c;
5590
+ try {
5591
+ let data;
5592
+ if (resp === null || resp === void 0 ? void 0 : resp._embedded) {
5593
+ const { _embedded, _links, page } = resp;
5594
+ const key = Object.keys(_embedded)[0];
5595
+ data = _embedded[key];
5596
+ if (updateLinks) {
5597
+ (_a = this.updateLinks) === null || _a === void 0 ? void 0 : _a.call(this, _links);
5598
+ }
5599
+ (_b = this.updatePage) === null || _b === void 0 ? void 0 : _b.call(this, page);
5600
+ }
5601
+ else
5602
+ data = resp;
5603
+ (_c = this.update) === null || _c === void 0 ? void 0 : _c.call(this, data);
5604
+ }
5605
+ catch (e) {
5606
+ throw new Error(`MECX Core - Method handleResponseData -> ${e}`);
5607
+ }
5608
+ }
5609
+ updateControl(data) {
5610
+ try {
5611
+ this.store.dispatch(this.action.updateControl({
5612
+ data
5613
+ }));
5614
+ }
5615
+ catch (e) {
5616
+ throw new Error(`MECX Core - Method updateControl -> ${e}`);
5617
+ }
5618
+ }
5619
+ mappingData(args) {
5620
+ try {
5621
+ const handle = (item) => {
5622
+ var _a;
5623
+ let id = '';
5624
+ const { href } = ((_a = new MonkeyEcxLinksModel(item)) === null || _a === void 0 ? void 0 : _a.getAction('self')) || {
5625
+ href: ''
5626
+ };
5627
+ if (href) {
5628
+ id = href.split('/').pop() || '';
5629
+ }
5630
+ return Object.assign(Object.assign({}, item), { id });
5631
+ };
5632
+ if (args instanceof Array) {
5633
+ return args.map((item) => {
5634
+ return handle(item);
5635
+ });
5636
+ }
5637
+ return handle(args);
5638
+ }
5639
+ catch (e) {
5640
+ throw new Error(`MECX Core - Method mappingData -> ${e}`);
5641
+ }
5642
+ }
5643
+ update(args) {
5644
+ try {
5645
+ let typeAction = 'updateOne';
5646
+ if (args instanceof Array) {
5647
+ typeAction = 'updateAll';
5648
+ }
5649
+ this.store.dispatch(this.action[typeAction]({
5650
+ data: this.mappingData(args)
5651
+ }));
5652
+ }
5653
+ catch (e) {
5654
+ throw new Error(`MECX Core - Method update -> ${e}`);
5655
+ }
5656
+ }
5657
+ updatePage(data) {
5658
+ try {
5659
+ this.store.dispatch(this.action.updatePage({
5660
+ data
5661
+ }));
5662
+ }
5663
+ catch (e) {
5664
+ throw new Error(`MECX Core - Method updatePage -> ${e}`);
5665
+ }
5666
+ }
5667
+ updateLinks(data) {
5668
+ try {
5669
+ this.store.dispatch(this.action.updateLinks({
5670
+ data
5671
+ }));
5672
+ }
5673
+ catch (e) {
5674
+ throw new Error(`MECX Core - Method updateLinks -> ${e}`);
5675
+ }
5676
+ }
5677
+ loadData(url, updateLinks = true) {
5678
+ var _a;
5679
+ return __awaiter(this, void 0, void 0, function* () {
5680
+ this.updateControl({ isLoading: true });
5681
+ try {
5682
+ const data = yield ((_a = this.monkeyecxService) === null || _a === void 0 ? void 0 : _a.get(url).toPromise());
5683
+ this.handleResponseData(data, updateLinks);
5684
+ }
5685
+ catch (e) {
5686
+ throw new Error(`${e === null || e === void 0 ? void 0 : e.message}`);
5687
+ }
5688
+ this.updateControl({ isLoading: false });
5689
+ });
5690
+ }
5691
+ loadPageData(pagination) {
5692
+ return __awaiter(this, void 0, void 0, function* () {
5693
+ const { store, selector } = this;
5694
+ const data = yield store
5695
+ .select(selector.selectLinks())
5696
+ .pipe(take(1))
5697
+ .toPromise();
5698
+ const { action } = pagination;
5699
+ const { href } = new MonkeyEcxLinksModel({ _links: data }).getAction(action) || {
5700
+ href: ''
5701
+ };
5702
+ if (href) {
5703
+ this.loadData(href);
5704
+ }
5705
+ });
5706
+ }
5707
+ /**
5708
+ * @description Neste método precisamos incluir a lógica para conferir se precisa limpar a
5709
+ * entidade ou não
5710
+ * E depois precisa invocar o método loadData
5711
+ * @param (url) ou de acordo com a action criada
5712
+ * @example
5713
+ * ```
5714
+ * const hasDifference = .....
5715
+ * if(hasDifference) {
5716
+ * store.dispatch(clear)
5717
+ * }
5718
+ *
5719
+ * this.loadData(...)
5720
+ * ```
5721
+ */
5722
+ load(args) {
5723
+ throw new Error('MECX Core - Method load not implemented.');
5724
+ }
5725
+ loadPage(args) {
5726
+ throw new Error('MECX Core - Method loadPage not implemented.');
5727
+ }
5728
+ }
5729
+ __decorate([
5730
+ MonkeyEcxCoreService({
5731
+ requestInProgress: {
5732
+ showProgress: true
5733
+ }
5734
+ })
5735
+ ], MonkeyEcxCommonsStoreBaseService.prototype, "loadData", null);
5736
+
5463
5737
  class MonkeyEcxCommonsActions {
5464
5738
  static getActions(actionName) {
5465
5739
  const clear = createAction(`[${actionName}] Clear All`, props());
@@ -5516,13 +5790,19 @@ class MonkeyEcxCommonsSelectors {
5516
5790
  const selectLinks = (props) => {
5517
5791
  return createSelector(selectState, (state) => {
5518
5792
  var _a;
5519
- return (_a = state.links) === null || _a === void 0 ? void 0 : _a[props.identifier];
5793
+ if (props === null || props === void 0 ? void 0 : props.identifier) {
5794
+ return (_a = state.links) === null || _a === void 0 ? void 0 : _a[props.identifier];
5795
+ }
5796
+ return state.links;
5520
5797
  });
5521
5798
  };
5522
5799
  const selectPage = (props) => {
5523
5800
  return createSelector(selectState, (state) => {
5524
5801
  var _a;
5525
- return (_a = state.page) === null || _a === void 0 ? void 0 : _a[props.identifier];
5802
+ if (props === null || props === void 0 ? void 0 : props.identifier) {
5803
+ return (_a = state.page) === null || _a === void 0 ? void 0 : _a[props.identifier];
5804
+ }
5805
+ return state.page;
5526
5806
  });
5527
5807
  };
5528
5808
  const linksHasDifference = (props) => {
@@ -6302,5 +6582,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
6302
6582
  * Generated bundle index. Do not edit.
6303
6583
  */
6304
6584
 
6305
- export { AlertsComponent, AlertsModule, ClosedToMaintenanceComponent, ClosedToMaintenanceModule, CurrencyConfigComponent, CurrencyConfigModule, decoratorsUtils as DecoratorsUtils, Link, MonkeyEcxAlertsService, MonkeyEcxAuthGuard, MonkeyEcxAuthGuardByRole, MonkeyEcxAuthGuardCompany, MonkeyEcxAuthGuardLogin, MonkeyEcxAuthenticationService, MonkeyEcxBlobSecurePipe, MonkeyEcxCommonsActions, 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 };
6585
+ 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 };
6306
6586
  //# sourceMappingURL=monkey-front-core.mjs.map