monkey-front-core 0.0.470 → 0.0.473

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.
@@ -2720,6 +2720,7 @@ class Link {
2720
2720
  constructor(data) {
2721
2721
  this.href = data?.href;
2722
2722
  this.type = data?.type;
2723
+ this.profile = data?.profile;
2723
2724
  this.templated = data?.templated;
2724
2725
  }
2725
2726
  }
@@ -2734,7 +2735,7 @@ class MonkeyEcxModel {
2734
2735
  const { from, to } = replaceOptions;
2735
2736
  link = new Link({
2736
2737
  ...link,
2737
- href: `${link.href}`.replace(from, to),
2738
+ href: `${link.href}`.replace(from, to)
2738
2739
  });
2739
2740
  }
2740
2741
  return link;
@@ -5640,6 +5641,170 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
5640
5641
  }]
5641
5642
  }], ctorParameters: function () { return [{ type: MonkeyEcxService }, { type: MonkeyEcxLoggedHandlingService }]; }, propDecorators: { doCall: [], doGenericCall: [] } });
5642
5643
 
5644
+ /**
5645
+ * Classe genérica que recebe duas interfaces como tipos genéricos.
5646
+ *
5647
+ * @typeparam T deve ser a mesma interface utilizada na Entity da Store
5648
+ * @typeparam K faz referência ao tipo de configuração.
5649
+ *
5650
+ * @description interfaces de configuração:
5651
+ * ```
5652
+ * MonkeyEcxCollectionStore e MonkeyEcxEntityStore
5653
+ * ```
5654
+ */
5655
+ class MonkeyEcxCommonsStoreBaseService extends MonkeyEcxCommonsService {
5656
+ constructor(monkeyecxService, tokenStorage, store, config) {
5657
+ super(monkeyecxService, tokenStorage);
5658
+ this.store = store;
5659
+ const { actions, selectors } = config;
5660
+ this.action = actions;
5661
+ this.selector = selectors;
5662
+ }
5663
+ handleResponseData(resp, updateLinks = true) {
5664
+ try {
5665
+ let data;
5666
+ if (resp?._embedded) {
5667
+ const { _embedded, _links, page } = resp;
5668
+ const key = Object.keys(_embedded)[0];
5669
+ data = _embedded[key];
5670
+ if (updateLinks) {
5671
+ this.updateLinks?.(_links);
5672
+ }
5673
+ this.updatePage?.(page);
5674
+ }
5675
+ else
5676
+ data = resp;
5677
+ this.update?.(data);
5678
+ }
5679
+ catch (e) {
5680
+ throw new Error(`MECX Core - Method handleResponseData -> ${e}`);
5681
+ }
5682
+ }
5683
+ updateControl(data) {
5684
+ try {
5685
+ this.store.dispatch(this.action.updateControl({
5686
+ data
5687
+ }));
5688
+ }
5689
+ catch (e) {
5690
+ throw new Error(`MECX Core - Method updateControl -> ${e}`);
5691
+ }
5692
+ }
5693
+ mappingData(args) {
5694
+ try {
5695
+ const handle = (item) => {
5696
+ let id = '';
5697
+ const { href } = new MonkeyEcxLinksModel(item)?.getAction('self') || {
5698
+ href: ''
5699
+ };
5700
+ if (href) {
5701
+ id = href.split('/').pop() || '';
5702
+ }
5703
+ return {
5704
+ ...item,
5705
+ id
5706
+ };
5707
+ };
5708
+ if (args instanceof Array) {
5709
+ return args.map((item) => {
5710
+ return handle(item);
5711
+ });
5712
+ }
5713
+ return handle(args);
5714
+ }
5715
+ catch (e) {
5716
+ throw new Error(`MECX Core - Method mappingData -> ${e}`);
5717
+ }
5718
+ }
5719
+ update(args) {
5720
+ try {
5721
+ let typeAction = 'updateOne';
5722
+ if (args instanceof Array) {
5723
+ typeAction = 'updateAll';
5724
+ }
5725
+ this.store.dispatch(this.action[typeAction]({
5726
+ data: this.mappingData(args)
5727
+ }));
5728
+ }
5729
+ catch (e) {
5730
+ throw new Error(`MECX Core - Method update -> ${e}`);
5731
+ }
5732
+ }
5733
+ updatePage(data) {
5734
+ try {
5735
+ this.store.dispatch(this.action.updatePage({
5736
+ data
5737
+ }));
5738
+ }
5739
+ catch (e) {
5740
+ throw new Error(`MECX Core - Method updatePage -> ${e}`);
5741
+ }
5742
+ }
5743
+ updateLinks(data) {
5744
+ try {
5745
+ this.store.dispatch(this.action.updateLinks({
5746
+ data
5747
+ }));
5748
+ }
5749
+ catch (e) {
5750
+ throw new Error(`MECX Core - Method updateLinks -> ${e}`);
5751
+ }
5752
+ }
5753
+ async loadData(url, updateLinks = true) {
5754
+ this.updateControl({ isLoading: true });
5755
+ try {
5756
+ const data = await this.monkeyecxService?.get(url).toPromise();
5757
+ this.handleResponseData(data, updateLinks);
5758
+ }
5759
+ catch (e) {
5760
+ throw new Error(`${e?.message}`);
5761
+ }
5762
+ this.updateControl({ isLoading: false });
5763
+ }
5764
+ async loadPageData(pagination) {
5765
+ const { store, selector } = this;
5766
+ const data = await store
5767
+ .select(selector.selectLinks())
5768
+ .pipe(take(1))
5769
+ .toPromise();
5770
+ const { action } = pagination;
5771
+ const { href } = new MonkeyEcxLinksModel({ _links: data }).getAction(action) || {
5772
+ href: ''
5773
+ };
5774
+ if (href) {
5775
+ this.loadData(href);
5776
+ }
5777
+ }
5778
+ /**
5779
+ * @description Neste método precisamos incluir a lógica para conferir se precisa limpar a
5780
+ * entidade ou não
5781
+ * E depois precisa invocar o método loadData
5782
+ * @param (url) ou de acordo com a action criada
5783
+ * @example
5784
+ * ```
5785
+ * const hasDifference = .....
5786
+ * if(hasDifference) {
5787
+ * store.dispatch(clear)
5788
+ * }
5789
+ *
5790
+ * this.loadData(...)
5791
+ * ```
5792
+ */
5793
+ load(args) {
5794
+ throw new Error('MECX Core - Method load not implemented.');
5795
+ }
5796
+ loadPage(args) {
5797
+ throw new Error('MECX Core - Method loadPage not implemented.');
5798
+ }
5799
+ }
5800
+ __decorate([
5801
+ MonkeyEcxCoreService({
5802
+ requestInProgress: {
5803
+ showProgress: true
5804
+ }
5805
+ })
5806
+ ], MonkeyEcxCommonsStoreBaseService.prototype, "loadData", null);
5807
+
5643
5808
  class MonkeyEcxCommonsActions {
5644
5809
  static getActions(actionName) {
5645
5810
  const clear = createAction(`[${actionName}] Clear All`, props());
@@ -5694,12 +5859,18 @@ class MonkeyEcxCommonsSelectors {
5694
5859
  };
5695
5860
  const selectLinks = (props) => {
5696
5861
  return createSelector(selectState, (state) => {
5697
- return state.links?.[props.identifier];
5862
+ if (props?.identifier) {
5863
+ return state.links?.[props.identifier];
5864
+ }
5865
+ return state.links;
5698
5866
  });
5699
5867
  };
5700
5868
  const selectPage = (props) => {
5701
5869
  return createSelector(selectState, (state) => {
5702
- return state.page?.[props.identifier];
5870
+ if (props?.identifier) {
5871
+ return state.page?.[props.identifier];
5872
+ }
5873
+ return state.page;
5703
5874
  });
5704
5875
  };
5705
5876
  const linksHasDifference = (props) => {
@@ -6462,5 +6633,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
6462
6633
  * Generated bundle index. Do not edit.
6463
6634
  */
6464
6635
 
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 };
6636
+ 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
6637
  //# sourceMappingURL=monkey-front-core.mjs.map